Skip to content

fix: let Doctor repair a Git checkout install after its first update - #204676

Merged
fuller-stack-dev merged 6 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-git-checkout-service-owner
Nov 24, 2026
Merged

fuller-stack-dev merged 6 commits into
openclaw:mainfrom
fuller-stack-dev:fix/doctor-git-checkout-service-owner

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

On a Git checkout install, openclaw doctor --fix fails after the first update with "the service belongs to a different OpenClaw installation", although the Gateway service is the installation's own. openclaw update repair stops at the same refusal, and openclaw gateway status --deep reports that the service runs an older version than the CLI. The update messages and docs send users to openclaw doctor --fix as the repair step, so every Git install that set up its service before updating loses that repair path.

User Impact

User impact: on a Git checkout install, openclaw doctor --fix and openclaw update repair run their maintenance while the Gateway keeps serving, and gateway status stops reporting a false version drift. A service that really belongs to another installation is still refused, as before. No configuration, state or service definition changes.

Why This Change Was Made

The installer runs openclaw gateway install from the checkout, so the service starts <checkout>/dist/index.js. A Git release update deliberately keeps that definition: it writes a forwarding marker into the checkout (.git/openclaw-launcher), and the checkout's entry imports the release launcher, which starts the selected release. Doctor runs from that release and compares its own package root with the service's. Service ownership read the service's package root from the entry path alone, saw the checkout, and called the service foreign.

Service layout already maps a unit that names the launcher to the release the launcher selects. It now does the same for a Git checkout entry that forwards to the launcher, reading the marker by the same rules as release-launcher-forward.mjs: the checkout has .git and the forwarder module, the marker names an existing launcher, the tree is not itself a release, and the selected release entry exists. Such a definition is kept unchanged, like a unit that names the launcher. Package trees are left to their own service staging.

Update behavior: the fix runs in the release that Doctor and update repair execute, so an install reaches it with its next ordinary openclaw update; the installed updater's code is not involved. Nothing is left for a person to do.

Evidence

Both cells: Linux, real systemd user service from openclaw gateway install, a Git checkout installed and built at T0 = 60d2ac66bb9 (main), a 512 MiB agent database under 1 MiB/s Gateway-gated writes, CLI openclaw update --yes --json (trigger api, Gateway update.run), T and T+1 are version-bump commits on top of the tested code.

