Repository navigation
feat(server): definePlatform/defineSalesPlatform helpers — fix req: unknown in typed-platform handlers - #1240
Merged
Conversation
…yped object-literal adoption Closes #1235 Fixes TypeScript's contextual-typing gap when building a DecisioningPlatform as an object literal. `createAdcpServerFromPlatform<P extends DecisioningPlatform<any,any>>` infers P from the argument instead of applying contextual types backward, leaving nested handler parameters as `req: unknown`. This caused 16 manual as-casts in the sales_social matrix validation run. New `definePlatform<TConfig, TCtxMeta>()` and `defineSalesPlatform<TCtxMeta>()` (plus one per remaining specialism) are pure identity functions that force the concrete interface type at the call site, giving TypeScript the annotation it needs to resolve req/ctx parameters throughout the handler body. Also removes the misleading `createAdcpServer` handler-grouping note from skills/build-seller-agent/specialisms/sales-social.md — it described the legacy v5 handler-bag path (where all requests are unknown) and steered LLM adopters away from the typed platform surface. Replaced with the createAdcpServerFromPlatform method-mapping table and a note that declaring TCtxMeta eliminates ctx_metadata casts. https://claude.ai/code/session_01BfQUoDUmf4gh9Ff1ETnW6v
Per pre-PR review: 1. Remove sync_catalogs from the core sales-social method table — it's a retail-media extension (sales-catalog-driven) not a sales-social requirement. LLMs seeing it in the table would generate unnecessary syncCatalogs stubs. 2. Change "or" to "and" (defineSalesPlatform AND defineAudiencePlatform) and add a concrete two-sub-object code snippet so LLMs see both wrappers used together rather than choosing one and dropping the other. https://claude.ai/code/session_01BfQUoDUmf4gh9Ff1ETnW6v
…heck coverage Address pre-PR review on #1240: - Drop sync_catalogs from the sales-social prose list — the method table was already correct, but the prose contradicted it. sync_catalogs is a retail-media extension (sales-catalog-driven), not a sales-social requirement; LLMs reading the prose would generate unnecessary syncCatalogs stubs. - Add type-level coverage in decisioning.type-checks.ts: two positive identity assertions and one negative, covering definePlatform and defineSalesPlatform contextual-typing behavior.
bokelley
force-pushed
the
claude/issue-1235-define-platform-helpers
branch
from
May 1, 2026 21:50
1f80b73 to
b993cfb
Compare
bokelley
marked this pull request as ready for review
May 1, 2026 22:50
This was referenced May 2, 2026
Merged
Closed
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.
Refs #1235
Summary
Fixes the TypeScript contextual-typing gap that caused handler method parameters to resolve as
req: unknownwhen aDecisioningPlatform(or sub-interface) was built as an object literal and passed directly tocreateAdcpServerFromPlatform. Asales_socialmatrix validation run produced 16 manualas { ... }coercions in a 743-lineserver.ts; this PR eliminates the need for all of them.Root cause:
createAdcpServerFromPlatform<P>(platform: P & ...)infersPfrom the argument instead of using the constraint for contextual typing. TypeScript can't backpropagate parameter types into nested method bodies from a generic constraint.Fix (non-breaking): Ten pure identity functions — one per platform sub-interface — that force a concrete parameter type at the call site:
The class pattern with explicit property-type annotations (
sales: SalesPlatform = { ... }) continues to work unchanged. These helpers are the object-literal escape hatch.Also: The
skills/build-seller-agent/specialisms/sales-social.mdhad a note describing handler-bag grouping for the legacycreateAdcpServerpath. This actively steered LLM adopters toward the v5 lower-level path (where allreqparameters areunknown) rather than the typed platform surface. Replaced with thecreateAdcpServerFromPlatformmethod-mapping table, aTCtxMetanote, and a concrete two-sub-object code example.Note on the signature-change suggestion from #1235
The issue suggested changing
AudiencePlatform.syncAudiences(audiences: Audience[], ctx)to(req: SyncAudiencesRequest, ctx). This would be a breaking change (existing implementations and the canonical example atexamples/decisioning-platform-identity-graph.ts:127would need updating). The identity-helper approach in this PR solves the core DX problem without breaking existing adopters. The signature change is flagged in the triage comment on #1235 for @bokelley to decide whether to pursue as a separate major-bump PR.What was tested
npx tsc --project tsconfig.lib.json --noEmit— no new type errors (pre-existing TS2688/TS5107 env errors unrelated to these changes)npx tsc --noEmit— clean (same)npm run format:check— passednode_modulesnot present in this environment;npm testandbuild:libcould not run. TypeScript compilation serves as the primary gate for a type-level-only change.Pre-PR review
sync_catalogsfrom sales-social method table (it's a retail-media extension, not a social requirement), (2) changed "or" to "and" fordefineSalesPlatform+defineAudiencePlatformand added concrete two-sub-object examplesync_catalogsfrom sales-social prose "Additional tools" list (method table was already correct; prose was contradicting it), (2) added type-check coverage indecisioning.type-checks.ts— two positive identity assertions and one negative verifying that a wrong method shape is rejectedSession: https://claude.ai/code/session_01BfQUoDUmf4gh9Ff1ETnW6v
Generated by Claude Code