Repository navigation
fix: wait for startup leases after container replacement - #160266
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 September 28, 2026, 4:07 PM ET / 20:07 UTC (Revision 9). ClawSweeper reviewWhat this changesGateway startup retries lease conflicts from another host within the existing wait limit; the branch also expands lease regression tests and waits for transcript resizing in a Control UI end-to-end test helper. Merge readiness✅ Ready for maintainer review Keep this PR open. Current main still exits on a foreign-host startup lease conflict, while the branch addresses that failure. The recorded deployment and upgrade runs support the fix, and this review found no concrete introduced defect. Priority: P1 Review scores
Verification
How this fits togetherGateway configuration preflight acquires a lease in shared SQLite state before startup recovery and plugin-index writes. A replacement container must wait until the previous lease is released or expires before it can finish startup. flowchart TD
A[Gateway startup] --> B[Configuration preflight]
B --> C[Shared SQLite lease]
C --> D{Lease available?}
D -- Yes --> E[Acquire lease and prepare state]
D -- No --> F[Bounded wait and retry]
F --> C
E --> G[Gateway ready]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -7, Tests +61. Total +54 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep lease acquisition in the existing bounded startup path and preserve SQLite ownership fencing so replacement Gateways can proceed after the prior lease ends. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source excludes foreign-host conflicts from retry, and the PR records two real deployment failures; this read-only review did not rerun the containers. Is this the best way to solve the issue? Yes. Reusing the timed acquisition loop addresses the startup failure without changing lease storage, owner fencing, or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3775359ab87d. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Use the exact helper postimage from d64568e (#160266). The canonical committed-size wait supersedes this branch's layout quiet-window variation while preserving every geometry assertion and viewport order. Validation: canonical Linux native-plugin E2E six cases and exact-head CI pass; helper and layout-owner source bindings verified; formatting, diff checks, and independent P0-P2 review pass. Native cancellation production is unchanged. Co-authored-by: Kimi Yu <[email protected]>
* fix(subagents): await native Stop persistence Move native cancellation reads and writes through the existing worker owners while retaining exact run, session, queue and source authority. Join claim publication, terminal settlement and cleanup, preserve earlier completion, and fence uncertain writes without replay. Validated registered Stop with real SQLite, public Gateway create/turn/Stop/describe, native lifecycle and scheduler controls, all changed checks, archive E2E and the full build. * fix(subagents): preserve optional snapshot owner shape * test(subagents): await finite lifecycle settlement * ci: consume canonical UI component type shard Take the exact landed shard repair so the native Stop branch retains all compiler roots under the unchanged budget. No native cancellation source changes. Receiving proof passes 35 routing cases, both UI type graphs, selected changed checks, and independent review. The original 721-root baseline failure remains attributed to main. (cherry picked from commit 52ae7e3) * test(agents): register native cancellation fixtures through real owner Replace resident-only run seeding and no-op persistence with awaited canonical registration. Preserve owner, foreign-run, generation-replacement, and real ACP interrupt assertions. * test(subagents): preserve canonical controller and abort fixtures Keep real controller resolution in tool tests and register the orphaned child through real session and registry persistence. Preserve all original cancellation assertions and isolate the running-child wait transport. * test(agents): match restored requester batch wake messages Update the held model fixture to recognize the batch-scoped completion prompt introduced by #158642. Preserve the two-active, third-queued, ordinary-probe, runtime-budget, and cleanup assertions. Verified on the exact native cancellation CI merge: the original four-case order reproduced three passes and the stale-marker failure, then all four passed with this single-line correction. Owning changed checks and independent review passed. * test(gateway): keep abort append faults connection-local * fix(subagents): retire superseded timing reads without false warnings * fix(subagents): retain finite completion reconciliation work * test(gateway): preserve real descendant abort fixture custody * test(ui): await settled native composer layout Wait for the existing layout-settled contract after viewport changes before measuring native composer footer clearance. ResizeObserver updates transcript width asynchronously while the footer follows its container immediately. Preserve every geometry formula, threshold, and variant order. Validation: six native-plugin UI cases, UI E2E types, scoped lint, formatting, and isolated review passed. Linux baseline passed; candidate remote attempts stopped during source synchronization before test execution. * test(subagents): use real abort persistence and publication barriers * fix(agents): fence collector adoption during cancellation Pending Swarm collectors can receive an aborted Gateway response while Stop is still persisting cancellation. Begin the existing kill claim immediately after native admission drains, then refuse launch adoption while its write is pending. This preserves cancellation publication before provisional-session cleanup and retains the current caller, session, generation, and database authority checks. Cover queued and already-started collectors whose acknowledgment races a pending kill write. Preserve the original three Gateway preaccept Stop cases and their publication, rollback, and timeout assertions. Validation: causal regression RED/GREEN; 273 focused and sibling tests; original 18-file shard with 264 tests; full check-changed including all 26 core test type graphs; independent P2 review with no actionable findings. * test(subagents): join canonical registry completion before assertions Reuse existing finite lifecycle/root-work settlement in collector-yield and completion-before-kill fixtures. Preserve their original assertions, order, and timeouts. Validation: original-order regression diagnosis; twenty standalone and two original 33-file replays passed; unchanged completion siblings reuse the qualified timing shard receipt; owning changed checks and independent component/combined P2 reviews passed. A third stress replay was interrupted by provider shutdown and is not counted as a test result. Current-head hosted CI remains required. * fix(tooling): stop reporting lazy imports as duplicate exports (#160558) Recognize transparent literal dynamic-import forwarders in the shared export-collision guard while preserving member, argument and body restrictions. Both variable and inline forwarding paths use the same predicate; runtime behavior is unchanged. Validation: original guard reproduces nine repository false positives and fails all three new positive fixtures. Candidate passes the repository guard and all 54 fixtures, including six new rejection cases, under a 7 GiB process-tree limit with swap disabled. Script types and formatting pass. Independent and exact-head ClawSweeper reviews identify no actionable findings. (cherry picked from commit f010fc0) * fix(agents): join registry writes before follow-up adoption A child follow-up can reach source replacement while its ended-hook stamp is still in the registry worker. Join the existing write owner before the exact durable comparison, retaining uncertain-write errors and rechecking the selected source and admitted caller after every await. Carry sessions.send session authorization through the same boundary. Cover held real writes, caller retirement, and source replacement. * test(ui): consume canonical composer readiness check Use the exact helper postimage from d64568e (#160266). The canonical committed-size wait supersedes this branch's layout quiet-window variation while preserving every geometry assertion and viewport order. Validation: canonical Linux native-plugin E2E six cases and exact-head CI pass; helper and layout-owner source bindings verified; formatting, diff checks, and independent P0-P2 review pass. Native cancellation production is unchanged. Co-authored-by: Kimi Yu <[email protected]> * test(codex): separate protocol timing from startup cost Keep protocol fixtures on their existing controlled deadline clock and measure unattended denial from the review-required hook to the actual decline. Preserve model, transport, history and approval assertions, the existing bounds, and all production clock and executable-integrity behavior. Validation: identical latency controls change four failures to four passes; the original six-file envelope passes 34 tests, with eight deadline and three no-approval-request siblings. Selected changed checks and independent P0-P2 review pass. The original Unix 120-second stall was not independently reproduced; current-head CI remains required. * refactor(config): align canonical worker result types Take the private result-alias cleanup from b4d93d2 (#159588) without importing unrelated main changes. Keep the canonical input declaration position while preserving the native selector, request fields, and distributive prepared-input union. The emitted runtime is unchanged. Core and worker-owner test types, scoped lint, formatting, and independent review pass; the qualified native runtime proof remains applicable. --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Kimi Yu <[email protected]>
…aw#160203) * fix(subagents): await native Stop persistence Move native cancellation reads and writes through the existing worker owners while retaining exact run, session, queue and source authority. Join claim publication, terminal settlement and cleanup, preserve earlier completion, and fence uncertain writes without replay. Validated registered Stop with real SQLite, public Gateway create/turn/Stop/describe, native lifecycle and scheduler controls, all changed checks, archive E2E and the full build. * fix(subagents): preserve optional snapshot owner shape * test(subagents): await finite lifecycle settlement * ci: consume canonical UI component type shard Take the exact landed shard repair so the native Stop branch retains all compiler roots under the unchanged budget. No native cancellation source changes. Receiving proof passes 35 routing cases, both UI type graphs, selected changed checks, and independent review. The original 721-root baseline failure remains attributed to main. (cherry picked from commit e7f5a85) * test(agents): register native cancellation fixtures through real owner Replace resident-only run seeding and no-op persistence with awaited canonical registration. Preserve owner, foreign-run, generation-replacement, and real ACP interrupt assertions. * test(subagents): preserve canonical controller and abort fixtures Keep real controller resolution in tool tests and register the orphaned child through real session and registry persistence. Preserve all original cancellation assertions and isolate the running-child wait transport. * test(agents): match restored requester batch wake messages Update the held model fixture to recognize the batch-scoped completion prompt introduced by openclaw#158642. Preserve the two-active, third-queued, ordinary-probe, runtime-budget, and cleanup assertions. Verified on the exact native cancellation CI merge: the original four-case order reproduced three passes and the stale-marker failure, then all four passed with this single-line correction. Owning changed checks and independent review passed. * test(gateway): keep abort append faults connection-local * fix(subagents): retire superseded timing reads without false warnings * fix(subagents): retain finite completion reconciliation work * test(gateway): preserve real descendant abort fixture custody * test(ui): await settled native composer layout Wait for the existing layout-settled contract after viewport changes before measuring native composer footer clearance. ResizeObserver updates transcript width asynchronously while the footer follows its container immediately. Preserve every geometry formula, threshold, and variant order. Validation: six native-plugin UI cases, UI E2E types, scoped lint, formatting, and isolated review passed. Linux baseline passed; candidate remote attempts stopped during source synchronization before test execution. * test(subagents): use real abort persistence and publication barriers * fix(agents): fence collector adoption during cancellation Pending Swarm collectors can receive an aborted Gateway response while Stop is still persisting cancellation. Begin the existing kill claim immediately after native admission drains, then refuse launch adoption while its write is pending. This preserves cancellation publication before provisional-session cleanup and retains the current caller, session, generation, and database authority checks. Cover queued and already-started collectors whose acknowledgment races a pending kill write. Preserve the original three Gateway preaccept Stop cases and their publication, rollback, and timeout assertions. Validation: causal regression RED/GREEN; 273 focused and sibling tests; original 18-file shard with 264 tests; full check-changed including all 26 core test type graphs; independent P2 review with no actionable findings. * test(subagents): join canonical registry completion before assertions Reuse existing finite lifecycle/root-work settlement in collector-yield and completion-before-kill fixtures. Preserve their original assertions, order, and timeouts. Validation: original-order regression diagnosis; twenty standalone and two original 33-file replays passed; unchanged completion siblings reuse the qualified timing shard receipt; owning changed checks and independent component/combined P2 reviews passed. A third stress replay was interrupted by provider shutdown and is not counted as a test result. Current-head hosted CI remains required. * fix(tooling): stop reporting lazy imports as duplicate exports (openclaw#160558) Recognize transparent literal dynamic-import forwarders in the shared export-collision guard while preserving member, argument and body restrictions. Both variable and inline forwarding paths use the same predicate; runtime behavior is unchanged. Validation: original guard reproduces nine repository false positives and fails all three new positive fixtures. Candidate passes the repository guard and all 54 fixtures, including six new rejection cases, under a 7 GiB process-tree limit with swap disabled. Script types and formatting pass. Independent and exact-head ClawSweeper reviews identify no actionable findings. (cherry picked from commit 34f3dab) * fix(agents): join registry writes before follow-up adoption A child follow-up can reach source replacement while its ended-hook stamp is still in the registry worker. Join the existing write owner before the exact durable comparison, retaining uncertain-write errors and rechecking the selected source and admitted caller after every await. Carry sessions.send session authorization through the same boundary. Cover held real writes, caller retirement, and source replacement. * test(ui): consume canonical composer readiness check Use the exact helper postimage from 47c33fe (openclaw#160266). The canonical committed-size wait supersedes this branch's layout quiet-window variation while preserving every geometry assertion and viewport order. Validation: canonical Linux native-plugin E2E six cases and exact-head CI pass; helper and layout-owner source bindings verified; formatting, diff checks, and independent P0-P2 review pass. Native cancellation production is unchanged. Co-authored-by: Kimi Yu <[email protected]> * test(codex): separate protocol timing from startup cost Keep protocol fixtures on their existing controlled deadline clock and measure unattended denial from the review-required hook to the actual decline. Preserve model, transport, history and approval assertions, the existing bounds, and all production clock and executable-integrity behavior. Validation: identical latency controls change four failures to four passes; the original six-file envelope passes 34 tests, with eight deadline and three no-approval-request siblings. Selected changed checks and independent P0-P2 review pass. The original Unix 120-second stall was not independently reproduced; current-head CI remains required. * refactor(config): align canonical worker result types Take the private result-alias cleanup from 886db07 (openclaw#159588) without importing unrelated main changes. Keep the canonical input declaration position while preserving the native selector, request fields, and distributive prepared-input union. The emitted runtime is unchanged. Core and worker-owner test types, scoped lint, formatting, and independent review pass; the qualified native runtime proof remains applicable. --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Kimi Yu <[email protected]>
What Problem This Solves
Fixes repeated Gateway startup failures after container replacement when the previous container leaves an unexpired startup migration lease.
User Impact
A replacement waits for the existing lease to be released or expire instead of immediately exiting and accumulating supervisor restart backoff. An abandoned lease can still require up to the existing five-minute lease lifetime; this does not make takeover immediate.
Why This Change Was Made
Use the existing bounded acquisition loop for foreign-host and unknown-owner conflicts too. Lease ownership, expiry, dead-owner checks, and storage remain unchanged; a live unexpired foreign lease cannot be reclaimed.
Evidence
f9a43b733c9b:pnpm test src/infra/startup-migration-checkpoint.test.ts --maxWorkers=1passed all 19 cases with 0 skips. Measured command wall time was 12.359 seconds on macOS with Node 24.19.0; Vitest reported 9.18 seconds including transform/setup. Hosted CI timing is unavailable because the test jobs were skipped for this draft.assertReliabilityForcedExitis imported but not exported. No check is suppressed.ff8c752dplus this PR, OCEe06ff962plus its deletion-retry fix, Codex 0.156.0, and the existing OCE read-only-paths bridge. This is selected PAT-path acceptance, not AWS or long-window qualification of this candidate.upgrade-survivorlegacy-operator-state / auto-auth lane upgraded npm[email protected]to a package built from main988be486with the reviewed startup/catalog fixes and existing OCE read-only-paths bridge. The test seeded a real-clock, 120-second foreign-host startup lease immediately before candidate service start and invalidated only the derived plugin-index policy hash. Gateway configuration loading resumed after 122.013 seconds, 2.013 seconds after expiry; the original published updater returned success without a product timeout override. Authenticated Gateway probes, the mock-provider model turn, idempotent update, Doctor, and backup/rollback checks all passed (container exit 0). This is local published-package upgrade coverage, separate from AWS and natural 24-hour pairing acceptance.CI follow-up
The UI E2E run on
1e55e17e50bsampled the transcript before itsResizeObserverhad committed the new scrollport size after a viewport change.4bb3792d209waits for the transcript dimensions to match its parent before measuring the footer. All original layout assertions and thresholds remain unchanged; production UI is unchanged. Changed-file lint, formatting, and independent review pass. Local browser replay was blocked by unavailable bundled Chromium and managed Chrome remote-debugging policy. Hosted CI on this exact head passed, including all UI and real-Gateway E2E shards and the required aggregate gate. The original failing native-plugin UI case ran in shard 4/9 this time and passed; all six tests in that file passed.