Skip to content

fix(compliance): backport the storyboard $context resolution lint and comparand fixes to 3.2.x (#8327, #8334) - #8411

Merged
bokelley merged 3 commits into
3.2.xfrom
backport/3.2.x-storyboard-context-resolution
Oct 22, 2026
Merged

bokelley merged 3 commits into
3.2.xfrom
backport/3.2.x-storyboard-context-resolution

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Backport of #8327 (main 8c262e3b6, closes #8317) and #8334 (main 4fe087610, closes #8328) to 3.2.x, so the 3.2.6 cut ships a clean bundle.

Without these, main's tests/lint-storyboard-context-resolution.test.cjs fails on the 3.2.6 forward merge. That test requires every bundled release outside its frozen defects table to be clean. Main's lint run against current 3.2.x source finds 4 problems:

What comes over:

  • scripts/lint-storyboard-context-resolution.cjs (byte-identical to main), wired as a hard gate in npm run build:compliance and as npm run test:storyboard-context-resolution in npm test.
  • The buyer_monitoring seed of media_buy_id from fixtures.fixture_publisher.active_buy.
  • The geo_place_targeting and vendor_metric_accountability assertions moved to read-back steps where the comparand is already in context.
  • The storyboard-authoring.md guidance.
  • Both changesets (patch).

Each cherry-pick is its own commit (-x). The third commit holds the 3.2.x adaptations.

Adaptations for 3.2.x

  1. package.json conflict. The test chain differs on 3.2.x, so the cherry-pick conflicted there. I kept 3.2.x's chain and made only test(compliance): fail the build when a storyboard leaves a $context token unresolved #8327's two edits: the new test:storyboard-context-resolution script, and its slot in test right after test:storyboard-context-output-paths. Everything else in package.json is 3.2.x's.

  2. Test: the pinned-key guard. On main, this test parses server/src/compliance/hosted-multi-agent-routing.ts. That file comes from hosted grading of governance-aware sellers (feat(compliance): hosted grading of governance-aware sellers #7808), which is 3.3-only, so it doesn't exist on 3.2.x. On this line the guard instead checks RUNNER_PINNED_CONTEXT_KEYS against GOVERNED_AGENT_CONTEXT_KEYS in server/src/compliance/storyboard-runner-options.ts, plus governance_agent_url. The check is still set equality in both directions.

    • I kept governance_agent_url in the pinned set because the hosted grader on main pins it for every 3.2 bundle it grades.
    • I dropped the pinnedGovernanceUrl source assertion, since 3.2.x has no server-side governance seed to check.
  3. Test: 3.0.27-dependent checks removed. dist/compliance/3.0.27 and 3.0.28 and their published-versions.json entries exist only on main. So I removed:

    The 3.0.26 half still runs, so 3.0.26 must still reproduce 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, and the existing seeded-governance_agent_url fixture test covers the resolving direction. I also removed the now-unused GOVERNANCE_CONTEXT_FIX_VERSION and PUBLISHED_MANIFEST constants.

  4. Frozen defects table: unchanged. Every version it lists is bundled on 3.2.x, and the bundle guard passes with the table as-is. That includes all the 3.0.x / 3.2.x entries and the 3.1.x bundles, which are clean.

  5. Changeset wording. In seed-buyer-monitoring-media-buy-id.md, the sentence about "the *_agent_url keys hosted grading seeds from server config" now says those governed-agent keys are seeded by the multi-agent runner, which is what happens on 3.2.x. resolve-storyboard-assertion-comparands.md is unchanged.

The lint script, build-compliance.cjs, the three storyboards and storyboard-authoring.md are byte-identical to origin/main. git diff origin/main HEAD on those paths is empty, so only the test file and package.json differ from main. On the forward merge, package.json and the changesets resolve automatically. The test file will be an add/add conflict; resolve it by taking main's version. The lint's pinned_context_key_captured message still points at hosted-multi-agent-routing.ts. That is accurate for 3.2 bundles because main's hosted grader is what grades them, and keeping the lint identical avoids a second forward-merge conflict.

Patch eligibility

This is a conformance-harness fix plus build tooling. There are no schema, task or wire-contract changes. Two storyboards now grade the invariant they already claimed, one storyboard seeds a key it already read, and a build-time lint rejects the defect class. Released dist/**/<semver>/ artifacts are untouched; 3.2.0-beta.6 through 3.2.5 stay in the frozen table.

Verification (on this branch)

  • node scripts/lint-storyboard-context-resolution.cjs: every $context placeholder resolves.
  • Main's scripts/lint-storyboard-context-resolution.cjs (git show origin/main:…) against this tree: 0 problems. It is byte-identical to the backported script.
  • npm run test:storyboard-context-resolution: 25/25.
  • Every test:storyboard-* and test:compliance-* script, plus test:doc-compliance-drift and test:substitution-vector-names: pass.
  • node scripts/build-compliance.cjs --check: passes, with the context-resolution lint running as a gate.
  • node scripts/check-changeset-protocol-scope.cjs origin/3.2.x: passes.
  • npx --yes @changesets/cli@^3.0.0 status --since=origin/3.2.x: adcontextprotocol patch.
  • Pre-commit hook passed on the adaptation commit.
  • Pushed with ADCP_SKIP_STORYBOARD_MATRIX=1; training-agent-storyboards.yml is the authoritative gate.

🤖 Generated with Claude Code

bokelley and others added 3 commits October 22, 2026 12:26
…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]>
…#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]>
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]>

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

Checked:

  • Two genuine assertion fixes: geo_place_targeting (field_contains previously compared supported_versions[*] to the literal "$context.place_system_version" — always failed) and vendor_metric_accountability (committed_at vs literal "$context.confirmed_at"). Both now resolve against captured comparands via a later stateless read.
  • buyer_monitoring seeds media_buy_id: "mb_monitoring_001" matching fixtures.fixture_publisher.active_buy.media_buy_id.
  • New scripts/lint-storyboard-context-resolution.cjs faithfully mirrors the runner (collects assertion reads + sample_request injection before folding step captures), correctly enforcing "a step cannot assert against a key it captures itself"; fail-open-aware on context_key.
  • Test ratchets immutable dist/** bundles with exact set-equality both directions.
  • Changesets are patch and in-scope for static/compliance/source/**. No schema touched (no drift), no oneOf change, no dist/** mutation. Non-breaking.

Decision path: no critical/high/medium findings; gated_paths false; high_risk false; no author team gate. Falls through to row 9 → approve.

@bokelley
bokelley merged commit 9dbfad0 into 3.2.x Oct 22, 2026
49 checks passed
@bokelley
bokelley deleted the backport/3.2.x-storyboard-context-resolution branch October 22, 2026 13:34
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