Repository navigation
fix: later CLI bridge calls fail after listener creator completes - #164944
nano-richtera wants to merge 2 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 1:33 PM ET / 17:33 UTC (Revision 2). ClawSweeper reviewWhat this changesThe CLI tool bridge starts its shared HTTP listener outside its creator’s temporary tool authority and adds regressions showing later callers retain their own permissions. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix absent from current main and the latest release. The new production-boundary evidence resolves the previous authority-proof gap; no blocking patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherThe CLI tool bridge accepts authenticated local HTTP tool requests from CLI-backed agent runs and dispatches them through Gateway tools. Its listener lasts for the process, while each request’s permissions and lifetime belong to its admitted run. flowchart TD
A[CLI agent run] --> B[Per-run grant]
B --> C[Shared HTTP listener]
D[Creator finishes] --> C
C --> E[Check caller permissions and liveness]
E --> F[Gateway tool dispatch]
F --> G[Guarded storage commit]
E --> H[Reject unauthorized request]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +6, Tests +205. Total +211 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the listener process-owned while each tool call uses its own live admitted-run authority through dispatch and final storage. Do we have a high-confidence way to reproduce the issue? Yes: current main retains invocation authority during listener creation, and dispatch checks its expired signal on later requests. The contributor records a failing production-boundary regression; this review did not execute it. Is this the best way to solve the issue? Yes: exiting the existing authority carrier at process-owned listener creation repairs the lifetime mismatch without replacing per-request authorization or adding configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 15f60faa8e09. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Thank you @nano-richtera, your fix landed. GitHub does not let maintainers push to organization-owned forks, so we carried your two commits (authorship preserved) plus a small cleanup in #165428, merged as 488c0f0. That PR keeps your listener-authority fix and focused regression, and credits you as co-author. Closing this one as superseded by #165428. |
Related: #157144
What Problem This Solves
Fixes: later CLI bridge tool calls can fail with “operator tool invocation authority expired” when the process-wide MCP listener was started inside an earlier operator-tool invocation.
User Impact
User impact: a completed listener-creating invocation no longer invalidates unrelated later MCP requests. No configuration changes or migrations are required. This is a narrowly scoped CLI bridge lifecycle fix, not a general native-agent continuation repair.
Why This Change Was Made
The listener outlives the invocation that happens to start it. Detach that invocation’s temporary operator-tool authority when starting the shared listener, using the existing authority owner’s exit helper. Keep per-request grant, caller, cancellation, and dispatch authorization checks unchanged.
This additional context leak was found while validating Amrit Chana’s related request-scope work in #157144. This PR contains only the operator-tool-authority detachment and its regressions; it does not duplicate that PR’s caller/request-scope implementation.
Evidence
Production-effect proof added for review feedback
pnpm test src/gateway/mcp-http.dispatch-effect.test.ts --maxWorkers=1now exercises real HTTP with an activated per-run MCP grant through production tool resolution, thethemetool, thethemes.sethandler, and a real SQLite preference commit. No resolver, tool execution, handler, or storage implementation is mocked.ui.themeMode=dark.lightupdate fails and persisteddarkis unchanged. A narrow checkpoint spy injects revocation, then delegates to the real admission check; it does not replace the effect.The identical test fails with the original
mcp-http.tsfrom the pinned base (allowed request returns HTTP 500): 1 failed, 46.29s command wall. With this PR's production fix: 1 passed, 47.08s command wall, 14.053s test-body time. The test runs in the existing forked database-worker project because SQLite host admission cannot run in a Vitest worker thread; no authorization guard was bypassed.Final combined run of the effect and async-scope files: 4 passed, 94.11s command wall (89.86s Vitest duration). This composition is needed to prove that authorization survives through actual final storage; helper-only or mocked-handler tests cannot establish that. Compilation/import and real storage-worker startup dominate wall time. No per-case sleeps or polling were added.
This is an isolated integration proof with an admitted test caller and a test Gateway context registering the production method, not a full Gateway or model-backed CLI acceptance test. It does not establish that native-worker continuation works.
Follow-up independent autoreview: scoped-clean at P0/P1. Codex exited without a report (
reviewer_unavailable, exit 1); the permitted Claude fallback completed. Focused type-aware lint: 0 warnings, 0 errors. Formatting andgit diff --checkpassed. The only post-review edit was the lint-required equivalent cleanup spelling,toReversed()instead ofreverse()on the newly spliced array.Original fix evidence (production source unchanged in the follow-up)
b2b434acbc624ed0c212fa2941dc9ac1fa5f1731.6a2a448ebcb7d55f6a5653566c84c395028b922d; follow-up proof head:b16dbcb7437b7932cffcb09f2b059b662aae3228.tools/callover HTTP. Tool resolution/execution is mocked; the HTTP listener and authority storage are real.pnpm test src/gateway/mcp-http.async-scope.test.ts --maxWorkers=1: before 1 failed / 2 passed, after 3 passed. Command wall: 68.94s before / 56.62s after; after test-body time 2.67s. Most command time is worker compilation/import. The test needs the actual listener boundary because asynchronous listener creation is where authority is retained; a helper-only test would miss it.pnpm test src/gateway/mcp-grant-store.test.ts --maxWorkers=1: 28 passed, 19.88s command wall.pnpm test src/gateway/server-plugin-in-process-dispatch.authorization.test.ts --maxWorkers=1: 47 passed, 152.61s command wall; includes operator restrictions, expired authority, and request cancellation controls.git diff --check: passed.action_required(maintainer approval pending), not an observed test failure; CI duration is unavailable. Full build/typecheck and an actual model-backed CLI session were not run for this standalone upstream patch.