Repository navigation
feat(decisioning): close v6 platform gaps for creative-template adopters (#1324, #1325, #1327) - #1348
Merged
Merged
Conversation
Three coordinated fixes for adcp-client issues #1324, #1325, #1327: #1324: Add `listCreativeFormats?` to `CreativeBuilderPlatform` and `CreativeAdServerPlatform`, dispatched through `buildCreativeHandlers`. Previously every creative-agent adopter that owned a format catalog had to drop down to the v5 escape hatch (`opts.creative.listCreativeFormats`) because the typed-platform path didn't carry the surface. #1325: Tighten codegen for the `Format.renders[]` mutual-exclusivity oneOf — extract closed-shape branches instead of `{ [k: string]: unknown }`. A new `flattenMutualExclusiveOneOf` preprocess in `generate-types.ts` detects the JSON Schema "X xor Y" pattern (`{ required: [X], not: { required: [Y] } }`) and inlines parent properties per branch with the excluded fields removed. The SDK's typed render builders (`displayRender`, `parameterizedRender`) now compose with `Format['renders']` under strict tsc. Same fix benefits sync_plans plan budget (reallocation_threshold xor reallocation_unlimited). Also tightens `RenderDimensions.unit` to the schema's `DimensionUnit` enum. #1327: New `NoAccountCtx<TCtxMeta>` request-context type whose `account: Account<TCtxMeta> | undefined` is applied to the no-account tool signatures (`previewCreative`, `listCreativeFormats`, `providePerformanceFeedback`). Converts the runtime-only gate into a compile-time invariant — same shape as the `definePlatformWithCompliance` fix in #1262. Adopters reading `ctx.account.ctx_metadata` without a narrow now get a TS error at authorship instead of a runtime crash. Tests added: dispatch + UNSUPPORTED_FEATURE coverage for the new `listCreativeFormats` path, type-only assertions in `decisioning.type-checks.ts` for builder assignability and ctx narrowing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Drop historical "Pre-#XXXX" comments in decisioning.type-checks.ts per
CLAUDE.md (no temporal/historical context); rewrite as invariant statements.
- Inline `_previewStub` returns to match the file's existing `({}) as never`
/ inline-cast idiom; drop the hoisted variable.
- `flattenMutualExclusiveOneOf`: filter outer `required` against each
branch's `not.required` exclusions before merging — prevents a latent
footgun where a future schema's outer-required + branch-excluded field
would land as `required: unknown` in TS. (No diff in 3.0.4 generated
output.) Also document the implicit `additionalProperties: false`
decision so a future open-branch idiom isn't silently closed.
- Update stale deferred-list JSDoc in `from-platform.ts` — the no-account
surface is no longer deferred for the creative path; it's now typed via
`NoAccountCtx`.
- Soften prescriptive language on `CreativeBuilderPlatform.listCreativeFormats?`
JSDoc to acknowledge per-tenant catalogs (Bannerflow / Celtra) and point at
the `accounts.resolve(undefined)` synthetic-account pattern.
- Improve `UNSUPPORTED_FEATURE` messages on `previewCreative` /
`listCreativeFormats` dispatch — name the adopter-side hook and the
cap-delegation alternative so LLM adopters can self-fix.
- Harden `previewCreative` dispatch check against `{ previewCreative:
undefined }` shape (matches the new `listCreativeFormats` check).
- Add comment on the `NoAccountCtx` inline type-import explaining why it
can't be a top-level `import type` (account.ts <-> context.ts cycle).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The v2-5 codegen path uses the same enforceStrictSchema preprocessing as v3, so the new flattenMutualExclusiveOneOf transform applies — Format.renders[] now produces closed shapes in v2-5 too. CI 'Validate generated files are in sync' caught the missed regen. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two pre-existing baselined errors in build-generative-seller-agent and build-retail-media-agent SKILL.md examples now report ctx as `NoAccountCtx<...>` instead of `Ctx<...>` — same underlying issue (example handlers return non-spec shapes; baselined as known issue), just the error-message prefix shifted with the signature change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
added a commit
that referenced
this pull request
May 2, 2026
Main shipped #1324 / #1325 / #1327 via PR #1348 with a different (and more refined) approach than this branch's version: - #1324 (`listCreativeFormats?` on creative platforms): main wires it with `ctx: NoAccountCtx<TCtxMeta>` typing for compile-time narrowing of the no-account ctx, and registers the dispatcher unconditionally (returns `UNSUPPORTED_FEATURE` internally when the method is absent). Take main's version. - #1325 (`Format.renders[]` codegen): main calls the preprocessor `flattenMutualExclusiveOneOf` and additionally tightens `RenderDimensions.unit` to the `DimensionUnit` enum. Same idea as my `tightenMutualExclusionOneOf`. Take main's. - #1327 (no-account-tool footgun): main solved with a `NoAccountCtx<TCtxMeta>` type narrowing on per-tool ctx (option 1 from the issue). My `accountStoreWithNoAccountFallback` + `defineAccountStore` helpers (option 2) become redundant. Drop them. Preserved from this branch: - #1337 (oneOf near-miss validator hint) — `compactUnionErrors` excludes `not`-failure variants from the survivor pick. Untouched in main. - #1338 (SHAPE-GOTCHAS §6 walled-garden CAPI projection) — pure docs, untouched in main. - #1341 (SalesPlatform split into core + ingestion) — sales.ts methods optional, `SalesCorePlatform` / `SalesIngestionPlatform` named subset types, `RequiredPlatformsFor<S>` per-specialism mapping, `defineSalesCorePlatform` / `defineSalesIngestionPlatform` helpers, conditional-spread dispatchers in `from-platform.ts`. The earlier follow-up commit (`0f0332e1`) documented the post-#1341 migration paths and locked them as type tests; that work is preserved through the merge. Conflict resolution: - `format-renders-codegen-tighten.md` — kept main's changeset. - `format-render-builders.ts` — kept main's standalone interface declarations (with `unit: DimensionUnit`); dropped my derive-from- generated approach. - `from-platform.ts` createMediaBuy / updateMediaBuy — wrapped main's hydrateForTool / routeIfHandoff bodies in this branch's #1341 conditional spreads (`...(sales.X && {})`), with `sales.X!()` non-null assertions inside. - `from-platform.ts` listCreativeFormats — dropped my conditional spread + `creativeListCreativeFormats` lookup in `buildCreativeHandlers`; kept main's unconditional registration with internal `UNSUPPORTED_FEATURE` check (matches the existing pattern for `previewCreative` / `listCreatives` / `getCreativeDelivery` and the regression test added in #1348). - Generated types — taken from main; regenerated locally to confirm byte-identity with the merged preprocessor + my #1341 sales.ts refactor. Verified: - `npx tsc --noEmit` clean - `npm run format:check` clean - `npm test` — 7595 pass, 0 fail, 7 skipped - `test/validation-oneof-cascade.test.js` 6/6 (#1337 regression test preserved) - `test/server-decisioning-from-platform.test.js` 109/109 (main's #1324 UNSUPPORTED_FEATURE regression test now passes against the conditional-spread + always-register hybrid) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Summary
Three coordinated fixes that surfaced together while building the worked-reference creative-template adapter (#1274 lineage). Each closes a distinct DX gap; they share the no-account / typed-handler / typed-Format surface so they ship as one PR.
listCreativeFormats?onCreativeBuilderPlatformandCreativeAdServerPlatformFormat.renders[]codegen tightening (no more{ [k: string]: unknown })NoAccountCtx<TCtxMeta>narrowsctx.accountfor no-account tools at compile timeChanges
#1324 —
listCreativeFormats?on creative platformslistCreativeFormats?(req, ctx)is now modeled on bothCreativeBuilderPlatformandCreativeAdServerPlatform, dispatched throughbuildCreativeHandlers(from-platform.ts). Pre-fix, every creative-agent adopter that owned a format catalog had to drop down to the v5 escape hatch (opts.creative.listCreativeFormats) — the typed-platform path didn't carry the surface. Adopters who delegate viacapabilities.creative_agentscontinue to omit; framework returnsUNSUPPORTED_FEATURE.#1325 — codegen tightening for
Format.renders[]New
flattenMutualExclusiveOneOfpreprocess inscripts/generate-types.tsdetects the JSON Schema "X xor Y" idiom (oneOfbranches with{ required: [X], not: { required: [Y] } }and no other keys) and inlines parent properties per branch with the excluded fields removed. The mutual-exclusivity constraint stays enforced at runtime by Ajv against the unstripped schema; the codegen pass only widens what TypeScript can express.Format.renders[]is now:Both branches are closed shapes —
displayRender({...})andparameterizedRender({...})compose cleanly under strict tsc. Same fix benefitssync_plansplan budget (reallocation_thresholdxorreallocation_unlimited), which had the identical loose-arm shape.RenderDimensions.unittightened fromstringto the schema'sDimensionUnitenum ('px' | 'dp' | 'inches' | 'cm' | 'mm' | 'pt') — adopters who passedunit: 'feet'or other off-spec strings will now see a TS error.#1327 —
NoAccountCtx<TCtxMeta>for no-account toolsNew
NoAccountCtx<TCtxMeta>type inaccount.tswhoseaccount: Account<TCtxMeta> | undefined. Applied to:CreativeBuilderPlatform.previewCreative?CreativeBuilderPlatform.listCreativeFormats?(new)CreativeAdServerPlatform.previewCreativeCreativeAdServerPlatform.listCreativeFormats?(new)SalesPlatform.providePerformanceFeedback?SalesPlatform.listCreativeFormats?Same shape as the
definePlatformWithCompliancefix in #1262 — converts a runtime gate (Cannot read properties of undefined (reading 'ctx_metadata')deep in upstream calls) into a compile-time invariant. The runtime dispatch was already passingctx.account === undefinedfor these tools wheneveraccounts.resolve(undefined)returned null; this PR makes the compiler force the narrow at authorship.Test plan
npm test— 7,485 pass, 7 skipped, 0 failnpx tsc --noEmitcleannpm run format:checkcleantest/server-decisioning-from-platform.test.jscoverlistCreativeFormatsdispatch + UNSUPPORTED_FEATUREdecisioning.type-checks.tscover (a)displayRenderassignability toFormat['renders'], (b) positivepreviewCreativenarrow, (c) negative@ts-expect-errorregression alarm on unnarrowedctx.account.ctx_metadataaccessMigration notes
Three changesets included:
creative-list-creative-formats.md(minor) — new platform methodformat-renders-codegen-tighten.md(patch) — codegen + RenderDimensions.unit narrowno-account-ctx-narrow.md(minor) —NoAccountCtxtyping changeAdopters of
'derived'resolution stores that always return a singleton are unaffected at runtime, but the compiler will now requireif (!ctx.account) ...narrows inpreviewCreative/listCreativeFormats/providePerformanceFeedbackhandlers. Migration guidance is in theno-account-ctx-narrowchangeset and theNoAccountCtxJSDoc.Follow-ups (not in this PR)
DX expert flagged skill / migration-doc updates. Out of scope for this PR; will follow:
skills/build-creative-agent/SKILL.md— showif (!ctx.account)narrow in cookbook examplesskills/build-decisioning-creative-template/SKILL.md— updatepreviewCreativeexample signaturedocs/migration-4.x-to-5.x.md— add 5.x → next-minor stanza for the codegen tightening +NoAccountCtx🤖 Generated with Claude Code