Repository navigation
fix: recover managed Gateways after updates and repairs - #159577
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 real behavior proof before merge. Reviewed September 27, 2026, 9:17 PM ET / September 28, 2026, 01:17 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch lets update recovery reload collected systemd unit metadata and lets standalone Doctor start and verify an owned Gateway that was stopped before repair; it also updates recovery docs and live-test routing. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 9 items remain Current main still leaves an already-stopped Gateway stopped after Doctor repair, so this PR addresses a real recovery gap. The previous P1 finding remains: the new activation path can start that service when final launcher inspection is inconclusive. The change to Doctor’s documented stopped-service behavior also needs a product decision. Priority: P0 Review scores
Verification
How this fits togetherThe updater and Doctor inspect an installed Gateway service before repairing packages or state. Their service-maintenance path decides whether the native service manager may stop, refresh, or start that Gateway, then checks readiness. flowchart LR
A[Update or Doctor repair] --> B[Installed Gateway service]
B --> C[Inspect manager and launcher]
C --> D{Current ownership verified?}
D -->|Yes| E[Native service activation]
D -->|No| F[Refusal and recovery guidance]
E --> G[Gateway readiness check]
Decision needed
Why: Current documentation and the linked recovery request preserve Doctor's stopped-service behavior, while this PR deliberately changes that default; code safety alone cannot choose the operator contract. Before merge
Findings
Agent review detailsSecurityNeeds attention: The new Doctor activation path can reach native start without a conclusive final check of the service launcher. PR surfaceSource +34, Tests +202, Docs +5, Other +10. Total +251 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep update recovery in the existing service-maintenance owner, require a verified current launcher before activating a previously stopped service, and give intentional stops an explicit recovery path. Do we have a high-confidence way to reproduce the issue? Yes, from source: take the introduced standalone Doctor path for an initially stopped owned service, then make final service inspection inconclusive. This reviewer did not execute that path. Is this the best way to solve the issue? No, not yet. Reusing restoration is appropriate for a service Doctor stopped, but an already-stopped service needs final launcher verification before activation and an agreed default for intentional stops. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6ae3331e0da3. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What 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 (4 earlier review cycles)
|
28ed016 to
5d26c38
Compare
Include src/commands live tests alongside the CLI update proofs in the existing native-live-src-infra release shard. Extend the routing fixture while preserving full-inventory coverage and provider-filtered fanout assertions. This is required live-shard inventory maintenance, not a baseline edit to silence a check. Validation: reproduced the missing Doctor file before the fix; test-live-shard passed 36 tests on each of three local runs (1.03s, 1.06s, 0.89s test time). Full check-changed and 551 package-acceptance-workflow tests passed on Testbox tbx_01m3jmz9qh20mefc5tw4yhmvgr (run 36360539165). Fresh P1 autoreview was clean.
abc386e to
893ab24
Compare
) * fix: recover managed Gateways after updates and repairs * refactor(update): simplify service inspection diagnostic * fix(test): route Doctor live proofs into the infra shard Include src/commands live tests alongside the CLI update proofs in the existing native-live-src-infra release shard. Extend the routing fixture while preserving full-inventory coverage and provider-filtered fanout assertions. This is required live-shard inventory maintenance, not a baseline edit to silence a check. Validation: reproduced the missing Doctor file before the fix; test-live-shard passed 36 tests on each of three local runs (1.03s, 1.06s, 0.89s test time). Full check-changed and 551 package-acceptance-workflow tests passed on Testbox tbx_01m3jmz9qh20mefc5tw4yhmvgr (run 36360539165). Fresh P1 autoreview was clean.
…tion (#160083) Classify fresh inspection before service-config repair and again before activation. Initially stopped Gateways remain untouched on inconclusive inspection, while Doctor-owned stops retain best-effort restoration and verified running services retain health checks. Refs #159577. Pre-fix controls reproduced unwanted starts/restarts. Final owner suite passed 3x locally; 32 importer files and the five-suite 3x matrix passed on Testbox tbx_01m3jx5am10xv49bp07664y9an. Final check-changed and direct-route P1 autoreview passed.
…tion (openclaw#160083) Classify fresh inspection before service-config repair and again before activation. Initially stopped Gateways remain untouched on inconclusive inspection, while Doctor-owned stops retain best-effort restoration and verified running services retain health checks. Refs openclaw#159577. Pre-fix controls reproduced unwanted starts/restarts. Final owner suite passed 3x locally; 32 importer files and the five-suite 3x matrix passed on Testbox tbx_01m3jx5am10xv49bp07664y9an. Final check-changed and direct-route P1 autoreview passed.
Closes #157205
Closes #157227
Closes #147357
What Problem This Solves
Updates and repairs could reject a stopped systemd unit as an ownership change and leave the Gateway down; standalone Doctor could finish repairing an already-stopped Gateway without starting it.
User Impact
Managed Gateways can recover after failed updates and repairs, including restarting the previous installation after rollback. Git-to-npm updates refresh the service to use the new installation. Successful standalone
doctor --fixalso starts and verifies an already-stopped, owned Gateway targeting the current installation.Ownership, current-authority, installation-drift, and data-safety checks remain enforced. Update-time Doctor leaves activation with its updater.
Why This Change Was Made
systemd can collect an inactive unit while its installed definition remains intact. Requiring an already-loaded command then failed before the updater could refresh the launcher or recover the previous service. The update service-inspection owner now uses its retained manager identity and current native/caller authority to reload unit metadata. Restart preparation, failure recovery, and rollback share that operation. Doctor reuses its existing restoration and readiness owner for a successfully repaired, previously stopped service.
The three expensive legacy-driver cases now use the existing opt-in live tier, collected by
vitest.live.config.tsandpnpm test:all. Their shared assertions are preserved; the remaining 14 cases run in ordinary PR CI. No new test tier or configuration was introduced.Thanks @Matuno, @DonnieFi, and @Navras98 for the reports.
Evidence
test/scripts/test-install-sh-docker.test.tsstill searches the parent Bun script forassert-release-versionsafter chore(ci): catch Node spawns in Bun-only installs #159439 moved it intoai-candidate.sh; main hourly 23:29Z is red, and the main fix is being handled separately.tbx_01m3h629kk0gt58ma1a91vtr5t; the remote batch exited 0 in 43m52s. Four helper-registered suites completed their third run separately: helper-suite run, leasetbx_01m3h986hp632w156vj32cny3c.node scripts/check-changed.mjspassed, including core/test/script typechecks, lint, dead exports, and guards. Final check run, leasetbx_01m3h628mggyktvtspy6df0bc6; final command exited 0 in 22m49s. The linked runs identify Testbox leases; command exit codes establish the proof result.Real Linux systemd user-service proof used isolated profiles and free ports:
doctor-failed; original package hashes and running PID preserved; readiness truesucceeded; new package serving; readiness trueExecStartand live PID target the new npm installation; channel persisted as stable; readiness trueComplete rebased live matrix, lease
tbx_01m3h628bhvj40km01an7ynag8; package preparation and all service cells exited 0 in 21m31s. Rollback verified exact prior serving-launcher, package manifest, build identity, and runtime-inventory hashes. Detached update handoffs were joined through their recorded terminal outcome and settled driver identities.The pending-plugin proof uses a synthetic installed plugin exercising the actual install-record deferral contract, with one injected Doctor read stall. The activation fault is restricted to the native serving command. These prove service availability; they do not claim completion of Google Chat-specific data migration.
Test cost and change size
The combined 17-case refusal file previously took 125.908 / 132.830 / 127.703 seconds of test time. After separating the existing live contracts:
The table records isolated one-worker runs through the repository test wrapper. The rebased validation repeated the split suites; its live-case test totals were 73.839 / 69.368 / 68.815s (94.41 / 86.79 / 87.64s file wall). Shared compiler/runtime preparation is separate. The change also removes a duplicate 31-second delayed probe, checks the caller's actual timeout budget at the runner boundary, and shares read-only inspection workers for the original-service fixture. No retries, weakened assertions, or increased timeouts were introduced.
The additional CI-planner importers exercise complete repository plans; their slowest observed case was 85.211s. Those suites already belong to the existing release-only tooling tier and passed unchanged.
Production: +55/−21 (net +34), reduced from +52 by centralizing repeated missing-manager checks and combining a redundant diagnostic-string concatenation without changing its text. Test routing: +6/−1. Tests/support: +606/−405, including the moved legacy-driver matrix. Docs: +12/−7.