Repository navigation
fix(creative-delivery): reconcile legacy package refs by constraint satisfaction - #3510
Conversation
…atisfaction On the legacy wire, sync_creatives carries one format_id per creative, and 17.0.0-beta.5 required every assigned package to resolve to an identical ref. A VAST creative assigned to 940x529 packages and unsized video_vast packages was refused, although the sized ref satisfies every package. Reconcile the per-package refs by constraint satisfaction instead: refs must share agent_url and id; width/height and duration_ms are constraints a package states (through its ref, declaration params or catalog entry) or leaves open. Open constraints accept the value another package states, the shared ref omits values no ref states, and size lists and duration ranges must accept the shared value. Refuse only on genuinely different stated values, naming the constraint and packages in the message and in CreativeFormatProjectionError.details.conflicts. Deprecate playerSizedRefs. It is still accepted and keeps its beta.5 meaning only as a host override for VAST packages that state different player sizes. The canonical wire is unchanged. Fixes #3506 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean fix for a 17.0.0-beta.5 (#3502) legacy-wire regression.
What I checked:
- New
reconcileLegacyAssignmentRefs(src/lib/v2/projection/creative-delivery.ts L2305-L2390) resolves refs by constraint satisfaction — open constraints accept stated values, conflicts refuse and surface indetails.conflicts. All branches (identity grouping viasameLegacyIdentity, discrete size/duration agreement, boundedsizes/duration_ms_range, shared-ref/exactreuse) trace consistently against the 10 new tests. - Non-size param-compatibility gate (compatibleParameters/parameterKeys) correctly preserved only on the deprecated opt-in override path; no new case accepts a value that base would have refused on params alone.
- Canonical wire untouched (gated on
wireMode !== 'canonical'); witness-not-translator respected (derives from package declarations, fabricates nothing). - Changeset present (
.changeset/legacy-ref-constraint-reconcile.md);patchis correct for a beta regression fix touchingsrc/lib/**.
No blocking or medium findings. high_risk false, gated_paths false, no author-team gate. review_decision is REVIEW_REQUIRED but with gated_paths false, row 2 does not apply. Falls through to row 9 → approve.
… constraints A package whose resolved ref is silent but whose declarations state several sizes (or durations) left that constraint open, so it accepted any value another package stated. Treat it as a set constraint: the shared value must be one the package declares, otherwise refuse with a conflict naming the package and its allowed values. Size lists and duration ranges use the same check. Document that the shared ref takes size and duration from resolved refs only, so declaration-only values never widen what the SDK sends. Name 18.0.0 as the removal version for playerSizedRefs and point to adcontextprotocol/adcp#8583 for declaring player-hint dimensions in the format itself. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean pass, no blocking or medium findings.
Checked:
reconcileLegacyAssignmentRefs(creative-delivery.ts L329-378) satisfies witness-not-translator: shared ref takes width/height/duration from resolved refs only (L363-371); declaration-only values are used for conflict detection but never fabricated onto the wire. Identity conflicts fail-closed viasameLegacyIdentity.constraintConflict(L277-300) correctly treats open constraints as accepting any value and refuses only when no value satisfies every package — fixing the beta.5 over-refusal.playerSizedRefsdeprecated without removal; no export removal.- Changeset present and
patchtype is appropriate (bug fix + additiveconflictserror detail, no breaking export change) — satisfies changeset-vs-wire-impact. - 14 new tests cover repro, deprecated opt-in, already-legacy, size/duration/format-identity conflicts, sizes lists, multi-declaration finite sets, declaration-only-never-flows, and canonical-wire-untouched.
No no-auto-approve team match, gated_paths is false, high_risk is false. Prior decision was approve; this run remains clean. No rows 1-8 fire → row 9 approve.
bokelley
left a comment
There was a problem hiding this comment.
Review: legacy format-ref reconciliation (#3506)
I checked out 5e399721 in a fresh worktree and built it. creative-delivery* and creative-format-projection* pass (293/293). I then ran scenario scripts against projectSyncCreativesForDelivery(..., 'legacy'), using the same vastPackage shape as the new tests. A creative is projected in either package order, and the shared record is identical across package and assignment orders for the combined size+duration case. The canonical gate (wireMode !== 'canonical') holds. The ref-stated widening from the first round is fixed. One widening remains.
Confirmed bugs
1. High: responsive, aspect-ratio and orientation declarations count as "open", so the package receives a size it rejects
src/lib/v2/projection/creative-delivery.ts:2354-2372 (packageSizeConstraint).
The size constraint only looks at width/height, a single sizes entry, multi-entry sizes, and the catalog. Any other size-limiting key returns undefined, which is treated as open. CanonicalFormatVASTVideo defines these keys: min_width, max_width, min_height, max_height, aspect_ratio, orientation. The same function's override path already treats them as size statements (statesSize, L2700-2709).
Results on this head (A = vastPackage('A', {width: 940, height: 529}), B's ref is silent):
| B declaration params | Result |
|---|---|
{max_width: 640, max_height: 360} |
projected 940x529 (either order) |
{min_width: 1280} |
projected 940x529 |
{orientation: 'vertical'} |
projected 940x529 |
{aspect_ratio: '9:16'} |
projected 940x529 |
{max_width: 640} + playerSizedRefs |
projected 940x529. Beta.5 + opt-in refused this, because parameterKeys differed. |
On its own, B resolves to the unsized ref. Under the PR's rule ("a package either leaves width/height open or restricts it"), max_width: 640 restricts it, and 940 violates that. Without the option, beta.5 refused all of these because the refs weren't identical. So these are newly accepted inputs that send B a ref outside its declaration. The opt-in row is a regression for callers who set playerSizedRefs.
Suggested fix: when a package's ref is silent on size and any of its declarations carries one of the statesSize keys other than width/height/sizes, build a predicate constraint instead of returning undefined:
- min/max bounds per axis;
orientationfrom the sign of W−H;aspect_ratioasW/Hwithin a small tolerance;- fail closed on any size-family key the predicate doesn't understand.
A sizes entry with only min/max should go through the same predicate, not be dropped (see #4). Add the four table rows as tests, plus a positive case (max_width: 1280 accepts 940×529).
2. Medium: whether projection succeeds depends on unrelated packages, because the identical-ref shortcut skips the declaration-only check
creative-delivery.ts:2447 (shortcut), compared with L2399-2403 (finite-set check in constraintConflict).
| Packages | Result |
|---|---|
| A: silent ref, declares 940×529; B: silent ref, declares 640×360 | projected, unsized (refs identical, so the shortcut fires) |
Same + C: vastPackage('C', {duration_ms: 30000}), open on size |
refused, size conflict 940x529 vs 640x360 |
Adding a package that accepts everything turns success into refusal. Durations behave the same way: two silent refs declaring duration_ms_exact 15000 and 30000 are projected, but refused once a sized third package is added.
Suggested fix: pick one rule. I'd drop the "no ref states a value, so finite sets must intersect" check. When no ref states the value, the shared ref omits it, which is exactly what each package resolved to alone. Nothing is widened, and the result matches the identical-ref shortcut (and beta.5). The alternative is to run the constraint checks before the shortcut, but that refuses inputs beta.5 accepted.
3. Low: in the no-ref-stated case, ranges are left out of the conflict check
creative-delivery.ts:2401. finite drops constraints that use duration_ms_range. A silent-ref package declaring [5000, 15000] plus one declaring exact 30000 (plus a sized C so the shortcut doesn't fire) is projected, but exact 15000 vs exact 30000 is refused. If #2 drops the check, this goes away. Otherwise test finite[0] values against every constraint's accepts.
4. Low: partial sizes refuse more than they should, including a package refusing its own resolved ref
creative-delivery.ts:2331, 2368.
- B's ref is silent and its declaration is
{width: 940}, so its key is940x(unstated). That refuses A's940x529, which satisfies it. - A's ref is
{width: 940}and its declaration is{width: 940, height: 529}. The stated key uses the ref only (940x(unstated)), but A's constraint goes throughlegacyRefParameterConstraints, which fills height from the declaration (940x529). A rejects its own ref and the error lists a single value:size conflicts: 940x529 for "A". - In a
sizeslist with mixed entries ([{640x360}, {min_width: 900}]), the responsive entry is silently dropped, so 940×529 is refused.
All three are fail-closed, so they're not urgent. Comparing per axis, with the same derivation for stated and accepted values, would fix all three and give a clearer message.
Questions
wireMode: 'unknown'also takes this branch, which forces'legacy'per package (unchanged from beta.5). The new doc text says this is "a legacy-wire concern only". Is it intended thatunknown-mode callers with more than one package get a legacy-only record? If so, could the guide say so?- The deprecation is JSDoc-only. Is a one-time runtime warning wanted when
playerSizedRefsis set and actually decides the outcome? Callers relying on it for the different-player-sizes case would find out before 18.0.0.
Verdict
The issue repro, the ref-only value flow and canonical isolation are right. #1 is a remaining widening and blocks merge. It sends a seller a ref outside the package's declared bounds, and for opt-in callers it reverses a refusal beta.5 made. #2 should be settled in the same pass. #3 and #4 can follow up.
…en reconciling legacy refs A package whose resolved ref was silent on size and whose declaration used min/max bounds, orientation or aspect_ratio counted as open, so it received another package's 940x529 in either order, and with playerSizedRefs this reversed a beta.5 refusal. Build a size predicate per declaration instead: exact or width-only sizes, sizes entries (including responsive entries), min/max bounds, orientation, and aspect_ratio within 1%. Size and duration constraints the SDK does not understand fail closed. A package always accepts its own resolved ref, and stated sizes compare per axis. When no ref states a value the shared ref omits it, so declarations that disagree only among themselves no longer refuse. The result no longer depends on unrelated open packages, and matches the identical-ref shortcut. Duration ranges accept null endpoints. Document that unknown wire mode reconciles like legacy, and log a one-time runtime deprecation warning when playerSizedRefs is set. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — subsequent pass with no blocking or medium findings.
What I checked:
src/lib/v2/projection/creative-delivery.ts(~360 added lines):reconcileLegacyAssignmentRefsplus size/duration acceptors. Reconciliation is sound — widths/heights unioned from resolved refs only,size.size > 1forces a conflict, declaration values feed conflict detection but are never copied into the shared ref (upholds witness-not-translator). Unknown size constraints fail closed viaSIZE_FAMILY_KEY; duration acceptor covers the real param keys (duration_ms_exact/duration_ms_range).warnOnce/resetWarningspresent and exercised by the deprecation test.- Changeset present (patch) — appropriate for a beta regression fix with additive
details.conflicts; nothing removed or renamed, so patch does not understate impact.
No critical/high/medium findings. Prior decision was also approve with no findings; this remains a clean net-positive. gated_paths is false and no author team gate applies, so row 2/7 do not fire. Falls through to row 9 → approve.
|
Addressed the review in 394ce8b:
Each case has a test, and the reviewer's repros run in both package orders. |
Main's ci.yml went red after #3510 and #3541 landed: - Package size: CI measured 26,363,856 packed bytes after #3510 and 26,369,089 after #3541, over the 26,360,000 cap set for beta.1. Raise the cap to 26,420,000 with the measurement recorded; the unpacked, file-count, schema and declaration budgets are unchanged. - test/lib/pre-dispatch-errors.test.js (#3507) pinned adcpVersion '3.3.0-beta.1', which #3541 retired, so the client constructor threw a ConfigurationError instead of reaching the feature gate. Use the SDK's own ADCP_VERSION so the test survives the next preview bump. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…3548) Main's ci.yml went red after #3510 and #3541 landed: - Package size: CI measured 26,363,856 packed bytes after #3510 and 26,369,089 after #3541, over the 26,360,000 cap set for beta.1. Raise the cap to 26,420,000 with the measurement recorded; the unpacked, file-count, schema and declaration budgets are unchanged. - test/lib/pre-dispatch-errors.test.js (#3507) pinned adcpVersion '3.3.0-beta.1', which #3541 retired, so the client constructor threw a ConfigurationError instead of reaching the feature gate. Use the SDK's own ADCP_VERSION so the test survives the next preview bump. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…adroom (#3568) * fix(packaging): stop shipping duplicate compliance and declaration bytes Trim @adcp/sdk from 26,862,556 to 24,993,401 packed bytes (8,529 to 8,176 files) without changing runtime behavior: - Exclude compliance/cache/*/domains/ from the package. Every bundle's domains/ is a byte-identical copy of protocols/, the only directory the storyboard loader reads (-286,556 bytes, -353 files). - Emit one-line ESM facades for the type-only generated declarations (types/core.generated, types/tools.generated, registry/types.generated), as types/schemas.generated already did, instead of copying 5.7 MB of declarations (-1,174,602 bytes). - Store the self-contained MCP tools/list request projections as compact JSON. They are only ever JSON.parse'd (-407,997 bytes). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * ci(packaging): size budgets with headroom and a per-PR growth check The packed-byte and file-count budgets were pinned to the measurement, so two PRs that each added a file or a few KB passed alone and broke main together (#3510 + #3541, #3564 + #3559/#3560). Replace the pins with: - Ceilings with headroom in scripts/package-size-budget.json: @adcp/sdk 26,000,000 packed bytes / 135,000,000 unpacked / 8,450 files against a measured 24,993,401 / 129,047,083 / 8,176 (about 4%), and @adcp/reporting-storage 490,000 / 2,250,000 / 150. A warning fires when less than two PRs' allowance of headroom is left. - A per-PR growth check. main caches each commit's measurement; a pull request compares itself with the record for its exact merge base and may add 100 KB / 25 files to the SDK (15 KB / 8 files to the storage package). More needs the same PR to raise the ceiling, so the growth is reviewed in the diff. A missing record skips only this comparison. - The focused-client eager graph count becomes a ceiling (230, measured 216) instead of an exact pin; the named heavy-module exclusions stay. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Fixes a 17.0.0-beta.5 regression from #3502 (13c162c) that broke a production buy. On the legacy wire,
projectSyncCreativesForDeliveryrequired every assigned package to resolve to an identical legacyformat_id. So one VAST creative assigned to ninevideo_vast940×529 packages and three unsizedvideo_vastpackages was refused, even though the 940×529 ref satisfies all twelve.The rule (legacy wire only)
After each package resolves on its own, a new
reconcileLegacyAssignmentRefspicks the one ref that satisfies every package:Identity: every ref must share
agent_url(normalized) andid.The shared ref takes size and duration from the resolved refs only, compared per axis. Refs that state different values conflict. Values that only declarations state are used to detect conflicts but never flow into the shared ref, because the shared ref must match what each package resolves to on its own. Copying declaration values in would widen what the SDK sends. The doc comment says this explicitly so a later change doesn't turn it into a widening.
When some ref states a value, every package must accept it. A package always accepts its own resolved ref. Where its ref is silent, it accepts what any of its declarations accepts:
width/height(width-only and height-only are fine) andsizesentries, including responsive entries;min_width/max_width/min_height/max_heightbounds;orientation(horizontal/landscape, vertical/portrait, square);aspect_ratio, within 1% so that 940×529 counts as 16:9;duration_ms_rangewhere either end may benull.The catalog entry for the id applies on top. A declaration with none of these leaves the constraint open. A size or duration constraint the SDK doesn't understand fails closed, e.g. an unknown orientation, an unparseable ratio, an unknown size-family key such as
min_aspect_ratio, or an emptysizesentry. So a package declaring 640×360 and 940×529, ormax_width: 640, refuses a 300×250 or 940×529 that another package states.When no ref states a value, the shared ref omits it, which is exactly what each package resolved to alone. Declarations that disagree only among themselves therefore don't refuse. The result never depends on unrelated open packages, and it matches the identical-ref shortcut and beta.5.
Refusal happens only when no value satisfies every package. The message names the constraint and the packages, e.g.
size (width, height) conflicts: 940x529 for "A" vs 640x360 for "B", orone of 640x360, 940x529 for "A" vs 300x250 for "B". A new optionalCreativeFormatProjectionError.details.conflictscarries the same thing as[{ constraint: 'format_id' | 'size' | 'duration', values: [{ value, package_ids }] }].details.package_refsis unchanged.Canonical wire is untouched. The reconciliation runs only on the existing
wireMode !== 'canonical' && assignedPackageIds.size > 1branch. Code comments anddocs/guides/CREATIVE-DELIVERY.mddescribe it as a legacy-wire concern, and a new test checks that the canonical output is the identical input object, with and without the option.What happened to
playerSizedRefsIt is deprecated, to be removed in 18.0.0, and until then still accepted with its narrowest compatible meaning. Setting it logs a one-time runtime deprecation warning (
warnOnce), so callers who rely on it find out before 18.0.0. Whether a stated VAST size is a hard requirement or a player hint is a fact about the seller's format. It belongs in the seller's format definition or the AdCP format params, not in host policy; see adcontextprotocol/adcp#8583. The JSDoc, the guide and the changeset all say this. I did not make it a no-op, because a no-op would quietly break any beta.5 caller that relies on it for the one case the declarations cannot settle: VAST packages that state different player sizes (640×360 vs 640×480). With the new rule those conflict, and only a host assertion that "this seller accepts a ref without width/height" can resolve them. So:Edge cases decided
widthis never refused by its own package's fuller declaration.playerSizedRefs,max_width: 640against 940×529 is refused, as beta.5 refused it.wireMode: 'unknown'sends the legacy projection (unchanged from beta.5 and documented in the guide), so multi-package creatives are reconciled the same way. There is a test for this.940x529, Bduration_ms: 30000, C neither gives940x529 @ 30000. When a package resolved to exactly the shared ref, its projected record is used unchanged. Otherwise the first sized (or timed) package's record gets the sharedformat_id. Asset-key mapping depends only on owner and id, which all packages share.sync_creativescreative can't be split. The "non-size format parameters" suffix now appears only when the deprecated override was attempted, since that is the only path where non-size params decide the outcome.Tests
New
describeblock intest/lib/creative-delivery-player-sized.test.js(#3506):wireMode: 'legacy'. It projects{id: video_vast, width: 940, height: 529}in either package order and doesn't mutate inputs.sizeconflict and the packages named in the message and indetails.conflicts.sizeslist accepts a listed size and refuses an unlisted one.one of 640x360, 940x529, and accepts 940×529. The duration equivalent (15000/30000 vs 45000, and vs 30000) behaves the same way.{max_width: 640, max_height: 360},{min_width: 1280},{orientation: 'vertical'}and{aspect_ratio: '9:16'}are refused, with B's constraint named.{max_width: 640}withplayerSizedRefsis refused.{max_width: 1280},{min_width: 640, max_height: 720},{orientation: 'horizontal'},{aspect_ratio: '16:9'},{width: 940}and a mixedsizeslist with amin_widthentry all accept 940×529.sizesentry.duration_ms_rangewithnullendpoints.wireMode: 'unknown'reconciles like legacy.All 45 existing #3502 tests pass unchanged.
Validation
npm run typecheck,npm run build, prettier: pass.creative-delivery*,creative-format-projection,creative-wire-mode,canonical-wire-undeclared-format-options,creative-tracker-downgrade,version-translation,v1-to-v2-projection,v2-getproducts-autowire,v2-augment-response,creative-schema-references,single-agent-deferred-recovery): 639/639 pass.lint:boundariespasses.Changeset:
@adcp/sdkpatch (pre modebeta).🤖 Generated with Claude Code
Fixes #3506