Repository navigation
fix(gateway): recover remote workers without blocking readiness - #192542
Conversation
Co-authored-by: galiniliev <[email protected]>
|
🦞👀 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. What this changesThis PR moves remote worker recovery into tracked background startup work while preserving newly admitted turn claims. Example: A Gateway restarts while provider inspection is held and a new native worker turn is submitted.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a current readiness blocker, fixes the previously reported claim-recovery defect, and supplies relevant native runtime proof; failed CI still needs attribution. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway placement runtime coordinates persisted session placements, provider reconciliation, workspace settlement, admission, and shutdown; it produces recovered placement state and session-change events. flowchart TD
A[Gateway startup] --> B[Settle local journals]
B --> C[Open readiness]
B --> D[Tracked remote recovery]
C --> E[New turn admission]
D --> F[Match pre-start claims]
E --> F
D --> G[Shutdown drain]
Technical reviewBest possible solution: Retain the existing recovery and shutdown owners, defer remote reconciliation, and restrict interrupted-claim recovery to the captured pre-start identity. Do we have a high-confidence way to reproduce the issue? Current-main source directly awaits remote reconciliation on readiness, and supplied original-owner controls demonstrate blocked readiness; no target code was executed during this review. Is this the best way to solve the issue? The patch is a focused fix using the existing tracked reconciliation slot and canonical claim store, with no competing recovery owner or unnecessary production layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against da4d414e4bd6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +19, Tests +52, Docs +8, Other +2. Total +81 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (1 earlier review cycle)
Reviewed November 4, 2026, 12:11 PM ET / 17:11 UTC (Revision 2). |
Address hosted review with production-owner proof and preserve current authority and lifecycle ownership. Co-authored-by: galiniliev <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…claw#192542) * fix(gateway): recover remote workers without blocking readiness Co-authored-by: galiniliev <[email protected]> * fix(gateway): preserve newly admitted claims during startup recovery Address hosted review with production-owner proof and preserve current authority and lifecycle ownership. Co-authored-by: galiniliev <[email protected]> --------- Co-authored-by: galiniliev <[email protected]>
…claw#192542) * fix(gateway): recover remote workers without blocking readiness Co-authored-by: galiniliev <[email protected]> * fix(gateway): preserve newly admitted claims during startup recovery Address hosted review with production-owner proof and preserve current authority and lifecycle ownership. Co-authored-by: galiniliev <[email protected]> --------- Co-authored-by: galiniliev <[email protected]> Source: d4f79d5 Release adaptation: Bounded readiness repair and exact pre-start claim snapshot, with all three focused consumer regressions. Local journals remain awaited, remote reconciliation tracked and drained on close. Baseline startup awaited provider and interrupted any current claim. Excluded docs/allocation. Later workspace publication-size repairs independent. Formatting passed; runtime proof blocked by shared-install setup. No schema change. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 9a848f64374fc14866ab66cf1f3c4275c4367902)
What Problem This Solves
Fixes: slow or unavailable remote worker recovery can keep the Gateway from becoming ready after restart.
User Impact
The Gateway can become ready while remote workers reconcile. Local workspace journals still settle first, and shutdown waits for tracked recovery before closing environments. Remote recovery errors remain reported through the existing owner.
Why This Change Was Made
Schedule provider reconciliation through the existing tracked recovery chain instead of awaiting it on the readiness path. Reuse the native placement lifecycle and shutdown drain; restart recovery only owns the exact interrupted claims captured before new admission.
Evidence
node scripts/run-vitest.mjs src/gateway/worker-environments/placement-dispatch-recovery.test.ts src/gateway/server-worker-placement-startup.test.ts src/gateway/server-worker-placement-recovery-events.test.ts --maxWorkers=1.Native restart and shutdown proof
The isolated shipped-runtime proof now passes on native base
8bc44540c46d8d1e3d80800c7ea1b11277c2db02plus the unchanged published production owners from6e521f0f1b752f535778cfd9dc538c8a11866fe9. Parent readback verifies both owner-file hashes against that PR head. This supersedes the earlier incomplete fixture experiment; it does not relabel the old failed experiment as a pass.A built Gateway and genuine paired Node CLI prepare real native worker state through public session APIs. An independent retained lease delays provider inspection while the target accepts a new native turn. The canonical read-only placement owner records the committed claim; after successful startup recovery the same complete claim remains, and that original native command and turn finish. No internal recovery/admission/authority decision hooks or fabricated placement records are used.
For shutdown, public reclaim records a retryable provider destruction after an expected synthetic DELETE503. A real restart retries that write. With its response held, the production close phase remains pending and the Gateway stays alive. Releasing the response permits close-phase completion and process exit before the fixture's escalation bound. Native inspection and shutdown budgets are unchanged.
Captured final-effect trace, original-owner failures, and exact oracles
Original fixed-run stdout (ANSI styling removed; no outcome reconstructed):
Original-owner control output (one synthetic session UUID redacted; all budgets and the frozen driver unchanged):
The recovery control proves erroneous recovery rejection, not physical erasure of the claim. Both original owner files were verified against the pinned native Git base. Every final run reported owned-container absence.
Exact excerpts from the frozen proof driver show the observation and final-effect assertions. This task-only driver adapts the native Codex/paired-node fixture; it is not a proposed replacement for the upstream Codex regression. Omitted sections prepare the two real leases and transport fixtures; the body above identifies those external fixtures as synthetic.
Executing-source and captured-log identities:
{ "nativeBase": "8bc44540c46d8d1e3d80800c7ea1b11277c2db02", "publishedOwnerHead": "6e521f0f1b752f535778cfd9dc538c8a11866fe9", "driverSha256": "b7f49656887db3f85b9b4eff768115d2089baa22ae4a911724d3448c030da534", "fixedSourceSha256": "source sha256:4ebf5e41d149cbe104869c3be66b995987917096f9dadc9cf14274b0394e1b28", "fixedLogSha256": "a5088b887815eea8b7fece5e856cca72b1faef93327d435b9473d1ad542926e8", "fixedOwners": [ { "path": "src/gateway/server-worker-placement-startup.ts", "bytes": 29424, "sha256": "160b7aebbb0555dfa64072c0962cf4747cacdee0abd8c2fa373d1a918ad335d6" }, { "path": "src/gateway/worker-environments/placement-dispatch-recovery.ts", "bytes": 23047, "sha256": "42d8fcbadc1b8fb61424ebd2f95c63e6289d0045d22376870dc9a69ae60a9eef" } ], "controls": [ { "variant": "race-red", "sourceIdentity": "source sha256:82a9a7f45a951b719a0a5d5aaeb0c9c151be644e923b4a1194057ae9924989d4", "exitCode": 1 }, { "variant": "startup-red", "sourceIdentity": "source sha256:632424a7ff3ffe2ede35e90a650e6380e0fa33f3f0e09ba2b7037538e3f510d4", "exitCode": 1 } ] }Qualification: formatter, typed lint, targeted TypeScript and whitespace checks passed on the frozen driver; original-owner controls were typechecked. Fresh independent P0–P2 review found no findings in the frozen passed proof and relevant fixed owners. All seven final source files match the executed R19 snapshot; the input copy is synchronized. No production source change was required by this proof.
Limits: external model/provider responses and credential fixtures are synthetic, not live cloud or commercial inference. The write-capable recovery join and process-exit ordering are proven, but terminal destruction of the persisted environment row was not separately asserted. The first race-control attempt failed during setup with
database is locked; its unchanged-source isolated replay reached the intended failure, and no database fix is claimed. This is a pinned native-base composition, not execution of every current-main change or an exact-head CI claim. Current CI, review and landing remain separate gates.CI attribution — exact startup base and merge
The failed CI attempt remains failed; this is maintainer attribution for the repository's supported pre-existing-failure path, not green-CI evidence.
CI run 41785818022, attempt 1, has 76 terminal jobs. Only
checks-node-changed-13(job126428180090) and its downstreamopenclaw/ci-gate(job126436810484) failed.security-fastpassed. Security High is successful; CodeQL is neutral, not represented as success or waived.The actual CI checkout is
632396007bed23029addefaf03d2518e1a76b220, with ordered parents baseline15e38612b4bed88f6595be4d16c0c7b2d4fe20a9and this PR's6e521f0f1b752f535778cfd9dc538c8a11866fe9. The failed case iscodex-node-app-server.e2e.test.ts:381:42: an empty observednativePidsarray omits the known app-server PID. A fresh, matched isolated run on each exact tree failed at that same assertion; base exit1 and candidate exit1. No PR source was removed from the candidate. The selected test, PID observer, shared wire fixture, isolation builder, pinned Bun and lock inputs have identical blobs across the two trees.The differing numeric PIDs are expected; the invariant is the empty observed list omitting the known parent. This establishes baseline reproduction, not the introducing commit or a full diagnosis of the PID observer. Both replays built qaRuntime and used the pinned Bun in the same source-bound network-none image; build/launcher Node26.12.1 differs from CI24.22.1, and selected serial execution is not whole-shard timing equivalence. The admitted source digests are candidate
52a89703efa7cccc2d451a7daa306515ff57faf042761457fbc5ede6040259f5and base7c7fe1755e2207e80e3d2f7110447e5f62cb4250eb59fc9697bc6c10ca878a9f. Both owned containers were confirmed absent.The earlier
database is lockedfailure in the separate race-control setup remains unexplained and retained above; this CI comparison does not clear it. The independently passing native startup/recovery/shutdown proof, its original-source limits, and the exact-head overall Platinum review remain separate facts. Source, live authority, security and enforced review gates remain required.Contributor credit
Co-authored with @galiniliev.
Work sessions