Skip to content

fix(doctor): recognize git checkouts whose root ends in whitespace - #197973

Closed
wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/doctor-git-root
Closed

wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/doctor-git-root

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw doctor classifies the install root with git rev-parse --show-toplevel before offering the git update path. The result was .trim()ed, so a checkout whose directory legitimately ends in whitespace (for example /srv/openclaw ) had its meaningful trailing space stripped, failed the root comparison, and was reported as "not a git checkout". The operator then got the package-manager guidance note and no git-update offer, even though the install is a source checkout. The same root-cause shape was approved for openclaw update status in #196654 and already shipped in src/projects/project-checkout.ts.

Precedent: #196654 (same one-line predicate fix at the update-check call site; this PR covers the doctor sibling)

Why This Change Was Made

detectOpenClawGitCheckout in src/commands/doctor-update.ts now removes only Git's final LF record terminator (replace(/\n$/, "")), preserving filesystem characters in the checkout path, exactly matching the approved #196654 wording. Ordinary checkouts, aliases, separate Git directories, and non-checkouts keep the current classification and messages.

Production LOC is +2/-1 in one file.

Classification: behavior-completing

User Impact

A source checkout under a whitespace-suffixed directory is now recognized by openclaw doctor, so the "Update OpenClaw from git before running doctor?" prompt (and the resulting git update flow) appears as it does for ordinary checkouts. Ordinary paths are byte-for-byte unaffected; a path that merely looks similar after trimming no longer misclassifies.

Evidence

Exact-head proof receipt

  • Product head SHA: 4ec78cebcf3b
  • Current-main RED baseline: 76024435027d4ac4e51a58468bb1b5c4842d9fb0
  • Production entry: maybeOfferUpdateBeforeDoctor → detectOpenClawGitCheckout in src/commands/doctor-update.ts
  • Canonical owner exercised: detectOpenClawGitCheckout at src/commands/doctor-update.ts:32-34
  • Decision surface: the "git" | "not-git" | "unknown" classification that gates the git-update offer and the package-manager guidance note
  • Recorder/readback boundary: maybeOfferUpdateBeforeDoctor return value plus the mocked confirm/updateCommand calls in the existing src/commands/doctor-update.test.ts harness
  • Acceptance RED: on current main, a root of /repo/source with show-toplevel returning /repo/source \n classifies as not-git: the offer resolves false, confirm is never called, and the package-manager note is printed
  • Acceptance GREEN: on exact head, the same inputs classify as git: the offer resolves true, confirm is called once, and updateCommand receives sourceUpdate: { root: "/repo/source " }
  • Legal control: the pre-existing table (another checkout, not-a-repository, missing git, inspection failure, host-owned install, non-interactive/non-TTY/declined gates, update-in-progress recursion) all passes unchanged — 11/11 prior cases green
  • Cleanup: isolated vitest temp dirs only; no production Gateway, session, token, or config was touched

Inspectable RED -> GREEN terminal trace

Vitest shard on the real runner (Node 24.22.1, docker lexiflow-all):

# BASE (76024435027d) + new test, via node scripts/run-vitest.mjs run src/commands/doctor-update.test.ts --maxWorkers=1
FAIL src/commands/doctor-update.test.ts > offers the git update for a checkout whose root ends in whitespace
expected false to be true  (offer resolves false; confirm never called)
Tests  1 failed | 11 passed (12)
# HEAD (4ec78cebcf3b), same command
Tests  12 passed (12)   Duration ~100s (compiled-worker preparation dominates)
# Legal control on HEAD: pre-existing classification/guidance table + interaction gates
Tests  12 passed (12)

Verification

  • node scripts/run-vitest.mjs run src/commands/doctor-update.test.ts --maxWorkers=1 — 12/12 passed on exact head; RED reproduced on current main with only the new test
  • Superseded: an earlier interactive-run gap was closed by the shipped-CLI proof below (produced on an unrestricted host with a real TTY); the vitest red/green at the classification boundary still stands.

