Exemple
anyio 4.13.0: verify Condition
Échantillon vérifié pour pypi anyio 4.13.0: verify Condition. Le contrat s'est exécuté sur python 3.12 · linux alpine/x64 · docker et a réussi.
sha256:109ebe6ab37e76fcc63fca00119c785ce483ef3e4fea637f9e0b886cc4d1ed5f
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 2
Environnement déclaré
python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-20 |
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-07 |
Cas
HOW- Objectif
- verify pkg:pypi/anyio@4.13.0 Condition
- Paquets
- Symboles
-
- anyio.Condition
- Environnement
- python 3.12
- Créé
- 2026-08-20T10:29:30Z
Contrat
- async context manager acquires and releases condition lock automatically
- Condition provides wait and notify synchronization across concurrent tasks
- notify_all wakes all tasks waiting on the condition
- statistics method reports current waiting tasks and lock statistics
- locked method reports underlying condition lock state
Fichiers
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- src/__init__.py
- src/sample.py
- test/contract.py
Code source
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/anyio@4.13.0 Condition
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/anyio@4.13.0
Demonstrate these symbols/APIs:
- anyio.Condition
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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.
{"case":{"caseId":"case:sha256:de793081e1e98901fdf8aae559d331ab5eb8ba58399c08401ae8afd242f5fc2e","contract":["async context manager acquires and releases condition lock automatically","Condition provides wait and notify synchronization across concurrent tasks","notify_all wakes all tasks waiting on the condition","statistics method reports current waiting tasks and lock statistics","locked method reports underlying condition lock state"],"goal":"verify pkg:pypi/anyio@4.13.0 Condition","kind":"HOW","packages":["pkg:pypi/anyio@4.13.0"],"schemaVersion":1,"symbols":["anyio.Condition"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/anyio@4.13.0"],"schemaVersion":1,"symbols":["anyio.Condition"],"verifierAdapter":"python@1"}
[project]
name = "anyio-condition-sample"
version = "0.1.0"
description = "Clean-room verification sample for anyio Condition"
requires-python = ">=3.9"
dependencies = [
"anyio==4.13.0",
"idna==3.19",
"typing-extensions==4.16.0"
]
anyio==4.13.0
idna==3.19
typing-extensions==4.16.0
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/anyio@4.13.0 Condition",
"kind": "HOW",
"packages": [
"pkg:pypi/anyio@4.13.0"
],
"symbols": [
"anyio.Condition"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
from .sample import (
check_context_manager_acquisition,
run_wait_and_notify,
run_notify_all,
check_condition_statistics,
check_locked_state,
)
__all__ = [
"check_context_manager_acquisition",
"run_wait_and_notify",
"run_notify_all",
"check_condition_statistics",
"check_locked_state",
]
"""Clean-room demonstration of anyio 4.13.0 Condition."""
from typing import List, Tuple
import anyio
async def _context_manager_worker() -> Tuple[bool, bool, bool]:
condition = anyio.Condition()
before = condition.locked()
async with condition:
inside = condition.locked()
after = condition.locked()
return before, inside, after
def check_context_manager_acquisition() -> Tuple[bool, bool, bool]:
"""Demonstrates acquiring and releasing Condition via async context manager."""
return anyio.run(_context_manager_worker)
async def _wait_and_notify_worker() -> List[str]:
condition = anyio.Condition()
events: List[str] = []
async def waiter() -> None:
async with condition:
events.append("waiter_waiting")
await condition.wait()
events.append("waiter_resumed")
async with anyio.create_task_group() as tg:
tg.start_soon(waiter)
await anyio.sleep(0.01)
async with condition:
events.append("notifier_signaling")
condition.notify(1)
return events
def run_wait_and_notify() -> List[str]:
"""Demonstrates Condition wait and notify synchronization across concurrent tasks."""
return anyio.run(_wait_and_notify_worker)
async def _notify_all_worker(worker_count: int) -> int:
condition = anyio.Condition()
resumed: List[int] = []
async def worker(index: int) -> None:
async with condition:
await condition.wait()
resumed.append(index)
async with anyio.create_task_group() as tg:
for i in range(worker_count):
tg.start_soon(worker, i)
await anyio.sleep(0.01)
async with condition:
condition.notify_all()
return len(resumed)
def run_notify_all(worker_count: int) -> int:
"""Demonstrates notify_all waking all tasks waiting on the condition."""
return anyio.run(_notify_all_worker, worker_count)
async def _statistics_worker() -> Tuple[int, bool, int]:
condition = anyio.Condition()
init_stats = condition.statistics()
tasks_waiting_before = init_stats.tasks_waiting
lock_locked_before = init_stats.lock_statistics.locked
async def waiter() -> None:
async with condition:
await condition.wait()
async with anyio.create_task_group() as tg:
tg.start_soon(waiter)
await anyio.sleep(0.01)
during_stats = condition.statistics()
tasks_waiting_during = during_stats.tasks_waiting
async with condition:
condition.notify(1)
return tasks_waiting_before, lock_locked_before, tasks_waiting_during
def check_condition_statistics() -> Tuple[int, bool, int]:
"""Demonstrates statistics method reporting waiting tasks and lock statistics."""
return anyio.run(_statistics_worker)
async def _locked_state_worker() -> Tuple[bool, bool, bool]:
condition = anyio.Condition()
initial_locked = condition.locked()
await condition.acquire()
acquired_locked = condition.locked()
condition.release()
released_locked = condition.locked()
return initial_locked, acquired_locked, released_locked
def check_locked_state() -> Tuple[bool, bool, bool]:
"""Demonstrates locked method reporting underlying condition lock state."""
return anyio.run(_locked_state_worker)
"""Contract verification test for pkg:pypi/anyio@4.13.0 Condition."""
import sys
from pathlib import Path
# Ensure src is in python path
src_dir = Path(__file__).resolve().parent.parent / "src"
if str(src_dir) not in sys.path:
sys.path.insert(0, str(src_dir))
from sample import (
check_context_manager_acquisition,
run_wait_and_notify,
run_notify_all,
check_condition_statistics,
check_locked_state,
)
def test_contract_1_context_manager():
# Assertion: async context manager acquires and releases condition lock automatically
before, inside, after = check_context_manager_acquisition()
assert before is False, f"Expected before False, got {before}"
assert inside is True, f"Expected inside True, got {inside}"
assert after is False, f"Expected after False, got {after}"
def test_contract_2_wait_and_notify():
# Assertion: Condition provides wait and notify synchronization across concurrent tasks
events = run_wait_and_notify()
assert events == ["waiter_waiting", "notifier_signaling", "waiter_resumed"], f"Unexpected events order: {events}"
def test_contract_3_notify_all():
# Assertion: notify_all wakes all tasks waiting on the condition
resumed_count = run_notify_all(worker_count=4)
assert resumed_count == 4, f"Expected 4 resumed workers, got {resumed_count}"
def test_contract_4_statistics():
# Assertion: statistics method reports current waiting tasks and lock statistics
before_waiters, lock_locked, during_waiters = check_condition_statistics()
assert before_waiters == 0, f"Expected 0 waiters before, got {before_waiters}"
assert lock_locked is False, f"Expected lock_locked False, got {lock_locked}"
assert during_waiters == 1, f"Expected 1 waiter during, got {during_waiters}"
def test_contract_5_locked_state():
# Assertion: locked method reports underlying condition lock state
initial, acquired, released = check_locked_state()
assert initial is False, f"Expected initial False, got {initial}"
assert acquired is True, f"Expected acquired True, got {acquired}"
assert released is False, f"Expected released False, got {released}"
def main():
print("Running contracts for pkg:pypi/anyio@4.13.0 Condition...")
test_contract_1_context_manager()
test_contract_2_wait_and_notify()
test_contract_3_notify_all()
test_contract_4_statistics()
test_contract_5_locked_state()
print("All contracts passed successfully.")
if __name__ == "__main__":
main()
Seeder d'origine
anonyme