Skip to content

fix(doctor): activate a stopped Gateway only on a positive ownership verdict - #160083

Merged
steipete merged 6 commits into
mainfrom
fix/doctor-positive-stopped-gateway-verdict
Sep 29, 2026
Merged

steipete merged 6 commits into
mainfrom
fix/doctor-positive-stopped-gateway-verdict

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Refs #159577

What Problem This Solves

Doctor could start a Gateway that was already stopped when its final service inspection failed, timed out, or could not verify the launcher.

User Impact

An already-stopped Gateway activates only after a positive, current ownership and offline verdict for the current installation. Ambiguous inspection leaves activation skipped and records the reason with openclaw gateway status --deep guidance. Recovery of a Gateway Doctor itself stopped remains best effort, and update-time Doctor still leaves activation with the updater.

Why This Change Was Made

The restoration owner previously retained the earlier ownership verdict after an inconclusive final probe and used its recovery fallback to start the service. It now classifies stopped-service inspection as owned-offline, not-ours, or inconclusive; only the positive outcome admits activation. Strict ownership revalidation and the canonical platform offline check run before service-config repair and after its second inspection. A contradictory running indicator blocks activation. A service that repair already started still receives health verification.

This follows up on ClawSweeper's finding. No configuration, schema, dependency, or timeout changes.

Evidence

  • Pre-fix controls through the real Doctor flow with a synthetic service adapter recorded repair, start after failed/timed-out launcher probes, unknown runtime, and unavailable launcher inspection. Post-config-repair controls also reproduced restart on unknown runtime/load state. The fixed controls reject those effects and preserve successful activation/readiness behavior.
  • The final seven-case owner suite passed three times locally: 1.224 / 0.583 / 1.561 seconds of test time (96.96 / 24.67 / 23.27 seconds file wall; shared compiler preparation dominates).
  • All 32 direct/importing sibling files passed on the Linux Testbox. Five selected suites then passed three times on the final tree, 76 tests per run, including existing Doctor-owned restoration controls and the managed flow matrix.
  • Final node scripts/check-changed.mjs passed all selected checks, including core/test typechecks, lint, dead exports, and guards. The final Testbox command exited 0 in 35m34.66s.
  • Fresh isolated direct-route Codex review at P1: scoped-clean after adding the running-indicator guard and regression.

Testbox run, provider blacksmith-testbox, lease tbx_01m3jx5am10xv49bp07664y9an. The tested tree is e3879e3ba8f1d32c1ddefd0dfd52ea227e070697.

The managed-admission suite also passed three local runs. The heavier settlement sibling hit its existing 120-second per-test limit on this Mac in ready and store-close-failed; the remaining heavy repetitions ran on the Testbox. These managed-flow suites already use the release-only runtime tier. A temporary spy-through profile of clean-repair measured 82 content-version child launches plus 6 snapshot launches consuming 16.5 of 26.9 test seconds. The synchronous SQLite freshness-reader cost remains a performance follow-up; the remote passes are additional evidence, not a claim that the local timeout was fixed. No retries, larger timeouts, or weaker assertions were added.

Production: +121/−48 (net +73); tests/support: +123/−4; docs: +5/−1. Growth covers the closed inspection outcome, shared inspection handling, and both activation gates while retaining Doctor-owned recovery.

…tion

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.
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 04:02
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 29, 2026, 5:28 AM ET / 09:28 UTC (Revision 6).

ClawSweeper review

What this changes

Doctor now starts an already-stopped Gateway only after fresh inspection verifies ownership and offline state, and adds recovery guidance and fault-case tests.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep open. Current main still starts a managed Gateway after an inconclusive Doctor restoration inspection, so this follow-up remains useful. Native authority proof and acceptance of the changed recovery behavior remain unresolved.

Priority: P1
Reviewed head: 1295ee66d75956dbad595587cac6aa3c8aab70ae
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused source change and synthetic regressions are useful, but native authority and upgrade outcomes remain unproven.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Authority-chain proof required: The changed Doctor restoration owner is exercised through synthetic service adapters, and the Testbox-tested production blob matches this head, but no native final-I/O trace shows owned activation and rejection of a launcher replaced after inspection. A published-updater/candidate recovery observation is also absent. No stored-data format or schema changes. Redact private paths, addresses, and credentials from terminal evidence; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Authority-chain proof required: The changed Doctor restoration owner is exercised through synthetic service adapters, and the Testbox-tested production blob matches this head, but no native final-I/O trace shows owned activation and rejection of a launcher replaced after inspection. A published-updater/candidate recovery observation is also absent. No stored-data format or schema changes. Redact private paths, addresses, and credentials from terminal evidence; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 10 items Introduced activation gate: The PR classifies an initially stopped service as owned and offline, not ours, or inconclusive; only the positive verdict proceeds.
Current-main need: Main records an inconclusive final inspection but then selects service.start, which can activate an already-stopped Gateway.
Final native boundary: After Doctor's new verdict, restoration calls the platform start or restart operation. The systemd action rechecks manager, unit path, and account identity before I/O, but that check does not compare the effective launcher command.
Findings None None.
Security Needs attention Unverified replaced-launcher rejection: A positive Doctor verdict precedes the service-manager action. Systemd rechecks manager and unit identity, but not the effective launcher command, so the nearest forbidden final effect remains unproven.

How this fits together

