Repository navigation
fix(media-buy): merge structured-only action metadata into update-field dispatch - #2889
Conversation
…ld dispatch Closes #2887. The update_fields generator reads enumMetadata from both enums/media-buy-valid-action.json and core/media-buy-available-action-id.json (AdCP 3.2, adcp#7449), with a conflict check (legacy wins on agreement, disagreement aborts) and a legacy-only fallback for schema caches that predate the id schema. Adds MediaBuyActionId and widens every hand-written narrowing of available_actions[].action / attempted_action from the legacy enum; decomposeUpdateMediaBuy maps the MediaBuy-level frequency_cap request field through the generated table. Codegen: own MediaBuyAvailableAction and ProductAllowedAction as priority canonical schemas so json-schema-to-typescript cannot degrade their `action` to the legacy enum once the pin ships the anyOf id alias. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Comment (human reviewer recommended)
Comment — 1 medium finding; changeset severity per repo policy warrants a human look.
The reviewer verified the AdCP 3.2 structured-only action merge as sound: generator merge logic, the codegen ownership relocation of MediaBuyAvailableAction/ProductAllowedAction, the MediaBuyValidAction→MediaBuyActionId widening, and frequency_cap decomposition are all well-tested and witness-faithful. No Critical/High findings on wire-shape fidelity or transport-client usage.
Medium findings
.changeset/merge-structured-only-action-metadata.md— Changeset typedpatchbut the PR ships four new public exports plus widened signatures (additive-minor under semver); should be bumped tominor.
Note on decision: The repo's mandatory changeset-vs-wire-impact policy treats a changeset that understates impact (e.g. patch for what is a minor/response-shape-affecting change) as a high finding. The reviewer classified this as a non-blocking Medium (additive-minor, not a removed/renamed export or required-param flip). Taking the reviewer's Medium severity at face value, this is a single medium finding with no escalation trigger — which by the decision table (row 9) would be approve. However, review_decision is REVIEW_REQUIRED and gated_paths is false, so no hard gate forces escalate. Because the changeset-type understatement sits right at the boundary of the repo's high-finding policy and the reviewer explicitly recommended a bump, surfacing this for a human via comment rather than auto-approving is the safe reading.
…ctured-only-action-metadata Regenerated types against the rc.2 cache; rc.2 still predates core/media-buy-available-action-id.json so the update_fields table stays legacy-only and the codegen change only relocates MediaBuyAvailableAction / ProductAllowedAction into core ownership. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
(see above) |
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — clean subsequent pass, no blocking or medium findings.
Checked:
- No critical/high/medium findings this run; hand-written PR files are byte-identical to the prior clean SHA.
- Changeset correctly bumped patch → minor to match additive new exports (changeset-vs-wire-impact satisfied).
.prettierignoreentry for vendored media-buy fixtures is legitimate.- Generated-type churn is rebase noise from new main; no PR-owned media-buy codegen changed.
Decision-table walkthrough: no critical/high (row 1 n/a); gated_paths false (row 2 n/a); high_risk false, no deletions (rows 3–5 n/a); prior decision was comment, not escalate, and no new findings (row 6 n/a); no no-auto-approve team match (row 7 n/a); zero medium findings (row 8 n/a) → falls through to row 9 = approve.
Closes #2887.
Summary
scripts/generate-media-buy-update-fields.tsnow mergesenumMetadatafrom bothenums/media-buy-valid-action.jsonandcore/media-buy-available-action-id.json(AdCP 3.2, feat(media-buy): add shared media-buy frequency cap adcp#7449). Rows follow legacy enum order, then structured-only ids inanyOforder. Legacy wins on agreement; a shared key with different metadata aborts generation, as does a structured-only const with noupdate_fieldsor metadata for an undeclared action. Caches that predate the id schema (the current3.2.0-rc.1pin and everything older) emit the legacy-only table, so older pins keep regenerating. Header comment and the "bump schema cache" error text updated;SCHEMA_DIR/OUT_PATHoverrides added alongside the existingSCHEMA_PATH.STRUCTURED_ONLY_MEDIA_BUY_ACTIONS,StructuredOnlyMediaBuyAction, andMediaBuyUpdateFieldAction(keys ofUPDATE_FIELDS_BY_ACTION).MediaBuyActionIdtype insrc/lib/media-buy/types.ts: every structuredavailable_actions[].actionid, derived from the generated wire type plus the dispatch-table union. Every hand-written narrowing to the legacy enum is widened to it:findAvailableAction,getRollupParent,ROLLUP_PARENT_OF,ResolvedAction.action,DecomposedUpdateMediaBuyMutation.action,PreflightDenial.action,recoveryForModeMismatch, and the server-sideACTION_NOT_ALLOWEDbuilder insrc/lib/server/media-buy-actions.ts.MediaBuyValidActionstays the type of the deprecated flatvalid_actions[]list.decomposeUpdateMediaBuy/preflightUpdateMediaBuymap the MediaBuy-levelfrequency_caprequest field (set ornullto clear) throughACTIONS_BY_FIELD, so the binding activates with the schema pin instead of being hardcoded.generate-typesemittedMediaBuyAvailableActionID = MediaBuyValidAction | 'update_media_buy_frequency_cap'and used it forattempted_action, butMediaBuyAvailableAction.actionandProductAllowedAction.actioncame out asMediaBuyValidActionin TypeScript and Zod. Root cause: json-schema-to-typescript degrades later occurrences of theanyOf [$ref enum, const]alias inside a large root toMediaBuyValidAction1, whichremoveNumberedTypeDuplicatesfolds back to the legacy enum.core/media-buy-available-action.jsonandcore/product-allowed-action.jsonare now priority canonical schemas (the repo's existing first-definition-ownership mechanism), so both interfaces are owned bycore.generated.tsand imported/re-exported bytools.generated.ts. Without this, an rc.3 seller advertisingupdate_media_buy_frequency_capwould be rejected by the strict Zod validators.Schema source
The pinned
3.2.0-rc.1cache (and the cutv3.2.0-rc.2release, tagged before #7449 merged) lackscore/media-buy-available-action-id.json. I did not re-pin the repo to the PR bundle: the repo's PR-bundle path (schemas/codegen-provenance.json) requiresADCP_VERSIONto match the bundle'spublished_version(3.2.0-rc.2), which would turn this fix into a full rc.1 → rc.2+ protocol adoption. Instead:frequency_capmapping, and the widened wire types all appear automatically when the pin moves to a release that ships the id schema (expected rc.3). Nothing else needs to change.test/fixtures/media-buy-update-fields/merged/so the regression tests run against the post-#7449 shape regardless of the pin.validate-schema-bundle.ymlrecipe on a disposable copy of this branch:ADCP_VERSION=3.2.0-rc.2,sync-version --force, the PR bundle served locally overpython3 -m http.server,ADCP_BASE_URL=http://127.0.0.1:8765 ADCP_GITHUB_FALLBACK=0 npm run sync-schemas, thengenerate-types,validate-schemas,build:lib,typecheck, and the media-buy tests.https://adcontextprotocol.org/protocol/pr/9e2bf6a949de2adc8d2835e44cb73c820ee69d99/latest.tgz(PR head of adcp#7449), SHA-256e2804ae31fc4400c0c98af492365d915195e84faed49d72fb7c0757a8f381f46.Wrote src/lib/media-buy/update-fields.generated.ts (25 actions, 1 structured-only: update_media_buy_frequency_cap);available_actions[].action,allowed_actions[].action, andattempted_actionall typedMediaBuyAvailableActionIDin TS and Zod; typecheck green; 60 pass / 1 skipped across the two media-buy test files (the skipped case is the legacy-only assertion).Tests
test/lib/media-buy-update-fields-generator.test.js(new): runs the generator against the vendored fixtures and evaluates the emitted module. Assertsupdate_media_buy_frequency_cap -> ["frequency_cap"]andupdate_frequency_caps -> ["packages[].targeting_overlay.frequency_cap"], the inverse index, structured-only ordering, legacy rollup/deprecation intact, the legacy-only path for caches without the id schema, the pre-3.1 refusal, the conflict abort, the agree-and-accept path, the unbound-const abort, the undeclared-metadata abort, and that the checked-in table tracks the pinned cache. Also pins the codegen invariant that the three wire sites share one action id type and that tool types import the two interfaces from core.test/lib/media-buy-preflight.test.js: new block for the MediaBuy-levelfrequency_cap(set, clear, preflight pass, preflight deny, mixed with the package-level cap). Cases that need the structured-only binding areskipped with a reason on pins that predate the id schema; the no-binding case runs today.Verification
npm run generate-types(checked-in output under the rc.1 pin is committed)npm run validate-schemasnpm run build:libnpm run typecheck,npm run ci:codegen-strict,npm run ci:docs-check,npm run format:checknpm test(full suite; see the final comment for the run)Under the current pin the regenerated
core.generated.ts/tools.generated.ts/schemas.generated.tsdiff only relocatesMediaBuyAvailableActionandProductAllowedActioninto core ownership. One visible TS-only relaxation:ProductAllowedAction.modesandallowed_statusestype as arrays rather than non-empty tuples (priority canonical schemas go through the same array-cardinality relaxation as the rest of core). The Zod validators are byte-identical apart from ordering and still enforceminItems: 1.No release is published by this PR.
🤖 Generated with Claude Code
Open workspace in Conductor