Repository navigation
docs(recipes): add composeMethod testing recipe and matching tests (#1345) - #1371
Merged
Merged
Conversation
1 of 4 tasks
…1345) Closes #1345. Adopters writing composeMethod-wrapped handlers had no canonical test scaffolding — every team reinvented their own. This PR adds a recipe doc with six test patterns and matching running tests so the patterns can't rot independently of the implementation. What changed: - docs/recipes/composeMethod-testing.md — new recipe doc (six patterns) - test/server-decisioning-compose-recipes.test.js — matching running tests (node:test, same import style as existing compose tests) - docs/llms.txt — cookbook entry in server section + table row - scripts/generate-agent-docs.ts — same two additions, so the changes survive `npm run generate-agent-docs` regeneration - .changeset/compose-method-testing-recipes.md — patch changeset (docs/llms.txt is in the published `files`) Six patterns: 1. Mock the base, assert pass-through (counter, no mocking library) 2. Short-circuit from a `before` hook 3. Stacked `before` hooks (ordering, early-exit semantics) 4. `after` hook enrichment 5. composeMethod + typed errors (AdcpError throw) 6. composeMethod over `accounts.resolve` with security presets Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
force-pushed
the
claude/issue-1345-composemethid-testing-recipes
branch
from
May 3, 2026 01:59
78391cf to
342891e
Compare
bokelley
added a commit
that referenced
this pull request
May 3, 2026
Came in via the main merge (#1342 → #1395). Buyers calling get_media_buy_delivery / get_creative_delivery with multiple media_buy_ids hand the array to the platform as-is — framework doesn't synthesize per-buy fan-out because cross-buy aggregates (reach, new_to_brand_rate, frequency) depend on dedup capability that's platform-domain knowledge. Closes one of the gaps the upstream-feedback screenshot flagged as "Not yet — adapters can still silently truncate." composeMethod test recipes (the other gap) are tracked separately in #1371. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
marked this pull request as ready for review
May 3, 2026 02:06
bokelley
added a commit
that referenced
this pull request
May 3, 2026
Final review of what's queued for 6.7 ship surfaced four adopter-relevant changes that weren't in the migration recipe yet: New recipes (12 → 15): - #13 createTenantStore — opinionated multi-tenant AccountStore builder with built-in fail-closed tenant-isolation gate. Resolves the screenshot's "RosterAccountStore (Postgres)" item — Postgres was always blocked on adopter persistence layer; the helper is the SDK side of that contract. - #14 state-machine helpers (MEDIA_BUY_TRANSITIONS, assertMediaBuyTransition, CREATIVE_ASSET_TRANSITIONS, assertCreativeTransition). Drop-in replacements for the local status-graph copy three example files were carrying. - #15 createMediaBuyStore — opt-in targeting_overlay echo on get_media_buys for sellers claiming property-lists / collection-lists. Recipe updates: - #5 — note AccountStore.syncGovernance is now typed (drops the v5 escape-hatch + `as any` pattern); credentials stripped on emit. - #10 — add Shape C (createRosterAccountStore) for publisher-curated rosters alongside Shape A (InMemoryImplicitAccountStore) and Shape B (createOAuthPassthroughResolver). Three-shape table. - #12 — `createOAuthPassthroughResolver` now also re-exported from `@adcp/sdk/server` (the patch landed on main); all three import paths work. What-else-changed additions: - Account<TCtxMeta> v3 wire alignment — billing_entity (with bank stripped on emit), rate_card, payment_terms, credit_limit, setup (drives pending_approval → active lifecycle), account_scope, governance_agents, reporting_bucket. Promoted from a footnote per adtech-product-expert's earlier review. - multi_id truncation dev warn paired with the existing media_buy_ids[] fan-out item. - Cross-specialism dispatch docs — no ctx.platform.<X> accessor; class instance + this OR closure capture. - composeMethod testing recipes link (docs/recipes/composeMethod-testing.md is now merged on main from #1371). - Sales-social + sales-guaranteed planning surface mocks (delivery_estimate / forecast / availability) — adopters can now wire Product.forecast against the mocks. - narrowAccountRef export. - Storyboard-runner task_completion.<key> capture + webhook fallback. CLAUDE.md and AGENTS.md blurbs updated from "twelve" to "fifteen" with the three new helper names called out. Picked up via merge from main (20 commits since the last sync): createTenantStore (#1420), createMediaBuyStore (#1424), state-machine helpers (#1427), createRosterAccountStore + Shape C docs, syncGovernance typed, Account v3 wire alignment, Account.bank strip, sales-* planning surface (#1414), task_completion capture (#1426), runner webhook fallback (#1434), narrowAccountRef (#1428), composeMethod testing recipes (#1371 merged), oauth-passthrough re-export, multi-id truncation warn. 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.
Closes #1345
Adopters writing
composeMethod-wrapped handlers had no canonical test scaffolding — every team reinvented their own. This PR adds a recipe doc with six test patterns and matching running tests so the patterns can't rot independently of the implementation.What changed
docs/recipes/composeMethod-testing.mdtest/server-decisioning-compose-recipes.test.jsdocs/llms.txtscripts/generate-agent-docs.tsnpm run generate-agent-docsregeneration.changeset/compose-method-testing-recipes.mdfiles)Six patterns
beforehook — including the{ shortCircuit: undefined }vs bareundefinedgotchacomposeMethodcalls —beforetakes a single function (not an array); stacking means nesting calls; outer fires firstafterhook enrichment —afterreceives(result, params, ctx); also runs on short-circuit valuescomposeMethod+ typed errors —PermissionDeniedErrorthrown frominnerorbeforepropagates naturallyrequireAdvertiserMatchwithcomposeMethod— demonstrates resolve-preset shape;requireAccountMatchandrequireOrgScopefollow the same patternNotes
docs/llms.txtis auto-generated — both the file and its generator (scripts/generate-agent-docs.ts) were updated identically so the content survivesnpm run generate-agent-docs.require('@adcp/sdk/server')(public import); test file usesrequire('../dist/lib/server')(repo-internal, consistent with all other test files).What tested
npm run build:libunavailable in this environment (missingtsc/tsxfrom node_modules). Test file follows identical import and assertion style astest/server-decisioning-compose.test.js. CI will validate.src/lib/types/*.generated.ts,src/lib/agents/index.generated.ts).Pre-PR review:
requireAccountMatchmissing from llms.txt preset list; Pattern 6 header scope mismatch with snippet. 1 nit fixed (add run command to authoritative note).composemethid→compose-method); doc snippets used internal dist path instead of@adcp/sdk/server. 2 issues fixed (missinginnerCalledreset; undeclaredinnerin Pattern 4 second snippet). 1 nit fixed (JSDoc cross-reference clarification).Session: https://claude.ai/code/session_01NnVDYEAhWe6VoWKzHttBn7