Skip to content

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

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

bokelley merged 1 commit into
mainfrom
conductor/issue-8328

Conversation

@bokelley

@bokelley bokelley commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8328

The defect class

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 are applied ~200
lines later in executeStep. Unlike sample_request, nothing guards this
surface, so a step that asserts against a key it captures itself does not fail
loudly; it quietly stops testing what it says it tests.

I confirmed all three failure modes against the installed SDK (these are now
pinned by tests, not asserted from reading):

surface unresolved behaviour
value / allowed_values[] the literal "$context.<key>" becomes the comparand — an ordinary comparison failure, nothing names the token
context_key resolveContextComparand returns found: false and the check passes with a context_key_absent observation
webhook filter buildFilter keeps the token, so the selector matches nothing: expect_webhook times out, expect_no_webhook passes without observing anything

The two live instances, and the grading impact

geo_place_targeting / get_place_capabilities asserted "current_version
is included in supported_versions" with value: "$context.place_system_version"
— captured by that same step. So the check compared the seller's
supported_versions array against the literal string. No seller could ever
pass that step
, so the whole scenario could never go green for any seller
declaring GeoNames NL/city support. That assertion is the only enforcement
anywhere in the repo of geo-place-catalog-capability.json's
x-adcp-validation.member_of ("conformance tooling MUST verify current_version
is present in supported_versions") — so in practice the invariant has been
unenforced and the scenario unpassable at the same time.

vendor_metric_accountability / create_media_buy asserted the day-1
committed_at equals confirmed_at with value: "$context.confirmed_at",
captured by the same step — so no seller could satisfy "day-1 commitment time
equals the media buy confirmed_at" either.

Hosted grades: both defects are in every 3.2 bundle from 3.2.0-beta.6
through 3.2.5, and all 14 are registered in
static/compliance/published-versions.json, so any seller graded on a 3.2
bundle that declares the gating capability has been failing a step it could not
pass. Both failures are unearned failures, not unearned passes.

Matrix floors do not move. The training agent declares neither
media_buy.features.committed_metrics_supported nor GeoNames support, so both
scenarios gate out with capability_unsupported before and after this change
(verified by running each with --filter against the local /sales tenant:
0P / 1S both times). That is also why neither defect was ever caught — these
two scenarios have no executed coverage in CI at all.

The fixes

geo — the step now also captures supported_versions, and a second,
stateless get_adcp_capabilities step (confirm_place_catalog_membership)
settles member_of directly, at capability scope:
current_version == $context.place_system_version (catalog stable across the
run, which the rest of the scenario depends on) plus field_in_context_array
of current_version in the captured supported_versions. I first routed this
through the get_media_buys read-back; review pushed back that it made a
capability-document invariant conditional on the whole buy flow and on a tool
the seller might not advertise, so it is unconditional now.

vendor — every day-1 committed_at on both packages is captured on
create, and a new get_media_buys read-back (read_back_commitment_timestamps)
settles the equality against the persisted confirmed_at, which is normatively
stable once set. Composition: persisted confirmed_at == create.confirmed_at
AND persisted confirmed_at == each day-1 committed_at ⇒ the normative rule.
The read-back pins media_buys[0].media_buy_id so a decoy buy at index 0 cannot
satisfy the timestamps (and get_media_buys' convention extractor rebinds
$context.media_buy_id for the delivery audit that follows, so this matters).
This also upgrades the original check, which only covered the first entry of
package 0 — the spec says "each such entry".

Both fixes exist because the SDK has no same-response field-to-field comparison
primitive; create_media_buy is the only response carrying both confirmed_at
and committed_metrics[].committed_at, and get_media_buys' PackageStatus
does not declare committed_metrics.

The gate

scripts/lint-storyboard-context-resolution.cjs (from #8327) gains
context_assertion_unresolved over all four comparand surfaces, using the same
before-own-capture ordering the request rule already uses. It runs as a hard
gate in npm run build:compliance. dist/** is immutable, so the 14 defective
3.2 bundles are quarantined in the frozen, exact table in
tests/lint-storyboard-context-resolution.test.cjs — a bundle outside the table
must be clean, and a bundle in it must still carry exactly the listed defects.

context_key is in scope even though it is a bare key rather than a token: it
reads the same pre-step context and is the fail-open member of the family. No
storyboard in the tree uses context_key, allowed_values or filter that way
today, so covering them costs nothing and closes the surface.

Security review verified the companion case the issue flagged: dropping the root
context: block from governance_agent_binding_acceptance.yaml now produces
three context_assertion_unresolved findings on exactly the
"seller persisted the accepted governance binding" checks, so the
unseed-regression-makes-an-echoing-seller-compliant shape is gated.

Proof

$ git stash push -- static/compliance/source && node scripts/lint-storyboard-context-resolution.cjs
lint-storyboard-context-resolution: 2 unresolved $context placeholder(s): ... exit=1
$ git stash pop && node scripts/lint-storyboard-context-resolution.cjs
lint-storyboard-context-resolution: every $context placeholder resolves.  exit=0

Three tests fail if the storyboard fix is reverted: the source-tree guard plus
the two behavioural tests that run the real SDK runValidations over the
authored validations and check a conformant seller passes and a violating one
fails.

Known limits (stated, not hidden)

  • A seller that does not advertise get_media_buys skips the vendor read-back,
    and the runner grades a skip as a pass, so the equality goes ungraded for that
    seller. That is the runner's skip-is-not-a-failure model, not something this
    assertion can close — required_tools is an any-of gate, so listing the tool
    there would widen selection, not tighten it. Before this PR the check was
    fail-closed only in the sense that nobody could pass it.
  • The vendor chain compares timestamp strings with === across two tasks, so a
    seller that re-serializes confirmed_at differently on get_media_buys would
    fail. confirmed_at is normatively stable once populated, so I took that as
    acceptable; flagging it because the first seller it bit would be surprised.
  • Neither scenario is executed anywhere in CI (both gate out on the training
    agent), so the new steps are covered by unit tests over the real SDK
    validators, not by an end-to-end run.
  • A generic x-adcp-validation evaluator (hanging off response_schema, or in
    the fix(compliance): public conformance verifier and served fixtures for provenance truth-of-claim #8218 conformance verifier) would retire the geo storyboard workaround and
    cover the other member_of sites at once — worth a follow-up, out of scope here.

Checks run locally

npm run precommit (full server unit suite + typecheck, exit 0), all 18
storyboard lint suites, npm run build:compliance,
node scripts/check-changeset-protocol-scope.cjs origin/main, changesets status.
Pushed with ADCP_SKIP_STORYBOARD_MATRIX=1 (documented skip) because the
pre-push matrix overruns on this sandbox; it is running separately and the
training-agent-storyboards.yml workflow is the authoritative gate.

Reviewed before opening by the code-reviewer, security-reviewer and
ad-tech-protocol-expert agents; every finding is either fixed above or answered
under "Known limits".

🤖 Generated with Claude Code


Open workspace in Conductor

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

@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 fix for #8328 with no blocking or medium findings.

What I checked:

  • Both storyboard assertions (geo_place_targeting 1.0.0→1.0.1, vendor_metric_accountability 1.0.1→1.0.2) previously compared against a $context token the same step captured, leaving the comparand literal and unpassable. Fix resolves comparands against prior captures/transitivity correctly; account and media_buy_id pinning guards against decoy-rebind.
  • New context_assertion_unresolved lint rule mirrors the runner's four comparand surfaces (value/allowed_values/context_key/webhook filter) before own-capture; suffix/location handling verified against existing tests.
  • Changeset present and patch — no wire-schema change, so changeset-scope and oneOf-discriminator gates are not implicated.
  • Released-artifact immutability respected: bundles 3.2.0-beta.6…3.2.5 quarantined via the frozen table rather than edited; FROZEN_DEFECT→FROZEN_DEFECTS refactor is sound (deduped+sorted).
  • No I/O/worker/async/schema surface touched. Not a breaking-class protocol change.

Gate checks: gated_paths is false (review_decision REVIEW_REQUIRED does not block a non-gated clean diff). high_risk false. No no-auto-approve team match. No critical/high/medium findings → falls through to row 9 (approve).

@bokelley
bokelley merged commit 4fe0876 into main Oct 19, 2026
62 checks passed
@bokelley
bokelley deleted the conductor/issue-8328 branch October 19, 2026 13:35
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.

Unresolved $context tokens in storyboard validation values can make assertions pass vacuously

1 participant