Skip to content

feat(storyboard): requires_capability skip gate (#933) - #934

Merged
bokelley merged 4 commits into
mainfrom
claude/issue-933-requires-capability-storyboard-skip
Apr 25, 2026
Merged

bokelley merged 4 commits into
mainfrom
claude/issue-933-requires-capability-storyboard-skip

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Adds requires_capability: { path, equals } to the Storyboard interface — evaluated against the agent's declared get_adcp_capabilities response before any phase runs
  • When the predicate is false (agent declared the capability unsupported), the runner emits a single capability_unsupported synthetic skip result (overall_passed: true, skipped_count: 1) instead of running phases that would produce misleading failures
  • Adds capability_unsupported to RunnerDetailedSkipReason, mapping to canonical unsatisfied_contract
  • Populates AgentProfile.raw_capabilities from the raw get_adcp_capabilities response in discoverAgentProfile

Open design question: absence semantics

When the dotted path resolves to undefined (field absent from the agent's capabilities response), the current implementation runs the storyboard. This treats absence as "not explicitly opted out — surface the gap." A permissive interpretation would skip instead (don't penalise agents that pre-date the capability field). The conservative choice (current) is better for compliance enforcement but may need revisiting once requires_capability is widely adopted.

Pre-PR expert review

Two expert rounds completed:

  • Step 4 (ad-tech-protocol-expert + code-reviewer panel): Approved the overall approach. Raised absence-semantics question; suggested not_applicable for the canonical skip reason.
  • Pre-PR (ad-tech-protocol-expert): Overrode not_applicable → unsatisfied_contract — consistent with rate_abuse_opt_out and missing_test_kit_contract in DETAILED_SKIP_TO_CANONICAL. Blocker applied and fixed before push.
  • Background code-reviewer: No blockers. Notes: error field on the synthetic skip step is consistent with the existing no_phases precedent; closeConnections is harmless (connections are lazy); equals: unknown narrowed to boolean|string|number|null (fixed in second commit).

Test plan

  • npm run build — clean TypeScript compilation
  • node --test test/lib/storyboard-capability-gate.test.js — 5/5 pass
    • emits capability_unsupported skip when agent declares supported: false
    • does not skip when agent declares supported: true (gate passes)
    • gate is a no-op when raw_capabilities absent
    • resolveCapabilityPath semantics: dotted path traversal
    • DETAILED_SKIP_TO_CANONICAL maps capability_unsupported to unsatisfied_contract
  • Integration: wire the idempotency-replay storyboard with requires_capability once it ships (separate PR, tracked in Storyboard runner: auto-skip capability-gated storyboards when agent declares the capability unsupported #933)

Closes #933

https://claude.ai/code/session_01RM3nKGVdi1DFHuRpJUTgUL


Generated by Claude Code

claude added 2 commits April 25, 2026 02:15
…#933)

Storyboard runner now evaluates a requires_capability predicate before
running any phase. When false, emits a single capability_unsupported
skip result instead of misleading per-phase failures for agents that
declared a capability unsupported (e.g. idempotency: 'disabled' mode).

https://claude.ai/code/session_01RM3nKGVdi1DFHuRpJUTgUL
- DETAILED_SKIP_TO_CANONICAL['capability_unsupported'] → 'unsatisfied_contract'
  (consistent with rate_abuse_opt_out, missing_test_kit_contract; semantically
  correct — agent explicitly opted out of the behaviour being tested)
- skip.reason in buildCapabilityUnsupportedResult → 'unsatisfied_contract'
- Narrow requires_capability.equals from unknown to boolean|string|number|null
  (YAML cannot encode JS undefined; explicit type prevents silent no-op gates)
- Update stale test description and matching assertion

https://claude.ai/code/session_01RM3nKGVdi1DFHuRpJUTgUL

@bokelley bokelley left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (didn't pre-read the author's expert rounds — opinions formed from the diff). Mergeable, three things worth fixing or noting before merge.

Real doc bug

src/lib/testing/storyboard/types.ts:838 TSDoc on 'capability_unsupported' says:

Maps to canonical not_applicable: the storyboard simply does not apply to this agent's self-declared profile.

But the actual mapping at line 853 is 'unsatisfied_contract'. The expert review correctly flipped the canonical reason; the docstring didn't follow. Worth a single-line fix — this is exactly the drift that costs a future reader real time when the next storyboard skip type lands.

Weak tests

Tests #2 and #3 in test/lib/storyboard-capability-gate.test.js (lines 107 and 131) end with assert.ok(true, '...') after a try/catch that captures threw and never asserts on it. If the gate fired when it shouldn't (false positive), these tests still pass.

Test #1 covers the substantive contract (supported: false → skip with the right shape) and test #4 covers the path traversal. Tests #2 and #3 are smoke at best. Three options:

  • (a) Rename and document them as smoke tests so the false confidence is calibrated
  • (b) Inject a network mock so they can assert the agent was actually contacted (or not)
  • (c) Drop them — the negative paths are covered by resolveCapabilityPath's undefined branch which test #4 already exercises

Re-implemented helper

Test #4 reimplements resolveCapabilityPath inline because the real function isn't exported. If the runtime behavior ever drifts (null-prototype edge, Symbol keys, prototype-chain access), the test stays green and the runner silently breaks. Either export the helper or replace test #4 with end-to-end requires_capability runs against richer profile shapes.

Nit: surface the absence-semantics rationale at the predicate site

The runner choice at runner.ts:493-494 (if (actual !== undefined && actual !== equals) — i.e. absence runs the storyboard) is documented in the PR body and the TSDoc on requires_capability, but not at the call site. One sentence next to the predicate makes the choice durable through future refactors. The conservative-vs-permissive interpretation will come up again when this gates a stricter storyboard.

Design ✅

  • { path, equals } generalizes correctly — same machinery applies to request_signing.supported, future capability discriminators, no special-casing
  • Synthetic skip shape carries phase_id, step_id, extraction.path, skip.reason — JUnit and CLI renderers will handle it
  • unsatisfied_contract mapping aligns with rate_abuse_opt_out and missing_test_kit_contract
  • Type narrowing boolean | string | number | null is the right call for capability discriminators today; expand if/when a capability ships an array discriminator

LGTM modulo the docstring fix. The two test improvements are post-merge polish unless you want them in this PR.

…pping

The TSDoc on the new `'capability_unsupported'` skip reason said
"Maps to canonical `not_applicable`" — drift from the second commit
that flipped the mapping to `'unsatisfied_contract'` after pre-PR
expert review (consistent with `rate_abuse_opt_out` and
`missing_test_kit_contract`). Update the docstring to match.

Pure docstring fix; no behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley marked this pull request as ready for review April 25, 2026 09:29
Three changes from review feedback (mine on the PR + github-code-quality
bot inline):

1. Drop the gate-passes and raw_capabilities-absent smoke tests. Both
   ended with `assert.ok(true, '...')` after a try/catch that captured
   `threw` and never asserted on it — they passed regardless of gate
   behavior, and the bot correctly flagged the unused `threw` variable.
   The negative paths are covered by `resolveCapabilityPath`'s
   undefined branch (now tested directly) and by the runner's
   `actual !== undefined && actual !== equals` condition.

2. Export `resolveCapabilityPath` from runner.ts and the storyboard
   barrel; rewrite test #4 to import it instead of reimplementing the
   logic inline. The inline copy would silently drift from the runtime
   if edge cases ever tightened (null prototypes, Symbol keys); testing
   the real implementation forecloses that class of bug. Added
   defensive cases (non-object intermediates, null/undefined input)
   that pin the behavior the gate relies on.

3. Inline the absence-semantics rationale at the predicate site in
   runner.ts. Earlier the choice "undefined runs the storyboard" was
   only documented on `Storyboard.requires_capability` TSDoc and in
   the PR body — not at the call site where it matters most for
   refactor-safety. The conservative-vs-permissive interpretation
   will come up again when this gates a stricter storyboard.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit efb2fa6 into main Apr 25, 2026
9 checks passed
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.

Storyboard runner: auto-skip capability-gated storyboards when agent declares the capability unsupported

2 participants