Skip to content

feat(decisioning): ProposalManager v1.5 follow-ups (wire-leak strip, recipe rename, extensibility) - #1562

Merged
bokelley merged 2 commits into
mainfrom
bokelley/proposal-followups
May 5, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/proposal-followups

Conversation

@bokelley

@bokelley bokelley commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-ups to PR #1557, addressing every actionable concern from the parallel expert review (code-reviewer / ad-tech-protocol-expert / security-reviewer / adtech-product-expert).

What lands

1. Wire-leak prevention: strip Product.implementation_config (security + protocol)

Recipe data (network_code, ad_unit_ids, line_item_template_id, GAM line-item priority, etc.) rides on Product.implementation_config server-side as the typed contract between ProposalManager and DecisioningPlatform. The wire schema is additionalProperties: true so the field is technically legal — but emitting it leaks publisher topology to buyers. Framework now runs stripImplementationConfig at the dispatcher response-boundary chokepoint right after stripCtxMetadata, parallel pattern. New helpers stripImplementationConfig + hasImplementationConfig re-exported from @adcp/sdk/server. Test coverage in test/lib/proposal-implementation-config-strip.test.js.

2. Recipe rename: KevelLikeRecipe → AuctionLikeRecipe (product / naming honesty)

Conflating a decision-engine (Kevel) with a wire protocol (OpenRTB) under one recipe_kind: 'kevel' was a category error. Renamed to AuctionLikeRecipe (generic across auction-cleared remnant backends) with recipe_kind: 'auction'. Adopters wanting sharper-typed shapes declare their own recipe_kind: 'kevel' | 'openrtb' | 'beeswax' | ... subtype on top.

3. Recipe extensibility: extensions slot (product / forward-compat)

Both GAMLikeRecipe and AuctionLikeRecipe gain an optional extensions?: Record<string, unknown> field. Adopters carrying richer upstream payloads (GAM creative_placeholders, Kevel frequency_caps, OpenRTB private_auction, FreeWheel placement_types, Operative revenue_type) use this slot rather than forking recipe_kind into N variants.

4. HITL finalize cancel-race documentation (security M2)

Inline comment in runtime/from-platform.ts at the finalize-intercept site documents the known gap: if the buyer calls tasks/cancel while the adopter's HITL handoff is still mid-run, the framework marks the task cancelled but intercept.project (which fires when the handoff resolves) still runs store.commit. Same gap exists for createMediaBuy HITL today. Mitigations: 7-day eviction window in InMemoryProposalStore, optional task-registry sweep by production durable stores. End-to-end fix requires AbortSignal propagation into projection callbacks — framework-level work, not finalize-specific.

5. projectFinalizeResponse products: [] echo: explicit decision (code-review nit)

Inline comment documents the design choice. Echoing on finalize would either re-emit from the persisted draft (extra wire bytes the buyer already has from brief_with_proposals) or call back into the adopter (extra round-trip). Buyers fetching products on the finalize response use get_products({ product_ids: [...] }) keyed off proposals[0].allocations[].product_id.

6. Spec issue filed: adcp#4107 — clarifies refine[] mixed-action semantics when finalize is one of multiple entries. Spec is silent today; both SDKs implement first-finalize-only by convention. Companion to adcp#4086.

Verification

  • npx tsc --noEmit clean
  • npm run check:adopter-types PASS
  • prettier --check clean
  • 146/146 targeted tests pass (proposal primitives + lifecycle + e2e + new wire-strip + mock-server lifecycle + recipes)
  • E2E adapter gate 3/3 (strict tsc, storyboard, façade) on hello_seller_adapter_proposal_mode

Test plan

  • Wire-strip: new test suite asserts stripImplementationConfig deletes the field on Product carriers (top-level products[], nested proposals[].products[]), preserves non-Product objects, handles null/non-object inputs, hasImplementationConfig detects across carriers.
  • Recipe rename: existing recipes.test.js updated for AuctionLikeRecipe / buildAuctionLikeRecipe / AUCTION_LIKE_OVERLAP / recipe_kind: 'auction'.
  • Extensibility: builders thread options.extensions onto the recipe when supplied.
  • No regressions on the v1.5 base — all proposal-mode lifecycle tests still pass.

