Architecture
Big picture
The playground is a FastAPI service that owns the run lifecycle. A client starts a run of a named scenario; the scenario drives one or more agents or producers; agents in the LLM-backed scenarios call an LLM, and every producer publishes signed context to a registry; the registry verifies and stores it and — where webhooks are enabled — fires a webhook back to the playground; the playground fans every protocol step out to the client over SSE.
┌──────────────────────────────────────────────┐
client ──POST /runs──▶ playground (FastAPI) │
▲ │ │
│ SSE │ scenario.run(spec, events) │
│ /runs/{id}/events ▼ │
└────────────── in-process SSE bus ◀── acdp.* (webhook) ──┐ │
│ │ │
▼ agent.publish / retrieve / search │ │
┌──────────────┐ webhook ┌───────────────┴┐ │
│ acdp_client │────────────▶│ registry-a /-b │ │
│ (async httpx)│◀────────────│ (Rust bins) │ │
└──────┬───────┘ POST /ctx └───────┬────────┘ │
│ sign via acdp (Rust SDK) │ │
▼ ▼ │
forward webhooks ───────────▶ control-plane ───┘
run start/complete (optional, NestJS)Components
The playground service (playground/)
| Module | Responsibility |
|---|---|
main.py | FastAPI app, CORS, router wiring, lifespan |
config.py | pydantic-settings over .env; get_settings() is lru_cached |
api/ | HTTP routers: health, scenarios, runs, contexts, webhooks |
scenarios/ | Scenario registry, run lifecycle, and the S1–S34 catalog |
agents/ | BasePlaygroundAgent + LangChain / CrewAI / LangGraph adapters |
events.py | In-process SSE bus — one asyncio.Queue per run |
control_plane.py | Optional fire-and-forget bridge to the control plane |
conformance.py | Live conformance probes against real binaries |
pinned_keys.py | Key-rotation window evaluation (RFC-ACDP-0008 §9.3) |
retry_after.py | RFC 9110 Retry-After parsing (re-export) |
logging_setup.py | pretty / json structured logging |
The client library (acdp_client/)
An async httpx + Pydantic layer over the acdp Rust SDK. It owns transport
and type marshaling; all cryptography, JCS canonicalization, and SSRF IP
classification are delegated to the Rust SDK. See Client SDK.
The SDK (acdp, published to PyPI from acdp-rs/bindings/acdp-py)
A compiled (maturin/pyo3) extension — installed as a prebuilt wheel from PyPI —
that the playground imports for every protocol
primitive — signers (AcdpProducer / AcdpP256Producer), the verifier, the JCS
canonicalizer, the SSRF policy, and the did:web resolver. The playground does
not reimplement any of these; it only orchestrates them. The SDK is its own
project — see
acdp-rs
(producing,
consuming,
security,
bindings).
Scenario helpers (playground/scenarios/_receipts.py)
Some trust scenarios need artifacts a registry produces — a signed receipt,
a lifecycle event, a lineage-head receipt, a log checkpoint, or the body a
retrieval would serve — in states a live registry never emits (e.g. a receipt
under a since-rotated key). _receipts.py models that registry side offline
(synthesize_retrieval_body, mint_receipt, mint_lifecycle_event,
mint_lineage_head_receipt, mint_log_checkpoint). The delegation boundary
still holds: every signature, digest and canonicalization comes from the SDK,
and the playground authors only the registry-owned fields. What those fields
are, and which sit outside the content hash, is the spec's — see
RFC-ACDP-0001 §5.7,
RFC-ACDP-0010
and the registry's
RECEIPTS.md.
The run lifecycle
-
POST /runs(api/runs.py) validates the scenario, generates a UUIDrun_id, merges scenario defaults with request inputs into aRunSpec, creates an event queue (events.create_queue), and spawnsrunner.execute(...)as a background task. Returns 202 with astream_url. -
runner.execute(scenarios/runner.py) emitsrun.startedand awaits the control-plane start notification (so start/complete stay ordered at the CP), calls the scenario'srun(spec, events)coroutine, then emitsrun.complete(withcontexts_produced, thelineage_graph, andstatus) orrun.error(with the exception message andstatus; the full traceback is kept on the persistedRunResult.error). The eventtypedistinguishes "returned" from "raised", not success from failure — a scenario can return without raising but withRunResult.status == "failed"(an internal assertion failing, not a transport exception), which still streamsrun.complete; itsstatusfield is what actually carries the outcome. TheRunResultis persisted in an in-process dict, thennotify_run_completeis awaited (the playground'scompleteis sent to the CP ascompleted;failedpasses through). -
The scenario uses
_factory.pyhelpers to mint deterministic agent identities, buildAcdpClients (one per registry, cached in anAgentBundle), and run agents. Each agent action (publish,retrieve,search) emits aStepEventonto the queue. -
The registry verifies the signature, stores the context, and (in a fully live deployment) POSTs a webhook to
/webhooks/acdp. The webhook handler verifies the HMAC signature, lifts tenant/dedup/run headers onto the event, transforms it into aStepEvent, and enqueues it onto the matching run's bus. -
GET /runs/{id}/eventsdrains the queue astext/event-stream, emitting keepalives every 15s and terminating onrun.complete/run.error. If the run already finished, it replays the final result instead. The queue is dropped only after the terminal event has been delivered, so a client that disconnects mid-run can reconnect and resume the same stream, andGET /runs/{id}keeps answering while the run is in flight.
Determinism & identity
Agent identities are deterministic within a run but fresh across runs.
RunSpec.agent_seed(slug) is sha256(run_id:slug), so the same slug always
yields the same 32-byte key seed within a run, while a new run_id produces a
new identity. Producers are minted from these seeds in _factory.producer_for
(P-256 rehashes the seed to a valid curve scalar). The DID method is chosen per
call: the factory default (method="did:web" on producer_for and
make_langchain_agent) yields did:web:{authority}:agents:{slug} with key id
{did}#key-1, but most scenarios pass method="did:key" — a self-certifying
DID derived from the key, which a stock registry can verify without fetching a
DID document — and several build AcdpProducer.from_seed_did_key(...)
directly. A few still use did:web (the factory default, or a DID pinned in
the registry config). Scenarios lists the identity each
scenario uses.
Graceful degradation
Many V2/security scenarios depend on infrastructure the stack may not provide
— the control plane, a provisioned registry profile (receipts, lifecycle, log),
or, for S10 only, live token issuance for a per-run did:web identity whose
DID document is not web-hosted. These scenarios are built to degrade
gracefully — they complete and mark themselves complete-but-degraded via a
degraded: true flag in the run summary rather than failing. Their
deterministic cores (P-256 crypto, cursor logic, tenant-header policy, rotation
windows, Retry-After) are always exercised offline. See
Scenarios for which scenarios degrade and why.
The control plane bridge
This describes only the playground side (playground/control_plane.py).
The control plane's ingest, auth, introspection, revocation, capability and
policy surfaces are its own — see
API.md,
INGEST.md
and AUTH.md.
CONTROL_PLANE_URLempty → every method is a no-op and the playground runs standalone.- Set → registry webhooks are forwarded to
/ingest/acdp(headers and signing in HTTP API → Webhooks), and run start/complete are posted and awaited by the runner. - Forwards and run notifications (
_post) get one retry on429/502/503/504, and only when the response carries a parseableRetry-After; the wait is capped at 30 s. Failures are logged, never raised into the run. domain_packs()(GET /domain-packs) needs onlyCONTROL_PLANE_URL.introspect,revocations,events,declare_capabilityandreload_pinned_keysadditionally needCONTROL_PLANE_ADMIN_TOKENand returnNonewithout it.