Scope and risk

  • Production LOC: +2/-1 (src/commands/doctor-update.ts)
  • Test LOC: +12 (src/commands/doctor-update.test.ts)
  • Existing-solutions preflight: reuses the existing resolveComparablePath comparison and the approved replace(/\n$/, "") predicate from fix(update): preserve Git identity for whitespace-suffixed checkout paths #196654; no new helper or export
  • Config/default, protocol/schema, authorization, storage, migration, upgrade impact: none (read-only discovery)

Real behavior proof (shipped interactive CLI)

The review asked for terminal evidence from a physical whitespace-suffixed checkout. Reproduced with the compiled CLI (node openclaw.mjs, dist built from the pinned trees) running from a real Git checkout whose path ends in a meaningful space (/tmp/oc-proof-doctor/leg2-head/openclaw-src ), inside a real TTY (tmux), with isolated OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH and a real Git identity. The checkout's branch tracks an offline bare remote one empty commit ahead, so the offered update could actually fast-forward.

Base — current main 76024435027d4ac4e51a58468bb1b5c4842d9fb0:

◇ Update ───────────────────────────────────────────────────────────────╮
│  This install is not a git checkout.                                   │
│  Run `openclaw update` to update via your package manager (npm/pnpm),  │
│  then rerun doctor.                                                    │

Doctor withholds the Git update offer and routes the operator to package-manager guidance.

Head — this PR 4ec78cebcf3b7a5b35ae8ec4ac00d18428fdbb0f, same checkout shape and harness. The interactive prompt now appears (tmux capture):

Doctor: maintenance admission
│
◆  Update OpenClaw from git before running doctor?
│  ● Yes / ○ No

Answering Yes enters the shipped source-update flow (same capture, after the answer):

◇  Update OpenClaw from git before running doctor?
│  Yes
Doctor source update requires the accepted Git checkout.

That final line is the update flow's second install-kind probe (src/infra/update-check.ts:278, result.stdout.trim() — the same pathname-loss family). It is owned by the already-open, same-shape fix #196654 (result.stdout.replace(/\n$/u, "")); it is deliberately not duplicated here. With #196654 landed, the offered update fast-forwards this exact checkout. Classification — the boundary this PR changes — is proven at the real CLI: base routes to package-manager guidance, head offers the Git update from the same physical whitespace-suffixed checkout.

Not tested here: the completed git pull inside the update runner (blocked by the separately-owned #196654, disclosed above, not by this diff).

Maintainer edits
  • Maintainer edits allowed: yes — address review comments directly on this branch.
Maintainer options

@clawsweeper

clawsweeper Bot commented Nov 12, 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 commands Command implementations size: XS labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Preserve meaningful trailing whitespace when Doctor compares a checkout root with Git’s output.

Example: Run interactive openclaw doctor from the source checkout "/srv/openclaw ".

  • Before: Doctor strips the trailing space and displays package-manager guidance.
  • After: Doctor offers the Git update; accepting it still encounters the separately tracked updater classification failure.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) A useful, minimal predicate repair with a focused regression, pending required upgrade evidence and coordinated landing.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor incorrectly tells an operator that a valid source checkout is a package installation.
Reason: The change restores the existing checkout-recognition contract without introducing configuration or changing canonical path policy.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR fixes a concrete current-main classification bug with a minimal change; coordinate landing with the updater sibling so the newly offered action works.

Priority: P2
Reviewed head: 26fb0ce28f1299730c38da163bc4ffba6eb56e6f

Before merge

  • Add real behavior proof - The supplied compiled-CLI TTY trace demonstrates the corrected prompt from a physical whitespace-suffixed checkout, but names an older head whose equivalence could not be verified; the previously requested latest-stable Doctor upgrade evidence remains absent. Prepared media concerns a different PR’s badge and does not establish this behavior. Redact IPs, API keys, phone numbers, and non-public endpoints from additional evidence. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve merge risk - The landing maintainer should land fix(update): preserve Git identity for whitespace-suffixed checkout paths #196654 first or together with this PR; otherwise accepting the newly offered update throws “Doctor source update requires the accepted Git checkout.”.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted evidence on the reviewed code of a latest-stable Doctor upgrade with settings and data intact, covering the whitespace checkout after the updater dependency is resolved.
