Repository navigation
fix(update): recover Gateway after failed activation - #164497
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: blocked before merge. Reviewed October 3, 2026, 10:26 PM ET / October 4, 2026, 02:26 UTC (Revision 13). ClawSweeper reviewWhat this changesThe branch backports recovery that settles Doctor subprocesses, restores compatible package and database state, completes pending migrations, and records Gateway recovery outcomes. Merge readiness⛔ Blocked before merge - 4 items remain Keep open: this member-authored release backport remains useful despite the upstream fixes on main. No concrete patch defect was established, but retained-state compatibility and explicitly excluded production validation remain unresolved. Priority: P1 Review scores
Verification
How this fits togetherThe managed updater coordinates package activation, Doctor repairs, database backups, and Gateway restart. Recovery selects a compatible runtime while preserving later writes and the original update failure. flowchart TD
A[Managed update request] --> B[Package activation]
B --> C[Doctor and child writers]
C --> D[Writer settlement]
D --> E[Database compatibility decision]
E --> F[Restore previous runtime]
E --> G[Repair preserved candidate]
F --> H[Verified Gateway and recorded outcome]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the existing recovery owners, verify preserved-state compatibility, and keep canonical final-candidate Full Release Validation as the publication gate. Do we have a high-confidence way to reproduce the issue? Yes, for the release baseline: activation Doctor failure after a managed stop, surviving writers, or unfinished agent migrations can prevent recovery. Source and upstream evidence support that path; this review did not execute the candidate. Is this the best way to solve the issue? Yes, backporting the existing recovery owners is a coherent repair; retained-state qualification and the explicitly uncovered production changes still need validation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1836ae214644. 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 (12 earlier review cycles; latest 8 shown)
|
791ca83 to
846b3b2
Compare
#162614) Doctor left its child writers (spawn-broker process groups) without durable custody, so an update that found an unsettled writer could neither prove settlement nor safely start the migrated candidate, and an operator could be left with a down Gateway. The update command owner now reserves custody before spawning, binds native process identity before admitting input, retains its inventory through Doctor death, and admits migrated-candidate Gateway recovery only after proven writer settlement; unverified writers keep the data-at-risk refusal with PID guidance. Recovery snapshot capture drains SQLite writers first so a refused candidate start still rolls back. The immutable 2026.9.5 parent limitation is documented. Closes #162055 (cherry picked from commit 8f364a7)
…deliver update outcomes durably (#163803) A 2026.9.5 to 9.7 managed update whose activation Doctor failed left the candidate package active with the agent databases on the old schema; the new Gateway exited 78 and systemd parked on RestartPreventExitStatus=78, and the failure notice depended on the Gateway the update had just stopped, so the operator saw nothing for 3.5 hours (#163638). A Gateway that finds the updater own unfinished agent migration at start now runs the candidate Doctor before its recovery restart, reinspects schemas, and records explicit recovery guidance when a mismatch remains; managed-update outcomes are delivered durably from the next Gateway start. The pre-migration backup stays on disk for manual restore; a successful live migration remains the point of no return (repair forward, never roll databases back). Thanks @chffhc for the timeline. Closes #163638 (cherry picked from commit b379364)
846b3b2 to
ee2b5b7
Compare
8f364a7 (#162614) made exec-spawn import custody types from a module that imports its cleanup constant back from exec-spawn. The runtime-only cycle check passed, but Madge rejected the type/value dependency cycle. Move the unchanged custody and identity types into a dependency-free leaf and migrate all type consumers. Preserve settlement behavior, timing, authority checks, and assertions. Also fix the touched Doctor fixture's existing shadowed parameter and inconsistent return syntax without changing its behavior. Validation: full check:architecture (zero cycles), source-contracts lane, deadcode export scans, check-changed, scoped and boundary lint, and P2 review. Static proof ran locally as authorized for this main repair. (cherry picked from commit 0f470ae)
…ness deadline (#163610) update-command-doctor-delegation flaked on main hourlies (3 cases, 37020939466): source loading exhausted the fixture deadline before the standalone Doctor writer reached readiness, so the settle-after-reject assertion observed a null record. Production already awaits custody settlement; the shared compiled-fixture owner now supplies every import up front. Test-support only. Refs #162614 (cherry picked from commit 8bb49fa)
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Related: #164066
Parent #164554 merged to
release/2026.9.9asd7e86e66e447.What Problem This Solves
Fixes: a genuine activation Doctor or unfinished-migration failure can leave the managed Gateway offline after an update.
User Impact
After the parent PR prevents the known false refusal, failed activation can restore the appropriate runtime, settle Doctor-owned writers, finish pending migrations when safe, and durably deliver the recovery outcome.
Why This Change Was Made
This is the second layer of the release backport. It carries the remaining recovery portion of #160671, then the writer-custody prerequisite from #162614 and pending-migration/outcome repair from #163803. The release-specific adaptation preserves the 2026.9.9 branch's synchronous display-progress contract instead of importing adjacent main-only refactors.
The merged parent PR owns the narrow requester-authority false-refusal fix. This layer remains large because generic recovery must keep package source, database generations, Doctor process groups, and the restarted Gateway runtime mutually compatible.
Evidence
d73af7ce9cf27e6278c9e26aa970633475b86ddb.runExec, and drive Doctor failures and observations through the UTF-8 process-custody transport. Unrelated UTF-8 subprocesses retain the real transport.env OPENCLAW_VITEST_WORKER_CACHE=0 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-pr164497-followup-cache node scripts/run-vitest.mjs src/cli/update-cli.fresh-doctor.test.ts --maxWorkers=1 -t 'records diagnostics as a warning|keeps an invalid config authoritative'— 2 tests passed, 15 skipped; 94.2s wall including worker preparation.node --experimental-vm-modules --test scripts/tests/update-restart-module-outcome.mjs— 19/19 tests passed in 2.95s wall.already-currentDoctor case passed locally at332cb0586da; the run was stopped after that affected case rather than spending wall time on unrelated cases.pnpm exec oxfmt --writeandgit diff --checkpassed for the changed fixture files.pnpm exec oxlint src/cli/update-cli.deferred-completion.test.tspassed after the immutable-sort correction.0030b6960a0..e4716dcb7ef: clean (0.82 confidence).git diff --checkpass for the finalizer fixture cutover.72043c07fb3..d73af7ce9cf: clean (0.81 confidence).pnpm buildand 65 focused recovery tests were recorded against production head791ca83656bba61f01001dc36be1607b1b10ee4d; the 29-test settlement suite passed after its fixture correction. That evidence does not claim coverage for the later database-identity projection or interrupted-Doctor settlement guard.Review Status
d73af7ce9cf27e6278c9e26aa970633475b86ddb.