Skip to content

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

Merged
bokelley merged 1 commit into
mainfrom
conductor/issue-8317
Oct 19, 2026
Merged

bokelley merged 1 commit into
mainfrom
conductor/issue-8317

Conversation

@bokelley

@bokelley bokelley commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8317

Problem

Nothing in CI exercised sync_governance in the 3.0 media-buy governance storyboards, so a regression of the governance_agent_url context binding fixed in #7797 / #7801 would go unnoticed. The training agent hides sync_governance on every 3.0-compat tenant except /signals (server/src/training-agent/tenants/tool-catalog.ts), so in the storyboard matrix those steps skip on missing_tool both before and after the fix.

The underlying defect class is quiet by construction. injectContext() substitutes a whole-string $context.<key> only when the key is in the run context. When it isn't, the runner refuses to send the request: the step comes back skipped with skip_reason: 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. On 3.0-compat the same step already skips on missing_tool, which hides the difference entirely.

What this adds

scripts/lint-storyboard-context-resolution.cjs — replays the runner's real injectContext() in step order over every sample_request. A key is resolvable when the root context: block declares it, when an earlier step captures it via context_outputs, or when an earlier step ran a task whose SDK convention extractor writes it. Anything left over is a violation.

Two gates:

  • npm run build:compliance runs it as a hard failure, alongside the other 20 storyboard lints. dist/** release artifacts are immutable, so the build is the last place a bad bundle can be stopped — fix(compliance): populate governance_agent_url in 3.0 governance storyboards #7801 had to ship a whole new patch because 3.0.25 could not be repaired.
  • npm run test:storyboard-context-resolution (wired into npm test) re-checks the source tree and every bundled release, against a frozen, exact table of the defects already baked into released artifacts.

The lint is deliberately stricter than the runtime guard in three places, all documented in the header: expect_error steps (the runner exempts them, so they really do put the literal on the wire), the discovery-account enricher (which drops an unresolved account before the guard sees it), and inherited Object members — $context.constructor resolves at runtime to a Function that JSON.stringify then drops, a silently-wrong request with no literal left for the guard to find. The simulated context is Object.create(null) so those are reported.

It also adds a second rule, pinned_context_key_captured: a context_outputs entry may not write governance_agent_url or the four *_agent_url keys that hosted grading seeds from server config. That seed is not a per-step guard — the runner overwrites context on every capture, and hostedMultiAgentRoutingForStoryboard only compares the authored sync_governance URL against the literal "$context.governance_agent_url" — so a capture would let the agent under test redirect the governance agent it is told to trust, with the per-run seller credential stapled on regardless. Not reachable today; the rule keeps it that way.

Proving it

  • Fails on 3.0.26, passes on 3.0.27+, asserted directly: 3.0.26 leaves $context.governance_agent_url in sync_governance and 3.0.27 resolves it checks all five storyboards named in the issue (media_buy_seller/governance_{approved,conditions,denied,denied_recovery}, brand_rights/governance_denied) on the broken side and asserts 3.0.27 is clean.
  • Fails if the fix is removed: deleting the governance_agent_url line from governance_approved.yaml fails both the source-tree test and npm run build:compliance (verified locally, exit 1).
  • Rule-semantics tests cover ordering (capture after read, self-capture), per-task convention producers, the pinned-key rule, the prototype-chain case, and anchored-match-only substitution.
  • The convention-producer map is checked against the installed SDK: each (task, key) pair is probed through the SDK's own extractContext, so a waiver cannot outlive the extractor that justifies it. The pinned-key set is checked for equality against HOSTED_GOVERNED_AGENT_CONTEXT_KEYS parsed out of the routing module.

One live defect it found, fixed here

buyer_monitoring polls delivery for the buy declared in fixtures.fixture_publisher.active_buy, but no step in the storyboard creates one, so $context.media_buy_id had no writer and both delivery reads could only ever skip. The root context: block now seeds it from the same fixture id. That is a static/compliance/source change, hence the patch changeset.

Scope decisions a maintainer should know

  1. Released 3.0 bundles below 3.0.27 still carry the defect and always will. dist/** is immutable, and an agent that advertises or pins an exact 3.0.x ≤ 3.0.26 still gets the broken bundle. The frozen table records that, asserts those bundles carry exactly the 3.0.x media-buy governance storyboards: $context.governance_agent_url is never populated, so sync_governance is skipped for every 3.0 agent #7797 defect and nothing else, and fails if any bundle outside the table is dirty — so the next release cannot reintroduce it. The hosted 3.0 alias floor (≥ 3.0.27) stays enforced by server/tests/unit/hosted-compliance-3-0-27.test.ts; a second test asserts every published 3.0 bundle from 3.0.27 on is clean.
  2. The 3.2 bundles through 3.2.5 carry the buyer_monitoring defect, for the same immutability reason. They are the second row of the frozen table; the source fix reaches a bundle with the next 3.2 cut.
  3. validations[].value / allowed_values are out of scope. The runner substitutes those too (against the pre-step context) and, unlike requests, does not guard them. Two live instances read a key their own step captures, so they compare against the literal token: geo_place_targeting.yaml:177 (place_system_version) and vendor_metric_accountability.yaml:266 (confirmed_at). Fixing those changes grading behaviour for storyboards already in the matrix floors, so they belong in their own change — filed separately.
  4. No tenant or runtime behaviour changed. tool-catalog.ts and sales.ts are untouched, so the 3.0-compat tenants keep hiding sync_governance exactly as before.

Validation

npm run test:storyboard-context-resolution (17 tests), npm run build:compliance, npm run test:compliance-snippets, npm run test:test-coverage, npm run test:owned-links, docs-nav, lint:schema-links, npm run typecheck, and the full npm run precommit all pass locally, as do the sibling storyboard lints. The changeset gates (check-changeset-protocol-scope.cjs, changesets status) pass with the patch changeset.

Pushed with ADCP_SKIP_STORYBOARD_MATRIX=1 — the documented skip. The local matrix had run for ~35 minutes without finishing one tenant on this sandbox, and two unrelated worker-spawning suites (addie/matched-v4-evaluation, addie/matched-pair-ni/exact-inference) were flaking under the contention; both pass in isolation, and the full precommit passed on the committed tree. training-agent-storyboards.yml is the authoritative gate, and nothing here touches a tenant or a storyboard the matrix grades (buyer_monitoring is buyer-track and has no matrix tenant).

🤖 Generated with Claude Code


Open workspace in Conductor

…token unresolved

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]>

Copy link
Copy Markdown
Contributor Author

Follow-up for the out-of-scope item in the PR description (validation-value surface, two live storyboard defects): #8328.

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

Checked:

  • Seeds media_buy_id: "mb_monitoring_001" into buyer_monitoring's root context:, aligning with fixtures.fixture_publisher.active_buy (index.yaml:65) and fixing the storyboard where get_media_buy_delivery (index.yaml:113) could only ever skip with prerequisite_failed.
  • Adds a fail-closed build:compliance gate via lint-storyboard-context-resolution.cjs with correct substitution-order semantics (request built before the step's own captures/convention keys).
  • 560 lines of tests pin the #7797 regression and frozen immutable-bundle defects.
  • Changeset present (patch), in-scope; no wire/schema drift, no immutability violations, no oneOf regressions.

No findings surfaced. high_risk false, gated_paths false, no author team gate, no prior decision. Falls through to row 9.

@bokelley
bokelley merged commit 8c262e3 into main Oct 19, 2026
65 checks passed
@bokelley
bokelley deleted the conductor/issue-8317 branch October 19, 2026 10:21
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]>
TekWorx pushed a commit to TekWorx/adcp that referenced this pull request Oct 24, 2026
Merge the published v3.2.6 maintenance release (tag v3.2.6,
3523bdc, the adcontextprotocol#8274 Version Packages merge on
3.2.x) into main as a record-only merge, following adcontextprotocol#8278 for 3.2.5.

The merge keeps main's tree (ours strategy) and adds only the 3.2.6 release
records:

- dist/schemas/3.2.6/, dist/compliance/3.2.6/ and the signed
  dist/protocol/3.2.6.tgz{,.crt,.sha256,.sig} tuple, byte-identical to the tag.
- CHANGELOG.md: the 3.2.6 block, verbatim from the tag, inserted below main's
  3.3.0-beta.0 section. (The workflow's take-3.2.x rule would have dropped
  that section.)
- static/compliance/published-versions.json: register 3.2.6, matching the
  3.2.x manifest.
- dist/schemas/index.json and latest.json: regenerated by build:schemas;
  latest_stable, v3 and v3.2 now 3.2.6. main's 3.3.0-beta.0 entry and v3.0
  (3.0.28) are kept; taking 3.2.x's copy would have regressed both.

The 3.2.5..3.2.6 source changes are all backports of work already on main in
its main form (adcontextprotocol#8335, adcontextprotocol#8402, adcontextprotocol#8218, adcontextprotocol#8216, adcontextprotocol#8341/adcontextprotocol#8387, adcontextprotocol#8327/adcontextprotocol#8334, adcontextprotocol#8260,
adcontextprotocol#8261, adcontextprotocol#8263, adcontextprotocol#8244), so no 3.2.x source is taken. The second parent records
that reconciliation so the next 3.2.x forward merge does not re-conflict on it.

Co-Authored-By: Claude Opus 5.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

Development

Successfully merging this pull request may close these issues.

No CI coverage for sync_governance context binding in 3.0 governance storyboards

1 participant