Exemplo
greenlet 3.5.4: greenlet.parent
Amostra verificada para pypi greenlet 3.5.4: greenlet.parent. O contrato rodou em python 3.12 · linux alpine/x64 · docker e passou: assert greenlet.greenlet…
sha256:3cd72ec2230ef46dee673e23871388b26db13461dc4455c9b9c6dd1a3634da3d
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
python 3.12 linux 24 · alpine · musl x64 python 3.12 python pip 24
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-09-01 |
Caso
HOW- Objetivo
- verify greenlet.greenlet.parent in pkg:pypi/greenlet@3.5.4
- Pacotes
- Símbolos
-
- greenlet.greenlet.parent
- Ambiente
- python 3.12
- Criado
- 2026-09-01T12:13:59Z
Contrato
- assert greenlet.greenlet default parent is the creating greenlet from greenlet.getcurrent()
- assert greenlet.greenlet accepts explicit parent argument in constructor and returns to specified parent on completion
- assert greenlet.greenlet.parent attribute is mutable and redirects completion control flow to new parent
- assert main greenlet parent is None and modifying main greenlet parent raises AttributeError or ValueError
- assert setting cyclic greenlet parent hierarchy raises ValueError
- assert setting non-greenlet or None parent raises TypeError or ValueError
- assert uncaught exceptions in child greenlet propagate to its parent greenlet
Arquivos
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
Código-fonte
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 greenlet.greenlet.parent in pkg:pypi/greenlet@3.5.4
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/greenlet@3.5.4
Demonstrate these symbols/APIs:
- greenlet.greenlet.parent
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:0e8c6060db78a3dd2d9110228861758997e7370c7d808e238593d96935488e18","constraints":{"executionContext":"python"},"contract":["assert greenlet.greenlet default parent is the creating greenlet from greenlet.getcurrent()","assert greenlet.greenlet accepts explicit parent argument in constructor and returns to specified parent on completion","assert greenlet.greenlet.parent attribute is mutable and redirects completion control flow to new parent","assert main greenlet parent is None and modifying main greenlet parent raises AttributeError or ValueError","assert setting cyclic greenlet parent hierarchy raises ValueError","assert setting non-greenlet or None parent raises TypeError or ValueError","assert uncaught exceptions in child greenlet propagate to its parent greenlet"],"goal":"verify greenlet.greenlet.parent in pkg:pypi/greenlet@3.5.4","kind":"HOW","packages":["pkg:pypi/greenlet@3.5.4"],"schemaVersion":1,"symbols":["greenlet.greenlet.parent"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"pypi","executionContext":"python","language":"python","libc":"musl","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/greenlet@3.5.4"],"schemaVersion":1,"subject":"pkg:pypi/greenlet@3.5.4","symbols":["greenlet.greenlet.parent"],"verifierAdapter":"python@1"}
[project]
name = "verify-greenlet-parent"
version = "0.1.0"
dependencies = [
"greenlet==3.5.4",
]
greenlet==3.5.4
{
"schemaVersion": 1,
"goal": "verify greenlet.greenlet.parent in pkg:pypi/greenlet@3.5.4",
"kind": "HOW",
"packages": [
"pkg:pypi/greenlet@3.5.4"
],
"symbols": [
"greenlet.greenlet.parent"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import greenlet
def test_default_parent_is_current():
current = greenlet.getcurrent()
def worker():
return 42
g = greenlet.greenlet(worker)
assert g.parent is current
res = g.switch()
assert res == 42
assert g.dead is True
def test_explicit_parent_constructor():
events = []
def p_func(*args):
events.append("p_start")
c_res = child.switch()
events.append(f"p_end:{c_res}")
return "p_done"
def c_func():
events.append("c_run")
return "c_done"
parent_g = greenlet.greenlet(p_func)
child = greenlet.greenlet(c_func, parent=parent_g)
assert child.parent is parent_g
val = parent_g.switch()
assert val == "p_done"
assert events == ["p_start", "c_run", "p_end:c_done"]
assert child.dead is True
assert parent_g.dead is True
def test_reassign_parent_redirects_control():
events = []
def worker():
events.append("worker_done")
return "from_worker"
def alt_parent(arg=None):
events.append(f"alt_received:{arg}")
return "alt_done"
g = greenlet.greenlet(worker)
alt_g = greenlet.greenlet(alt_parent)
g.parent = alt_g
assert g.parent is alt_g
res = g.switch()
assert res == "alt_done"
assert events == ["worker_done", "alt_received:from_worker"]
assert g.dead is True
assert alt_g.dead is True
def test_main_greenlet_parent_is_none_and_immutable():
main = greenlet.getcurrent()
assert main.parent is None
g = greenlet.greenlet(lambda: None)
try:
main.parent = g
assert False, "Should have raised AttributeError/ValueError when setting parent of main greenlet"
except (AttributeError, ValueError) as exc:
assert isinstance(exc, (AttributeError, ValueError))
def test_cyclic_parent_raises_value_error():
g1 = greenlet.greenlet(lambda: None)
g2 = greenlet.greenlet(lambda: None)
try:
g1.parent = g1
assert False, "Should have raised ValueError for self-referential parent"
except ValueError as exc:
assert isinstance(exc, ValueError)
g2.parent = g1
try:
g1.parent = g2
assert False, "Should have raised ValueError for cyclic parent chain"
except ValueError as exc:
assert isinstance(exc, ValueError)
def test_invalid_parent_type_raises_type_error():
g = greenlet.greenlet(lambda: None)
try:
g.parent = "not_a_greenlet"
assert False, "Should have raised TypeError for non-greenlet parent"
except TypeError as exc:
assert isinstance(exc, TypeError)
try:
g.parent = None
assert False, "Should have raised TypeError/ValueError for None parent"
except (TypeError, ValueError) as exc:
assert isinstance(exc, (TypeError, ValueError))
def test_exception_propagates_to_parent():
events = []
class CustomError(Exception):
pass
def faulty_child():
events.append("child_raising")
raise CustomError("boom")
child = greenlet.greenlet(faulty_child)
assert child.parent is greenlet.getcurrent()
try:
child.switch()
assert False, "Exception should have propagated to parent"
except CustomError as exc:
events.append("parent_caught")
assert str(exc) == "boom"
assert events == ["child_raising", "parent_caught"]
assert child.dead is True
def main():
test_default_parent_is_current()
test_explicit_parent_constructor()
test_reassign_parent_redirects_control()
test_main_greenlet_parent_is_none_and_immutable()
test_cyclic_parent_raises_value_error()
test_invalid_parent_type_raises_type_error()
test_exception_propagates_to_parent()
print("All greenlet.greenlet.parent contract assertions passed.")
if __name__ == "__main__":
main()
Seeder de origem
anônimo