fix(server): forward authInfo/agent/toolName ctx to AccountStore.upsert and list (#1310)#1318
Closed
bokelley wants to merge 2 commits into
Closed
fix(server): forward authInfo/agent/toolName ctx to AccountStore.upsert and list (#1310)#1318bokelley wants to merge 2 commits into
bokelley wants to merge 2 commits into
Conversation
…rt and list (#1310) - Adds optional `ctx?: ResolveContext` to `AccountStore.upsert` and `AccountStore.list` (non-breaking — existing implementations compile unchanged) - Fixes `buildAccountHandlers` dispatcher to forward `authInfo`, `agent`, and `toolName` to both methods, matching the `accounts.resolve` pattern - Also fixes pre-existing `ctx.agent` omission in `reportUsage` and `getAccountFinancials` dispatchers - Updates JSDoc on `upsert` and `list` to document the billing gate use-case - Adds regression tests asserting `ctx.authInfo` and `ctx.toolName` reach `accounts.upsert` and `accounts.list` Closes #1310 https://claude.ai/code/session_01V19x4iEy2Gt3yqt4d9vpj4
Code-reviewer and protocol-expert noted the JSDoc and changeset referenced #3851 where the rest of the codebase uses adcp#3831 for BILLING_NOT_PERMITTED_FOR_AGENT. Also adds the Phase 2 (#1292) caveat — framework-level enforcement is not yet active; adopters can gate on ctx.agent?.billing_capabilities today. https://claude.ai/code/session_01V19x4iEy2Gt3yqt4d9vpj4
Contributor
Author
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 #1310
AccountStore.upsertandAccountStore.listcaptured_ctxin the framework dispatcher but discarded it, silently blocking any adopter who needs the calling principal (e.g. for the per-agent billing gateBILLING_NOT_PERMITTED_FOR_AGENTfrom adcp#3831). This PR adds optionalctx?: ResolveContextto both interface methods (non-breaking — existing implementations compile unchanged) and updatesbuildAccountHandlersto forwardauthInfo,agent, andtoolNameusing the same pattern already established foraccounts.resolveat lines 1009-1012. Also fixes the identical pre-existingctx.agentomission in thereportUsageandgetAccountFinancialsdispatcher blocks in the same function.What was tested
npm run format:check— passednpx tsc --project tsconfig.lib.json— only pre-existingTS2688/TS5107tsconfig warnings (not code errors); no new errors introducedtest/server-decisioning-from-platform.test.js— 109/109 pass (2 new ctx-forwarding tests added forupsertandlist)test/*.test.js test/lib/*.test.js) — 232 failures before and after; no new failuresPre-PR review
#3851→#3831reference (fixed in follow-up commit) and missingctx.agenttest coverage as issues (no blocker);as constremoval is intentional cleanupResolveContextis correct shape forupsert/list;sync_accounts/list_accountstoolName strings are correct wire names; Phase 2 caveat added to JSDoc per reviewer recommendationNits (not fixed, surfaced for human reviewer)
ctx.agentforwarding is untested — wiring a fullBuyerAgentRegistryin a test is medium complexity; theauthInfo+toolNametests cover the new dispatcher path and thectx.agentbranch follows identical conditional-spread logic. A follow-up can add registry-backed agent forwarding tests once Phase 2 (feat(server): BuyerAgentRegistry Phase 2 — wire billing-capability enforcement (AdCP 3.1) #1292) lands.#3851reference in the original issue (vsadcp#3831used throughout the codebase forBILLING_NOT_PERMITTED_FOR_AGENT) may indicate a distinct follow-up spec PR — if so, the JSDoc reference should be revisited when that PR merges.Session: https://claude.ai/code/session_01V19x4iEy2Gt3yqt4d9vpj4
Generated by Claude Code