Control Plane integration
The Control Plane (CP) is an optional, external service
(aitp-control-plane, a Next.js app) that the playground can talk to for
agent discovery, audit ingestion, revocation propagation, webhook
fan-out, and trust-anchor configuration. Everything here is best-effort
and optional — the service runs fully without a CP, and every CP call
has a graceful fallback. This page is the map of what the playground does
with a CP when one is wired up.
The hard invariant: no CP call is ever load-bearing. When
CP_BASE_URLis empty (the default), discovery returns[], ingest is a no-op, observability proxies returncp_enabled: false, and CP-only workflow steps emitstep.skipped. See architecture.md for where this sits.
The CP is a separate service with its own docs — this page does not restate them. Endpoint request/response shapes, auth, idempotency, the event envelope, and the database schema live in the control-plane repo: api.md · events.md · data-model.md. The stable contract the playground actually depends on (and what the CP may/may not change without coordination) is the CP's integration-playground.md. This page is only the playground side: which playground feature calls which CP endpoint, and what happens when the CP is absent.
Enabling it
CP_BASE_URL=http://localhost:4000 # the CP's base URL; empty disables everything here
CP_API_KEY=<bearer> # optional; sent as Authorization: Bearer on write/observability calls
CP_TIMEOUT_MS=5000 # per-request timeout (default 5000)The CP must speak the same wire protocol: this playground is on aitp/0.3
(aitp-sdk 0.19; aitp/0.3 since 0.17), so it needs a CP built on aitp >= 0.17. There is no
dual-accept: an older CP rejects the agents' Manifests at enrollment.
CpClient.enabled is simply bool(settings.cp_base_url). The Dockerized
e2e suite (docker-compose.test.yml) brings up a Postgres + CP + playground
stack and points CP_BASE_URL at the in-network CP container — see
docker.md.
Two clients, one CP
CP traffic originates from two places, and it's worth keeping them straight:
CpClient(src/aitp_playground/cp_client/client.py) — the service talks to the CP for discovery, event ingest, revocation publish, webhook management, and all the read-only observability projections surfaced under/cp/*.- Agent workers (
agents/base/agent_admin.py) — an agent talks to the CP directly for self-enrollment (enroll_with_cp) and to pull the revocation list (refresh-revocations) — verified before use, see aitp-integration.md § Revocation list ingest. The playground never enrolls on an agent's behalf; it pokes the agent's/adminroute and the agent makes the call itself (the same boundary rule as the AITP protocol — see aitp-integration.md).
CP endpoints the playground uses
Every method below lives on CpClient and degrades to the documented
fallback when the CP is disabled or any HTTP error occurs. This table is
the playground's dependency surface — for each endpoint's exact
request/response shape, auth, and filters, follow it into the CP's
api.md.
CpClient method | CP endpoint | Used by | Fallback |
|---|---|---|---|
discover_by_capability(cap) | GET /api/registry/agents?capability= | cp_registry discovery | [] → static localhost |
ingest_events(events) | POST /api/events | end of every run (background); cp_delegation_tree (awaited, mid-run) | no-op, logged |
publish_revocation(jti, reason) | POST /api/revocation/entries | revoke_tct with via_cp | False |
create_webhook(url, events, secret) | POST /api/webhooks | cp_subscribe_webhook | None |
list_webhooks() | GET /api/webhooks | startup sweep (main.py) | None → nothing swept |
delete_webhook(id) | DELETE /api/webhooks/{id} | run-end teardown, startup sweep | False, logged (404 = success) |
fetch_events_history(...) | GET /api/events/history | GET /runs/{id}/cp-audit | [] |
fetch_sessions(...) | GET /api/sessions | GET /runs/{id}/cp-sessions | [] |
fetch_tcts(...) | GET /api/tcts | GET /cp/tcts | [] |
fetch_delegations(...) | GET /api/delegations | GET /cp/delegations, cp_delegation_tree | [] |
replay_session(id, ...) | GET /api/sessions/{id}/replay | GET /cp/sessions/{id}/replay | [] |
fetch_dashboard_overview(window) | GET /api/dashboard/overview | GET /cp/dashboard | {} |
fetch_dashboard_agents() | GET /api/dashboard/agents | GET /cp/agents | [] |
list_trust_anchors(ns) | GET /api/trust-anchors | GET /cp/trust-anchors | [] |
list_pinned_keys(ns) | GET /api/pinned-keys | GET /cp/pinned-keys | [] |
upsert_trust_anchor(...) | POST /api/trust-anchors | cp_provision_trust_anchor | None |
upsert_pinned_key(...) | POST /api/pinned-keys | cp_provision_trust_anchor | None |
The playground does not call every CP route: for example
GET /api/trust-anchors/:id/jwks exists on the CP but is unused here, and
POST /api/registry/enroll + POST /api/registry/agents are called by the agent
workers (see "Two clients, one CP"), not by CpClient.
fetch_dashboard_overview(window) forwards the window to the CP as ?range=
(1h|24h|7d|30d; an unknown value makes the CP fall back to 24h).
The list-fetch methods are tolerant of envelope shape — they accept both
{items: [...]} / {events: [...]} and a bare top-level list, so they
keep working across CP response-shape tweaks.
Discovery (cp_registry)
(CP side: api.md § Discovery.)
When a scenario sets spec.trust.discovery: cp_registry, the
TrustOrchestrator resolves peers marked org: external through the CP:
- Derive a capability hint — the first workflow capability the runner sees targeted at that agent.
GET /api/registry/agents?capability=<hint>.- If the CP returns anything, read the first result's
handshakeEndpoint(the CP's camelCase key; the snake_case spelling is also accepted), derive the manifest URL from it, and tag the peersource: cp_registry. - On empty result, disabled CP, or any error, fall back to
http://localhost:<port>and tagsource: static_fallback.
cross-org/federated-analysis@1.0.0 is the worked example. Run it without
a CP and it transparently falls back to static localhost — the handshake
still completes.
CP-backed workflow steps
These step types only do CP work; each emits step.skipped when the CP is
disabled. Full field reference is in scenarios.md.
| Step type | What it does | Demo scenario |
|---|---|---|
enroll_with_cp | Agent self-enrolls (CP registry API): POST /api/registry/enroll to mint a one-time bearer token, then POST /api/registry/agents with that token and the identical manifest bytes — the CP binds the token to a hash of the exact /enroll body (so re-serializing the manifest between the two calls is rejected 401 TOKEN_INVALID). | intra-org/external-enrollment |
revoke_tct (via_cp: true) | Local revoke plus POST /api/revocation/entries under the issuer's AID, then the issuer pulls its entries (GET /api/revocations?iss=), signs them into its own list at /.well-known/aitp-revocation-list and verifies that list against its own AID before applying any entry — an unverifiable list is discarded, never merged. The CP signs nothing. Where that lives in the code: aitp-integration.md § Revocation list ingest; the rule itself is RFC-AITP-0008 §1.5. | intra-org/revocation-via-cp |
revoke_tct (via_cp: true, local_revoke: false) | POST /api/revocation/entries only — no local revoke — then the agents in refresh_agents (default: the issuer) pull, sign and verify their own lists. The grantor's next redemption rooted in that jti is refused with source revoked (issuer-list): the CP entry alone decides it. Skips without a CP. | intra-org/revocation-cp-only |
cp_subscribe_webhook | POST /api/webhooks pointing at this run's /webhooks/cp/{run_id} receiver; stores the returned secret on the run record for HMAC verification. | intra-org/webhook-subscription |
cp_provision_trust_anchor | upsert_pinned_key + optional upsert_trust_anchor (OIDC issuer) for an agent under a namespace, then reads them back. | intra-org/cp-trust-anchor-provisioning |
cp_delegation_tree | Flushes the run's events to the CP (awaiting the ingest, so the projection is populated mid-run), then walks a delegator's chain via GET /api/delegations (CP's recursive root_jti query) to show the chain as the CP observed it. | intra-org/cp-delegation-tree |
Webhooks (reverse fan-out)
cp_subscribe_webhook is the only place the CP calls back into the
playground. The flow:
-
The step registers a webhook at the CP whose URL is
<PLAYGROUND_BASE_URL>/webhooks/cp/{run_id}. -
The CP responds with a webhook
idand asecret. The playground stores the secret on the run record (and strips it from API responses). -
As CP-side events occur, the CP
POSTs them to/webhooks/cp/{run_id}. What the CP sends (delivery body, signature header, retries, circuit breaker) is the CP's contract: see api.md § Webhooks and events.md. -
The receiver (
api/webhooks.py) checks two HMAC-SHA256 signatures against the stored secret, both with a constant-time compare:X-Aitp-Signature(sha256=<hex>), computed over the body;X-Aitp-Timestamp-Signature, computed over"<X-Aitp-Timestamp>.<body>".
X-Aitp-Timestampis Unix seconds, written as bare digits, and is set on every attempt. It must be within 5 minutes of now. The body'senqueuedAtis ignored for this check, so a late retry is still accepted.Valid deliveries append a
cp.webhook.deliveredevent to the run log, and a repeateddeliveryIdis recorded only once. The receiver returns401for a missing or invalid signature or timestamp, a stale timestamp, or a body that carries only the body signature. An unknown run returns410 Gone, which the CP takes as "stop delivering here": it disables the subscription instead of retrying.
Inspect what arrived with GET /runs/{id}/cp-deliveries (the run's
webhook config, secret stripped, plus the delivered events).
A subscription lives only as long as its run:
- At run end (completed, failed or cancelled) the runner deletes it. On
success it first waits for the end-of-run event ingest, and in every case
then waits
CP_WEBHOOK_TEARDOWN_GRACE_SECS(default120), so the CP can still deliver and retry the run's own events. - At startup the service lists the CP's webhooks and deletes every one
under its own
PLAYGROUND_BASE_URL/webhooks/cp/, except those this process has already made. No run survives a restart, so the rest are orphans. This assumes one deployment per base URL: a second replica on the same URL would delete the first one's live subscriptions.
Observability projections
(CP side: api.md § Sessions, TCTs, Delegation chains, Dashboard, Trust anchors, Pinned keys.)
Two families of read-only endpoints surface what the CP knows. All return
cp_enabled: false with an empty payload when no CP is configured — safe
to call unconditionally from a dashboard.
Run-scoped (filtered to one run):
| Endpoint | CP source | Shows |
|---|---|---|
GET /runs/{id}/cp-audit | /api/events/history?run_id= | audit events the CP recorded for this run |
GET /runs/{id}/cp-sessions | /api/sessions?run_id= | handshake sessions for this run |
GET /runs/{id}/cp-deliveries | (local) | webhook deliveries received for this run |
Entity-scoped (across the CP, not one run):
| Endpoint | CP source | Shows |
|---|---|---|
GET /cp/tcts | /api/tcts | TCTs the CP has observed (filter by issuer/subject/audience/capability/session) |
GET /cp/delegations | /api/delegations | delegation chains (root_jti walks the whole tree) |
GET /cp/sessions/{sid}/replay | /api/sessions/{sid}/replay | ordered event stream for one session |
GET /cp/dashboard | /api/dashboard/overview | aggregate CP metrics for a time window |
GET /cp/agents | /api/dashboard/agents | per-agent CP metrics |
GET /cp/trust-anchors | /api/trust-anchors | configured OIDC issuer bindings |
GET /cp/pinned-keys | /api/pinned-keys | registered pinned keys |
Console passthrough (/cp-proxy)
GET /cp-proxy/{path} forwards a fixed list of CP read routes, so the
console reads the CP through the playground instead of calling it
anonymously (api/cp_proxy.py).
- Always key-gated. The playground API key (
x-api-keyorAuthorization: Bearer) is required whateverAITP_PLAYGROUND_REQUIRE_API_KEYsays. The route is new, so it has no keyless behaviour to keep. - GET only, exact allowlist. Anything else is a 404 before any upstream
call; other methods are a 405. Allowed:
api/health,api/readyz,api/dashboard/overview,api/dashboard/agents,api/delegations,api/events/history,api/events/stream,api/pinned-keys,api/registry/agents,api/registry/agents/{id},api/registry/agents/{id}/manifest,api/sessions,api/sessions/{id},api/sessions/{id}/replay,api/tcts,api/trust-anchors,api/trust-anchors/{id},.well-known/aitp-manifest. Admin and export reads are not on the list. - Path safety. The raw, still-encoded path is checked segment by
segment. Empty segments,
./..(encoded or not), and segments that decode to/,\,%or a control character are refused. Each segment is re-encoded before it goes upstream. The query string is passed through unchanged. - Credentials. Nothing from the caller's credentials goes upstream. The
request carries only
accept,if-none-matchandlast-event-id, plus the playground's own CP key:CP_READ_API_KEY(a read-only key) when it is set, otherwiseCP_API_KEY. - Responses. Status,
content-type,cache-control,etag,last-modified,expiresandretry-afterare passed through. Cookies andlocationare dropped, and redirects are never followed. Bodies are buffered up to 5 MiB (larger is a 502cp_response_too_large).api/events/streamis streamed as server-sent events with no read timeout, and the upstream connection closes when the caller disconnects. - Errors are
{"code", "detail"}JSON: 404not_found, 503cp_disabled(noCP_BASE_URL), and 502cp_unreachable. The upstream timeout isCP_PROXY_TIMEOUT_SECONDS(default 10).
Event ingest
(CP side: api.md § Events.)
After every run reaches run.complete, the runner fires a background task
that POSTs the full run event log to the CP's /api/events
(CpClient.ingest_events). This is fire-and-forget: a CP outage never
fails a run, and the task is only tracked so its reference stays alive.
What gets ingested is the store's event log for the run, not just the
orchestrator's own events. That distinction matters: the agent
subprocesses deliver their canonical events (handshake.complete,
delegation.issued/delegation.redeemed, tct.*) to
POST /internal/telemetry, which lands them in the store — and those are
exactly the events the CP projects sessions, TCTs, and delegations from.
(The delegation.issued telemetry also carries the signed delegation
token, so the CP's delegation projection can parse jti/src_jti.) The
one mid-run exception is the cp_delegation_tree step, which flushes the
run's events to the CP and awaits the ingest before querying the
delegation projection — otherwise the query would race the post-run batch
and always see an empty tree. CP projections are idempotent, so the
post-run batch re-sending those events creates no duplicates.
Which event types the CP recognizes vs. merely stores, and which it fans out to webhooks, is the CP's events.md.
What lives where (boundary check)
- The playground never signs revocation lists, mints CP bearer tokens, or canonicalizes CP payloads — agents and the CP own that. The playground only orchestrates when those calls happen.
- Revocation-list trust lives in
agents/, and only there — the single decision point isrefresh_revocations(); details in aitp-integration.md § Revocation list ingest.CpClientdeliberately has no revocation-fetch method — a second ingest path for the same artifact is what produced the signature-blind divergence this boundary now prevents. - The CP is a separate repo (
aitp-control-plane); its API contract is the source of truth for the endpoint shapes above. The envelope-tolerant parsing that survives inCpClientcovers observability projections only. It does not extend to the revocation snapshot: once a signature is checked, a response shape the parser accepts but the verifier did not sign over is a downgrade path, so the snapshot is parsed as the exact RFC-AITP-0008 §1.5 envelope and a wrapper-less response ismalformed, not a second accepted shape.
Where to read next
- The CP itself (API, events, data model, ops, deploy) → aitp-control-plane · docs
- The stable playground↔CP contract → integration-playground.md
- Trust discovery internals → aitp-integration.md
- Webhook/event surfacing in the UI → observability.md
- The CP-backed scenarios end-to-end → scenarios.md