샘플
pluggy 1.6.0
검증된 샘플 — pypi pluggy 1.6.0. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: PluginManager discovers and executes hook implementations…
sha256:d75b8d3bf24e09f110b96bfaaf01d99c0aecd7ab8d552e0d02697d72269de09a
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-21 |
케이스
HOW- 목표
- verify pkg:pypi/pluggy@1.6.0
- 패키지
- 생성일
- 2026-08-21T06:17:42Z
컨트랙트
- PluginManager discovers and executes hook implementations registered across multiple plugins with deterministic ordering
- Hook specifications with firstresult=True return the first non-None result from registered implementations
- Hook wrappers intercept execution and allow inspecting or transforming hook return values
- Historic hooks record calls and automatically replay them to plugins registered later
- PluginManager manages plugin lifecycle including registration, lookup, blocking, and unregistration
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
소스
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/pluggy@1.6.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/pluggy@1.6.0
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:e9841afd533e6f3720ccd77b27517e29b0d621de1c61e43544dd19907e893551","contract":["PluginManager discovers and executes hook implementations registered across multiple plugins with deterministic ordering","Hook specifications with firstresult=True return the first non-None result from registered implementations","Hook wrappers intercept execution and allow inspecting or transforming hook return values","Historic hooks record calls and automatically replay them to plugins registered later","PluginManager manages plugin lifecycle including registration, lookup, blocking, and unregistration"],"goal":"verify pkg:pypi/pluggy@1.6.0","kind":"HOW","packages":["pkg:pypi/pluggy@1.6.0"],"schemaVersion":1},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pluggy@1.6.0"],"schemaVersion":1,"subject":"pkg:pypi/pluggy@1.6.0","verifierAdapter":"python@1"}
[project]
name = "verify-pluggy"
version = "0.1.0"
dependencies = [
"pluggy==1.6.0",
]
pluggy==1.6.0
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/pluggy@1.6.0",
"kind": "HOW",
"packages": [
"pkg:pypi/pluggy@1.6.0"
]
}
"""Contract verification test for pkg:pypi/pluggy@1.6.0."""
import sys
import pluggy
hookspec = pluggy.HookspecMarker("sample_project")
hookimpl = pluggy.HookimplMarker("sample_project")
class SampleSpecification:
"""Hook specifications for sample project."""
@hookspec
def calculate(self, x: int, y: int) -> int:
"""Calculate a value given x and y."""
@hookspec(firstresult=True)
def resolve_status(self, code: int) -> str:
"""Resolve a status string for a given code."""
@hookspec(historic=True)
def notify_event(self, event_name: str) -> None:
"""Historic hook to record and broadcast events."""
class AddPlugin:
@hookimpl
def calculate(self, x: int, y: int) -> int:
return x + y
class MultiplyPlugin:
@hookimpl(tryfirst=True)
def calculate(self, x: int, y: int) -> int:
return x * y
class StatusPluginA:
@hookimpl
def resolve_status(self, code: int):
if code == 200:
return "OK"
return None
class StatusPluginB:
@hookimpl(tryfirst=True)
def resolve_status(self, code: int):
if code == 404:
return "NOT_FOUND"
return None
class TransformWrapperPlugin:
@hookimpl(wrapper=True)
def calculate(self, x: int, y: int):
res = yield
return [item * 10 for item in res]
class LegacyHookWrapperPlugin:
@hookimpl(hookwrapper=True)
def calculate(self, x: int, y: int):
outcome = yield
raw_res = outcome.get_result()
outcome.force_result([item + 1 for item in raw_res])
def test_hook_registration_and_execution():
"""Verify PluginManager registers hooks and executes them with expected ordering."""
pm = pluggy.PluginManager("sample_project")
pm.add_hookspecs(SampleSpecification)
p1 = AddPlugin()
p2 = MultiplyPlugin()
pm.register(p1, name="add_plugin")
pm.register(p2, name="multiply_plugin")
results = pm.hook.calculate(x=3, y=4)
assert results == [12, 7]
def test_firstresult_hook():
"""Verify firstresult=True stops at the first non-None result."""
pm = pluggy.PluginManager("sample_project")
pm.add_hookspecs(SampleSpecification)
pm.register(StatusPluginA())
pm.register(StatusPluginB())
res_200 = pm.hook.resolve_status(code=200)
assert res_200 == "OK"
res_404 = pm.hook.resolve_status(code=404)
assert res_404 == "NOT_FOUND"
res_500 = pm.hook.resolve_status(code=500)
assert res_500 is None
def test_hook_wrappers():
"""Verify wrapper=True and hookwrapper=True can inspect and transform results."""
pm = pluggy.PluginManager("sample_project")
pm.add_hookspecs(SampleSpecification)
pm.register(AddPlugin())
pm.register(TransformWrapperPlugin())
res_wrapper = pm.hook.calculate(x=3, y=4)
assert res_wrapper == [70]
pm_legacy = pluggy.PluginManager("sample_project")
pm_legacy.add_hookspecs(SampleSpecification)
pm_legacy.register(AddPlugin())
pm_legacy.register(LegacyHookWrapperPlugin())
res_legacy = pm_legacy.hook.calculate(x=3, y=4)
assert res_legacy == [8]
def test_historic_hooks():
"""Verify historic hooks replay recorded calls to newly registered plugins."""
pm = pluggy.PluginManager("sample_project")
pm.add_hookspecs(SampleSpecification)
events_early = []
events_late = []
class EarlySubscriber:
@hookimpl
def notify_event(self, event_name: str):
events_early.append(event_name)
class LateSubscriber:
@hookimpl
def notify_event(self, event_name: str):
events_late.append(event_name)
early = EarlySubscriber()
pm.register(early)
pm.hook.notify_event.call_historic(kwargs={"event_name": "initialized"})
pm.hook.notify_event.call_historic(kwargs={"event_name": "started"})
assert events_early == ["initialized", "started"]
assert events_late == []
late = LateSubscriber()
pm.register(late)
assert events_late == ["initialized", "started"]
def test_plugin_lifecycle():
"""Verify plugin registration, lookup, blocking, and unregistration."""
pm = pluggy.PluginManager("sample_project")
pm.add_hookspecs(SampleSpecification)
plugin = AddPlugin()
pm.register(plugin, name="my_plugin")
assert pm.is_registered(plugin) is True
assert pm.get_plugin("my_plugin") is plugin
assert pm.get_name(plugin) == "my_plugin"
assert plugin in pm.get_plugins()
subset_caller = pm.subset_hook_caller("calculate", remove_plugins=[plugin])
assert subset_caller(x=2, y=3) == []
unregistered = pm.unregister(name="my_plugin")
assert unregistered is plugin
assert pm.is_registered(plugin) is False
assert pm.get_plugin("my_plugin") is None
pm.set_blocked("blocked_plugin")
assert pm.is_blocked("blocked_plugin") is True
pm.check_pending()
def main():
test_hook_registration_and_execution()
test_firstresult_hook()
test_hook_wrappers()
test_historic_hooks()
test_plugin_lifecycle()
print("All pluggy contract tests passed successfully.")
return 0
if __name__ == "__main__":
sys.exit(main())
오리진 시더
익명