Repository navigation
fix(v2-adapter): derive buyer_ref from idempotency_key in create_media_buy (#1115) - #1123
Merged
Merged
Conversation
bokelley
force-pushed
the
bokelley/v2.5-schemas
branch
from
April 30, 2026 23:29
78392b2 to
426ea19
Compare
bokelley
force-pushed
the
bokelley/v2.5-buyer-ref-v2
branch
3 times, most recently
from
May 1, 2026 00:31
6df0526 to
34bb590
Compare
…a_buy Closes #1115. v2.5's create_media_buy schema requires buyer_ref top-level + per-package as the buyer's reference for THIS media buy. v3 doesn't model buyer_ref directly, but idempotency_key carries the same client-controlled-unique-identity contract. Reusing it preserves the seller-side dedupe contract on replays — the same v3 input always produces the same v2.5 buyer_ref values. Derivation precedence: - Top-level: caller-supplied → idempotency_key → omitted - Per-package: caller-supplied → package.idempotency_key → ${parent_buyer_ref}-${index} adaptPackageRequestForV2 gains an optional second argument PackageAdapterContext ({ parentBuyerRef?, index? }) so callers threading per-package derivation supply the parent's reference + index. Backward-compatible — existing single-argument callers (update_media_buy adapter, third parties) continue to work without derivation. The v2.5 adapter-conformance test suite (#1121) flips create_media_buy from a known-drift expected_failures fixture to a passing fixture. 7 new unit tests pin the derivation rules, including a replay-stability test that asserts identical inputs produce identical buyer_refs. Lib regression: 5485 pass / 7 skipped (pre-existing) / 0 fail. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
force-pushed
the
bokelley/v2.5-buyer-ref-v2
branch
from
May 1, 2026 00:41
34bb590 to
a212650
Compare
This was referenced May 1, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1115. Stacks on top of #1121 — base is
bokelley/v2.5-schemasso the conformance-suite update lives in the same review. Once #1121 lands, GitHub will retarget this PR tomainautomatically.Summary
v2.5's
create_media_buyschema requiresbuyer_reftop-level + per-package as the buyer's reference for THIS media buy. The v2 adapter previously omitted it, causing every v3-buyer call against a v2 seller to fail v2.5 wire validation. This PR derivesbuyer_reffromidempotency_key, which already carries the client-controlled-unique-identity contract sellers need for dedupe.Mapping
Per the protocol expert review on PR #1121 (
bokelley/v2.5-schemas):buyer_ref: caller-supplied wins → elseidempotency_key→ else omitted (v3 pre-send validation should have rejected the missing required field; on warn-mode passthrough the v2.5 validator surfaces it).buyer_ref: caller-supplied wins → elsepackage.idempotency_key→ else\${parent_buyer_ref}-\${index}. Position-based composition is stable across replays.Why not generate fresh UUIDs: replays must hit the same
buyer_refor sellers can't dedupe, defeating idempotency. Reusingidempotency_key(which already has that contract) is correct.Why not use
account.account_id: that's tenant identity, not buy identity. v2.5'sbuyer_refis "buyer's reference for THIS media buy."API change
adaptPackageRequestForV2gains an optional second argumentPackageAdapterContext({ parentBuyerRef?, index? }). Backward-compatible — single-argument calls keep working unchanged.Conformance
The v2.5 adapter-conformance test suite (added in #1121) flips
create_media_buyfrom a known-driftexpected_failuresfixture to a passing fixture. Future regressions on this fixture surface as test failures.7 new unit tests in
test/lib/v3-compatibility.test.js:buyer_refderives fromidempotency_keywhen caller didn't supply onebuyer_refwins over derivationbuyer_refemitted when neither is present (defensive — better than synthesizing an unstable value)buyer_refdefaults to\${parent}-\${index}idempotency_keywins over the parent-derived defaultbuyer_refwins over bothbuyer_refs(pins the dedupe contract)Test plan
node --test test/lib/adapter-v2-5-conformance.test.js— 5 pass (create_media_buy now clean; sync_creatives still tracked at v2 adapter: flatten v3 manifest to v2.5 single-asset payload in adaptSyncCreativesRequestForV2 #1116)node --test test/lib/v3-compatibility.test.js— 176 pass (169 existing + 7 new)node --test test/lib/*.test.js— 5485 pass / 7 pre-existing skipped / 0 failRelated
bokelley/v2.5-schemas(PR feat(v2.5): schema cache + warn-only post-adapter validation + conformance suite #1121) — base; foundation, conformance suite, warn-only passadcontextprotocol/adcp-client#1116— sync-creatives manifest flatten (next PR)adcontextprotocol/adcp#3689— upstream tag/release pipeline🤖 Generated with Claude Code