Skip to content

fix(install): preserve Git command when npm verification fails - #128502

Merged
steipete merged 1 commit into
openclaw:mainfrom
Alix-007:alix/fix-install-final-verify-rollback
Aug 24, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Alix-007:alix/fix-install-final-verify-rollback

Conversation

@Alix-007

Copy link
Copy Markdown
Contributor

Fixes #127410.

What Problem This Solves

Fixes an issue where users switching a Git installation to npm could lose their working openclaw command when the npm package installed but the installer's final CLI verification failed. The installer discarded its rollback backup before that final check, leaving the failed npm link in place.

Why This Change Was Made

The outer npm install transaction now owns the command backup through its final --version probe: it restores the previous command on failure and commits the backup only after the probe succeeds. install_openclaw still owns package installation and link publication, but no longer ends a transaction whose final verification belongs to main.

The open same-file changes in #118927, #112754, #110657, and #128407 touch security guards, Git target validation, download timeouts, or explicit Git selection; none changes this backup/final-probe transaction.

User Impact

An npm migration that fails final verification now leaves the previously working Git wrapper restored instead of an unusable npm symlink. Successful migrations still publish and retain the npm command.

Evidence

  • Head: 3cf0c89766ffb372776b6fbb7deee13ea214eb0b
  • Base: 6178409d9a0fa9284eb7c5c0c0594cb3b86de102
  • Production delta: scripts/install.sh +6/-6 (net 0)
  • Test delta: test/scripts/install-sh.test.ts +84/-0

Parent reproduction on 055a7302c4a4e11a5233bd5ed3abcfa17f456923:

node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git wrapper when final npm verification fails'
Tests 1 failed | 140 skipped
expected: status=1 version=git-version link=no calls=3
received: status=1 version=unavailable link=yes calls=4

The same production-boundary scenario on this head:

Tests 1 passed | 140 skipped
status=1 version=git-version link=no calls=3

This proof runs the real Bash main flow against a temporary HOME, a real executable Git wrapper, a real npm launcher, and an actual filesystem symlink. The third and final npm candidate probe fails; the assertion reads the restored executable from disk and invokes it.

Affected sibling checks:

- same-bin success + lifecycle-guard failure: 2 passed
- final-probe failure + signal restoration: 2 passed
- bash -n scripts/install.sh: passed
- formatter and git diff --check: passed

The same-bin success/guard fixture also passed against the parent production code after making its env command hermetic (2 passed), so the fixture adjustment is independent from the production fix.

AI disclosure: This change was developed with Codex assistance. The reported failure, owner boundary, competitor state, parent failure, fixed behavior, and commit identity were verified directly.

Limitations: The proof uses a local fake npm executable rather than mutating a machine-wide npm installation or contacting the registry. It exercises the real installer transaction and real filesystem rollback boundary; unrelated tests in this file were not used as evidence.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Aug 24, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 2:03 AM ET / 06:03 UTC.

ClawSweeper review

What this changes

The PR keeps the Git-wrapper backup alive through the final npm command probe, restoring the old command if that probe fails, and adds a regression test for that path.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This is a focused, source-supported repair for the linked installer rollback bug; no actionable patch defect was found, so it should remain open for normal maintainer merge review.

Priority: P2
Reviewed head: 3cf0c89766ffb372776b6fbb7deee13ea214eb0b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with credible before/after terminal proof and no identified correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body shows a before/after production-boundary Bash run with a real executable Git wrapper and filesystem link; the final candidate invocation fails after package/link success and the restored command is invoked from disk.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body shows a before/after production-boundary Bash run with a real executable Git wrapper and filesystem link; the final candidate invocation fails after package/link success and the restored command is invoked from disk.
Evidence reviewed 5 items Current-main failure boundary: Current main commits the same-bin backup inside the package-install helper before main runs the final installed-command probe; that later failure therefore has no active backup to restore.
Patch preserves the owner boundary: The PR removes the early commit from install_openclaw and commits only after the outer --version probe; both failure paths call the existing restore owner.
Boundary regression coverage: The added test runs the real shell main flow with an executable Git wrapper and filesystem link, makes the third candidate probe fail, and asserts that the old executable is restored.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git wrapper when final npm verification fails'

Result: PASS (completed)

node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git wrapper when final npm verification fails'runner@runnervm76f27:/tmp/cl
awsweeper-live-proof-128502-ohhNRx/target$ node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git wrapper when final npm veri
fication fails'
node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git wrapper when final npm verification fails'
[test] starting test/vitest/vitest.tooling.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128502-ohhNRx/target

 ✓  tooling  test/scripts/install-sh.test.ts (141 tests | 140 skipped) 15141ms
     ✓ restores the same-bin git wrapper when final npm verification fails  15139ms

 Test Files  1 passed (1)
      Tests  1 passed | 140 skipped (141)
   Start at  06:04:26
   Duration  15.65s (transform 279ms, setup 63ms, import 92ms, tests 15.14s, environment 0ms)

