CodeSampleX

Sample

uvloop 0.22.1: EventLoopPolicy, install, new_event_loop

Verified sample for pypi uvloop 0.22.1: EventLoopPolicy, install, new_event_loop. The contract ran on python 3.12 · linux alpine/x64 · docker and passed.

sha256:2ce47866a5864ba793f7f51ce3a1dc73d5d710e5d46be32bc3511c1870f071bf

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip

Verification-run environments

Environment Contract Stages Run
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-27

Case

HOW
Goal
verify pkg:pypi/uvloop@0.22.1
Packages
Symbols
  • uvloop.EventLoopPolicy
  • uvloop.install
  • uvloop.new_event_loop
  • uvloop.run
Environment
python 3.12
Created
2026-08-27T18:07:40Z

Contract

  1. uvloop.EventLoopPolicy implements asyncio.AbstractEventLoopPolicy and creates uvloop.Loop instances
  2. uvloop.install sets uvloop.EventLoopPolicy as the default asyncio event loop policy
  3. uvloop.new_event_loop returns a new unclosed uvloop.Loop instance
  4. uvloop.run executes an async coroutine to completion and returns its result
  5. uvloop.run propagates unhandled exceptions raised inside the coroutine
  6. uvloop.run raises TypeError when passed a non-coroutine object

Files

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

Download the source artifact (tar.gz)

Source

NOTES.md
# uvloop: Fast asyncio Event Loop (pkg:pypi/uvloop@0.22.1)

## Prior Network Solutions

The network query for `verify pkg:pypi/uvloop@0.22.1` returned NO_SAFE_MATCH.

## Release Pinned

- `uvloop`: 0.22.1

## Observed Behaviour

In `uvloop` 0.22.1:
1. `uvloop.EventLoopPolicy()` instantiates an `asyncio.AbstractEventLoopPolicy` that creates `uvloop.Loop` instances upon calling `new_event_loop()`.
2. `uvloop.install()` installs `uvloop.EventLoopPolicy` as the default event loop policy via `asyncio.set_event_loop_policy()`.
3. `uvloop.new_event_loop()` returns a fresh, unclosed `uvloop.Loop` instance that can execute async coroutines via `run_until_complete()`.
4. `uvloop.run(coro)` creates a new uvloop event loop, runs the coroutine to completion, and returns its result.
5. `uvloop.run(coro)` propagates exceptions raised within the coroutine.
6. `uvloop.run(obj)` raises `TypeError` if passed a non-coroutine object.
PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:pypi/uvloop@0.22.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/uvloop@0.22.1
Demonstrate these symbols/APIs:
  - uvloop.EventLoopPolicy
  - uvloop.install
  - uvloop.new_event_loop
  - uvloop.run

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:bbe1bad0eb43decaee81946c826973f51356cecd553ac7897cf147915e566dd2","contract":["uvloop.EventLoopPolicy implements asyncio.AbstractEventLoopPolicy and creates uvloop.Loop instances","uvloop.install sets uvloop.EventLoopPolicy as the default asyncio event loop policy","uvloop.new_event_loop returns a new unclosed uvloop.Loop instance","uvloop.run executes an async coroutine to completion and returns its result","uvloop.run propagates unhandled exceptions raised inside the coroutine","uvloop.run raises TypeError when passed a non-coroutine object"],"goal":"verify pkg:pypi/uvloop@0.22.1","kind":"HOW","packages":["pkg:pypi/uvloop@0.22.1"],"schemaVersion":1,"symbols":["uvloop.EventLoopPolicy","uvloop.install","uvloop.new_event_loop","uvloop.run"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/uvloop@0.22.1"],"schemaVersion":1,"subject":"pkg:pypi/uvloop@0.22.1","symbols":["uvloop.EventLoopPolicy","uvloop.install","uvloop.new_event_loop","uvloop.run"],"verifierAdapter":"python@1"}
requirements.txt
uvloop==0.22.1
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/uvloop@0.22.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/uvloop@0.22.1"
  ],
  "symbols": [
    "uvloop.EventLoopPolicy",
    "uvloop.install",
    "uvloop.new_event_loop",
    "uvloop.run"
  ]
}
test/contract.py
import asyncio
import sys
import uvloop


def test_event_loop_policy() -> None:
    policy = uvloop.EventLoopPolicy()
    assert isinstance(policy, asyncio.AbstractEventLoopPolicy)

    loop = policy.new_event_loop()
    try:
        assert isinstance(loop, uvloop.Loop)
        assert isinstance(loop, asyncio.AbstractEventLoop)
    finally:
        loop.close()


def test_install_policy() -> None:
    uvloop.install()
    current_policy = asyncio.get_event_loop_policy()
    assert isinstance(current_policy, uvloop.EventLoopPolicy)


def test_new_event_loop() -> None:
    loop = uvloop.new_event_loop()
    try:
        assert isinstance(loop, uvloop.Loop)
        assert not loop.is_running()
        assert not loop.is_closed()

        async def compute() -> int:
            return 42

        res = loop.run_until_complete(compute())
        assert res == 42
    finally:
        loop.close()
    assert loop.is_closed()


def test_run_success() -> None:
    async def fetch_payload():
        await asyncio.sleep(0.01)
        return {"status": "ok", "items": [1, 2, 3]}

    result = uvloop.run(fetch_payload())
    assert result == {"status": "ok", "items": [1, 2, 3]}


def test_run_exception() -> None:
    async def faulty_task():
        await asyncio.sleep(0.01)
        raise ValueError("simulated execution error")

    try:
        uvloop.run(faulty_task())
        raise AssertionError("Expected ValueError from uvloop.run")
    except ValueError as exc:
        assert str(exc) == "simulated execution error"


def test_run_type_error() -> None:
    try:
        uvloop.run("not a coroutine")  # type: ignore
        raise AssertionError("Expected TypeError when passing non-coroutine to uvloop.run")
    except TypeError:
        pass


def main() -> None:
    test_event_loop_policy()
    test_install_policy()
    test_new_event_loop()
    test_run_success()
    test_run_exception()
    test_run_type_error()
    print("All uvloop contract assertions passed successfully.")


if __name__ == "__main__":
    main()

Origin Seeder

anonymous