Repository navigation
Conversation
Expose MEDIA_BUY_TRANSITIONS, isLegalMediaBuyTransition, assertMediaBuyTransition, CREATIVE_ASSET_TRANSITIONS, isLegalCreativeTransition, assertCreativeTransition, CREATIVE_APPROVAL_TRANSITIONS, isLegalCreativeApprovalTransition, and assertCreativeApprovalTransition from @adcp/sdk/server and the root barrel. The assertion helpers throw the spec-correct AdcpError codes: NOT_CANCELLABLE for cancel-on-terminal, INVALID_STATE for other illegal transitions. The conformance runner's status.monotonic invariant uses the same maps, so sellers using assertMediaBuyTransition are guaranteed to agree with the storyboard runner. Refactors default-invariants.ts to import the maps from the new module instead of maintaining its own copies. Updates three example files and SKILL.md to eliminate copy-pasted transition tables. Closes #1416 https://claude.ai/code/session_01Dd2cvBgL7mZiLFHqTMb7pj
…guard
assertMediaBuyTransition now only throws NOT_CANCELLABLE for the
canceled → canceled re-cancel case (per storyboard second_cancel assertion).
completed → canceled and rejected → canceled correctly use INVALID_STATE,
matching the manifest example ("updating a completed or canceled media buy").
Rename local assertCreativeTransition in comply-controller-seller.ts to
requireLegalCreativeTransition to avoid shadowing the SDK export of the
same name that throws AdcpError instead of TestControllerError.
https://claude.ai/code/session_01Dd2cvBgL7mZiLFHqTMb7pj
This was referenced May 3, 2026
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 #1416
Summary
Exports the canonical AdCP state-machine transition maps from
@adcp/sdk/serverso sellers don't copy-paste the graph (three examples already had diverged copies). The conformance runner'sstatus.monotonicinvariant uses the same maps, so sellers who guard handlers withassertMediaBuyTransitionare guaranteed to agree with the storyboard runner.New public exports (available from both
@adcp/sdkand@adcp/sdk/server):MEDIA_BUY_TRANSITIONSReadonlyMap<MediaBuyStatus, ReadonlySet<MediaBuyStatus>>isLegalMediaBuyTransition(from, to)assertMediaBuyTransition(from, to)NOT_CANCELLABLE(re-cancel) orINVALID_STATECREATIVE_ASSET_TRANSITIONSReadonlyMap<CreativeStatus, ReadonlySet<CreativeStatus>>isLegalCreativeTransition(from, to)assertCreativeTransition(from, to)INVALID_STATECREATIVE_APPROVAL_TRANSITIONSReadonlyMap<CreativeApprovalStatus, ReadonlySet<CreativeApprovalStatus>>isLegalCreativeApprovalTransition(from, to)assertCreativeApprovalTransition(from, to)INVALID_STATECreativeApprovalStatusis also newly exported from the root barrel.Error code semantics for
assertMediaBuyTransition:NOT_CANCELLABLE(recovery: correctable) — only forcanceled → canceledre-cancel; matches storyboardmedia_buy_seller/invalid_transitions/second_cancelINVALID_STATE— all other illegal transitions includingcompleted → canceledandrejected → canceled(per manifest example: "updating a completed or canceled media buy")Structural change:
src/lib/testing/storyboard/default-invariants.tsnow imports the three exported maps fromserver/state-machine.tsinstead of maintaining its own copies. Import direction istesting → server, which already existed viaserver/envelope-allowlist. No circular dependency.Examples updated:
seller-test-controller.tsandcomply-controller-seller.tsreplace inline copy-pasted tables with SDK imports.skills/build-seller-agent/SKILL.mdupdates the test-controller sketch and adds a production-handler code sample.What was tested
npm run format:check— cleannpm run typecheck— 2 pre-existing tsconfig warnings only, no new errors (verified by stash comparison)npx vitest run— same pass/fail asmain(all failures are pre-existingdist/not-built integration tests)Pre-PR review
assertCreativeTransition→requireLegalCreativeTransitionin comply example) and noted absence of unit tests forstate-machine.ts(pre-existing low test density pattern; tracked separately)NOT_CANCELLABLEscope was too broad (to === 'canceled'); tightened tofrom === 'canceled' && to === 'canceled'only, per spec manifest distinction between "cannot be canceled" and "wrong lifecycle state"Nit noted but not fixed (deferred):
TransitionGraph-wrapped local variable names indefault-invariants.tsshadow the import aliases — cosmetic only, no runtime impact; can be addressed in a follow-up.Out of scope for this PR:
ACCOUNT_TRANSITIONS,SI_SESSION_TRANSITIONS,CATALOG_ITEM_TRANSITIONS,PROPOSAL_TRANSITIONS,AUDIENCE_TRANSITIONS— specialized specialisms, low immediate impact.state-machine.tsunit tests — pre-existing low test density; should be added in a dedicated test PR.Session: https://claude.ai/code/session_01Dd2cvBgL7mZiLFHqTMb7pj
Generated by Claude Code