Skip to content

fix: doctor skips host services for isolated state - #115922

Merged
steipete merged 5 commits into
mainfrom
fix/doctor-host-service-isolation
Jul 29, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/doctor-host-service-isolation

Conversation

@steipete

@steipete steipete commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a critical isolation issue where running openclaw doctor --fix against a copied install with non-default state/config paths could inspect, stop, rewrite, and re-bootstrap the operator's real host Gateway service. The rewritten service could then point at temporary wrapper and credential-bearing environment files, interrupting the live listener and coupling the host service to copied state.

The same stress run also found that a copied auth-profile row referencing an omitted SecretRef provider prevented isolated Gateway startup even though the owning account was identifiable.

Why This Change Was Made

Host launchd/systemd/Scheduled Task management now belongs only to the OS account's default OpenClaw install identity. A single path predicate compares the active state and config against the canonical account home; doctor skips all service inspection/repair for non-default identities with an explicit diagnostic, while shared service mutation guards prevent install and start-repair paths from bypassing the boundary. There is no force override.

For copied auth rows, the missing provider now has its own typed resolution code. Only persisted auth-store assignments with a known account owner may start configured-unavailable; config-owned missing providers, source mismatches, invalid refs, and unknown owners remain fail-closed.

This change is AI-assisted and was reviewed with the repository autoreview workflow until no accepted/actionable findings remained.

User Impact

Operators can run doctor against copied or otherwise isolated state without risking changes to the host's managed Gateway service. Default-install doctor and service commands retain their existing management behavior.

Gateways with stale copied auth rows now reach readiness with the exact account marked configured-unavailable and a typed redacted diagnostic, instead of failing the entire startup. Requests targeting that account still fail before provider dispatch.

Evidence

  • Focused post-rebase proof: 283 tests passed across path identity, daemon service, doctor service flows, install/start repair, SecretRef resolution, and real Gateway startup shards.
  • Final rebase sanity: 46 focused tests passed across the isolation predicate, doctor service seam, copied auth-store resolution, and /readyz Gateway startup.
  • node scripts/check-changed.mjs -- <23 touched files> passed on Blacksmith Testbox tbx_01kyq0xf8zc1x5trn8jxfvyq9b in 8m14s, including core/core-test typechecks, changed lint, formatting, import cycles, database-first guards, and boundary checks: https://github.com/openclaw/openclaw/actions/runs/30456065301
  • Real after-fix CLI proof used a brand-new /tmp state/config identity and a non-default Gateway port. Redacted result: doctor_exit=0, skip_message_seen=true, plist_unchanged=true, listener_unchanged=true. The minimal fixture was moved to Trash after the run.
  • Required exact-head CI is green for c5ef839bb79a46e46e27dbd10ce4f9e0466e16ff: https://github.com/openclaw/openclaw/actions/runs/30462097997
  • Autoreview accepted and fixed the HOME/OPENCLAW_HOME identity bypass and incomplete recovery guidance; the final review reported no accepted/actionable findings.
  • git diff --check passed.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: M labels Jul 29, 2026
@steipete
steipete marked this pull request as ready for review July 29, 2026 13:46
@steipete
steipete requested a review from a team as a code owner July 29, 2026 13:46
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Jul 29, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 11:05 AM ET / 15:05 UTC.

ClawSweeper review

What this changes

The branch makes Doctor and daemon service management skip copied or otherwise non-default OpenClaw state/config identities, while allowing a known copied auth-store account with an omitted SecretRef provider to start as configured-unavailable instead of aborting Gateway startup.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal maintainer handling. The focused patch appears correct: it puts the copied-install boundary ahead of Doctor service inspection and shared daemon mutation, and the copied-auth exception stays limited to persisted known-owner assignments. The contributor’s updated PR body and follow-up comment provide redacted after-fix CLI results plus real Gateway-readiness coverage, so the prior proof blocker is cleared; the remaining compatibility and auth-provider behavior is explicitly accepted in the supplied maintainer work order.