[test] passed 1 Vitest shard in 21.65s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128502-ohhNRx/target$ node scripts/run-vitest.mjs test/scripts/install-sh.test.ts -t 'restores the same-bin git
 wrapper when final npm verification fails'
































Assertions:

  • PASS expect_output: 1 passed

How this fits together

The POSIX installer can replace a Git-installed openclaw wrapper with an npm command at the same path. The backup transaction protects the old executable while installation, link creation, and final runtime verification complete.

flowchart LR
A[Existing Git command] --> B[Create rollback backup]
B --> C[Install npm package and link]
C --> D[Run final npm command probe]
D -->|passes| E[Commit backup and finish install]
D -->|fails| F[Restore Git command]
F --> G[Return install failure]
Loading

Before merge

  • Resolve merge risk (P1) - This changes an existing upgrade rollback boundary; the focused proof uses a local npm stand-in, so exact-head validation should preserve same-bin success, final-probe restoration, and interruption behavior.
  • Complete next step (P2) - This PR is already the focused repair and has no discrete automation-ready blocker.
Agent review details

Security

None.

PR surface

Tests +84, Other 0. Total +84 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 84 0 +84
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 6 0
Total 2 90 6 +84

Review metrics

Metric Value Why it matters
Production versus test delta production +0 net (+6/-6); tests +84 The repair relocates existing transaction calls rather than adding production logic, while adding a boundary regression for the formerly uncovered final probe.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #127410
Summary: This PR is the focused candidate repair for the canonical same-bin Git-to-npm final-verification rollback bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the tested rollback boundary (recommended)
    Approve the final-probe transaction after exact-head checks retain the successful migration and rollback behavior demonstrated by the focused installer test.

Technical review

Best possible solution:

Keep one transaction owner through the final executable probe, then merge this focused repair once exact-head checks confirm the retained installer paths.

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

Yes: current source shows the backup is committed before the later failing probe, and the PR supplies a focused parent-failing/head-passing real-shell scenario; this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes: moving the existing commit to the caller that owns final verification is the narrow canonical repair, avoiding a new fallback path or duplicate transaction.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The patch changes rollback ownership during an existing Git-to-npm upgrade path and must preserve installed-command recovery semantics.

Label justifications:

  • P2: A failed npm migration can leave the operator without the previously working command, but the blast radius is limited to this installer transition.
  • merge-risk: 🚨 compatibility: The patch changes rollback ownership during an existing Git-to-npm upgrade path and must preserve installed-command recovery semantics.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body shows a before/after production-boundary Bash run with a real executable Git wrapper and filesystem link; the final candidate invocation fails after package/link success and the restored command is invoked from disk.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body shows a before/after production-boundary Bash run with a real executable Git wrapper and filesystem link; the final candidate invocation fails after package/link success and the restored command is invoked from disk.

Evidence

What I checked:

  • Current-main failure boundary: Current main commits the same-bin backup inside the package-install helper before main runs the final installed-command probe; that later failure therefore has no active backup to restore. (scripts/install.sh:3421, c43166a9208c)
  • Patch preserves the owner boundary: The PR removes the early commit from install_openclaw and commits only after the outer --version probe; both failure paths call the existing restore owner. (scripts/install.sh:3800, 3cf0c89766ff)
  • Boundary regression coverage: The added test runs the real shell main flow with an executable Git wrapper and filesystem link, makes the third candidate probe fail, and asserts that the old executable is restored. (test/scripts/install-sh.test.ts:1085, 3cf0c89766ff)
  • Feature history: Installer lifecycle work around this transaction was recently maintained by Peter Steinberger; blame ties the current early-commit and final-probe lines to the current installer source lineage. (scripts/install.sh:3421, 8b18d22db1f5)
  • Release scope: The local release tag check found no release tag containing the recent installer lifecycle lineage, so the reported defect remains a current-main installer behavior rather than a proven latest-release regression. (e78b9d3ce4aa)

Likely related people:

  • steipete: Recent main history and blame connect Peter Steinberger to the installer lifecycle code containing the early backup commit and outer verification split. (role: recent installer lifecycle contributor; confidence: high; commits: 8b18d22db1f5, e78b9d3ce4aa, b514fca522cc; files: scripts/install.sh, test/scripts/install-sh.test.ts)
  • Alix-007: The current PR author also appears in prior merged installer history, including the runtime-download installer repair. (role: prior installer contributor; confidence: medium; commits: 5f2828b50ada; files: scripts/install.sh)

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 (1 earlier review cycle)
  • reviewed 2026-08-24T05:03:04.635Z sha 3cf0c89 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 24, 2026
@steipete
steipete merged commit d9c350a into openclaw:main Aug 24, 2026
195 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

install.sh discards the working Git wrapper before final npm CLI verification

2 participants