🤖 Generated with Claude Code

bokelley and others added 2 commits May 4, 2026 17:58
… recipe rename, extensibility

Addresses every actionable concern from the parallel expert review on
PR #1557 (code-reviewer / ad-tech-protocol-expert / security-reviewer /
adtech-product-expert). Stacks on the v1.5 base; will be opened as a
follow-up PR once #1557 lands.

1. Wire-leak prevention: strip Product.implementation_config

   Recipe data (network_code, ad_unit_ids, line_item_template_id, GAM
   line-item priority) rides on Product.implementation_config server-
   side as the typed contract between ProposalManager and
   DecisioningPlatform. The wire schema is additionalProperties: true
   so the field is technically legal — but emitting it leaks publisher
   topology to buyers. Framework now runs stripImplementationConfig at
   the dispatcher response-boundary chokepoint right after
   stripCtxMetadata, parallel pattern. New helpers re-exported from
   @adcp/sdk/server. Test coverage in
   test/lib/proposal-implementation-config-strip.test.js.

2. Recipe rename: KevelLikeRecipe → AuctionLikeRecipe

   Conflating a decision-engine (Kevel) with a wire protocol (OpenRTB)
   under one recipe_kind: 'kevel' was a category error per product-
   expert review. Renamed to AuctionLikeRecipe with recipe_kind:
   'auction'. Adopters who want sharper-typed shapes declare their own
   recipe_kind subtype on top. Breaking but pre-release.

3. Recipe extensibility: extensions slot

   Both GAMLikeRecipe and AuctionLikeRecipe gain an optional
   extensions?: Record<string, unknown> field. Adopters carrying
   richer upstream payloads (GAM creative_placeholders, Kevel
   frequency_caps, OpenRTB private_auction, FreeWheel placement_types)
   use this slot rather than forking recipe_kind. Adopters with
   stricter shape requirements declare a typed subtype literal on top.

4. HITL finalize cancel-race documentation

   Inline comment in runtime/from-platform.ts at the finalize-intercept
   site documents the known gap: if the buyer cancels mid-handoff, the
   framework marks the task cancelled but intercept.project still runs
   store.commit. Same gap exists for createMediaBuy HITL today.
   Mitigations: 7-day eviction window in InMemoryProposalStore +
   optional task-registry sweep by production stores. End-to-end fix
   requires AbortSignal propagation into projection callbacks — a
   framework-level concern, not finalize-specific.

5. projectFinalizeResponse products echo: explicit decision

   Inline comment documents the products: [] choice. Echoing would
   either re-emit from the persisted draft (extra wire bytes) or call
   back into the adopter (extra round-trip). Buyers fetching products
   on the finalize response use a follow-up get_products call keyed
   off proposals[0].allocations[].product_id.

6. Spec issue filed: adcp#4107

   Clarifies refine[] mixed-action semantics when finalize is one of
   multiple entries. Spec is silent today; both SDKs implement
   first-finalize-only by convention. Companion to adcp#4086.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… leak surfaced by security review

PR #1562 security review caught a ship-blocker the parent PR (#1557)
also inherited: the wire-strip chokepoint in projectSync only covers
the sync arm. The HITL handoff path runs the projection callback
inside dispatchHitl, then writes the projected result directly to
taskRegistry.complete + emitTaskWebhook without re-stripping. Buyers
polling tasks_get see ctx_metadata + implementation_config verbatim;
webhook receivers see them too.

Three fixes:

1. stripCtxMetadata + stripImplementationConfig now run inside
   dispatchHitl before taskRegistry.complete. Mirrors projectSync's
   chokepoint pattern. Every downstream consumer (tasks/get polling
   at line 1826, emitTaskWebhook at line 2493, idempotency replays of
   the Submitted envelope) inherits a clean payload.

