Skip to content

feat(compliance): hosted grading of governance-aware sellers - #7808

Merged
bokelley merged 8 commits into
mainfrom
fix/7758-hosted-governance-grading
Oct 1, 2026
Merged

bokelley merged 8 commits into
mainfrom
fix/7758-hosted-governance-grading

Conversation

@bokelley

@bokelley bokelley commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Part of #7758. Fixes #7772. Supersedes #7779: its four commits are rebased here, unchanged apart from review fixes.

Builds on the compliance fixtures merged in #7803 (the hosted-grader buyer brand, caller, and test kit). No changeset: this PR touches server code and docs only, not the protocol release surface.

Summary

Hosted grading can now run the governance-aware-seller multi-agent storyboards against a third-party seller. It uses the two approaches the maintainer approved.

D. A real buyer brand.json. hosted-grader.adcontextprotocol.org serves only two things:

  • /.well-known/brand.json. This is a Brand Canonical Document with two entries:
    • a governance agent whose url is https://test-agent.adcontextprotocol.org, which is the token iss and the URL sync_governance registers;
    • a buying agent for the grader.
  • /.well-known/jwks.json, which holds the governance-signing key and nothing else.

Every other path returns 404. The router is mounted first in setupMiddleware and matches both the raw Host header and req.hostname, so no app-wide route (in particular Addie's request-signing JWKS) is ever served on that origin. security.mdx requires governance keys to sit on a different origin from request-signing keys, and this dedicated host is how that holds.

B4. One fixed grader buyer agent, https://hosted-grader.adcontextprotocol.org/buyer.

  • A new hosted-grader credential role in governance-agent-credentials.ts, reusing fix(training-agent): let third-party sellers use the public governance agent (#7758) #7786's design:
    • its own tag (adcp-sandbox-gov-grader.v1.), its own HKDF info, and its own audience, all derived from TRAINING_GOVERNANCE_CREDENTIAL_SECRET. With the secret unset, the feature is off;
    • a 30-minute TTL and a run nonce, now required to be a UUID;
    • timingSafeEqual on the MAC;
    • agent_url fixed to the grader URL and checked exactly;
    • it authenticates on /governance only.
  • The tenant router re-verifies the credential and stamps trusted auth extra. The buyer-agent registry maps it to the grader URL, and that URL becomes the intent caller.
  • It can only call sync_plans, intent check_governance (including the adjusted re-check), get_plan_audit_logs (explicit plan ids only) and report_plan_outcome, and only on plans carrying the run nonce. The scope is checked from the request, before any cross-session lookup.
  • Execution checks and report_plan_adjustment are denied.
  • A seller credential never verifies as a grader credential, or the reverse.

Routing (#7779 finished). hostedGovernanceAgentForRun() mints two credentials per run: a grader credential for the governance route, and a seller credential bound to the exact graded agent URL.

  • The seller credential is substituted into sync_governance, but only for the hosted governance agent. Any other registration target makes the storyboard unroutable.
  • governance_agent_url is always pinned, and caller is bound to the grader.
  • Only storyboards whose buyer is the hosted-grader brand are routed. Older bundles, which name acmeoutdoor.example, are skipped as not runnable, never graded as failures.

Heartbeat and registry refresh. compliance-testing.ts#comply passes routeStoryboard (createHostedRouteStoryboard), which returns undefined, { skip }, or { agents, default_agent, context, storyboard }. That covers the heartbeat, evaluate_agent_quality, and both registry comply() routes. The SDK enforces per-agent auth isolation and refuses run-level headers. Addie's run_storyboard uses the same routing.

Keeping credentials out of output. Minted credentials are scrubbed from comply() and run_storyboard results before anything is stored, rendered, or logged. The scrub matches the exact strings and also the credential tag, so truncated echoes are caught.

#7772. Storyboards whose declared test kit is a live-mode principal (sandbox: false, i.e. comply_controller_mode_gate), and where every step reads from_test_kit, are routed to the agent under test only. The replacement storyboard sets each step's auth to the declared kit's key. The owner's grading credential still authenticates discovery, and the public live key carries only the gate probe.

  • This relies on step auth not being part of the SDK's grading-shape check. A comply()-level test fails CI if an SDK release starts refusing it.
  • The cleaner long-term fix is in the SDK: make a declared sandbox: false kit win over the run-level kit in resolveDeclaredTestKit (adcp-client#2817).

Docs. aao-verified.mdx gets a new section, "Grading governance-aware sellers":

  • the grader buyer agent URL sellers map their grading credential to;
  • the buyer brand domain and operator, with pre-provisioning in place of an authorized_operators check;
  • the per-run seller credential, the caller to send, and the canonical-URL requirement for aud;
  • the brand.json, jwks_uri, and revocation URLs;
  • the warning that this trust is sandbox-only, because the signing key is public;
  • that skipped storyboards mean no badge.

storyboard-troubleshooting.mdx notes the live-mode kit exception.

Maintainer actions

  1. DNS for adcontextprotocol.org, set to DNS only (not proxied), the same as test-agent:
    hosted-grader.adcontextprotocol.org.  A     66.241.125.182
    hosted-grader.adcontextprotocol.org.  AAAA  2a09:8280:1::99:89c2:0
    
  2. Fly certificate:
    fly certs add hosted-grader.adcontextprotocol.org -a adcp-docs
    fly certs check hosted-grader.adcontextprotocol.org -a adcp-docs
    
  3. Secret, if fix(training-agent): let third-party sellers use the public governance agent (#7758) #7786's secret isn't set yet. This enables both credential roles.
    fly secrets set TRAINING_GOVERNANCE_CREDENTIAL_SECRET="$(openssl rand -hex 32)" -a adcp-docs
    
    Without it, the governance storyboards are skipped with "hosted governance grading is not enabled on this deployment". That's the same outcome as today (requirement_unmet).

Verification

End-to-end (.context/3.2-final/gov7758-e2e-final.ts). It runs the SDK's comply() with this PR's routeStoryboard hook against a loopback third-party seller that does real SDK verification. None of the ASSUME_D/ASSUME_B4 shortcuts are used. The seller:

  • maps its grading credential to the grader buyer agent and brand;
  • fetches the buyer brand.json, finds the governance entry (step 13), and loads keys from its jwks_uri;
  • runs verifyGovernanceAuthorization with authenticatedCaller set to the grader;
  • makes an online execution check at the registered URL with the per-run seller credential, then verifies the purchase token.

Results:

Storyboard Result
governance_approved PASS
governance_conditions PASS
governance_denied PASS
governance_denied_recovery PASS

Zero failed steps. None of the 8 minted credentials appear in the result.

Negative controls: when the seller maps its credential to another buyer, verification fails with governance_token_not_applicable (caller mismatch). When brand.json omits the governance entry, it fails with governance_issuer_not_authorized.

What the e2e simulated:

  • DNS for hosted-grader.adcontextprotocol.org: a loopback host running the production brand.json/JWKS builders;
  • the governance agent: the training agent on loopback, with the authored governance_agent_url rewritten to it;
  • commerce: responses proxied to the training sales tenant, with controller seeds mapped onto the storyboard account.

Unit tests:

npm run typecheck passes. A security review and a protocol review ran on this PR. Every must-fix and should-fix item is addressed, along with four of the five security nits. The one not taken is a separate off switch per credential role.

🤖 Generated with Claude Code

bokelley and others added 6 commits September 30, 2026 15:50
…he public governance agent

Storyboards that declare `requires: [multi_agent]` send their plan-setup
and intent-check steps (`agent: governance`) to a governance agent. Hosted
grading ran them single-URL, so a governance-aware seller could never
complete them (#7758).

Add hostedMultiAgentRoutingForStoryboard(): the storyboard's default_agent
routes to the agent under test with the owner's credentials, `governance`
routes to the public test agent's /governance/mcp tenant with the public
test-agent credential from server config, and any other agent key makes
the storyboard unroutable rather than sending it to the seller. Every
routed entry carries explicit auth so the SDK's run-level auth fallback
cannot hand the owner credential to the governance agent. The governance
endpoint comes only from server config; the authored governance_agent_url
must share its origin and is pinned over caller context. Governance steps
that pull test-kit credentials and runs with shared headers are refused.

Wire it into Addie's run_storyboard. The heartbeat's comply() cannot take
per-storyboard routing on @adcp/sdk rc.51 (runStoryboard rejects `agents`
with the positional URL comply() passes), so heartbeat wiring needs an SDK
hook.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Run a routed multi_agent storyboard through the real @adcp/sdk runner
against two loopback MCP agents, with the owner credential at run level
and in the test kit as hosted runs set it. The governance agent sees only
the governance credential and receives sync_plans; the seller sees only
its own credential and never receives sync_plans.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- Suffix governance plan ids with a per-run nonce so concurrent runs, or
  anyone holding the public token, can't overwrite the plan a run grades
  against on the shared governance tenant.
- Refuse step-level credentials on every step not pinned to the agent
  under test (unpinned steps can route to governance by protocol), and
  `$test_kit.auth` references in storyboard context.
- Return the governance-served step ids; run_storyboard skips them for
  OAuth detection, labels them in output, and notes the shared sandbox
  state they write.
- Rename HostedAgentUnderTest.transport to protocol.
- Wire test returns schema-valid responses and asserts both routed steps
  executed and passed.

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

The cross-check fed our own bare-hex key_id to the training agent's
registry, so it couldn't catch a key_id format change. Derive the
credential through @adcp/sdk verifyApiKey, which the training agent uses,
so a prefix or length change breaks the test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Serve the hosted-grader buyer brand, authenticate hosted grading to the
sandbox governance agent as one fixed buyer agent, and route the
multi-agent governance storyboards through comply()'s routeStoryboard hook.

- hosted-grader.adcontextprotocol.org serves only its brand.json (listing
  the sandbox governance agent under the token iss, and the grader buyer
  agent) and a governance-only JWKS, mounted before every app-wide route so
  no request-signing keys share that origin.
- New hosted-grader credential role: own tag, HKDF info, and audience;
  authenticates only on the governance tenant as
  https://hosted-grader.adcontextprotocol.org/buyer; 30-minute TTL; limited
  to sync_plans, intent checks, audit reads, and outcome reports on plans
  carrying the run nonce.
- Hosted routing mints a per-run grader credential and a per-run seller
  credential bound to the graded agent URL, substitutes the latter into
  sync_governance, binds caller to the grader, and only routes storyboards
  whose buyer is the hosted-grader brand. Minted credentials are scrubbed
  from comply() and run_storyboard results.
- The same hook runs live-mode test-kit storyboards
  (comply_controller_mode_gate) with the declared kit's key instead of the
  owner's grading credential.
- Docs: what governance-aware-seller grading needs from a seller.

Fixes #7772
Refs #7758

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

- Issue the seller credential only for the hosted governance agent and
  always pin governance_agent_url; other registration targets are unroutable.
- Route the hosted-grader host on the raw Host header as well as
  req.hostname, so X-Forwarded-Host cannot get app-wide routes served there.
- Check the grader credential's scope in check_governance from the request
  alone, before any cross-session lookup; allow adjusted intent re-checks.
- Run nonces are UUIDs, so the plan-id suffix check is exact.
- Scrub minted credentials by tag too, covering truncated echoes.
- Multi-agent storyboards never take the live-mode kit route.
- Docs: canonical URL and aud, operator pre-provisioning, revocation
  signing, sandbox origin separation, badge consequence; the troubleshooting
  guide notes the live-mode kit exception.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bokelley
bokelley force-pushed the fix/7758-hosted-governance-grading branch from cce7448 to f878880 Compare September 30, 2026 15:50

@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 — hosted multi-agent routing for grading governance-aware sellers (#7758/#7772).

No blocking findings. The reviewer found no Critical/High/Medium concerns: credential minting, routing/auth isolation, plan-scope enforcement, and tenant separation are carefully designed and heavily tested (wire-level isolation proofs, E2E all-PASS with negative controls, tamper/expiry/cross-run scope checks).

Checked against decision table:

  • No critical/high findings (row 1 n/a).
  • gated_paths: false (row 2 n/a).
  • high_risk: true, but both matched files (server/src/addie/mcp/member-tools.ts, server/src/addie/services/compliance-testing.ts) are (modified) with no medium-or-higher findings, so rows 3/5 do not fire.
  • No medium data-loss/schema/infra findings (row 4 n/a).
  • No prior decision (row 6 n/a).
  • No no-auto-approve team match (row 7 n/a).
  • Zero medium findings (row 8 n/a).

No protocol-schema change under static/schemas/source/**, so schema↔docs coherence and the absent changeset are both correct (server/app + docs only). Falls through to row 9 — approve.

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

The reviewer examined the largest and most sensitive changes in PR #7808 (hosted grading of governance-aware sellers): credential isolation, fail-closed routing, run-nonce plan scoping, host-router origin separation, and secret redaction across hosted-multi-agent-routing.ts (+467) plus the credential/handler/http changes. All trust boundaries hold. No changeset is required since the diff is server-side plus docs/building only (not the published protocol surface under static/schemas/source/, docs/reference/, or dist/**).

Decision-table walk:

  • Rows 1–4: no critical/high/medium findings; gated_paths is false; no schema/infra/data-loss category concerns.
  • Row 3: high_risk is true, but the two matching files (member-tools.ts, compliance-testing.ts) are (modified), not (deleted).
  • Row 5: high_risk (modified) is true, but there are zero medium findings, so this does not fire.
  • Rows 6–8: no prior decision, no no-auto-approve team match, fewer than three medium findings.
  • Falls through to row 9: approve.

Note: review_decision is REVIEW_REQUIRED, but gated_paths is false, so the row-2 hard gate does not apply. No breaking-class protocol change is present (no schema surface touched), so the breaking-change escalation gate is not triggered.

Copy link
Copy Markdown
Contributor Author

Resolved the code-quality finding (unused PUBLIC_TOKEN in training-agent-hosted-grader-credential.test.ts) in 133238e by removing the constant. vi.hoisted can't reference module-level constants, so the literal stays inside the hoisted block.

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

Re-approval: no reviewable delta since the prior approval; re-submitting after stale-review dismissal.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Schema Link Check Results

Commit: 4a42528 - Merge branch 'main' into fix/7758-hosted-governance-grading

❌ Errors (schema not found)

These schemas do not exist and the links will be broken:

  • https://adcontextprotocol.org/schemas/latest/error-details/execution-requirement-unmet.json
    • Schema is already released in 3.2.1
    • Action: Change URL to /schemas/v3/error-details/execution-requirement-unmet.json
  • https://adcontextprotocol.org/schemas/latest/error-details/requote-required.json
    • Schema is already released in 3.2.1
    • Action: Change URL to /schemas/v3/error-details/requote-required.json

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

Checked:

  • Credential isolation on the hosted multi-agent governance routing (#7758) and live-mode test-kit route (#7772) is load-bearing and verified on the wire and over HTTP: governance endpoint is config-only/non-overridable, run-level owner auth is stripped from routed options, test-kit credential forwarding to non-seller steps is refused, minted secrets are redacted after the run, grader credentials are UUID-nonce-scoped fail-closed, and the hosted-grader host enforces origin separation.
  • No protocol surface touched: no static/schemas/source/**, no docs/reference/** normative changes, no dist/** released artifacts, no changeset-scoped surface — so schema↔docs coherence, changeset, oneOf-discriminator, and artifact-immutability gates do not apply.
  • high_risk: true is driven by two (modified) server/src/addie/** files, but the reviewer found no medium-or-higher concerns on them, so the modification is presumed safe (no row-5 trigger).
  • gated_paths: false; review_decision: APPROVED. No no-auto-approve team match. Prior decision was approve with no findings — consistent net state.

Decision table: rows 1–8 do not fire (no critical/high/medium findings, no gated-path gap, no deletion, no sensitive-category medium, no team gate, fewer than three mediums). Falls through to row 9 → approve.

Blocking findings: none.
Medium findings: none.

bokelley commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Merging under the maintainer's authorization. The maintainer completed the DNS, Fly certificate and TRAINING_GOVERNANCE_CREDENTIAL_SECRET steps. The host resolves and serves TLS. 57 checks pass. The one failure, check-schema-links, comes from docs on main (/schemas/latest/ links to schemas released in 3.2.1) and is fixed in #7845.

@bokelley
bokelley merged commit 680552b into main Oct 1, 2026
57 of 58 checks passed
@bokelley
bokelley deleted the fix/7758-hosted-governance-grading branch October 1, 2026 11:06
bokelley added a commit that referenced this pull request Oct 22, 2026
… comparand fixes to 3.2.x (#8327, #8334) (#8411)

* test(compliance): fail the build when a storyboard leaves a $context token unresolved (#8327)

The storyboard runner substitutes `$context.<key>` only when the key is in the
run context. When it isn't, the step comes back skipped with
`prerequisite_failed` and a failed `unresolved_substitution` validation — the
storyboard can never pass, but it reports as a skip, which is also what
legitimate capability gating produces.

That is how #7797 shipped: the 3.0.x governance scenarios registered the
governance agent with `url: "$context.governance_agent_url"` and never declared
the key, so `sync_governance` could only ever skip. On the 3.0-compat tenants
that step already skips on `missing_tool`, hiding the difference entirely, and
the defect rode every released 3.0 bundle up to 3.0.26 until #7801 added the
default.

Adds `scripts/lint-storyboard-context-resolution.cjs`, which replays the real
`injectContext()` in step order over every `sample_request` and reports any
token with no writer. It runs as a hard gate in `npm run build:compliance` —
`dist/**` is immutable, so the build is the last place a bad bundle can be
stopped — and `npm run test:storyboard-context-resolution` re-checks the source
tree plus every bundled release against a frozen table of the defects already
frozen into released artifacts.

The lint also rejects a `context_outputs` capture of `governance_agent_url` or
the `*_agent_url` keys hosted grading seeds from server config: the seed is not
a per-step guard, so a capture would let the agent under test redirect the
governance agent it is told to trust.

Fixes one live instance it found: `buyer_monitoring` polls delivery for a buy
no step creates, so `$context.media_buy_id` had no writer. It now seeds the id
from `fixtures.fixture_publisher.active_buy`.

Closes #8317

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 8c262e3)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(compliance): resolve $context comparands in storyboard assertions (#8334)

The storyboard runner substitutes `validations[].value` and
`validations[].allowed_values[]` and resolves `validations[].context_key`
against the context as it stood *before* the step, and substitutes a webhook
step's `filter` the same way. A step's own `context_outputs` land after its
validations run, so a step cannot assert against a key it captures itself —
and unlike `sample_request`, nothing guards this surface. An unresolved
`value` silently becomes the comparand, an absent `context_key` makes the
check *pass* with a `context_key_absent` observation, and a token left in a
`filter` yields a selector no delivery can match.

Two storyboards read a key their own step captures, so the assertion graded
something other than what it claimed:

- `geo_place_targeting` asserted "current_version is included in
  supported_versions" against `$context.place_system_version`, captured by the
  same `get_adcp_capabilities` step. The check compared the seller's
  `supported_versions` against the literal token, so the capability step could
  not pass for any seller and the scenario could never go green. It now
  captures `supported_versions` too and settles the
  `geo-place-catalog-capability.json` `x-adcp-validation.member_of` invariant
  on a second, stateless capabilities read — directly, at capability scope,
  before any product or buy state exists to make it conditional.
- `vendor_metric_accountability` asserted the day-1 `committed_at` equals
  `confirmed_at` against `$context.confirmed_at`, captured by the same
  `create_media_buy` step, so no seller could satisfy it. Every day-1
  `committed_at` on both packages is now captured on create and settled on a
  `get_media_buys` read-back that pins the buy under test — "each such entry's
  `committed_at` MUST equal `confirmed_at`", not just the first entry.

Both scenarios are capability-gated out of the training-agent matrix (it
declares neither `media_buy.features.committed_metrics_supported` nor GeoNames
NL), so no floor moves; the grading impact lands on third-party sellers graded
against a 3.2 bundle, all 14 of which are registered in
static/compliance/published-versions.json.

`scripts/lint-storyboard-context-resolution.cjs` gains a
`context_assertion_unresolved` rule over all four comparand surfaces, using
the before-own-capture ordering the request rule already uses, so
`npm run build:compliance` rejects the class. Released bundles are immutable,
so 3.2.0-beta.6 through 3.2.5 keep both defects under the frozen table in
tests/lint-storyboard-context-resolution.test.cjs.

Closes #8328

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 4fe0876)
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* test(compliance): adapt the context-resolution lint backport to 3.2.x

The #8327 test reads server/src/compliance/hosted-multi-agent-routing.ts and
the 3.0.27/3.0.28 bundles, none of which exist on 3.2.x: hosted grading of
governance-aware sellers (#7808) is 3.3-only, and the fixed 3.0 bundles are
registered on main.

- Pin RUNNER_PINNED_CONTEXT_KEYS against GOVERNED_AGENT_CONTEXT_KEYS in
  server/src/compliance/storyboard-runner-options.ts (plus
  governance_agent_url, which main's hosted grader pins for every 3.2 bundle).
- Drop the "published 3.0 bundles from 3.0.27 on are clean" test and the
  3.0.27 side of the #7797 bracket; 3.0.26 still reproduces the defect.
- Reword the #8327 changeset's pinned-key sentence for this line.

The lint script itself is byte-identical to main.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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