Boundary note: This document should not be treated as the primary home for PyHall-specific Python worker implementation guidance. PyHall implementation-facing worker guidance belongs in:
/mnt/fafolab/dev/2026-432_pyhall/internal/planning/PYHALL_PYTHON_WORKER_E2E_REFERENCE.mdWCP itself stays at the protocol layer:
Classification,Routing,Controls,Evidence.
Status: Canonical reference for Python worker packaging and execution until superseded
Authority: WCP clarification layer for PyHall v0.3.0-era Python workers
Prepared: 2026-03-14
Prepared by: Codex
This document is the concrete canonical reference for what a Python WCP worker package is supposed to look like end to end.
It exists because:
- loose example files are not enough
- design-review reference code is not the same as canonical implementation guidance
- PyHall is the first serious implementation of this model
- the identity clarification must now be reflected in the worker example shape
This document defines:
- the canonical package layout
- the canonical identity fields
- the canonical startup flow
- the canonical attestation flow
- the canonical Python file roles
- the difference between:
PyHall app / opinionated full worker packagePyHall API-only / external runtime worker
- which existing files are authoritative source material
- which existing files are useful but non-canonical
For Python workers, the identity rules are:
cap.*= capability contractwrk.*= worker species taxonomyworker_id= actual worker instance identity- authority namespace inside
worker_idmust be one of:org.<name>.*x.<name>.*
Examples:
worker_id = "org.xyzcompany.rss.instance-1"worker_id = "org.abcdevelopmentcorp.telegram.instance-1"worker_id = "x.joe.summarizer.instance-1"worker_id = "x.lisajohnson.notifications.instance-1"
Examples of species identity:
worker_species_id = "wrk.pyhall.rss"worker_species_id = "wrk.pyhall.telegram"worker_species_id = "wrk.doc.summarizer"
Critical rule:
- trust attribution comes from
worker_id - taxonomy membership comes from
worker_species_id wrk.*is not an authority namespace
There are two valid ways to use PyHall governance with a Python worker.
This is the stronger, more opinionated model.
Typical characteristics:
- worker package exists on disk
- package includes
worker_logic.py,bootstrap.py,requirements.lock,config.schema.json, andmanifest.json - desktop app can scaffold and enroll the worker
- package-level attestation runs locally
- local evidence and local worker package structure matter
This path expects the full package shape.
This is the looser, language-agnostic integration model.
Typical characteristics:
- developer may run their own router, Hall-like runtime, or API server
- developer may not use the PyHall desktop app at all
- developer may use PyHall only for:
- namespace authority
- enrollment
- registry
- attestation checks
- policy/routing support
- local package layout can be thinner or externalized
This path does not require the same local file/package footprint as the app path.
PyHall app usage is not required for PyHall API usage.
PyHall can be:
- the full operator-facing stack
- or the governance/attestation layer used by an external runtime
The canonical Python worker package layout is:
worker-package/
code/
worker_logic.py
bootstrap.py
requirements.lock
config.schema.json
manifest.json
File roles:
code/worker_logic.py- the actual worker implementation
- identity declarations
- policy gate
- business logic
- telemetry and evidence emission
code/bootstrap.py- simple entrypoint that dispatches into worker logic
requirements.lock- pinned dependencies for the package
config.schema.json- package configuration contract
manifest.json- signed attestation manifest for the full package
Canonical rule:
- attestation applies to the full worker package, not just one
.pyfile
The canonical Python worker flow is:
- package exists on disk with the standard layout
manifest.jsonexists for the package- startup attestation runs before normal work
- worker verifies:
- package hash
- manifest identity
- manifest signature
- worker fails closed in production on attestation failure
- worker constructs
WCPContext - worker applies a fail-closed policy gate
- worker executes business logic only if allowed
- worker emits telemetry and evidence receipts
- worker returns a structured result
This is the canonical end-to-end posture for the full packaged worker path.
For API-only use, some of these steps may be externalized into the caller's own runtime.
This document adopts the 8-section model as the primary operator-facing Python worker shape because it is simpler, easier to scaffold, and aligns to the desktop app.
Internal substructure can still exist inside a section, but the visible top-level file shape should use these 8 sections.
The canonical worker_logic.py structure is:
Header + Identity + WCP DeclarationsCore ModelsUtility FunctionsPackage Attestation + Signature VerificationPolicy Gate (fail-closed)ObservabilityBusiness LogicCLI + Bootstrap
- required for PyHall app
- required for API-only usage
- this is where a human expects to find the top-of-file worker identity and declarations
- should include imports, identity fields, capabilities, controls, and versioning
- required for PyHall app
- required for API-only usage
- this defines the minimal request/response or context/result contract
- required for PyHall app
- optional/minimal for API-only usage
- can be very small
- helper functions can be externalized in API-only runtimes
- required for PyHall app
- not strictly required for API-only local file shape
- attestation still matters for governed production use, but the verification step may be externalized to API/runtime services instead of living inside the local worker file
- required for PyHall app
- optional in the local worker file for API-only usage if policy gating is handled by the external Hall/router/API layer
- if omitted locally, the external runtime must be the actual fail-closed enforcement point
- required for PyHall app
- required for API-only usage in some form
- local file implementation can be thinner if evidence/telemetry is emitted by the surrounding runtime instead
- required for PyHall app
- required for API-only usage
- this is the actual worker behavior
- required for PyHall app
- is not required for only API usage
- if an external server/runtime invokes the worker directly, this section can be absent or replaced by host-runtime glue
The canonical identity section should look like this:
WORKER_ID = "org.xyzcompany.rss.instance-1"
WORKER_SPECIES_ID = "wrk.pyhall.rss"
WORKER_NAME = "RSS Intelligence Worker"
WORKER_VERSION = "0.3.0"
CAPABILITIES = [
"cap.pyhall.rss.read",
"cap.pyhall.rss.manage",
]
REQUIRED_CONTROLS = [
"ctrl.obs.audit_log_append_only",
"ctrl.integrity.package_attested",
"ctrl.authz.fail_closed_policy_gate",
"ctrl.trace.correlation_id_required",
]Core model shape should include:
@dataclass
class WorkerContext:
correlation_id: str
capability_id: str
payload: dict[str, Any]| Section | Required for PyHall app | Required for API-only | Can be externalized | Notes |
|---|---|---|---|---|
| Header + Identity + WCP Declarations | Yes | Yes | No | Identity and declarations are the minimum contract anchor. |
| Core Models | Yes | Yes | Partially | Caller/runtime may define equivalent models externally, but the contract still has to exist. |
| Utility Functions | Yes | No | Yes | Helpers can live elsewhere. |
| Package Attestation + Signature Verification | Yes | No | Yes | API-only runtimes can call PyHall attestation APIs instead of verifying locally in the file. |
| Policy Gate | Yes | No | Yes | External Hall/router can enforce it. |
| Observability | Yes | Yes | Yes | Evidence and telemetry can be emitted by the host runtime. |
| Business Logic | Yes | Yes | No | This is the worker. |
| CLI + Bootstrap | Yes | No | Yes | Required for app-scaffolded packaged workers; not required for API-only invocation. |
For the PyHall app/full package path, package attestation should be explicit, for example:
verifier = PackageAttestationVerifier(
package_root=package_root,
manifest_path=manifest_path,
worker_id=WORKER_ID,
worker_species_id=WORKER_SPECIES_ID,
)
ok, deny_code, attest_meta = verifier.verify()For the API-only path, a developer may use a thinner local worker file and rely on PyHall APIs from an external runtime, for example:
# SECTION 1: Header + Identity + WCP Declarations
WORKER_ID = "org.xyzcompany.rss.instance-1"
WORKER_SPECIES_ID = "wrk.pyhall.rss"
CAPABILITIES = ["cap.pyhall.rss.read"]
# SECTION 2: Core Models
class WorkerContext: ...
class WorkerResult: ...
# SECTION 7: Business Logic
def execute(context: WorkerContext) -> WorkerResult:
...In that model, the external runtime may handle:
- attestation verification
- policy gate enforcement
- evidence emission
- API dispatch
That is valid as long as those responsibilities are actually handled somewhere real.
These are the current best authoritative source files for the canonical Python worker model.
Primary concrete implementation source:
/mnt/fafolab/dev/2026-432_pyhall/git-working/sdk/python/workers/rss_worker/code/worker_logic.py
Why:
- full worker package shape
- startup attestation
- fail-closed policy gate
- real worker operations
- evidence / telemetry pattern
- SQLite-backed concrete business behavior
Secondary concrete implementation source:
/mnt/fafolab/dev/2026-432_pyhall/git-working/sdk/python/workers/telegram_worker/code/worker_logic.py
Why:
- same overall WCP worker shape
- broader operation surface
- more complex external API interaction pattern
Attestation authority:
/mnt/fafolab/dev/2026-432_pyhall/git-working/sdk/python/pyhall/attestation.py
Why:
- canonical package hash
- manifest build logic
- signature verification logic
- tenant namespace extraction from
worker_id - trust statement semantics
Packaging/signing companion:
/mnt/fafolab/dev/2026-424_fafolab/git-working/docs/directives/examples/pyhall_attest_build_sign.py
Why:
- useful companion utility for package scaffold, sign, and verify flow
- good operational reference
- not the primary worker implementation itself
Useful design-review reference:
/mnt/fafolab/dev/2026-424_fafolab/git-working/docs/directives/examples/artifact_worker_wcp_v030_reference.py
Why non-canonical:
- it is a strong reference artifact
- but it is explicitly a reference rewrite for design review
- it is not the best “actual shipped worker package” example
The concrete PyHall worker packages are the right structural source, but some current worker IDs are not yet aligned with the sharpened authority-namespace rule.
Example current pattern found in implementation:
WORKER_ID = "pyhall.rss.instance-1"WORKER_ID = "pyhall.telegram.instance-1"
That is not the clarified canonical authority form.
Canonical authority form must be:
org.<name>.*- or
x.<name>.*
Therefore:
- the concrete package structure is canonical
- the authority-namespace field values still need follow-on alignment
Do not treat old pyhall.* worker IDs as the canonical namespace rule.
If Claude or any future agent needs to explain or implement a Python WCP worker, the order of authority should be:
- this document
WCP_IDENTITY_NAMESPACE_AND_TAXONOMY_MODEL.mdsdk/python/pyhall/attestation.pysdk/python/workers/rss_worker/code/worker_logic.pysdk/python/workers/telegram_worker/code/worker_logic.py- helper/reference examples in
fafolabdirectives
That is the correct order.
The canonical Python WCP worker is:
- usually a full package in the PyHall app path
- allowed to be thinner in the API-only path if runtime responsibilities are externalized explicitly
- attested at package level in the full package path
- fail-closed either locally or in the surrounding runtime
- identity-bound through
worker_id - taxonomy-bound through
worker_species_id - concretely modeled today by the PyHall Python worker packages
If a future example contradicts this document, this document wins until formally superseded.