Skip to content

feat(server): compile-time invariant for complyTest / compliance_testing pairing - #1262

Merged
bokelley merged 2 commits into
mainfrom
claude/issue-1261-comply-test-compile-time
May 2, 2026
Merged

bokelley merged 2 commits into
mainfrom
claude/issue-1261-comply-test-compile-time

Conversation

@bokelley

@bokelley bokelley commented May 2, 2026

Copy link
Copy Markdown
Contributor

Closes #1261

Summary

createAdcpServerFromPlatform had a runtime-only guard for the complyTest/capabilities.compliance_testing pairing. In CI harnesses that can't see the agent's stderr, a missing compliance_testing capability silently made all requests return 500 — the PlatformConfigError was invisible.

This PR adds two compile-time mechanisms (both additive/non-breaking):

  1. RequiredOptsFor<P> — conditional type on the opts parameter. When P extends { capabilities: { compliance_testing: ComplianceTestingCapabilities } }, the resolved opts type is CreateAdcpServerFromPlatformOptions & { complyTest: ComplyControllerConfig }, making complyTest required. Catches the cap-without-adapter direction at compile time.

  2. definePlatformWithCompliance<TConfig, TCtxMeta>() — identity helper (same pattern as defineSalesPlatform etc.) that enforces capabilities.compliance_testing non-optional at the platform definition site. Combined with RequiredOptsFor<P>, provides bidirectional enforcement: use the helper → TypeScript requires both compliance_testing in platform AND complyTest in opts.

The runtime PlatformConfigError check 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 — passed
  • Type-check tests in decisioning.type-checks.ts cover:
    • definePlatformWithCompliance accepts a CT platform (positive)
    • definePlatformWithCompliance rejects a plain DecisioningPlatform with optional compliance_testing (@ts-expect-error)
    • RequiredOptsFor<_PlatformBase> resolves to base opts (positive)
    • RequiredOptsFor<_PlatformWithCT> resolves to require ComplyControllerConfig (positive, typed to exact type)
    • CreateAdcpServerFromPlatformOptions is NOT assignable to RequiredOptsFor<_PlatformWithCT> — call-site regression alarm that fires if RequiredOptsFor stops requiring complyTest

Nits (not fixed — surfaced for reviewer)

  • definePlatformWithCompliance breaks the define<Sub>Platform naming convention (all other helpers name the sub-interface, not a capability modifier). Reviewer may prefer defineCompliancePlatform for naming consistency.

Pre-PR review

  • code-reviewer: approved — no blockers. Noted RequiredOptsFor inference is safe (any in base constraint doesn't escape into the conditional check). Import of ComplyControllerConfig is type-only at emit. Pre-blocker issues (fragile { scenarios?: [] } type and complyTest: object over-broad check) were fixed before this commit.
  • dx-expert: approved after blocker fixed — added call-site regression alarm test (_check_ct_opts_requires) asserting CreateAdcpServerFromPlatformOptions is not assignable to RequiredOptsFor<_PlatformWithCT>. Nit: helper naming inconsistency surfaced above.

Triage-managed PR. This bot does not currently iterate on
review comments or PR conversation threads (only on the source
issue). To unblock:

  • Push fixup commits directly: gh pr checkout <num> →
    fix → push.
  • Or re-trigger: comment /triage execute on the source
    issue.

See adcp#3121
for context.

Session: https://claude.ai/code/session_01Eec8o47CTq6jpoDoLGqNoT


Generated by Claude Code

claude added 2 commits May 2, 2026 12:30
…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
bokelley marked this pull request as ready for review May 2, 2026 16:13
@bokelley
bokelley merged commit f951b0f into main May 2, 2026
10 checks passed
@bokelley
bokelley deleted the claude/issue-1261-comply-test-compile-time branch May 2, 2026 16:13
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DX: opts.complyTest requires capabilities.compliance_testing should be a compile-time invariant, not runtime

2 participants