Priority: P1
Reviewed head: c5ef839bb79a46e46e27dbd10ce4f9e0466e16ff

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered repair with real after-fix operator evidence; normal maintainer merge review remains appropriate because it deliberately changes service and auth-provider compatibility behavior.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.
Evidence reviewed 5 items Service-boundary coverage: The branch introduces one default-install identity predicate and uses it both before Doctor Gateway service work and inside the shared assertion used by daemon install/start-repair paths, covering diagnostic and mutation seams rather than only one caller.
Host-service mutation guard: The shared Gateway-supervision assertion rejects non-default state/config identities with recovery guidance, while the Doctor flows return before service inspection or rewrite work.
Auth degradation stays narrow: The new not-configured provider code is mapped to configured-unavailable only for auth-store assignments with an identified owner; the PR’s tests cover copied-store readiness and provider dispatch remaining blocked for the unavailable account.
Findings None None.
Security None None.

How this fits together

Doctor health flows inspect, repair, install, and restart the local Gateway’s OS-managed service; this patch prevents an isolated copy from modifying that host-level service. During Gateway startup, secrets runtime resolves persisted auth profiles, so the patch also determines when a missing provider degrades one stored account rather than preventing readiness for the entire Gateway.

flowchart LR
  A[Copied state or config] --> B[Install identity check]
  B -->|Default identity| C[Doctor and daemon service flows]
  B -->|Isolated identity| D[Show skip diagnostic]
  D --> E[Leave host service untouched]
  F[Persisted copied auth profile] --> G[Secret provider resolution]
  G -->|Known stored owner unavailable| H[Gateway ready with unavailable account]
  G -->|Other invalid or unknown input| I[Fail closed before dispatch]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally changes existing non-default state/config installations from being able to inspect, install, repair, or restart native Gateway services to receiving a skip diagnostic; maintainers should land only the reviewed merge result and retain the explicit default-install ownership rule.
  • Resolve merge risk (P1) - A persisted copied auth-store profile with an omitted provider now permits Gateway readiness as an unavailable account; the source/owner restrictions are tested, but this remains a compatibility-sensitive provider-startup policy.
  • Complete next step (P2) - The patch has no discrete automated repair finding, but the protected maintainer label and intentional compatibility policy require a maintainer to approve the refreshed merge result.
Agent review details

Security

None.

PR surface

Source +127, Tests +293. Total +420 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 13 147 20 +127
Tests 14 295 2 +293
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 442 22 +420

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/daemon-cli/start-repair.ts, migration/backfill/repair: src/commands/doctor-gateway-services.test.ts, migration/backfill/repair: src/commands/doctor-update.test.ts, migration/backfill/repair: src/flows/doctor-health-contributions.test.ts, unknown-data-model-change: src/commands/doctor-gateway-daemon-flow.test.ts, unknown-data-model-change: src/commands/doctor-gateway-services.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh the exact merge result (recommended)
    Rebase or otherwise refresh this clean-but-behind branch, then require the normal exact-head checks so the accepted isolation rule is evaluated with current main.
  2. Accept the explicit policy change
    Maintainers may land the reviewed boundary knowing that isolated state/config identities no longer manage the OS account’s native Gateway service and known copied auth-store owners may start unavailable.

Technical review

Best possible solution:

Land the single install-identity policy only after refreshing the branch against current main and confirming the exact merge-result checks; preserve fail-closed handling for config-owned, invalid, mismatched, and unknown-owner SecretRef failures.

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

Yes for source reproduction: copied state/config overrides reach the Doctor and daemon service seams, while the proposed tests and reported real CLI run exercise the isolated identity and unchanged-host-service result. I did not independently execute the destructive service scenario in this read-only review.

Is this the best way to solve the issue?

Yes. One canonical install-identity predicate shared by Doctor early exits and daemon mutation guards is the narrowest durable service-ownership fix, and the auth exception is constrained to persisted known-owner assignments rather than broadening missing-provider fallback behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A copied-install Doctor run could otherwise rewrite or interrupt a real operator Gateway service, affecting an active core workflow.
  • merge-risk: 🚨 compatibility: The new default-install predicate changes native service-management behavior for existing non-default state or config path setups.
  • merge-risk: 🚨 auth-provider: Known persisted auth-store profiles with an omitted SecretRef provider receive a new degraded-startup outcome.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body and contributor follow-up provide redacted after-fix real CLI results for isolated Doctor behavior and report real Gateway /readyz readiness for the copied-auth case; the results directly cover the changed operator outcomes.

Evidence

