Repository navigation
fix(codegen): support structured media buy features - #3118
Conversation
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — generator-only fix with no blocking findings.
This PR rewrites widenMediaBuyFeaturesIndexSignature (scripts/generate-types.ts:41-97) from a single-interface regex to an AST walk that derives the catch-all index union from each named non-boolean field. The reviewer traced idempotency (shared included set, line 82 early-continue), named-field type preservation (TS2411 fix without relaxing named props), reverse-ordered edits, and the require.main === module guard for import-safe test harness. Change is witness-preserving — runtime Zod unchanged, zero generated-file delta against released 3.2.1. Changeset present and patch type is accurate for a generator-only fix. Thorough regression test added.
Decision table: no critical/high/medium findings (row 1 N/A). gated_paths is false (row 2 N/A). high_risk is false (rows 3/5 N/A). No medium findings (rows 4/8 N/A). No prior escalation (row 6 N/A). No no-auto-approve team match (row 7 N/A). Falls through to row 9 → approve.
Note: review_decision is REVIEW_REQUIRED, but since gated_paths is false this does not force escalation; the deprecated protected-branch gate no longer applies.
There was a problem hiding this comment.
Ladon verdict: Approve
Approve.
Replaces the regex-based widenMediaBuyFeaturesIndexSignature in scripts/generate-types.ts with an AST-based generalization that widens index signatures for every structured MediaBuyFeatures field (including inline capability objects). Output is byte-identical for the current schema since all four MediaBuyFeatures interfaces carry only bidding_policy as a structured field, so no regenerated *.generated.ts files ship — correctly omitted. Edits apply in reverse to preserve offsets; dedup is sound; idempotency and the TS2411 failure are both asserted by the new test. Changeset present (patch, correctly scoped per changeset-vs-wire-impact since this is a build-script change with no wire-shape or export impact).
No Critical/High/Medium findings. Not a no-auto-approve team; gated_paths is false; high_risk is false. Rows 1–8 do not fire — falls through to row 9.
There was a problem hiding this comment.
Ladon verdict: Request changes
Request changes — 1 blocking finding
Blocking findings
- scripts/generate-types.ts:3268 — New AST-based index-union emission appends the named type after the existing union (
boolean | undefined | (BiddingPolicyCapability)) instead of the committedboolean | BiddingPolicyCapability | undefined. Nothing downstream reorders it, so a full regen rewrites 4 committed generated lines and the CI "Validate generated files are in sync" gate fails — contradicting the PR body's zero-change claim. Fix: preserve legacy ordering in the emitted union, or regenerate and commit the updated generated types.
The AST refactor itself is sound (idempotent, dedupes, handles inline/optional/variant interfaces) and well-tested, but the ordering divergence is a reproducible CI/sync-gate break on a build-affecting script. Row 1 of the decision table applies (a high finding is present).
Blocking findings
- scripts/generate-types.ts:3268 — New index-union emission order diverges from committed generated types; sync gate fails
Superseded by a later Ladon review that rechecked and resolved its blocking findings.
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — prior blocker resolved, no current findings.
This is a subsequent review. The prior run flagged one high finding (scripts/generate-types.ts:3268 — index-union emission order diverged from committed generated types, failing the sync gate). The developer has addressed it: the emission now special-cases the | undefined suffix (head L89-91), producing boolean | BiddingPolicyCapability | undefined to match all four committed sites (core.generated.ts:29260,32488; tools.generated.ts:1925,8440). A full regen no longer rewrites committed lines, so the sync gate passes. A new test (legacy output drift) pins that exact ordering; idempotency and grouping paths check out.
Decision-table walk-through:
- Row 1 (critical/high): no current findings — not triggered.
- Row 2 (gated_paths && not APPROVED): gated_paths is false — not triggered.
- Row 3 (deleted high-risk): high_risk false — not triggered.
- Rows 4–5 (medium + category / high-risk modified): no medium findings — not triggered.
- Row 6 (sticky escalate): prior decision was request-changes, not escalate, and there are no fresh findings — not triggered.
- Row 7 (no-auto-approve team): no team match — not triggered.
- Row 8 (≥3 medium): zero medium findings — not triggered.
- Row 9: approve.
Net improvement over the prior pass: the sole blocker is gone and no new findings surfaced in the delta. Changeset present (.changeset/structured-feature-index-types.md) and consistent with the build-affecting scripts/ change.
Adding a second structured media-buy capability currently breaks SDK generation with TS2411: the generator widens the boolean feature-map index only for
bidding_policy. Protocol PR adcontextprotocol/adcp#7927 exposed the failure forcatalog_ingestion.Derive the index union from each named non-boolean property using TypeScript AST nodes. This covers referenced and inline capability types, optional fields, and generated interface variants without self-references that would break downstream Zod generation. The protocol schema and runtime processing remain unchanged; generated types will incorporate new declarations when schemas sync.
Validation: regression reproduces TS2411, verifies repaired interfaces compile, preserves named-field typing, checks idempotence and byte-identical legacy output, compiles generated Zod schemas, and parses referenced/inline capability values. Prettier and diff checks pass. Independent schema/code/security review found no remaining blockers. Full generation, schema synchronization validation, and library/declaration build passed against protocol PR #7927's exact bundle. Full regeneration from released AdCP 3.2.1 also produces zero generated-file changes. Unreleased protocol-generated artifacts are kept out of this generator-only fix.
This companion fix must land before rerunning the TypeScript SDK validation on protocol PR #7927.