Repository navigation
feat(server): Account.mode + sandbox-authority helpers (#1435 phase 1) - #1436
Merged
Merged
Conversation
Two design artifacts that anchor the next chapter of the v6.x state- management arc: - `docs/proposals/lifecycle-state-and-sandbox-authority.md` — three account modes (live/sandbox/mock), SDK-as-router for compliance, authority-gated comply controller. The SDK-side design. - `docs/architecture/adcp-stack.md` — layered AdCP stack (L0 wire → L4 business logic), what each layer contains, what an SDK at each layer should provide, two kinds of compliance (spec vs live). Written for cross-SDK / cross-language audience; planned to upstream to `adcontextprotocol/adcp`. These land first so #1435 (Phase 1 — Account.mode + dispatch gate) and the eventual Phase 2/3 PRs can reference them. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Phase 1 of the three-account-mode rollout (see docs/proposals/lifecycle-state-and-sandbox-authority.md). Establishes the type and the gate primitive; auto-wiring into the comply controller dispatch lands alongside mock-mode routing in phase 2. New surface from @adcp/sdk/server: - AccountMode: 'live' | 'sandbox' | 'mock' — resolved-account convention - getAccountMode(account) — reads mode with back-compat for sandbox: true - isSandboxOrMockAccount(account) — predicate for non-production accounts - assertSandboxAccount(account, opts?) — throws PERMISSION_DENIED for live-mode or missing accounts, with details.scope: 'sandbox-gate' Pure additive. Legacy sandbox: true adopters keep working — inferred as sandbox mode by getAccountMode. No shipped behavior changes. Closes #1435 (phase 1 only) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closed
8 tasks
Read `mode` and `sandbox` via Object.hasOwn rather than bare property
access. Bare access traverses the prototype chain, so an attacker who
reaches a __proto__-via-merge sink upstream (reachable in MCP envelope
handling) could stamp Object.prototype.mode = 'sandbox' and silently
downgrade every account's gate to a no-op. Own-property check makes the
gate immune regardless of upstream hardening.
Add resolver-discipline guidance to assertSandboxAccount JSDoc:
adopters' AccountStore.resolve must not spread untrusted input into the
resolved account, and opts.message must be a static string literal
(echoed on the wire — interpolating user data creates a reflection sink).
Regression test pollutes Object.prototype.{mode,sandbox} and asserts
getAccountMode({}) and getAccountMode({ id: 'acc' }) both return 'live'.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced May 3, 2026
Merged
bokelley
added a commit
that referenced
this pull request
May 3, 2026
* Revert "docs: layered architecture, decision page, version-adaptation guide (#1437)" This reverts commit aa85657. * docs: remove now-redundant adcp-stack.md, point readers at protocol docs Beyond the strict revert in the previous commit: - Removes docs/architecture/adcp-stack.md (introduced in #1436). The same layered-architecture content now lives canonically at /docs/building/sdk-stack on the protocol docs site, language-agnostic. - Adds a top-of-page pointer in docs/index.md so SDK readers find /docs/building/sdk-stack, /where-to-start, /migrate-from-hand-rolled, and /version-adaptation on the protocol docs site for protocol-level orientation. The remaining pages here stay @adcp/sdk-specific (TypeScript/JavaScript). - Empty changeset (docs-only). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Brian O'Kelley <[email protected]> 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.
Phase 1 of #1435 — the three-account-mode rollout designed in
docs/proposals/lifecycle-state-and-sandbox-authority.md. This PR ships the type + gate primitives so adopters can opt in to authority-based sandbox enforcement today; auto-wiring into the comply controller dispatch lands in phase 2 alongside mock-mode routing.Also commits the design docs (
docs/proposals/lifecycle-state-and-sandbox-authority.mdanddocs/architecture/adcp-stack.md) so phase 2/3 PRs can reference them as tracked artifacts.Summary
New surface from
@adcp/sdk/server(also re-exported from top-level@adcp/sdk):AccountModetype —'live' | 'sandbox' | 'mock'. Resolved-account convention; default'live'when unspecified (fail-closed).getAccountMode(account)— readsmodeoff any account-shaped value, with back-compat for legacysandbox: boolean.isSandboxOrMockAccount(account)— predicate: is the account non-production?assertSandboxAccount(account, opts?)— throwsAdcpError('PERMISSION_DENIED')(withdetails: { scope: 'sandbox-gate', tool? }) for live-mode or missing accounts. Use to gate test-only surfaces.Why phase 1 is helper-only
The proper enforcement point for the comply controller is after account resolution — trust the SDK's resolved account, not the caller-supplied envelope. But the controller registers separately from
createAdcpServer's dispatcher (viaregisterTestController/createComplyController(...).register(server)), so the framework's account-resolution flow doesn't currently see controller calls.Auto-wiring requires plumbing account resolution into the controller registration, which is a meaningful surgery best paired with phase 2 (mock-mode routing) where we're already touching the dispatch layer. Phase 1 ships the helpers as a public API so adopters can wire
assertSandboxAccount(ctx.account, { tool: 'comply_test_controller' })inside their existingsandboxGate(input)callback if they have account resolution available.Pure additive
account.sandbox === trueadopters keep working unchanged —getAccountModeinfers'sandbox'from the legacy flag.Test plan
npx tsc --noEmitcleannpm run format:checkcleannpm run test:lib— 6,025 pass, 0 failtest/lib/server-account-mode.test.js— 14 cases covering: explicit mode wins, legacysandbox: trueback-compat, fail-closed defaults,assertSandboxAccountfor all combinations + custom message + tool-name in details🤖 Generated with Claude Code