Repository navigation
fix(server): MCP mutation retries survive credential reissue - #23796
juliusmarminge wants to merge 6 commits into
Conversation
…ential reissue Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reissued Thread-issued MCP credentials namespaced mutation command ids by the per-credential provider session id, so a restart that reissued the credential turned a retried clientRequestId into a new child task. Key the namespace by the owning thread instead; client callers keep their client:<session> namespace. Fixes #16184 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| requestNamespace: providerSessionId, | ||
| // Keyed by thread, not credential: a reissued credential (for example | ||
| // after a server restart) must replay the thread's earlier mutations. | ||
| requestNamespace: `thread:${request.threadId}`, |
There was a problem hiding this comment.
The credential-reissue regression uses a mocked ThreadManagementService to implement receipt lookup and replay in an in-memory map. That mocks core business logic rather than only external services, so it cannot verify that a real persisted command receipt is replayed after reissue. Could you add a focused test with the real thread-management service and test layers only for external dependencies, asserting that the retry creates no second child?
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — MCP mutation identities now remain stable across credential reissue for the same thread. An unresolved review concern asks for real persisted-receipt coverage demonstrating that a retry does not create a second child or launch duplicate work. You can add or adjust custom eligibility rules. Learn more. |
…rvices Replace the mocked ThreadManagementService replay with the real thread management service, command receipt store, and in-memory orchestrator, so the retry after a reissued MCP credential is proven against persisted receipts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the receipt-replay test finding in 6a60cb9. The regression now uses real thread management, orchestration and SQLite command receipts. Reissue returns the original task and leaves exactly one persisted child. Restoring the old namespace fails the identity assertion; the fixed full test file passes 34/34. Red/green proof. Production code is unchanged. |
# Conflicts: # apps/server/src/mcp/OrchestratorMcpService.test.ts
Dismissing prior approval to re-evaluate 9250b25
EvidenceOn both commits: create a fresh synthetic project and active replay parent; call async delegate_task with clientRequestId review-round-1; retry immediately; restart the server; continue the same parent with a newly issued credential; repeat the identical call and inspect its children. Both captures use isolated Linux development servers, Chromium, a 1280×800 CSS viewport, light theme, and fresh synthetic databases. The driver calls the real MCP endpoint using actual provider-issued credentials.
Immediate retries returned the original task on both commits. Credentials changed across both restarts. Fresh-key and other-thread controls created independent work on both commits. Each final still matched a second screenshot taken at least 500 ms later. Stills and sampled recording frames were visually inspected. Runtime transcript and task IDs · Driver and seed script · Launcher · Launcher helper · Redacted setup logs Manual runtime proof followed two scenario setup failures. No unit-test results are used as evidence. AI-assisted; verified with the tests and tools listed above. Not shown:
|


Problem
Retrying a thread-owned MCP mutation with the same
clientRequestIdafter a server restart created new work. In a real Codex/web reproduction, the samedelegate_taskcall replayed before restart but created a second child after restart.Change
Scope thread callers' mutation IDs to the calling thread instead of the random MCP credential ID. Reissued credentials now reach the existing command receipts, so keyed delegation, thread creation, messages, schedules, metadata updates and cancellation retain their identity. Credential IDs, authentication, revocation, liveness and capabilities retain their existing behavior; OAuth client callers retain their session namespace. Correct the existing scope documentation and comment.
Scope and approval
Fixes https://git.cafe/pingdotgg/t3code/issues/16184
Triaged bug via the automated issue flow: #16184. One reproduced idempotency defect; no new settings, storage or tool capabilities.
Verification
vp test run src/mcp/OrchestratorMcpService.test.ts src/mcp/McpSessionRegistry.test.ts src/mcp/McpHttpServer.test.ts src/mcp/McpToolAccess.test.tsfromapps/server: 113 passed. After replacing the mocked regression with real persisted receipts,vp test run src/mcp/OrchestratorMcpService.test.tspasses 34/34 at the current head; targeted lint, formatting and server typecheck pass. Server typecheck passed; targeted lint had only existing unused-variable warnings. Diff whitespace check passed.NEEDS_JULIUSverdicts reflect the checklist's MCP-sensitive classification.Evidence (server-only; visual fixture matrix is empty):
Current real-service red/green proof. This replaces the original Map-backed receipt mock after review.
Evidence index · Empty visual matrix.
Limits: interrupted waiting calls and automatic restart continuation were not runtime-exercised. The guarantee applies to mutations first accepted with the fixed namespace; older per-credential receipt IDs cannot be reconstructed across the upgrade. No client render paths or platform-specific code changed.
Models and harnesses: GPT-6.1-Sol via Codex; Claude Opus 5.5 via Claude Agent SDK, orchestrated through T3 Code. Runtime probe: GPT-6-Astra via Codex.
Fixes #16184