Repository navigation
Conversation
Let repair bypass custody grace for positively dead owners while preserving descendant checks. Restore gateways stopped by interrupted managed updates, retain startup evidence across readiness failures, and preserve later operator stops. Refs #164800.
Keep handoff bookkeeping in the staged runtime and recover from recorded publication and generation state after an updater signal or missing result. Finalize verified candidates under the same run, restart through the guarded helper path, and retain actionable terminal refusals for unsafe recovery. Refs #164800.
|
🦞👀 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: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
|
ClawSweeper status: applying reviewed decision. I am applying the reviewed decision for this pull request: fix(update): restore managed Gateway after updater process death This is item 1/1 in the current shard. Shard 1/1. This transient lease prevents a newer review from overlapping label, comment, or close mutations. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Superseded by #188497, which consolidates this draft and its sibling onto current main and adds the live Crabbox proof. |
Refs #164800. Supersedes #186328; this draft combines the helper and repair lanes.
What Problem This Solves
Fixes a managed Gateway remaining stopped when its updater is killed before, during, or after package publication, including when the updater itself stopped the service.
User Impact
The live helper settles the interrupted update and restores a verified Gateway. If the helper also dies,
openclaw update repaircan recover promptly and restart the Gateway the update left stopped. Operator stops, lost ownership, named data risk, and unverifiable runtime identity still prevent automatic restart.Why This Change Was Made
The live Linux reproduction exposed two related ownership gaps. The helper only armed restoration when it parked the service through the foreground protocol; the normal native updater stops systemd itself (
update-command-service-maintenance.ts:618). Its SIGKILL therefore reached the old “no verified recovery result” branch. Standalone repair also only recognized the helper'sservice-stopstep. Dead handoff owners could additionally retain the 45-minute recovery grace.Both recovery paths now consume
findUpdateGatewayStopinsrc/infra/update-run-gateway-stop.ts. It recognizes the helper's stop, or a managed handoff followed by activation with the service currently stopped. The existing completedmanaged-service update handoffreceipt is written by both Gatewayupdate.run(src/gateway/server-methods/update.ts:546) and automatic updates (src/infra/update-startup-auto-run.ts:379), so it remains usable after target selection changesinstallationMethodtonpm-global. The initialupdate.runrunning snapshot is not a restart receipt. Later incoming running observations after activation persist the existingservice-runningreceipt; those receipts, replacement boot/settled verification, completed managed restarts, and newer settled runs retire the stop. These receipts survive ledger compaction. No new stop protocol, ledger schema, or updater-side stop receipt is needed.The helper uses its staged runtime to retain bookkeeping while the installed tree is missing. It cancels untouched publication preparation; once displacement begins it completes publication forward through the sealed publication owner, runs the installed post-core finalizer as this run's continuation, then uses
gateway restart --preserve-definition --jsonand verifies readiness/version/build identity. Updater-stopped recovery does not require the helper-only parked systemd generation. History records rollback, success with recovery, or failure with repair/deep-status guidance.Repair reclaims promptly only when the recorded owners are proven dead; live/unknown owners and descendant/runtime-holder fences remain. After finalization, it uses the same stop evidence to start and verify an update-stopped service while preserving later operator stops.
Rejected alternatives: treating a signal as an unrecoverable result; inferring restart permission solely from an inactive unit; requiring a new native-stop receipt from an older installed driver; importing bookkeeping from the package while it is being swapped; and adding a second helper/repair stop policy. The combined change retains one publication owner and one stop-evidence reader.
LOC against base
4daeb9252ce: production +800/−235; tests/support +764/−73; docs +76/−12; total +1640/−320 across 39 files. The required growth covers sealed crash recovery, standalone service restoration, and their boundary proof. Simplification removed the repair-only stop inference and reuses existing durable handoff evidence.Evidence
cc34e4ae6ea, five helper regressions, two repair regressions, and two compaction regressions failed. Native-stop fixtures include the real entry point's initialserviceRunning: truesnapshot. The base reproduced the old no-verified-result branch and the missing installed-runtime failure during publication. Production was restored with SHA-256 verification; all corresponding tests pass on this change. A separate interim run also proved that the initial running snapshot suppressed recovery before its fix (three helper and two repair failures).oxfmt --check,oxlint, line-cap ratchet, andgit diff --checkpassed for the changed files.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfostops before source checking withDeclaration input escapes checkoutfortsrsin the prescribed external pnpm virtual store. The checkout containment guard was preserved; this is not a passing typecheck.4daeb9252cefinishedscoped-clean(P0–P2), with no accepted/actionable findings. A fresh final pass included the termination-harness fix.Focused test command
The termination file was rerun with the same runner after fixing its stale lookup. The existing manager/lifecycle suites exercise process startup, publication, cancellation, and lease custody and take longer than unit-only tests.
The helper boundary uses real SIGKILL children, package publication journals, ledger writes, and native lease custody, with synthetic native-manager/readiness/finalizer I/O. The repair boundary runs the registered CLI with real ledger and dead-handoff reclamation. This is not a fresh live Linux/systemd upgrade result; the AWS reproduction still needs to be rerun against this head.