Agent review details

How this fits together

Doctor consumes the installation root and Git subprocess output, compares canonical filesystem paths, and either offers the canonical updater or displays package-manager guidance.

flowchart LR
  A[Interactive Doctor] --> B[Git root discovery]
  B --> C[Remove final LF]
  C --> D[Canonical path comparison]
  D --> E[Update confirmation]
  E --> F[Canonical updater]
Loading

Technical review

Best possible solution:

Keep the focused Doctor fix and coordinate it with the existing updater repair rather than duplicating that work.

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

Current-main source directly demonstrates the pathname loss, and the contributor’s terminal trace shows the corresponding CLI failure; no target code was executed during this review.

Is this the best way to solve the issue?

Removing only Git’s final LF is the smallest repair to the existing canonical comparison, with one focused regression and no new state or abstraction.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4f7b426a4e3f.

Merge-risk options

Maintainer options:

  1. Land the updater sibling first (recommended)
    Land fix(update): preserve Git identity for whitespace-suffixed checkout paths #196654 before or together with this PR so both checkout probes preserve the same pathname.

Provenance checked

  • Doctor canonical checkout comparison keeps the original intent (c897384: Recognize junction and symlink source installations using filesystem canonicalization while rejecting genuinely different checkout roots.)
  • Existing Doctor regression suite keeps the original intent (b2f37ae: Consolidate repeated fixtures while retaining distinct behavior coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Gio Della-Libera: Raw commit c897384 adds src/commands/doctor-update.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c897384ae96e; files: src/commands/doctor-update.ts)

PR surface

Source +1, Tests +12. Total +13 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 12 0 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 1 +13

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:

No label changes.

Label justifications:

  • P2: Incorrect classification affects source installations with unusual but legal pathname suffixes.
  • merge-risk: 🚨 compatibility: Existing whitespace-suffixed installations gain an update prompt whose accepted action fails until the sibling classifier repair lands.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-12T23:41:44.700Z sha 4ec78cebcf3b7a5b35ae8ec4ac00d18428fdbb0f :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-13T03:51:10.118Z sha 26fb0ce :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-13T14:25:08.733Z sha 26fb0ce :: needs real behavior proof before merge. :: none

Reviewed November 13, 2026, 10:13 PM ET / November 14, 2026, 03:13 UTC (Revision 4).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 13, 2026
wangmiao0668000666 added a commit to wangmiao0668000666/openclaw that referenced this pull request Nov 13, 2026
…pace

Git appends one LF to rev-parse --show-toplevel output; trimming the
whole line also strips meaningful trailing whitespace from the checkout
path, so a source checkout under a whitespace-suffixed directory failed
the toplevel comparison and the Control UI dev-gateway badge silently
never rendered. Strip only the record terminator, matching the shipped
project-checkout.ts wording and the approved openclaw#196654/openclaw#197973 predicate.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 13, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — head 26fb0ce now carries the full real-behavior proof in the body: shipped interactive CLI terminal trace from a physical whitespace-suffixed checkout (/tmp/oc-proof-doctor/leg2-head/openclaw-src ) inside a real TTY (tmux) with isolated OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH and a real Git identity, comparing current-main RED (7602443 — 'This install is not a git checkout' / package-manager guidance) against this head GREEN (Git update prompt offered, fast-forward actually available). The vitest red/green at the classification boundary stands as well.

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 14, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Closing as stop-loss: this PR is structurally blocked. It is rated silver (2/6) with an unmet upgrade-proof gate (latest-stable Doctor upgrade evidence), and ClawSweeper requires landing #196654 (still open, Alix) first or together — otherwise the offered update throws 'Doctor source update requires the accepted Git checkout.' The one-line fix duplicates the #196654 shape already covered by the update-status sibling. Keeping the branch for reference.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/doctor-git-root branch November 14, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS 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