Repository navigation
fix(mcp): avoid memory spikes from oversized client TLS files - #110016
wahaha1223 wants to merge 16 commits into
Conversation
|
Codex review: blocked before merge. Reviewed September 25, 2026, 12:55 PM ET / 16:55 UTC (Revision 11). ClawSweeper reviewWhat this changesThe branch bounds MCP client certificate and key reads, adds matching Doctor diagnostics and documentation, and repairs Codex app-server client cleanup and related runtime fixtures. Merge readiness⛔ Blocked before merge - 5 items remain Current main still reads MCP client TLS files without a size bound, so this PR remains useful. The earlier Doctor diagnostic finding is resolved. The new 64 KiB ceiling can reject an existing valid mTLS configuration, and the current head is reported as conflicting with main. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s MCP HTTP client reads configured certificate and key files before dispatching requests to remote tool servers; the MCP Doctor checks those settings for operators. The Codex plugin separately uses app-server clients to discover models and serve agent runs, then closes them during plugin retirement. flowchart LR
A[Configured MCP server] --> B[Certificate and key reader]
B --> C{Within file limit?}
C -->|Yes| D[Guarded HTTP request]
C -->|No| E[Doctor error or failed connection]
F[Codex model discovery] --> G[App-server client owner]
G --> H[Plugin retirement cleanup]
Decision needed
Why: The cap prevents unbounded reads but changes a previously accepted public configuration contract; source and tests cannot establish the intended compatibility tradeoff. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +325, Tests +1085, Docs +24. Total +1434 across 44 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep bounded TLS reads and shared Doctor validation, but settle the acceptable PEM-chain limit against existing configurations and verify the upgrade path before landing the integrated branch. Do we have a high-confidence way to reproduce the issue? Yes for the source-level defect: current main synchronously reads configured MCP TLS files without a bound. This read-only review did not run an oversized-file reproduction. Is this the best way to solve the issue? Unclear until maintainers settle the 64 KiB upgrade contract. Sharing a bounded reader with Doctor is a narrow repair for the memory spike; the exact ceiling remains a product choice. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4c4fc7b79f42. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
6b6ee3c to
66e1a0f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
Share asynchronous bounded TLS file loading between HTTP requests and MCP Doctor. Preserve configured links and PEM bytes, bound each file to 64 KiB, and keep origin scoping, cancellation, and final request authority intact. Clean up request deadlines when dispatcher preparation fails. Co-authored-by: wahaha1223 <[email protected]>
Preserve the reviewed bounded TLS-file correction and contributor ancestry while including the canonical popup listener and test-fixture repairs. Keep main's shared MCP CLI option and list helpers.
Include the mainline maintenance-owner line-cap repair from openclaw#156809. The reviewed nine-file TLS delta and all reviewed owner modules are unchanged.
Include the readonly-reuse wrapper archive and release validation repairs. Preserve the reviewed bounded TLS-file correction and contributor ancestry.
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Adopt the native compiler tooling while preserving the bounded asynchronous MCP TLS-file reader and its existing validation. Co-authored-by: wahaha1223 <[email protected]>
Integrate main through 92635da. The reviewed TLS delta and its owners are unchanged; the canonical projection helper removes the registry line-limit failure without changing the lint budget. Co-authored-by: wahaha1223 <[email protected]>
Integrate plugin cache retirement from ec78e8e, the lightweight idle fixture from 14f4d2d, and the reviewed pressure-listener repair ea9b2cc (openclaw#157584). These repairs let validation finish within the existing heap and worker budgets.
Complete the paired idle-worker fixture migration from openclaw#157341 and isolate independent PR fixtures from outer maintainer controls as reviewed in openclaw#157755. Keep production behavior, worker budgets, and assertions unchanged.
Integrate the canonical cleanup correction from openclaw#157323 (0440fa7). Retain registry resources through terminal cleanup and invoke harness disposal through the existing cleanup admission. In-process retirement continues to preserve shared clients owned by live peers. Co-authored-by: Ayaan Zaidi <[email protected]>
Adopt canonical main repair 537ac5f. Clear inherited inline Git configuration only in fixture-owned child commands, retaining the real Git maintenance assertions. Exact landed postimage and its review and test evidence are unchanged.
Register catalog cleanup with the plugin lifecycle and join its admitted request producers before closing unclaimed clients. Explicit harness shutdown starts catalog disposal and shared startup cancellation together so parked work cannot launch a replacement while shutdown waits. Retain cleanup receipts for returned and late-returned startup clients until physical exit or a successful retry. Preserve peer leases and report cleanup failures before reopening startup admission. Adopt the canonical startup-joining repair from 890ab59.
Adopt canonical main repair 481045d. Seed the fixture title before observing the setter so an already-correct inherited title cannot fail the startup-policy test. Keep the exact canonical postimage and all existing assertions; production code is unchanged.
Keep the Gateway HOME test inside a temporary account home so plugin metadata cannot read an operator database. Wait for stdin to close before checking that startup still awaits physical exit, and keep fixture cleanup reachable on test cancellation. Group the startup fixtures in their own support file while preserving test order, deadlines, and assertions.
Preserve the default and named-profile environments and assertions while consolidating their repeated setup. Keep the test isolated in its temporary account home and below its original line count.
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
What Problem This Solves
Fixes memory spikes when an MCP client certificate or key points to a very large file, and makes MCP Doctor report the same configuration error as the connection path.
User Impact
Each certificate/key file is limited to 64 KiB. Regular files, symbolic links, and hard links remain supported; no configuration migration is needed.
Why This Change Was Made
Runtime and Doctor share a bounded asynchronous file reader. Each runtime fetch client coalesces pending TLS-material reads and reuses successful material; failed reads remain retryable. Credentials remain scoped to the configured server origin, with cancellation and request authority checked before dispatch.
The cleanup repair also closes unclaimed native model-catalog clients on plugin retirement while preserving active peers. For returned or late-returned startup clients, terminal cleanup retains ownership until exit is observed or an explicit retry succeeds.
Original contribution by @wahaha1223.
Evidence
Earlier TLS regression proof used real localhost mutual TLS: ordinary and linked PEM files authenticated, oversized files and FIFOs were rejected before HTTP dispatch, and the registered CLI Doctor agreed. This proof predates the final cleanup composition.
3a82a986fc8epassed all 89 cases in 61.44 seconds. The unchanged shared-client fixtures passed all 137 cases in 48.93 seconds before signing theird964818c2e5cparent. Relevant test typechecks, scoped lint, and the line-growth check passed. Independent reviews of the fixture repairs found no actionable P0–P2 findings.HOMEand await actual startup close events instead of assuming fake-clock advancement finishes real I/O. The preceding CLI-title fixture correction passed 73 cases in 46.188 seconds with an inherited CLI title.fb0f8320676cpassed its Linux build in 209.607 seconds and the unchanged three-case native-discovery comparison in 49.708 seconds. Completed cases and suite teardown retained zero client entries; both controls retained two. The canonical runner verified the completed compiler generation before retaining it.Signed candidate
3a82a986fc8ediffers from the live execution SHA only in the CLI preaction test and the three fixture files above. Runtime, documentation, and dependency bytes are identical; the live comparison was not rerun on this descendant.Both recorded managed launchers exited via SIGKILL, and the final scoped process check was empty. Individual native-child exits were not captured; this is not exhaustive descendant-exit proof. Cleanup failures before a transport returns a client remain outside this repair.
Native build, full repository checks, and all 616 scheduled Vitest shards passed on
3a82a986fc8ein 2h43m51.854s. The full run passed the repaired Gateway and shared-client files, the registered Doctor TLS-limit regression, and the HTTP-fetch and request-authority cases. Pending: required CI and reviews on the exact published head. Earlier incomplete runs are not counted as full passes.