Step (same cell) RED: base main 60d2ac66bb9 (cell R1) GREEN: this head 218af41e4b9 (cell G2)
Update T0 → T exit 0, 333 s, outage 11.6 s exit 0, 333 s, outage 11.8 s
gateway status --deep false drift: "CLI 2026.11.8-mgd.1 … differs from the Gateway service's 2026.11.7 at ~/openclaw" no drift reported
doctor --fix --non-interactive --yes exit 1 in 2.1 s: "the service belongs to a different OpenClaw installation"; nothing repaired exit 0 in 68 s: maintenance ran, "Gateway restarted and verified after Doctor maintenance" (outage 52 s, Gateway PID 9310 → 14203)
Update T → T+1 exit 0, 323 s, outage 6.8 s exit 0, 315 s, outage 6.8 s
No-op update exit 0, 7.2 s exit 0, 6.9 s
Doctor again exit 1, same refusal exit 0, 65 s
gateway restart exit 0 exit 0
update repair exit 1, same refusal, hands off to openclaw triage exit 0, "Update finalization completed with warnings" (the warning is the cell's plaintext token)
Service definition after Doctor ExecStart=… /home/appuser/openclaw/dist/index.js gateway unchanged: ExecStart=… /home/appuser/openclaw/dist/index.js gateway

In both cells the checkout's .git/openclaw-launcher names ~/.openclaw/git-install/openclaw-launcher.mjs, git-install/openclaw links to the release Doctor runs from, and the Gateway served the target build after every step (/readyz 200).

Negative control (cell N1, same T0 → T on this head): a copy of the checkout without the forwarding marker installs the service (node ~/other-openclaw/openclaw.mjs gateway install --force, older-binary guard waived for that one command). Doctor still refuses it: exit 1 in 2.1 s with the unchanged "belongs to a different OpenClaw installation" message, and the Gateway keeps serving. openclaw gateway install --force from the release CLI then writes ExecStart=… ~/.openclaw/git-install/openclaw-launcher.mjs gateway, and Doctor passes (exit 0, 78 s). (G2 tried the same step first; there the older-binary guard blocked the copy's install, so the unit stayed this checkout's and Doctor correctly ran.)

Adjacent guard and published driver (cell P1): npm openclaw 2026.11.7 with its systemd user service, updated by its own shipped updater to a pack of this head (version-bumped to 2026.11.30, served as the registry's latest): exit 0 in 158 s (trigger cli, outage 57 s), serving 2026.11.30. Then openclaw doctor --fix --non-interactive --yes with the Gateway running: exit 0 in 99 s, "Gateway restarted and verified after Doctor maintenance" (PID 5091 → 12768, outage 82 s). The npm package has no .git, so the new forwarding rule does not apply there.

Regression tests (src/infra/git-release.test.ts, "classifies a checkout service whose tree …"): 8 cases through inspectManagedGatewayServiceBeforeUpdate and summarizeGatewayServiceLayout with real release trees, launchers and markers. On the base production code the three forwarding cases fail (expected { kind: 'foreign' }) and the other-state-directory case reports the checkout's version; on this head all 44 tests in the file pass.

Recordings (raw lines from each cell's own step outputs, host paths removed):

RED, base main, cell R1:

red-R1-replay.mp4

GREEN, this head, cell G2:

green-G2-replay.mp4
Decisive raw lines
# RED (R1), after T0 -> T
--- marker
/home/appuser/.openclaw/git-install/openclaw-launcher.mjs
--- slot
/home/appuser/.openclaw/git-install/releases/af08f553-4cab-447a-917e-6163f9e10d3c/openclaw
--- unit
ExecStart=/usr/local/bin/node --max-old-space-size=8017 /home/appuser/openclaw/dist/index.js gateway --port 44853
Doctor: maintenance begin
Doctor: maintenance release
Doctor could not enter maintenance. Error: Gateway service management skipped: the service belongs to a different OpenClaw installation and was left untouched. Run openclaw gateway status --deep to find the Gateway installation. [...]
exit=1 ms=2129

# GREEN (G2), after T0 -> T
--- unit
ExecStart=/usr/local/bin/node --max-old-space-size=8017 /home/appuser/openclaw/dist/index.js gateway --port 44983
Stopped the managed Gateway for Doctor repair.
Restarted systemd service: openclaw-gateway.service
Gateway restarted and verified after Doctor maintenance.
exit=0 ms=67992
MainPID=14203
Checks on this head

All on 218af41e4b9, the head the cells ran. The later commits are a docs wording fix and merges of main that touch src/commands/models/* and Doctor's tool-schema inspection, not service ownership, so the cells were not rerun:

  • OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs on src/infra/git-release.test.ts, src/daemon/service-layout.test.ts, src/cli/daemon-cli/status.gather.test.ts, src/cli/run-main-service-installation.test.ts, src/commands/doctor-maintenance.{installation,service-identity,service-inspection}.test.ts, src/infra/restart-intent.test.ts, src/update/convert-service.test.ts, src/cli/update-cli/update-command-service-{maintenance,install-root}.test.ts, src/commands/doctor-gateway-services.authority.test.ts, src/infra/update-runner-git-release.test.ts, test/scripts/update-restart-module-outcome.test.ts, test/scripts/eager-import-closure.test.ts: 15 files passed (Node runtime; git-release.test.ts skips itself under the default Bun test runtime).
  • src/cli/update-cli/update-command-rollback.test.ts: 49 passed, 1 failed (excludes a competing config writer …, setgid mode 0o2770 on macOS); it fails the same way on base 115e7114dea.
  • pnpm tsgo:core, pnpm tsgo:test:src: pass. oxlint and oxfmt --check on touched files: pass.
  • check-session-identity-ratchet.mts --base origin/main --no-merge-base, pnpm check:baseline-ratchets: pass.
  • pnpm check:docs, git diff --check: pass.
  • node scripts/check-changed.mjs: every lane passes except the dead-export scan, which flags scripts/lib/release-fast-track-publication.mts (fastTrackValidationSnapshot, releaseFastTrackDigest), not touched here.

Also observed, not changed here: the two other symptoms seen in earlier cells (a CLI update ending failed/interrupted at prepare:install while the same run kept going, and a following update hanging in prepare:ui-build) came from an installed driver older than #204215 and #204512. On current main the same cell had both updates exit 0 (333 s, 323 s) with 11.6 s and 6.8 s outages, and the no-op update returned in 7.2 s.

Update proof rules (#203915), from the cells' raw logs and the landing checks.

  • Route: every update step was openclaw update --yes --json without OPENCLAW_UPDATE_PACKAGE_SPEC, --tag, --no-restart or a shortened --timeout. In R1 and G2 the Git release hops record trigger api, and each journal has three [gateway] update.run <runId> actor=gateway-client lines; N1 has one. P1's update was the shipped 2026.11.7 updater (trigger cli).
  • Service: the unit comes from openclaw gateway install. After each step the cell saved the full unit file, the release link, the serving version and build ID, and the database marker rows. The forwarding marker and MainPID are in the step outputs quoted above. NeedDaemonReload was not captured.
  • Freshness: the cells name base 60d2ac66bb9 and head 218af41e4b9. git diff 218af41e4b9 5ec5da4bd3c -- src/infra/git-release-paths.ts src/daemon src/cli/update-cli src/update is empty, so the receipts cover the final head. Public npm view openclaw dist-tags at landing: latest 2026.11.8, beta 2026.11.10-beta.3, extended-stable 2026.10.33.
    • 2026.11.8 was published at 10:14 UTC, before P1 ran (13:35 UTC), but P1 used 2026.11.7 as its driver. A 2026.11.8-driver cell was not run.
    • The fix runs in the release's Doctor, not in the installed updater, and an npm tree has no .git, so the new rule cannot apply there.
    • src/daemon/service-layout.ts, src/infra/git-release-paths.ts and update-command-service-plan.ts are identical between v2026.11.7 and v2026.11.8.
  • Next build: T and T+1 are version-bump commits of the tested code, so no migration or rollback ran. This change does not touch either.
  • Installed code: no change to src/update/launcher.ts, run.ts, preflight.ts or convert-service.ts.
  • Platforms: only Linux systemd user services ran. A Linux container without a user bus, the macOS LaunchAgent and the Windows Scheduled Task are unproven.
  • CI coverage: PR CI runs src/infra/git-release.test.ts under Bun in checks-node-changed-6, where the file skips itself (Tests 44 skipped (44)). That skip predates this PR (feat(update): run Git checkout installs from releases behind the release link #199706), so CI did not run its regression cases. They pass under Node on the exact head (OPENCLAW_VITEST_RUNTIME=node, 44 of 44). update-command-rollback.test.ts passes 50 of 50 in CI (Linux, checks-node-changed-2); its setgid failure is macOS-only. The dead-export scan (scripts/check-deadcode-exports.mts) now passes with 0 entries on the exact head, and scripts/lib/release-fast-track-publication.mts is identical there and on current main.

Not proven

  • macOS LaunchAgent and Windows Scheduled Task services: not run. The change is path logic shared by all platforms; Windows forwarding through a junction is not exercised.
  • A service with a relative entry and WorkingDirectory=<checkout> still resolves to the checkout; gateway install writes absolute entries.
  • Switching a converted Git install to a package channel (openclaw update --channel stable) with this forwarding service: not run. The service now gets the same verdict as a unit that names the launcher, so it follows that existing path.
  • During an interrupted link switch whose release link is missing, the checkout service still reads as foreign (unchanged), so Doctor refuses until the launcher finishes the switch on the next start.
  • autoreview does not run on this machine; an independent reviewer read the diff and test file instead.
  • Full raw logs are not attached because the artifact store rejected uploads (http 401).

A Git checkout install keeps the service that `openclaw gateway install`
wrote for the checkout's `dist/index.js`; after the first release update
the checkout's entry forwards to the release launcher. Service ownership
still read the checkout as the service's package root, while Doctor runs
from the release, so `openclaw doctor --fix` and `openclaw update repair`
refused with "the service belongs to a different OpenClaw installation"
and `gateway status` reported a false CLI/service version drift.

Service layout now follows the same forwarding marker the entry follows,
and such a definition is kept unchanged like one naming the launcher.
Follow the forwarding marker only for a Git checkout or linked worktree,
resolve the tree's real path before the release guard, require the
release entry to exist, and check only the service's entrypoint when
keeping its definition. Package trees keep their own service staging.
@clawsweeper

clawsweeper Bot commented Nov 24, 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 gateway Gateway runtime cli CLI command changes size: S labels Nov 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Recognize a Git checkout service that forwards to the selected release as belonging to that release without rewriting its service definition.

Example: A service starts /home/appuser/openclaw/dist/index.js after its checkout has updated into a managed release.

  • Before: Doctor refuses maintenance because it identifies the checkout as another installation.
  • After: Doctor recognizes the forwarded release, completes maintenance, and preserves the existing service command.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, apparently correct repair with credible production-path evidence and distinct regression coverage, held below an end-to-end pass by incomplete upgrade qualification.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After a Git checkout update, Doctor and update repair reject the installation's own service, and status reports false version drift.
Reason: This restores the documented repair path through the existing service-layout owner, and the maintainer-authored direction requires no further product decision.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current service-ownership bug, and no concrete patch defect was found; maintainer-authored work also remains protected from cleanup.

Priority: P2
Reviewed head: 5ec5da4bd3c586a10443e308e48abc29e8f44338

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output of a v2026.11.8 checkout service upgraded to this fix, followed by Doctor, update repair, and gateway status with existing settings and data intact.
Agent review details

How this fits together

Service layout translates a service command into its effective package root; Doctor, update repair, and status consume that identity for maintenance admission and version reporting.

flowchart TD
  A[Installed service command] --> B[Checkout entry]
  B --> C[Forwarding marker]
  C --> D[Release launcher]
  D --> E[Selected release]
  F[Service layout resolver] --> C
  F --> E
  F --> G[Doctor repair and status]
Loading

Technical review

Best possible solution:

Extend the existing service-layout owner to resolve checkout forwarding while retaining installation comparison and preserving the installed service command.

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

Current-main source establishes the ownership mismatch, and the supplied systemd trace demonstrates the corresponding Doctor refusal; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs the shared identity resolver used by all reported consumers and preserves the existing foreign-installation checks without adding state or configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8656b1e18257.

Provenance checked

  • Service entrypoint identity keeps the original intent (6747b1e: Resolve a directly named release launcher to its selected release so ownership follows the code it starts.)
  • Preserving launcher service definitions keeps the original intent (6747b1e: A launcher-backed service definition remains stable across release switches; converted checkout entries now reach that same launcher.)
  • Checkout update documentation changes intended behavior with a stated reason (b229b26: Earlier updates staged services onto the launcher; feat(update): Git installs update through prepared releases and a resident launcher #203194 subsequently retained checkout definitions through forwarding, which this documentation now reflects.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main ownership mismatch: Main resolves a directly named release launcher but leaves a forwarded checkout entry unchanged, so package-root comparison identifies the checkout instead of the selected release. (src/daemon/service-layout.ts:170, 8656b1e18257)
  • Focused shared repair: The introduced resolver follows existing checkout markers, excludes package trees and release trees, requires an existing selected entry, and feeds the existing installation comparison. (src/infra/git-release-paths.ts:120, 5ec5da4bd3c5)
  • Forwarding is intentional: The existing update owner writes the marker while retaining checkout entry points; feat(update): Git installs update through prepared releases and a resident launcher #203194 explicitly describes preserving existing service definitions through forwarding. (src/update/run.ts:489, 5ec5da4bd3c5)
  • Production-path evidence: The supplied Linux systemd trace shows base-main Doctor refusing the forwarded service and the fixed build completing maintenance and verifying the restarted Gateway; production hunks are unchanged from tested commit 218af41. (5ec5da4bd3c5)
  • Distinct regression cases: Added cases exercise both checkout entry forms, linked worktrees, missing markers or launchers, another state directory, absent forwarders, and package-tree exclusion through the production ownership and layout functions. (src/infra/git-release.test.ts:709, 5ec5da4bd3c5)
  • Upgrade evidence remains incomplete: The demonstrated checkout starts from main; the published-version cell remains pending and targets 2026.11.7 rather than the supplied latest stable release v2026.11.8. (5ec5da4bd3c5)

Likely related people:

  • Ayaan Zaidi: Raw commit 6747b1e adds src/infra/git-release-paths.ts:70 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6747b1ec5ae3; files: src/infra/git-release-paths.ts)

PR surface

Source +78, Tests +82, Docs +7. Total +167 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 84 6 +78
Tests 1 82 0 +82
Docs 1 12 5 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 178 11 +167

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: The bug blocks maintenance and produces false version drift for updated Git checkout services, while the Gateway can continue serving.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The bug blocks maintenance and produces false version drift for updated Git checkout services, while the Gateway can continue serving.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 24, 2026, 9:04 AM ET / 14:04 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 04d9699 into openclaw:main Nov 24, 2026
154 of 155 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/doctor-git-checkout-service-owner branch November 24, 2026 14:30
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…penclaw#204676)

* fix(doctor): treat a Git checkout's forwarded service as its own

A Git checkout install keeps the service that `openclaw gateway install`
wrote for the checkout's `dist/index.js`; after the first release update
the checkout's entry forwards to the release launcher. Service ownership
still read the checkout as the service's package root, while Doctor runs
from the release, so `openclaw doctor --fix` and `openclaw update repair`
refused with "the service belongs to a different OpenClaw installation"
and `gateway status` reported a false CLI/service version drift.

Service layout now follows the same forwarding marker the entry follows,
and such a definition is kept unchanged like one naming the launcher.

* fix(doctor): limit forwarded-service ownership to Git checkouts

Follow the forwarding marker only for a Git checkout or linked worktree,
resolve the tree's real path before the release guard, require the
release entry to exist, and check only the service's entrypoint when
keeping its definition. Package trees keep their own service staging.

* docs(update): say which installs keep or restage a checkout service
RomneyDa pushed a commit that referenced this pull request Nov 26, 2026
…204676) (#205804)

* fix(doctor): treat a Git checkout's forwarded service as its own

A Git checkout install keeps the service that `openclaw gateway install`
wrote for the checkout's `dist/index.js`; after the first release update
the checkout's entry forwards to the release launcher. Service ownership
still read the checkout as the service's package root, while Doctor runs
from the release, so `openclaw doctor --fix` and `openclaw update repair`
refused with "the service belongs to a different OpenClaw installation"
and `gateway status` reported a false CLI/service version drift.

Service layout now follows the same forwarding marker the entry follows,
and such a definition is kept unchanged like one naming the launcher.

* fix(doctor): limit forwarded-service ownership to Git checkouts

Follow the forwarding marker only for a Git checkout or linked worktree,
resolve the tree's real path before the release guard, require the
release entry to exist, and check only the service's entrypoint when
keeping its definition. Package trees keep their own service staging.

* docs(update): say which installs keep or restage a checkout service

(cherry picked from commit 04d9699)
tideclaw-bot pushed a commit that referenced this pull request Nov 26, 2026
…out lsof or ss (#204017)

* fix: let Doctor drain a release install's Gateway on hosts without lsof or ss

A release install's service runs the resident launcher, and the Gateway
serves as its child. Maintenance drain accepted that child only from port
listener attribution, which needs lsof or ss. Without them Doctor and
update repair refused with 'Gateway process changed during maintenance
drain' while the same Gateway kept serving. When the listener is
unattributed, require the kernel parent of the reporting process to be
the service's main process instead.

* fix: also drain the launcher's Gateway when ss lists its socket without an owner

ss prints a LISTEN row without process details when it cannot see the
socket's owner. Treat a busy port whose listener rows all lack a PID like
an unattributed one and use the kernel-parent check; rows that name a
different PID still refuse.

(cherry picked from commit cff8782)

Backport review: #205736 changes update cohort settlement and #204676 changes Git service layout; their only overlap is the update docs. Neither is a prerequisite for resident-child proof.

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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