2. CARRIER_KEYS extended with 'proposal' / 'proposals'. Without it,
   server-only fields on proposals[].products[] survived the strip —
   a proposal-mode-specific nesting the pre-existing carrier list
   didn't anticipate. Pre-existing latent ctx_metadata leak too.

3. stripImplementationConfig now reuses CARRIER_KEYS rather than
   maintaining its own narrower list. The two strips share a
   carrier set so future spec additions can't silently extend one
   and not the other.

Also adds credential-leak warning to the recipe `extensions` slot
JSDoc on both GAMLikeRecipe and AuctionLikeRecipe (security M3 from
the review): adopters putting credentials there are protected only
by coincidence of the implementation_config strip, not by a
credential scanner.

Test coverage:
- New e2e regression in test/lib/proposal-manager-e2e.test.js drives
  a finalize HITL → tasks/get round-trip with both server-only
  fields embedded; asserts no leak via either path.
- New shared-carrier test asserts implementation_config strip walks
  media_buys[].products[] and creatives[].product (carriers the
  narrower original list missed).

148/148 targeted tests pass (proposal primitives + lifecycle + e2e +
strip + recipes + mock-server). 46/46 existing ctx_metadata tests
still pass. check:adopter-types passes. prettier + tsc clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley

bokelley commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 8205d9bb addressing the security review's ship-blocker plus two medium items.

HIGH (ship-blocker, fixed): HITL handoff result bypassed the strip. projectSync ran stripCtxMetadata + stripImplementationConfig for sync arms, but dispatchHitl wrote the projected result directly to taskRegistry.complete + emitTaskWebhook without re-stripping. tasks/get polling (line 1826) and webhook receivers saw server-only fields verbatim. Pre-existing latent ctx_metadata leak too — the new field inherited it; both are now stripped at the same chokepoint inside dispatchHitl before the registry write.

MEDIUM (carrier-list divergence, fixed): IMPL_CONFIG_CARRIER_KEYS was ['product', 'products'] while stripCtxMetadata's CARRIER_KEYS was much broader. Future spec additions extending one strip and not the other would silently leak. stripImplementationConfig now reuses CARRIER_KEYS directly. Also extended CARRIER_KEYS to include proposal / proposals (the proposal-mode-specific nesting the original list didn't anticipate — same ctx_metadata leak the original had on proposals[].products[]).

MEDIUM (extensions credential-leak class, documented): JSDoc on both GAMLikeRecipe.extensions and AuctionLikeRecipe.extensions now warns explicitly that the slot MUST NOT carry credentials. Protection is strip-by-coincidence (the entire implementation_config envelope gets stripped), not a credential scan. Same hazard class as ctx_metadata and ext. Docs link to CTX-METADATA-SAFETY.md.

Idempotency-cache write (verified, no fix needed): traced the cache write at create-adcp-server.ts:3813. It stores formatted which is the post-strip wire from the dispatch handler. HITL Submitted envelopes cache cleanly; the resolved task result lives in the task registry (now also clean after this fix).

Code-reviewer nits (fixed): dropped the misleading @public JSDoc on the non-exported IMPL_CONFIG_CARRIER_KEYS const; corrected the comment that claimed parity with the ctx_metadata carrier set (it now is — the two strips share the constant).

Test coverage: new e2e regression in proposal-manager-e2e.test.js drives the full finalize HITL → tasks/get round-trip with both server-only fields embedded; asserts no leak via either path. New shared-carrier test asserts the strip walks media_buys[].products[] and creatives[].product (carriers the narrower original list missed).

148/148 targeted tests pass; 46/46 existing ctx_metadata tests still pass; check:adopter-types green; prettier + tsc clean.

@bokelley

bokelley commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged — 8205d9bb looks comprehensive. The chokepoint fix in dispatchHitl, the shared CARRIER_KEYS constant, and the JSDoc warnings on extensions all address the security review's findings cleanly. Green tests and the idempotency-cache trace noted.


Generated by Claude Code

@bokelley

bokelley commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the confirmation, @bokelley. No further action needed on my end — standing by on the source issue if anything resurfaces.


Generated by Claude Code

@bokelley
bokelley merged commit 4642329 into main May 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant