fix(doctor): prevent non-interactive --fix from auto-restarting gateway#94148
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 22, 2026, 3:43 AM ET / 07:43 UTC. Summary PR surface: Source +4, Tests +33. Total +37 across 2 files. Reproducibility: yes. source-level: current main can reach the running-service restart prompt after a failed Gateway health/probe path, and Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow lifecycle split after maintainers accept that headless doctor repair may start stopped services but must not implicitly restart an already-running Gateway. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main can reach the running-service restart prompt after a failed Gateway health/probe path, and Is this the best way to solve the issue? Yes for implementation shape: the PR fixes the implicated owner path in AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f9ebb8d91bea. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +33. Total +37 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
15fac61 to
3f01d5a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
82d5728 to
d4a539f
Compare
|
Land-ready maintainer verification:
Known gaps: issue #78217 also describes timeout/port diagnostics outside this PR's self-restart fix. |
b3f23b2 to
e360313
Compare
Mark gateway service start/restart lifecycle prompts as requiring interactive confirmation, so `doctor --fix --non-interactive` skips them instead of auto-approving via shouldAutoApproveDoctorFix. Previously, a transient gateway health probe timeout would cause the non-interactive repair path to auto-approve `service.restart()`, which could SIGTERM a running gateway.
e360313 to
60d9d1c
Compare
|
Merged via squash.
Thanks @zhangguiping-xydt! |
…ay (openclaw#94148) Merged via squash. Prepared head SHA: 60d9d1c Co-authored-by: zhangguiping-xydt <[email protected]> Co-authored-by: steipete <[email protected]> Reviewed-by: @steipete
Summary
What problem does this PR solve?
doctor --fix --non-interactiveneeded to stop auto-restarting an already-running gateway after a transient health/probe failure, but the earlier PR branch also made loaded-but-stopped gateway services stop auto-starting. Root cause: the stopped-service start prompt was marked interactive-only, soDoctorPrompter.confirmRuntimeRepaircould no longer auto-approve that repair in normal non-interactive--fixmode.Why does this matter now?
Cron, launchd, systemd timer, and other unattended doctor runs rely on stopped-service repair for gateway self-healing. Keeping restart blocked for a running service is the safety fix; blocking start for an actually stopped service removes the recovery behavior that
--fix --non-interactiveis supposed to provide.What is the intended outcome?
This is a root-cause lifecycle-scoping fix: the already-running restart path remains interactive-only, while the stopped-service start path again follows the existing non-interactive repair auto-approval policy. The source-of-truth boundary is the internal gateway daemon repair flow plus
DoctorPrompterrepair-mode policy; this PR does not change any public API, user config, schema, protocol, migration, or provider contract.What is intentionally out of scope?
Gateway install policy, external supervisor policy, update-in-progress repairs, restart-handoff behavior, LaunchAgent/bootstrap handling, port/probe diagnostics, and any public contract/default changes are intentionally out of scope. Related PR scan: this is an update to existing PR #94148 for issue #78217, not a new competing contract or compatibility PR.
What does success look like?
A running but temporarily unhealthy gateway is not restarted by
doctor --fix --non-interactive, and a loaded but stopped gateway still reaches the start repair path under the same command.What should reviewers focus on?
Reviewers should focus on the lifecycle split in
maybeRepairGatewayDaemon: stopped-service start repair should be auto-approved by normal non-interactive--fix, while running-service restart repair should require interactive confirmation.Linked context
Which issue does this close?
Closes #78217
Which issues, PRs, or discussions are related?
Related: #94148 existing review noted that the previous patch over-broadened the non-interactive lifecycle skip by covering stopped-service starts.
Was this requested by a maintainer or owner?
No direct maintainer request; this update addresses the review concern on the existing PR branch.
Real behavior proof (required for external PRs)
doctor --fix --non-interactiveshould not restart an already-running gateway service after a transient health/probe failure, while stopped gateway services continue through the normal start-repair path described in the validation section.10b5073.doctor --fix --non-interactive, and the doctor command completed without restarting that service.expected "vi.fn()" to be called 1 times, but got 0 times, proving the earlier patch skipped stopped-service starts.Tests and validation
Which commands did you run?
What regression coverage was added or updated?
service.restart()once whenserviceRuntime.statusis stopped.What failed before this fix, if known?
If no test was added, why not?
A regression test was updated for the stopped-service branch and kept alongside the existing running-service restart guardrail.
Risk checklist
Did user-visible behavior change? (
Yes/No)Yes.
doctor --fix --non-interactiveagain auto-starts a loaded but stopped gateway service, while still refusing to auto-restart a running gateway service.Did config, environment, or migration behavior change? (
Yes/No)No.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)No.
What is the highest-risk area?
Gateway service lifecycle semantics in non-interactive repair mode.
How is that risk mitigated?
The fix only removes the interactive-only flag from the stopped-service start prompt; the running-service restart prompt remains interactive-only. Regression tests cover both branches directly, and live proof shows a running gateway keeps the same PID across
doctor --fix --non-interactive.Current review state
What is the next action?
Ready for maintainer review after this PR branch update settles.
What is still waiting on author, maintainer, CI, or external proof?
No known author-side code changes remain. Remote CI and hosted ClawSweeper will need to run on the pushed head.
Which bot or reviewer comments were addressed?
10b5073reportedNothing found.