Doctor repairs OpenClaw state and may restore a managed Gateway afterward. It inspects the service, may repair its definition, then asks the platform service manager to activate it and checks readiness.

flowchart LR
A[Doctor repair] --> B[Service inspection]
B --> C[Ownership and offline verdict]
C --> D{Activation allowed?}
D -->|Yes| E[Native service action]
D -->|No| F[Recovery warning]
E --> G[Readiness check]
Loading

Decision needed

Question Recommendation
Should standalone Doctor leave an already-stopped managed Gateway offline when its final ownership inspection is inconclusive? Keep the strict default: Accept the offline outcome after native authority and published-updater recovery proof establishes its practical impact.

Why: The PR intentionally trades automatic recovery for a stronger activation boundary; accepting the resulting operator impact requires maintainer intent and upgrade evidence.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Authority-chain proof required: The changed Doctor restoration owner is exercised through synthetic service adapters, and the Testbox-tested production blob matches this head, but no native final-I/O trace shows owned activation and rejection of a launcher replaced after inspection. A published-updater/candidate recovery observation is also absent. No stored-data format or schema changes. Redact private paths, addresses, and credentials from terminal evidence; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security concern: Unverified replaced-launcher rejection - A positive Doctor verdict precedes the service-manager action. Systemd rechecks manager and unit identity, but not the effective launcher command, so the nearest forbidden final effect remains unproven.
  • Resolve merge risk (P1) - Doctor's positive launcher verdict precedes native activation. The systemd final check verifies service identity but does not re-pin the effective command, and rejection of a launcher replaced after inspection has not been observed at final I/O.
  • Resolve merge risk (P1) - An inconclusive inspection now leaves an already-stopped Gateway offline. The recovery outcome with a published updater running the candidate Doctor has not been shown, and the operator may need command-line recovery.
  • Complete next step (P2) - Add redacted native final-effect and published-updater/candidate recovery evidence, then obtain maintainer acceptance of the changed offline outcome.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [medium] Unverified replaced-launcher rejection — src/commands/doctor-maintenance-restoration.ts:150
Agent review details

Security

Needs attention: Native activation still lacks demonstrated rejection of a launcher replaced after Doctor's verdict; the diff adds no supply-chain dependency.

PR surface

Source +73, Tests +119, Docs +4. Total +196 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 121 48 +73
Tests 3 123 4 +119
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 249 53 +196

Review metrics

Metric Value Why it matters
Inspection gates and growth 2 activation gates; production net +73, tests net +119 The stated production growth serves both pre-repair and post-repair decisions, while the added tests cover synthetic fault paths.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-maintenance-restoration.ts, unknown-data-model-change: src/commands/doctor-maintenance-restoration.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove native and upgrade outcomes (recommended)
    Capture redacted allowed and replaced-launcher final effects, then show a published-updater run with the candidate Doctor and an inconclusive inspection.
  2. Pause for boundary repair
    Keep the PR open if final-effect proof exposes an authority gap or the upgrade recovery outcome cannot be established safely.

Technical review

Best possible solution:

Keep Doctor's positive-verdict gate in its restoration owner, bind the verified launcher to the final native effect, and leave clear recovery guidance when authority cannot be established.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main records an inconclusive restoration inspection and then calls the service start fallback. This read-only review did not run a native reproduction.

Is this the best way to solve the issue?

Unclear pending native final-effect proof. Doctor restoration is the narrow owner for the gate, but the final service action must still honor the verified launcher.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c82063902aa1.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The PR addresses unsafe activation in Doctor's managed-Gateway recovery workflow.
  • merge-risk: 🚨 compatibility: An inconclusive final inspection changes standalone Doctor from attempting activation to leaving an already-stopped service offline.
  • merge-risk: 🚨 security-boundary: The changed ownership verdict controls native activation, but final-I/O rejection after launcher replacement remains unproven.
  • merge-risk: 🚨 availability: Failing closed may leave a Gateway offline after repair, and the published-updater recovery outcome has not been observed.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Authority-chain proof required: The changed Doctor restoration owner is exercised through synthetic service adapters, and the Testbox-tested production blob matches this head, but no native final-I/O trace shows owned activation and rejection of a launcher replaced after inspection. A published-updater/candidate recovery observation is also absent. No stored-data format or schema changes. Redact private paths, addresses, and credentials from terminal evidence; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Unverified replaced-launcher rejection — src/commands/doctor-maintenance-restoration.ts:150
    A positive Doctor verdict precedes the service-manager action. Systemd rechecks manager and unit identity, but not the effective launcher command, so the nearest forbidden final effect remains unproven.
    Confidence: 0.84

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Sebastien Tardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record redacted native Doctor final effects for owned activation and a launcher replaced after inspection.
  • Show the published-updater/candidate Doctor outcome when final inspection is inconclusive.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-28T04:09:58.316Z sha 683fe9e :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T08:37:23.951Z sha 5fb4fc2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T12:08:12.179Z sha 60f7d67 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T14:44:57.391Z sha b654764 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T04:31:54.637Z sha 93eff00 :: needs real behavior proof before merge. :: none

@steipete
steipete enabled auto-merge (squash) September 28, 2026 04:27
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 28, 2026
@steipete
steipete merged commit 1eded52 into main Sep 29, 2026
221 checks passed
@steipete
steipete deleted the fix/doctor-positive-stopped-gateway-verdict branch September 29, 2026 09:45
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant