Repository navigation
feat(server): compile-time invariant for complyTest / compliance_testing pairing - #1262
Merged
Merged
Conversation
…g pairing Add RequiredOptsFor<P> conditional type and definePlatformWithCompliance helper so the cap/adapter consistency that was previously runtime-only (PlatformConfigError) is now also enforced at the TypeScript type level when the platform is typed with compliance_testing non-optional. Closes #1261 https://claude.ai/code/session_01Eec8o47CTq6jpoDoLGqNoT
…riant
- Use ComplianceTestingCapabilities directly in _PlatformWithCT (was fragile
structural match with { scenarios?: [] })
- Use ComplyControllerConfig (not object) in _check_opts_with_ct
- Add call-site regression alarm: assert CreateAdcpServerFromPlatformOptions is
NOT assignable to RequiredOptsFor<_PlatformWithCT> (catches if RequiredOptsFor
stops requiring complyTest for compliance_testing platforms)
- Export ComplianceTestingCapabilities from decisioning/index.ts
https://claude.ai/code/session_01Eec8o47CTq6jpoDoLGqNoT
bokelley
marked this pull request as ready for review
May 2, 2026 16:13
This was referenced May 2, 2026
bokelley
added a commit
that referenced
this pull request
May 2, 2026
…ers (#1324, #1325, #1327) (#1348) * feat(decisioning): close v6 platform gaps for creative-template adopters 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]> * chore: address reviewer feedback for #1324/#1325/#1327 - 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]> * chore(types): regenerate v2-5 tools.generated for flattened oneOf 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]> * chore: refresh skill-examples baseline for NoAccountCtx ctx-string 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]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
8 of 9 tasks
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 #1261
Summary
createAdcpServerFromPlatformhad a runtime-only guard for thecomplyTest/capabilities.compliance_testingpairing. In CI harnesses that can't see the agent's stderr, a missingcompliance_testingcapability silently made all requests return 500 — thePlatformConfigErrorwas invisible.This PR adds two compile-time mechanisms (both additive/non-breaking):
RequiredOptsFor<P>— conditional type on theoptsparameter. WhenPextends{ capabilities: { compliance_testing: ComplianceTestingCapabilities } }, the resolved opts type isCreateAdcpServerFromPlatformOptions & { complyTest: ComplyControllerConfig }, makingcomplyTestrequired. Catches the cap-without-adapter direction at compile time.definePlatformWithCompliance<TConfig, TCtxMeta>()— identity helper (same pattern asdefineSalesPlatformetc.) that enforcescapabilities.compliance_testingnon-optional at the platform definition site. Combined withRequiredOptsFor<P>, provides bidirectional enforcement: use the helper → TypeScript requires bothcompliance_testingin platform ANDcomplyTestin opts.The runtime
PlatformConfigErrorcheck is preserved as defense-in-depth for untyped/JS callers.Coverage: The cap-with-missing-adapter direction is caught at compile time by
RequiredOptsFor<P>. The adapter-with-missing-cap direction remains runtime-only — it cannot be expressed as a cross-parameter TypeScript constraint without breaking callers who pass opts as a typed variable.What was tested
npx tsc --project tsconfig.lib.json --noEmit— no new errors (pre-existing TS2688/TS5107 env errors unchanged, same as feat(server): definePlatform/defineSalesPlatform helpers — fix req: unknown in typed-platform handlers #1240)npm run format:check— passeddecisioning.type-checks.tscover:definePlatformWithComplianceaccepts a CT platform (positive)definePlatformWithCompliancerejects a plainDecisioningPlatformwith optionalcompliance_testing(@ts-expect-error)RequiredOptsFor<_PlatformBase>resolves to base opts (positive)RequiredOptsFor<_PlatformWithCT>resolves to requireComplyControllerConfig(positive, typed to exact type)CreateAdcpServerFromPlatformOptionsis NOT assignable toRequiredOptsFor<_PlatformWithCT>— call-site regression alarm that fires ifRequiredOptsForstops requiringcomplyTestNits (not fixed — surfaced for reviewer)
definePlatformWithCompliancebreaks thedefine<Sub>Platformnaming convention (all other helpers name the sub-interface, not a capability modifier). Reviewer may preferdefineCompliancePlatformfor naming consistency.Pre-PR review
RequiredOptsForinference is safe (anyin base constraint doesn't escape into the conditional check). Import ofComplyControllerConfigis type-only at emit. Pre-blocker issues (fragile{ scenarios?: [] }type andcomplyTest: objectover-broad check) were fixed before this commit._check_ct_opts_requires) assertingCreateAdcpServerFromPlatformOptionsis not assignable toRequiredOptsFor<_PlatformWithCT>. Nit: helper naming inconsistency surfaced above.Session: https://claude.ai/code/session_01Eec8o47CTq6jpoDoLGqNoT
Generated by Claude Code