Repository navigation
fix(plugins): prevent Gateway stalls while copying reload recovery - #200374
Conversation
Move the complete asynchronous recovery copy into the existing capture broker, including root creation, copy filtering, native link validation, and cleanup. Reuse one physical copy algorithm for the retained sync fork. Follow up on #198262 and Wes (@akmad)'s original #181491 recovery work. Preserve the independent native leases established by #200320. A synthetic two-second create delay reduces the median MAIN heartbeat gap from 2010 to 10 ms. Cold owner time rises 94.750 to 124.388 ms; that cost and the remaining synchronous fork/import contracts are recorded in the PR evidence. No configuration or schema changes.
|
🦞👀 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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR moves asynchronous reload-recovery filesystem work into the existing capture broker while preserving synchronous recovery forks. Example: A recovery-root creation stalls for two seconds during plugins.reload.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a remaining Gateway stall with a coherent broker-owned copy path. Both prior findings are resolved, and no new actionable defect was found; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway plugin replacement captures the serving generation before retirement; the broker copies its files, while host-owned mappings and native leases support rollback and eventual cleanup. flowchart LR
A[Plugin reload RPC] --> B[Reload recovery owner]
B --> C[Host recovery adapter]
C --> D[Existing capture broker]
D --> E[Shared physical copy algorithm]
E --> F[Private recovery files]
C --> G[Native leases and path mappings]
B --> H[Replacement or rollback]
Technical reviewBest possible solution: Retain the broker-owned asynchronous copy and shared synchronous copy policy, then land through the existing exact-head CI gate. Do we have a high-confidence way to reproduce the issue? Current main creates recovery roots and executes synchronous copy-filter metadata on the Gateway thread; supplied before/after Gateway traces demonstrate the resulting delay under a two-second filesystem fault. Is this the best way to solve the issue? The patch fixes the physical operation at its existing broker boundary, preserves host native leases and synchronous fork contracts, and removes duplicated copy policy without introducing another manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against df78722789e0. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +159, Tests +99, Docs 0, Other +254. Total +512 across 18 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)Reviewed November 16, 2026, 11:04 PM ET / November 17, 2026, 04:04 UTC (Revision 3). |
A cold full Vitest worker compilation took 76 seconds inside the first 60-second heartbeat build-graph test. Enroll this selection in the existing runner preparation owner; preserve graph selection, test limits and assertions. Direct and projects runner regressions fail before the correction and all 55 runner cases pass afterward. Changed checks retain only the previously attributed Slack/UI dead exports.
|
Addressed the review items on head
The real model turns were requested during the hold and completed afterward; this does not claim inference finished during reload admission. The bounded APFS fault uses preserved canonical builds with equivalent recovery runtime and a later erased type-import difference, not an exact-final-head full build. The PR body records that boundary and the excluded first injector attempt; CPU/allocation evidence remains the separate accepted campaign. The second CI run exposed a distinct cold compiler preparation bug: 76,348 ms of full test-worker compilation began inside the first 60-second build-graph test. The existing runner preparation owner now finishes that work before test launch. Both direct/projects runner regressions fail before the fix and all 55 cases pass afterward; the original Bun build case passes with preparation visibly preceding startup. Timeouts, assertions and graph selection are unchanged. Independent Codex review is scoped-clean. Fresh exact-head CI is required before landing. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Use the existing controlled compiler for the unrestricted tooling selection. The eight-case admission table reproduces the missing manifest before this fixture migration and passes after it; retain the compiler count, receipt and selection assertions. No production behavior or timeout changes.
|
Addressed the latest review item in
The earlier P1 wrapper inventory correction remains present, and the shipped-Gateway evidence accepted in this review remains unchanged. The completed third CI run identified only this admission-fixture failure. The PR body records the correction and the unchanged local Slack/UI export findings; fresh exact-head CI remains required before merge. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#200374) * fix(plugins): keep reload recovery metadata off the Gateway thread Move the complete asynchronous recovery copy into the existing capture broker, including root creation, copy filtering, native link validation, and cleanup. Reuse one physical copy algorithm for the retained sync fork. Follow up on openclaw#198262 and Wes (@akmad)'s original openclaw#181491 recovery work. Preserve the independent native leases established by openclaw#200320. A synthetic two-second create delay reduces the median MAIN heartbeat gap from 2010 to 10 ms. Cold owner time rises 94.750 to 124.388 ms; that cost and the remaining synchronous fork/import contracts are recorded in the PR evidence. No configuration or schema changes. * fix(tooling): include recovery imports in the PR wrapper * test: prepare runtime build graph workers before test launch A cold full Vitest worker compilation took 76 seconds inside the first 60-second heartbeat build-graph test. Enroll this selection in the existing runner preparation owner; preserve graph selection, test limits and assertions. Direct and projects runner regressions fail before the correction and all 55 runner cases pass afterward. Changed checks retain only the previously attributed Slack/UI dead exports. * test: provide compiler artifacts for eager tooling admission Use the existing controlled compiler for the unrestricted tooling selection. The eight-case admission table reproduces the missing manifest before this fixture migration and passes after it; retain the compiler count, receipt and selection assertions. No production behavior or timeout changes.
Backport #200374. Move root creation, source-copy filters, native link validation and cleanup into the existing capture broker. Share copy policy with retained synchronous forks and preserve independent exported native leases. No schema, permission, or retention change. (cherry picked from commit 5275f43) Co-authored-by: RomneyDa <[email protected]>
* fix(plugins): avoid Gateway stalls during source preparation Move source/native capture root and staging-token custody into the existing broker resource owner. Preserve cache/recovery retention and loaded-addon custody across execution shutdown, ordinary Gateway restarts, and broker loss. The actual root boundary now performs zero main-thread metadata calls instead of 28; two-second create faults leave the Gateway event loop responsive. Cold/warm preparation and whole-process CPU costs are measured and disclosed in the PR. No schema, config, cache, or public protocol changes. * fix(plugins): preserve capture failure contracts across broker custody Complete capture-root consumer migration, restore low-space setup containment through the existing source-acquisition classification, and keep physical commit typing distinct from asynchronous leases. Preserve actual cleanup and yielding proof, update wrapper and fixed factory inventories, and remove the redundant broker-port suppression. * refactor(plugins): keep native capture contract in a type leaf (cherry picked from commit 907e17b) Co-authored-by: RomneyDa <[email protected]> Release adaptation: #200320 is required by #200374 because the baseline async recovery path still performs root creation, filtering and link metadata synchronously on the Gateway. Retain the coherent existing broker-resource migration rather than invent a second worker owner.: (cherry picked from commit a7feea3b844d37918527cca29e9f9812b61b156a)
…200374) * fix(plugins): keep reload recovery metadata off the Gateway thread Move the complete asynchronous recovery copy into the existing capture broker, including root creation, copy filtering, native link validation, and cleanup. Reuse one physical copy algorithm for the retained sync fork. Follow up on #198262 and Wes (@akmad)'s original #181491 recovery work. Preserve the independent native leases established by #200320. A synthetic two-second create delay reduces the median MAIN heartbeat gap from 2010 to 10 ms. Cold owner time rises 94.750 to 124.388 ms; that cost and the remaining synchronous fork/import contracts are recorded in the PR evidence. No configuration or schema changes. * fix(tooling): include recovery imports in the PR wrapper * test: prepare runtime build graph workers before test launch A cold full Vitest worker compilation took 76 seconds inside the first 60-second heartbeat build-graph test. Enroll this selection in the existing runner preparation owner; preserve graph selection, test limits and assertions. Direct and projects runner regressions fail before the correction and all 55 runner cases pass afterward. Changed checks retain only the previously attributed Slack/UI dead exports. * test: provide compiler artifacts for eager tooling admission Use the existing controlled compiler for the unrestricted tooling selection. The eight-case admission table reproduces the missing manifest before this fixture migration and passes after it; retain the compiler count, receipt and selection assertions. No production behavior or timeout changes. (cherry picked from commit 5275f43) Co-authored-by: RomneyDa <[email protected]> Release adaptation: apply after #200320 native capture owner prerequisite; retain source recovery copy and regression contracts unchanged. Follow-up #200571 detaches the independent owner from retired caller context.: (cherry picked from commit b1d97f0a472874e12bbfb3a0e429f97f509d3710)
What Problem This Solves
Keeps plugin reload recovery from blocking the Gateway event loop while creating and copying its private recovery source.
Follow-up to #198262, #200320 and #200136. #198262 already adapted and credited Wes (@akmad)'s rollback-capture work from #181491; this change addresses the remaining physical metadata inside that asynchronous copy, while preserving its synchronous fork contract. The motivating Team incident (25c9790, 2026-11-16 05:02 PST) held MAIN in
openat2(O_CREAT)for 1.97 seconds while btrfs waited for a transaction. After physical preparation custody moved to the broker, the real serving-plugin reload recovery path still performed synchronous root creation and metadata work in the copy filter on MAIN. Awaitingfs.promises.cpdid not move those filter callbacks off the event loop.User Impact
Reload recovery still waits for its source copy, but unrelated Gateway work can continue during a filesystem stall. No configuration, schema or operator action changes.
The measured tradeoff is explicit: normal cold owner time increases by about 30 ms, from 94.750 to 124.388 ms. Warm median owner time is 87.023 versus 86.476 ms, but its maximum increases from 227.783 to 266.447 ms. These costs are accepted for removing the foreground filesystem boundary; this is not an overall speedup claim.
Why This Change Was Made
The existing broker resource now owns the complete asynchronous recovery copy: root creation, copy/filter work, link relocation, native-reference validation and physical cleanup. The host retains native leases and path mappings. Failed-copy roots stay recorded under the same owner until cleanup succeeds; sequential release/close settlement preserves both failures.
The retained synchronous fork and broker-owned asynchronous copy share one physical copy algorithm. No second manager, cache, schema, configuration switch or public protocol is introduced. Production grows by 159 lines for the private command/adapter and complete lifetime handoff; duplicated copy/filter policy is removed. Existing synchronous recovery forks and runtime-selected synchronous imports remain separate contracts, so this PR does not claim every Gateway filesystem path is asynchronous.
Evidence
The existing main-thread filesystem observer reproduces the defect through the real loaded serving-plugin recovery owner. In five compiled fault pairs, the baseline executes 28 selected MAIN sync calls and records heartbeat gaps of 2,007–2,014 ms; the candidate executes zero and records 7–14 ms while the actual broker create is delayed for about two seconds. Median heartbeat gap is 2,010 versus 10 ms. The recovery operation itself still waits: fault owner medians are 2,132.034 versus 2,164.273 ms.
The synthetic plugin actually imports 199 companion payloads and proves their evaluated lengths through its retained provider callback. Every run copies 202 regular files totaling 1,647,404 bytes, verifies copied entry bytes, joins removal and retains the serving callback. A minimal three-file qualification exposed an undersized workload and was replaced before accepted measurements; the unused 2 MiB native fixture input is not counted as copied work. Surrounding 35 GiB/5,000-session/62,000-file fixtures are synthetic and are not scanned by this owner. No Team data was copied.
Canonical built Node 26.12.1/APFS proof ran 20 normal processes (five A1/A2 controls and five A/B pairs, each cold/warm), then five two-second A/B fault pairs. All 30 processes and observed brokers exited; source/build/driver/fixture hashes were verified and every row retained. The baseline is the physical-custody revision
03b70d9; the candidate also includes its later source-acquisition error projection and sender/type repair. The error projection is inactive on successful samples, and the subsequent pure type-leaf move changes no executable behavior. These dependency differences are explicit rather than described as identical bytes.MAIN counters exclude broker work. Whole-tree CPU includes fixture generation, imports and initial plugin loading; it is not an exclusive recovery CPU measure or a global savings claim. A/A cold owner medians were 123.342/101.710 ms, warm 105.621/111.534 ms. Host one-minute load ranged from 27.257 to 41.711 despite pausing this task's other local work. Variability limits precision; no tail is dismissed as noise. Candidate warm capture maximum was 255.886 ms versus 171.691 ms, while cold capture maximum improved from 145.623 to 117.785 ms.
Rerun using the committed
scripts/perf/plugin-capture-custody-measure.mjsand fixture setup from #200320. Build each pinned checkout withpnpm build sourcePerformance, then invoke the candidate driver against each--repowith the same fixture and a fresh label:Add
--fault recovery --delay-ms 2000, plus candidate--expect-off-main, for the fault arms. Run A1/A2/A/B five times serially, followed by five A/B fault pairs; wrap processes in/usr/bin/time -lfor whole-tree counters. Fixture generation, initial loading and byte verification are outside the owner timing intervals.Focused consumer proof passes 56 tests with one existing cross-filesystem skip. The final Gateway regression gates the actual broker copy, proves the event loop advances while it is pending, checks the real source/destination and exact copy count, and observes zero selected MAIN sync calls through capture and joined disposal. Core and affected test types, scoped lint/format/line limits and the static import-cycle guard pass. Independent final publication Codex review is scoped-clean; its complete source receipt includes the adapted Gateway gate, scaled workload and error-cause fields.
The earlier full
pnpm check:changedretained 14 production/108 full-tree dead-export identities identical to its exact parent, with no added or removed identities. Its task-owned style issues were fixed and rechecked. This is a recorded local failure, not an all-green census or an inherited-CI exception. Exact-head CI and final-head zero-open ClawSweeper review remain landing gates.The final 14 reviewed file hashes apply unchanged to main
53278c30303, which contains #200320. The dependency lock and scoped instructions are unchanged. Both current-main Gateway cases pass. The finalpnpm check:changedrun passes every gate except the unused-export scan: five production findings and three full-tree findings in Slack/UI, outside this patch. Both scans reproduce identically on exact clean parent53278c30303. The Slack exports were introduced byabdc09f1355(#143882), browser approval by1ce9df608b4(#200088), and the two other UI exports lost their last production consumers inc3baf0d8484(#199111). These are named main regressions for follow-up, not ignored noise. No inherited-CI exemption is claimed; exact-head green CI remains required. This is a current-main follow-up, not a rewrite of the older contributor fork.CI repair: the first exact-head run
44005730906found four newly reachable modules missing from the extracted PR-wrapper inventory. Both closure tests failed locally before the correction and passed afterward. The two applicable provisioning cases pass on macOS; the third case requires Linux and remains covered by the new CI run. Four inventory entries complete the existing extraction contract, with no production change or exception. Fresh independent Codex review of this correction is scoped-clean.The live entry-point proof now passes through an isolated built Gateway and the public
plugins.reloadRPC. With exactly one successful recovery-root create held for two seconds, the baseline blocked Gateway MAIN and overlapping HTTP/WebSocket health requests took up to 1,998/2,088 ms. The candidate held the separate broker for 2,007 ms while 48 HTTP and 23 WS responses completed during the hold; overlapping maxima were 223/249 ms. Both reloads published the synthetic plugin from v1 to v2 without restarting, removed the recovery root, and completed a realopenai/gpt-5.6-lunaassistant turn with the expected response and normal stop. Those turns were requested during the hold and completed afterward; inference completion within the hold is not claimed.Both canonical live wrappers and cleanup exited successfully. This uses retained canonical builds whose recovery runtime matches the final patch, with only a later erased type-import difference; it is not presented as an exact-final-head full build. Exact-head CI is separate. This bounded APFS fault proof supplements the accepted CPU/allocation campaign without rerunning it. One earlier injector qualification mistakenly included a preparation-worker root; its failed evidence was preserved, the path predicate and receipt identity were corrected, and it is excluded from accepted results.
The second CI run (
44008299130) exposed a cold test-worker preparation defect: the first timed heartbeat build-graph case waited for a 76,348 ms full worker compilation (20,233 inputs), exceeding its unchanged 60-second deadline. The existing runner preparation owner now admits that test before launch. The new direct/projects boundary cases fail before the correction because no prepared manifest exists at launch; all 55 runner cases pass afterward in 31.39 seconds, including exclusion and cleanup. The original Bun build case passes in 483 ms after preparation is visibly completed before test startup. No timeout, graph selection, assertion or cache contract changes. Independent Codex review is scoped-clean. This is a concrete runner repair, not an inherited-CI exemption or a rerun for green.The repair-only
pnpm check:changed --staged --base cfcdaaadda05passes all gates except the same five production/three full-tree Slack/UI exports already reproduced and attributed above. Script export findings remain zero. Gateway production remains +159 lines; this CI correction adds three tooling lines and 13 net test lines.The third run (
44012000507) identified one consumer fixture missed by that enrollment. Its unrestricted tooling case mocked compiler success without writing a manifest. A one-line fixture migration now uses the existing controlled compiler for that selection, retaining the real preparation owner and existing compiler-count/receipt assertions. The exact eight-case table reproduces one failure before the change and passes all eight afterward (7.58-second wrapper). No production change, added test, timeout change or weaker assertion; independent Codex review is scoped-clean. ClawSweeper accepted the live Gateway proof and identified this same fixture as its sole remaining item.The fixture-only changed-check run again passes every gate except the identical five production/three full-tree Slack/UI unused exports, with zero script export findings. All 18 final file hashes are recorded; the eight Gateway production files remain unchanged.