Skip to content

fix(compliance): collapse key_reuse_conflict into replay_same_payload phase (3.0.x) - #4365

Merged
bokelley merged 1 commit into
3.0.xfrom
bokelley/idempotency-yaml-collapse-conflict-into-replay-phase
May 11, 2026
Merged

bokelley merged 1 commit into
3.0.xfrom
bokelley/idempotency-yaml-collapse-conflict-into-replay-phase

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Companion to adcp-client#1657 / adcp-client#1658.

#1658 fixes a runner bug where \$generate:uuid_v4#alias placeholders leaked across phase boundaries within a single pass. The fix resets the alias cache at every non-skipped phase entry.

universal/idempotency.yaml is the one storyboard in the corpus that depends on cross-phase alias sharing: \#replay_key is reused in the key_reuse_conflict phase to assert IDEMPOTENCY_CONFLICT against the cache entry the replay_same_payload phase populated. With #1658's reset, that phase boundary mints a fresh UUID — the seller sees a new request and returns 201 instead of IDEMPOTENCY_CONFLICT, masking the assertion.

This PR restructures the storyboard so the alias stays in a single phase:

Phase Before After
replay_same_payload 3 steps (initial, replay, no-dup-webhooks) 4 steps — adds create_media_buy_conflict
key_reuse_conflict 1 step (create_media_buy_conflict) removed

The conflict step's task, schema refs, request body, validations, and reviewer_checks are unchanged — only its parent phase changes. Phase narrative is updated to cover both replay and conflict semantics, including a one-paragraph note on why both branches must share the same phase (so future authors don't try to re-split for organizational cleanliness).

Why this lives in the same phase, not a sibling phase with explicit alias propagation

Three options on the table:

  1. Same-phase grouping (this PR) — pure YAML restructure, no spec/runner change beyond fix: security hardening — webhook auth, bounded limits, talent role types #1658.
  2. Syntactic marker — \$generate:uuid_v4@scenario#replay_key (or similar) for storyboard-scoped aliases. Requires runner + spec change; broadens the substitution grammar; one more thing for storyboard authors to learn.
  3. Capture-and-reinject via \$context.<name> — would require the response to echo idempotency_key (it doesn't, per protocol-envelope.json), or a new `from: request` source on `context_outputs`. Bigger spec change.

Option 1 is the smallest landing surface for the 3.0.x patch line. Options 2/3 can be revisited in 3.1+ if a future storyboard legitimately needs cross-phase aliases.

Compatibility

  • Compliance reports. The `key_reuse_conflict` phase row goes away; the step result moves under `replay_same_payload`. Consumers that pin to `(storyboard_id, step_id)` are unaffected. Consumers that pin to `(storyboard_id, phase_id)` lose one row and gain a step under the renamed phase.
  • Step IDs. `create_media_buy_conflict` keeps its step ID.
  • Validations. Identical — same `error_code`, same `field_present`/`field_value` checks on `context`, same reviewer_checks.
  • Sellers. No wire-level change. The seller receives the same four calls in the same order with the same key and the same bodies; the only difference is that they all arrive within one phase from the runner's perspective.
  • YAML schema validation. Passes `yaml.safe_load`; phase count drops from 6 to 5; `replay_same_payload.steps` count increases from 3 to 4.

Wire order

Steps fire sequentially:

  1. `create_media_buy_initial` — fresh `#replay_key` UUID, body A → seller caches.
  2. `create_media_buy_replay` — same key, body A → seller returns cached response, `replayed: true`.
  3. `no_duplicate_webhooks_on_replay` — drains receiver for 30s, asserts ≤1 webhook fired.
  4. `create_media_buy_conflict` — same key, body B (different end_time + budget) → seller MUST raise IDEMPOTENCY_CONFLICT.

Step 4's error response doesn't fire a webhook, so it doesn't interact with step 3's drain window.

Forward-merge

Branch is 3.0.x. The forward-merge bot will replay to main once landed.

Linked

  • adcp-client#1657 — bug report (cross-phase alias leak).
  • adcp-client#1658 — runner fix (phase-boundary alias reset). Blocked-on this storyboard restructure to avoid breaking `universal/idempotency`.

🤖 Generated with Claude Code

… phase

The conflict step shares `$generate:uuid_v4#replay_key` with the replay
steps by design — same key, different body, to assert IDEMPOTENCY_CONFLICT
against the cache entry the replay phase populated. With
adcp-client#1658's phase-boundary alias-cache reset (the fix for #1657's
cross-phase alias leak), aliases no longer persist across phase
boundaries. A separate `key_reuse_conflict` phase would mint a fresh UUID
on the wire and the seller would treat the request as new — masking the
conflict assertion entirely.

Move `create_media_buy_conflict` into `replay_same_payload` as a fourth
step so the alias stays scoped to a single phase. Phase title and
narrative updated to cover both replay and conflict semantics. Step body
unchanged — same request, same validations, same reviewer_checks.

Companion to adcp-client#1657 / adcp-client#1658. No seller-visible
behavior change; pure storyboard restructure so the runner fix is safe
to land.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit e03978d into 3.0.x May 11, 2026
12 checks passed
@bokelley
bokelley deleted the bokelley/idempotency-yaml-collapse-conflict-into-replay-phase branch May 11, 2026 08:44