What I checked:

  • Service-boundary coverage: The branch introduces one default-install identity predicate and uses it both before Doctor Gateway service work and inside the shared assertion used by daemon install/start-repair paths, covering diagnostic and mutation seams rather than only one caller. (src/config/paths.ts:119, c5ef839bb79a)
  • Host-service mutation guard: The shared Gateway-supervision assertion rejects non-default state/config identities with recovery guidance, while the Doctor flows return before service inspection or rewrite work. (src/infra/gateway-supervision.ts:39, c5ef839bb79a)
  • Auth degradation stays narrow: The new not-configured provider code is mapped to configured-unavailable only for auth-store assignments with an identified owner; the PR’s tests cover copied-store readiness and provider dispatch remaining blocked for the unavailable account. (src/secrets/runtime-owner-assignments.ts:85, c5ef839bb79a)
  • After-fix real behavior proof: The updated PR body and follow-up comment report a real CLI run against a new isolated state/config identity: doctor exited successfully, emitted the skip message, left the host plist unchanged, and left the existing listener unchanged. They also report a real Gateway /readyz run for the copied auth-store path. (c5ef839bb79a)
  • Current-main and history check: The supplied current-main SHA is 5fa8c4a, distinct from this open branch head. GitHub history for the central paths shows steipete repeatedly maintaining state/config-path behavior, including the prior isolated-gateway work and its revert. (src/config/paths.ts:119, c5ef839bb79a)

Likely related people:

  • steipete: Current and historical path/config work repeatedly attributes isolation, state-directory, and Gateway-path behavior to this contributor; the same person authored the proposed boundary repair. (role: recent area contributor; confidence: high; commits: 34b18ea, 7b172d6, 96f0983; files: src/config/paths.ts, src/infra/gateway-supervision.ts, src/commands/doctor-gateway-services.ts)
  • PerfectPan: Git history records a recent shared Gateway state-directory path fix with steipete, making this contributor a relevant adjacent routing candidate for identity/path semantics. (role: adjacent contributor; confidence: medium; commits: 2e5be0c; files: src/config/paths.ts)
  • vincentkoc: Recent refactor history on the central path module provides an additional current-main contact for changes affecting its helper boundaries. (role: recent adjacent contributor; confidence: medium; commits: 1b6f3e4, 0771ac8; files: src/config/paths.ts)

Rank-up moves

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

  • Refresh the exact merge result and required checks after the branch’s behind-main drift is resolved.

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 (4 earlier review cycles)
  • reviewed 2026-07-29T13:51:09.107Z sha 955bf55 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-29T14:10:57.067Z sha 2c96efb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-29T14:25:21.128Z sha ce8a1ff :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-29T14:45:20.961Z sha c5ef839 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up move disposition for c5ef839bb79a46e46e27dbd10ce4f9e0466e16ff:

  • Applied the copied-install proof move with a real CLI run against a brand-new /tmp state/config identity and non-default Gateway port. Redacted outcome: doctor_exit=0, skip_message_seen=true, plist_unchanged=true, listener_unchanged=true. No credential values, host paths, IPs, or plist contents were printed or inspected.
  • Applied the copied-auth readiness move with server-startup-copied-auth-secretref.test.ts: it seeds a raw SQLite auth-store row with the omitted provider, starts the real Gateway server, reaches HTTP /readyz with status 200, and verifies the exact account owner plus typed SECRETS_OWNER_UNAVAILABLE diagnostic. The canonical selected-account boundary test verifies SECRET_SURFACE_UNAVAILABLE is raised before its provider-request spy can run. I did not add an external credentialed provider call because this boundary must fail before dispatch.
  • Applied the merge-result proof move: required exact-head CI is green at https://github.com/openclaw/openclaw/actions/runs/30462097997. The branch was rebased onto current origin/main before its first push; GitHub reports no conflict, and later behind-main drift is advisory under the repository landing policy.
  • Maintainer acceptance: the work order explicitly froze the default-install service ownership rule and the known-owner SecretRef degradation policy, requested this proof-and-land flow, and forbade a force override. The compatibility and auth-provider behavior are accepted for this landing.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 29, 2026
@steipete
steipete merged commit 383f894 into main Jul 29, 2026
137 of 146 checks passed
@steipete
steipete deleted the fix/doctor-host-service-isolation branch July 29, 2026 15:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* fix(doctor): isolate host service management

* fix(doctor): clarify service isolation recovery

* test(doctor): isolate service identity fixtures

* test(daemon): keep lifecycle fixtures lint-clean

* test(daemon): isolate install identity fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant