Skip to content

fix(training-agent): let third-party sellers use the public governance agent (#7758) - #7786

Merged
bokelley merged 2 commits into
mainfrom
fix/7758-governance-agent-third-party
Sep 30, 2026
Merged

bokelley merged 2 commits into
mainfrom
fix/7758-governance-agent-third-party

Conversation

@bokelley

@bokelley bokelley commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of #7758. This PR fixes two of the three public-governance-agent blockers listed in #7779. The third blocker, and a fourth one found while testing, need decisions (see "Decisions needed").

Reproduced first

I ran these against production https://test-agent.adcontextprotocol.org/governance/mcp with the public token (2026-09-30):

# Blocker Result
1 Execution check with the storyboards' gov-token-xxxx… credential HTTP 401
2 Public token with caller = seller URL Authenticated agent identity … must match caller
2 Public token with caller = its own identity Execution governance caller must authenticate as the service audience
3 Intent token iss https://agenticadvertising.org/governance, while the registered URL is https://test-agent.adcontextprotocol.org

Other findings for blocker 3:

  • That registered URL doesn't serve MCP.
  • No revocation list is published at the iss origin.
  • acmeoutdoor.example has no brand.json anywhere, including AAO's /brands/…/brand.json and /api/brands/resolve.

The new test file reproduces blockers 1 and 2 over HTTP before it checks the fix.

Fixes

Blockers 1 and 2: seller credential bound to the seller URL

New server/src/training-agent/governance-agent-credentials.ts adds a stateless, HMAC-signed sandbox credential: adcp-sandbox-gov.v1.<claims>.<mac>.

  • How it's used. The hosted runner mints it in-process for the agent under test. It substitutes the credential into its copy of the storyboard's sync_governance step, the same way fix(compliance): route hosted multi_agent governance storyboards to the public governance agent #7779 already rewrites caller and plan ids. The seller receives the credential and presents it on check_governance.
  • Spec basis. It implements specification.mdx §Setup: the governance agent resolves the credential to the registered agent URL and requires that URL to equal caller.
  • Scope. The credential:
    • authenticates on the governance tenant only (/governance/mcp and the new root route). Every other route returns 401.
    • resolves to exactly the bound seller URL.
    • expires within 30 minutes.
    • may call only check_governance execution checks and report_plan_adjustment (report only), and only on plans whose id ends with that run's nonce. The router enforces this with a tool allowlist, and the handlers reject the credential again on every buyer-side operation.
  • Minting rules. HTTPS only. The URL can't carry userinfo, a query or a fragment. Hosts under agenticadvertising.org and adcontextprotocol.org are refused, so a minted credential can never take a sandbox identity such as ${base}/sales or …/authenticated/<hash>.
  • Key. HKDF-derived from the new secret TRAINING_GOVERNANCE_CREDENTIAL_SECRET (32+ characters). With the secret unset, the feature is off: minting throws and nothing verifies. There is no default fallback.
  • Redaction. Addie's storyboard output redaction now also matches the credentials key and the credential prefix. Before this, the existing credential key pattern would have shown the minted value.

Blocker 3, issuer half: one governance identity

Governance tokens are now signed with iss = the training agent's own URL:

  • Production: https://test-agent.adcontextprotocol.org, with no trailing slash.
  • Local and CI runs: TRAINING_AGENT_URL.

This is the URL the storyboards register, and it satisfies the SDK seller helper's byte-for-byte expectedIssuer check. The URL is now coherent:

  • POST / on the training agent serves the governance tenant, so a seller can call check_governance at the registered URL. Exact POST / is now exempt from CSRF so an unauthenticated MCP client gets the bearer challenge (no cookie route handles POST / on any host); GET / is unchanged.
  • The signed revocation list at {origin}/.well-known/governance-revocations.json names the same issuer.
  • The S6 lab verifier and its demo tokens use the same issuer.
  • Tenant audiences (${canonicalBase}/<tenant>) and fix(training-agent): accept the training governance service's own tokens at governed tenants #7757's self-authority path are unchanged.

I didn't add the governance key to the app-level /.well-known/jwks.json. That document serves Addie's request-signing keys on every host, and the sandbox governance key can be derived by anyone (security review). Key discovery goes through buyer brand.json, which is decision D below.

Decisions needed (not implemented)

Both reviewers agreed these can't be closed without a normative or conformance-program decision.

  • D: buyer brand.json for .example test-kit brands.
    • Step 13 and JWKS discovery trust only brand.json fetched from the authenticated buyer's domain (security.mdx §Buyer identity resolution). acmeoutdoor.example can never resolve.
    • The test kit's note that "agents resolve acmeoutdoor.example via the standard AAO brand resolution path" isn't normative, and no such path exists in production.
    • Decision: may a seller use AAO's /brands/{domain}/brand.json in place of https://{domain}/.well-known/brand.json for reserved-TLD test-kit brands, and for which accounts? If not, step 13 can't be graded in hosted runs.
  • B4: intent caller binding.
    • The SDK's verifyGovernanceAuthorization rejects the token unless its caller claim equals the seller's authenticated caller. security.mdx:860 lists that mismatch as governance_token_not_applicable, but the 15-step checklist doesn't include it.
    • In hosted grading, caller is the identity the governance agent bound to the grader's governance credential. The seller maps the owner's credential to an identity of its own, so the two never match.
    • Decision: must a service bind caller to its authenticated buyer? If yes, what is the canonical buyer agent URL for hosted grading (for example https://compliance-runner.example from signed-requests-runner.yaml)? The runner would then authenticate to governance as that identity. The credential format here supports binding any URL.

Separate fixture defect (not changed here): governance_denied has no intent step. A correct seller with a registered governance agent and no governance_context returns PERMISSION_DENIED (error-handling.mdx:374), but the fixture asserts GOVERNANCE_DENIED. It also buys on the sandbox: true account, which is not the account governance was registered on.

What the #7779 routing and the heartbeat wiring must also do

In production, blockers 1 and 2 close only after the runner mints and substitutes the credential and the secret is set. Nothing in this PR mints it outside tests.

  • Check governanceAgentCredentialsEnabled(), then mint per run with mintGovernanceAgentCredential(sellerAgentUrl, { nonce: runNonce }). runNonce is the suffix fix(compliance): route hosted multi_agent governance storyboards to the public governance agent #7779 already appends to the plan ids. Substitute it into every sync_governance step's governance_agents[].authentication.credentials in the storyboard copy.
  • sellerAgentUrl must be byte-identical to context.seller_agent_url (the intent target_agent / token aud). Mint it from the URL after the SSRF check.
  • Scrub the minted value from stored run results and logs, not just Addie's output.
  • Keep governance_agent_url pinned to the authored https://test-agent.adcontextprotocol.org. That's now the real issuer and the MCP endpoint.
  • Ops: set the Fly secret TRAINING_GOVERNANCE_CREDENTIAL_SECRET. All machines must share it.

Testing

  • server/tests/unit/training-agent-governance-agent-credentials.test.ts: 9 tests over HTTP against the training-agent router.

    • It reproduces blockers 1 and 2.
    • A minted credential completes the execution check at the registered root URL: approved, with a purchase token carrying iss = registered URL and aud = caller = seller.
    • iss and the revocation-list issuer match, with no trailing slash.
    • Negative cases:
      • URL binding: another seller's credential is rejected.
      • Run scope: plans from another run are rejected.
      • Buyer-side tools: sync_plans, outcomes, audit logs, the controller, accounts and intent checks are rejected.
      • Other tenants and legacy /mcp return 401.
      • Tampered or expired credentials, an unset secret, and reserved or non-HTTPS mint targets are all rejected.
  • Existing suites: training-agent*, server/src/training-agent, comply-test-controller, storyboard-runner-options, storyboard-fix-plan, the Addie web-tool tests and training-agent integration all pass. The Training agent rejects governance tokens in local multi-agent runs: issuer/audience are pinned to the production host #7742 tests and the lab verify_governance_token test were updated for the new issuer.

    • One webhook integration test failed once under load and passes on rerun.
  • End-to-end diagnostic (local, not committed).

    • Setup:

      • media_buy_seller/governance_{approved,conditions,denied} routed as fix(compliance): route hosted multi_agent governance storyboards to the public governance agent #7779 does.
      • sales goes to a loopback HTTPS third-party seller. That seller is not the training agent's sales tenant: it enforces with the SDK's verifyGovernanceAuthorization, using expectedIssuer = the registered URL, and runs an online execution check at the registered URL with the registered credential.
      • governance goes to the training agent's governance tenant.
    • Results:

      Run Result
      With decisions D and B4 assumed governance_approved 13/13 and governance_conditions 12/12 pass. governance_denied fails only at create_media_buy_denied (fixture defect above).
      Placeholder credential The execution check fails with HTTP 401 (blocker 1)
      Without the B4 assumption governance_token_not_applicable: Governance token caller mismatch
      Without the D assumption Buyer brand.json can't be resolved
  • npx tsc --noEmit -p server/tsconfig.json passes.

  • No changeset: training agent and Addie only.

🤖 Generated with Claude Code

@gitguardian

gitguardian Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@bokelley
bokelley force-pushed the fix/7758-governance-agent-third-party branch from 4f9373a to c2d197c Compare September 30, 2026 08:41
…e agent (#7758)

Third-party governance-aware sellers could not complete the governed commit
against the public sandbox governance agent in hosted grading:

- Seller credential / audience binding: the storyboards register the
  governance agent with a literal placeholder credential, and the shared
  public token maps to a per-token identity, so no credential could
  authenticate as the seller URL the intent is bound to. Add stateless,
  HMAC-minted sandbox governance-agent credentials
  (TRAINING_GOVERNANCE_CREDENTIAL_SECRET) that the hosted runner mints for
  the agent under test and substitutes into its storyboard copy. They
  authenticate only on the governance tenant, resolve to exactly the bound
  seller URL, expire within 30 minutes, and may only run execution checks
  and seller adjustment reports on plans from their own run.
- Issuer: governance tokens were signed as `${canonicalBase}/governance`
  (https://agenticadvertising.org/governance in production) while the
  storyboards register https://test-agent.adcontextprotocol.org. The issuer
  is now the training agent's own URL, the revocation list names the same
  issuer, and POST / on the training agent serves the governance tenant so
  a seller can call check_governance at the registered URL.
- Addie's storyboard output redaction now covers the `credentials` key and
  the minted credential prefix.

No protocol change; training agent and Addie only.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bokelley
bokelley force-pushed the fix/7758-governance-agent-third-party branch from 274717d to 0647ad4 Compare September 30, 2026 08:43

@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 — sandbox governance-agent credential design (mint/verify, router allowlist, handler-level buyer-side/plan-scope guards, reserved-host mint protection, redaction) plus app-only governance issuer unification. Fail-closed at every layer with strong test coverage on the largest changed files (governance-agent-credentials.ts +289 and its +320 test).

Gate checks:

  • No critical/high/medium findings.
  • gated_paths: false; review_decision REVIEW_REQUIRED does not force escalation without a gate.
  • high_risk true only from a modified match on server/src/addie/mcp/member-tools.ts, but reviewer found no medium-or-higher concerns there (row 5 not triggered).
  • No no-auto-approve team match; no deletions in high-risk paths.
  • Training-agent/Addie code only — no protocol surface touched, so no changeset required.

Only a single Low note (duplicated issuer constant), not blocking. Rows 1–8 do not fire; falls through to row 9.

@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 review, no blocking or medium findings.

Checked:

  • Auth boundary: governance-tenant-only authenticator, router re-verification and tool allowlist, defense-in-depth handler guards — verified.
  • Cross-run/tenant isolation and MAC-before-parse credential verification — verified.
  • Issuer coherence across signer/verifier/self-authority/revocation — consistent.
  • Changeset scope: correctly omitted; changes are training-agent + Addie only, no protocol surface (static/schemas/source/**, docs/reference/**, dist artifacts) touched.

Notes on gates:

  • high_risk is true only via server/src/addie/mcp/member-tools.ts (modified), but the reviewer surfaced no medium-or-higher concerns on that file, so the modification is presumed safe (does not trigger row 5).
  • gated_paths: false, so row 2 does not apply despite review_decision: REVIEW_REQUIRED.
  • No no-auto-approve team match; no prior decision.
  • No breaking protocol/wire change — this is a platform/app change, not a spec change.

None of decision-table rows 1–8 fire; falls through to row 9 → approve.

@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 — no blocking or medium findings.

The reviewer found no Critical/High/Medium issues across this training-agent sandbox governance-agent credentials PR. Verified points: seller identity derives solely from HMAC-signed claims with server-side re-verification; nonce plan-scope and audience binding are not request-spoofable; router allowlist and handler rejections layer correctly; tenant isolation, issuer coherence, redaction, and the fail-closed unset-secret path all hold.

Decision-rule walk-through:

  • Row 1 (critical/high): no such findings.
  • Row 2 (gated_paths + not APPROVED): gated_paths is false — does not fire despite review_decision=REVIEW_REQUIRED.
  • Row 3 (deleted high-risk): no deletions.
  • Row 4 (medium data-loss/schema/infra): no medium findings.
  • Row 5 (high_risk modified + medium): server/src/addie/mcp/member-tools.ts is (modified) and high_risk, but there are zero medium findings, so this does not fire.
  • Row 6 (sticky escalate): no prior decision.
  • Row 7 (no-auto-approve team): no team match.
  • Row 8 (≥3 medium): zero medium findings.
  • Row 9: approve.

App-only change (training agent + Addie); no changeset required, no schema/dist/docs surface touched. high_risk is only a heuristic here and the modified sensitive file carries no findings, so no escalation is warranted.

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Sep 30, 2026

@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.

Checked: PR scopes a stateless HMAC-signed sandbox governance-agent credential to a single seller URL + hosted-run nonce with layered defense — mint-time HTTPS/reserved-host validation, timing-safe MAC verify with a 30-min TTL cap, router re-verification from the Authorization header plus governance-tenant + method/tool allowlist failing closed, and handler-level buyer-side rejection reading the authoritative plan id (governance-handlers.ts:1207). Issuer coherence flows through one getTrainingGovernanceIssuer(). Scope is server/** only, so changeset omission is correct — no schema/docs/dist/oneOf concerns.

Decision path:

  • Rows 1–2: no critical/high findings; gated_paths is false, so the REVIEW_REQUIRED status does not trigger the hard gate.
  • Rows 3–5: high_risk is true (server/src/addie/mcp/member-tools.ts modified), but there are zero medium-or-higher findings, so the modified-file escalation rows do not fire, nor does any deleted-path trigger.
  • Rows 6–8: no prior decision, no no-auto-approve team match, zero medium findings.
  • Row 9: approve.

No blocking findings.

… review

- Check the seller credential's scope before any plan lookup in
  check_governance, so it cannot distinguish unknown plans.
- Carry the credential scope into handler context whenever present, so its
  restrictions cannot lapse on an identity mismatch.
- Exempt exact POST / from CSRF so an unauthenticated MCP client at the
  registered governance URL gets the bearer challenge, not a CSRF 403.
- Correct the authenticator-order comment.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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 subsequent pass with no blocking or medium findings.

This is a follow-up review over the 5-file delta since the prior clean approve. All changes are scoped hardening of the sandbox governance-agent credential path:

  • governance-handlers.ts — seller-credential gate moved ahead of plan lookup (prevents plan probing), preserving intent-vs-execution routing.
  • custom-tool-helper.ts / v6-governance-platform.ts — credential now always carried so seller restrictions cannot lapse.
  • csrf.ts — exempts the literal root POST via exact match; no cookie route serves POST / on any host.

No protocol surface (static/schemas/source/**, docs/reference/**, dist artifacts) touched, so no changeset is required. Reviewer found no Critical/High/Medium findings.

Gate checks:

  • No no-auto-approve team match (HARD RULE clear).
  • gated_paths: false — path gate (row 2) does not apply despite review_decision: REVIEW_REQUIRED.
  • high_risk: true only from a (modified) file (server/src/addie/mcp/member-tools.ts); no (deleted) reason (row 3 clear) and no medium finding on the modified file (rows 4/5 clear).
  • Prior decision was approve, not escalate (row 6 clear).
  • Zero medium findings (rows 7/8 clear).

Falls through to row 9 → approve.

@bokelley
bokelley merged commit 98f75fa into main Sep 30, 2026
52 checks passed
@bokelley
bokelley deleted the fix/7758-governance-agent-third-party branch September 30, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant