Skip to content

fix(training-agent): accept the training governance service's own tokens at governed tenants - #7757

Merged
bokelley merged 1 commit into
mainfrom
fix/multi-agent-governance-storyboards
Sep 29, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/multi-agent-governance-storyboards

Conversation

@bokelley

@bokelley bokelley commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7742

Refs #7741, which is not fixed here: its routing is still blocked by the SDK, even on @adcp/sdk rc.50. See "Where #7741 stands" below.

The branch is rebased onto main at 080cdcebf (#7759, the @adcp/[email protected] bump). The results below are from that base unless marked otherwise.

Root cause

When a buyer registers a governance authority through sync_governance, the governed tenants verify the token with iss === <registered authority URL>. They get the key only through the buyer's brand.json, and local keys are off. This covers create_media_buy / update_media_buy on sales, activate_signal on signals and build_creative on creative.

The seller allowlist's entry for the training agent's own governance service is https://test-agent.adcontextprotocol.org. The storyboards register that URL as governance_agent_url. The /governance tenant signs as ${getCanonicalBase()}/governance:

  • production: https://agenticadvertising.org/governance (CANONICAL_GOV_ISS);
  • local: http://localhost/governance, or the local origin when TRAINING_AGENT_URL is set.

So the tenants never accepted the governance tenant's own tokens: governance_context issuer does not match the registered governance authority. This isn't only a local problem. The same mismatch happens in production. Even with a matching iss, the key lookup would still fail, because the fictional buyer brand (acmeoutdoor.example) has no brand.json. acquire_rights on brand never looks at the registered authority and already expects ${getCanonicalBase()}/governance, so brand only hit the audience half.

The audience half is on the runner side. The governed tenant verifies aud === ${getCanonicalBase()}/<tenant>. The storyboards' default target_agent context value is https://test-agent.adcontextprotocol.org/<tenant>, and their prerequisites say the runner must override it with the endpoint under test. The harness doesn't do that yet. That override belongs with the #7741 routing work. The verifier's audience check is correct and is not changed here.

Reproduced with a routed run of the three governance_approved storyboards (throwaway diagnostic, see below):

Governed call token iss expected iss (before) token aud expected aud
activate_signal http://localhost/governance https://test-agent.adcontextprotocol.org/ https://test-agent.adcontextprotocol.org/signals http://localhost/signals
build_creative http://localhost/governance https://test-agent.adcontextprotocol.org/ https://test-agent.adcontextprotocol.org/creative-builder http://localhost/creative-builder
acquire_rights http://localhost/governance http://localhost/governance https://test-agent.adcontextprotocol.org/brand http://localhost/brand

Fix

  • getTrainingGovernanceIssuer() (canonical-base.ts) is now the only source for the governance issuer. The signer (check_governance) and every verifier use it.
  • isTrainingSelfGovernanceAuthority() (account-handlers.ts) matches only the allowlist entry for the training governance service.
  • For that authority, the governed tenants expect exactly this deployment's governance issuer and verify only against the one governance public key this deployment publishes. allowLocalVerificationKeys stays false, so the local revoked demo key is still rejected.
  • Every other registered authority is unchanged: iss must equal the registered URL byte for byte, and the key comes from remote discovery.
  • aud, caller, phase, task, payload-hash, commitment and replay checks are untouched.
  • For the self authority, the create_media_buy online execution check now goes to the deployment's own /governance tenant in process. The seller authenticates as its canonical ${base}/sales identity. The returned purchase token is verified with the same issuer/key rule.
    • Before, the old issuer check made this path unreachable.
    • Without this change, it would dial the registered locator URL over the network.

Production values don't change. The issuer is still https://agenticadvertising.org/governance, and the advertised accepted_governance_agents list is unchanged. The one behavior change is that a correctly bound token from the production governance tenant is now accepted when the buyer has registered the training governance service. Before, that token was always rejected.

No changeset: this is training-agent code only, with no protocol surface.

Tests

New cases in server/tests/unit/training-agent.test.ts ("with the training governance service registered as the authority (#7742)"):

  • Production canonical base and local-origin canonical base: activate_signal accepts the tenant's own token (iss = <base>/governance, aud = <base>/signals), and create_media_buy completes through the in-process execution check.
  • The production issuer is still CANONICAL_GOV_ISS.
  • Strictness:
    • a token issued under another deployment base is rejected (issuer);
    • a token bound to https://test-agent.adcontextprotocol.org/signals is rejected (audience);
    • the revoked demo key is rejected;
    • a third-party authority (https://governance.example/mcp) still gets issuer does not match for a self-issued token.
  • The tests fail without the fix. Reverting the verifier change fails 4 cases, and disabling the in-process execution check fails 2.

Verification

  • npx vitest run --config server/vitest.config.ts server/src/ server/tests/unit/{training-agent*,account-handlers*,storyboard-runner*,governance*}: 40 files, 1419 tests passed on rc.50 (38 files, 1395 tests on rc.49 before the rebase).
  • npm run typecheck: passed.
  • node --test tests/test-coverage-registration.test.cjs: passed. No new test files.

Storyboards, harness as on main (ADCP_COMPLIANCE_DIR=dist/compliance/latest):

  • "Before" is main on rc.49.
  • "After" is this branch on rc.50 main, run with a built ADCP_SCHEMA_ROOT as the matrix uses.

The rows match, as expected: routing isn't enabled, so nothing here reaches the changed path.

Tenant Storyboard Before After
signals signal_marketplace/governance_approved 0P/1S (multi_agent) 0P/1S
brand brand_rights/governance_approved 0P/1S (multi_agent) 0P/1S
creative-builder creative_transformers/governance_approved 0P/1S (multi_agent) 0P/1S
sales media_buy_seller/governance_approved 0P/1S (multi_agent) 0P/1S
sales media_buy_seller/governance_conditions 0P/1S (multi_agent) 0P/1S
sales media_buy_seller/governance_denied 0P/1S (multi_agent) 0P/1S
sales media_buy_seller/governance_denied_recovery 0P/1S (multi_agent) 0P/1S
sales reporting_core 23P 23P
sales media_buy_seller/account_change_feed 17P 17P
sales media_buy_seller/governance_agent_binding_acceptance 5P 5P
sales pagination_integrity_list_accounts 8P/1F* 9P
sales sales_guaranteed 14P/1F* 15P
signals signal_marketplace 8P 8P
signals signal_marketplace/governance_denied 4P 4P
brand brand_rights 9P 9P
brand brand_rights/governance_denied 5P 5P
creative-builder creative_transformers/governance_denied 4P 4P
governance governance_spend_authority 11P/1S 11P/1S
governance governance_spend_authority/denied 5P 5P
governance governance_delivery_monitor 11P/17S 11P/17S

* The before run had no built ADCP_SCHEMA_ROOT, so the get_capabilities schema check failed locally. With the schema root set, both storyboards are clean on rc.49 as well.

Routed diagnostic runs, with the #7742 fix and the #7741 routing held back from this PR. The SDK blockers were bypassed locally only to reach the governed calls. The tokens' iss and aud now equal the governed tenant's expected values for activate_signal, build_creative, acquire_rights and create_media_buy. On @adcp/sdk rc.49, brand_rights/governance_approved runs 7P, clean, with issues A and B below bypassed, and media_buy_seller/governance_denied runs 5P, clean, with A bypassed. The #7742 unit tests and typecheck also pass on @adcp/[email protected].

No floors change.

Where #7741 stands (not in this PR)

I built routing for requires: [multi_agent] storyboards (branch wip/7741-multi-agent-routing, local for now):

  • each agent key maps to its sibling tenant in the one embedded training-agent process;
  • default_agent must be the tenant under test;
  • the authored governed-agent context key (signal_agent_url, seller_agent_url, ...) gets that tenant's service identity, which the storyboards' prerequisites ask the runner to supply;
  • controller seeding is left to the SDK.

@adcp/[email protected] fixes adcontextprotocol/adcp-client#3047 and #3044, but routing still can't land. Results with routing on rc.50 (branch wip/7741-multi-agent-routing on the same rc.50 main):

Storyboard Unrouted (today) Routed on rc.50 What blocks it
signal_marketplace/governance_approved 0P/1S 3P/1F/3S A, B, then D
brand_rights/governance_approved 0P/1S 3P/4S A, B
creative_transformers/governance_approved 0P/1S 3P/3S A, B, C
media_buy_seller/governance_approved 0P/1S 0P/1S A, B
media_buy_seller/governance_conditions 0P/1S 3P/9S A, B
media_buy_seller/governance_denied 0P/1S 1P/4S A only (5P clean with A bypassed)
media_buy_seller/governance_denied_recovery 0P/1S 0P/1S Correctly not applicable: sales doesn't declare media_buy.governance_aware

What blocks them:

  • A (SDK). The runner applies the storyboard-level requires_capability, which describes the governed agent, to each routed step's own agent. Every governance-agent step (sync_plans, check_governance, ...) is therefore skipped as not_applicable, and the governed call cascades to a skip. This is evaluateStoryboardCapabilityGates(storyboard, selected.profile, ...) in the routed pre-pass. It is still present in rc.50 and has no issue yet.
  • B (SDK or spec). The SDK client adds adcp_version/adcp_major_version to the downstream governed request but not to check_governance.payload. The payload hash excludes exactly governance_context and context, so the service correctly rejects the call with "The governed task payload does not match the signed authorization." Seen on create_media_buy, activate_signal, build_creative and acquire_rights.
  • C (SDK). The build_creative request builder merges brand, quality: "draft" and include_preview: true into the authored request after the payload was approved.
  • D (training agent, follow-up). get_signals readback reports only the agent deployment, so a live platform destination activation isn't visible.

Turning routing on now would drop the signals clean count by one. It would also report the others as clean while skipping the governed call, so it stays off until A and B are fixed. The account_change_feed brandFromKit exclusion from #7716 passes 17/17 without it on rc.50. I removed it on the WIP branch, because it can only go once rc.50 is merged.

🤖 Generated with Claude Code

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — clean, correctly-scoped training-agent fix.

What I checked:

  • Change is confined to server/src/training-agent/** plus unit tests — no protocol surface (static/schemas/source/**), no docs/reference/**, no dist/** artifacts, no version bump, no oneOf change. No changeset required.
  • Governed tenants now accept the training governance service's own tokens by pinning the deployment's governance issuer and single published signing key; fail-closed posture preserved (allowLocalVerificationKeys stays false, revoked demo kid rejected).
  • TRAINING_AGENT_URL swap is value-identical; getTrainingGovernanceIssuer centralization is a no-op rename; self-authority create_media_buy path runs in-process, verified by tests asserting the network client is never dialed.

Decision path: No critical/high/medium findings (rows 1, 4, 5, 6, 8 don't fire). gated_paths is false (row 2 n/a). high_risk is false (rows 3, 5 n/a). No no-auto-approve team match (row 7 n/a). Falls through to row 9 → approve. Note: review_decision is REVIEW_REQUIRED but the gated-paths gate (row 2) only applies when gated_paths is true, which it is not here.

One Low follow-up noted (in-process check errors mapped to transient GOVERNANCE_UNAVAILABLE, sandbox-only impact) — non-blocking.

…ens at governed tenants

With a governance authority registered through sync_governance, the
governed tenants (sales create/update_media_buy, signals activate_signal,
creative build_creative) required iss to equal the registered URL and
resolved the key only through buyer brand.json. The seller allowlist's
entry for the training agent's own governance service
(https://test-agent.adcontextprotocol.org) never matches what the
/governance tenant signs (${canonical base}/governance), so its own
tokens were always rejected, locally and in production.

For that single self entry, governed tenants now expect exactly this
deployment's governance issuer and verify only against the one governance
key this deployment publishes; local demo keys stay disallowed and every
other authority keeps the byte-for-byte iss rule and remote discovery.
The create_media_buy online execution check consults the deployment's own
governance tenant in process for the self authority instead of dialing the
registered locator over the network. The governance issuer now has one
source, getTrainingGovernanceIssuer(), used by the signer and verifiers.

Closes #7742

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bokelley
bokelley force-pushed the fix/multi-agent-governance-storyboards branch from 3d55778 to feab1c0 Compare September 29, 2026 18:18

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — clean fail-closed security refactor to the sandbox training agent's governance-token verification.

What I checked:

  • The delta teaches the training agent to accept its own /governance tenant as a registered authority (#7742) while preserving byte-for-byte issuer/audience checks and remote key discovery for every third-party authority. Self-authority is verified against the deployment's own issuer and single published signing key with allowLocalVerificationKeys: false.
  • New tests prove the wrong-base, wrong-audience, revoked-demo-key, and third-party rejection boundaries all still fail closed.
  • All changes are under server/** app code — no protocol surface (static/schemas/source/**, docs/reference/**, dist/**), so no changeset required per repo scope rules.
  • No high-risk paths, no gated paths (and review_decision is APPROVED regardless), no no-auto-approve team match.

Findings: none (no critical/high/medium). Prior decision was also approve with no findings — this run confirms the clean state.

Rows 1–8 do not fire; falls through to row 9 → approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant