Skip to content

fix: keep a package install when the old Git checkout's openclaw wrapper cannot be removed - #200579

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-keep-package-when-git-wrapper-stays
Nov 17, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:fix/update-keep-package-when-git-wrapper-stays

Conversation

@fuller-stack-dev

Copy link
Copy Markdown
Member

Related: #200331, #200507

What Problem This Solves

Switching a Git checkout to a package install (openclaw update --channel beta from a checkout) removes the openclaw wrapper the installer wrote for the checkout. If that file cannot be removed and no Gateway restart was verified (--no-restart, or no Gateway service), the update exits 1, rolls the package install back, and reports that recovery could not prove a runnable installation. With a verified restart the same failure was already a warning.

User Impact

User impact: the package install is now kept in both cases. The update exits 0 with one warning that names the path it could not remove or inspect and says the old wrapper keeps starting the old checkout wherever it comes first on PATH until it is removed.

Still failing, as before: a wrapper that a system package owns fails the update and rolls the package install back, and an update that lost its authority stops before it removes the wrapper.

A switch started by an already installed version behaves as before, because this step runs in the updater that started the update.

Why This Change Was Made

A leftover wrapper does not make the new package install unusable, so it should not undo a finished install. The failure is a warning and not an owed step: update history has no field for the wrapper path, so no later command could prove the wrapper is gone. A recheck over PATH was tried and rejected in review, because the installer writes the same wrapper template to places the Gateway service PATH does not include and also writes it for package installs.

The wrapper-retirement-failed reason and its two special cases in the finisher are removed; nothing else read them.

This came out of an inventory of everything that can still fail or roll back an update after the new version is in place. The other rows either already warn, are already owed steps, or protect update authority, plugin cohort settlement, ledger integrity, or state only this run can restore, and are unchanged.

Evidence

Before, on unmodified main (ae31ea3be6d). Through the update command with a private state directory, for both --no-restart and no Gateway service: exit 1, run failed, reason wrapper-retirement-failed, and a package rollback step.

After. The same two cases: run succeeded, no package rollback step, the package at the new version, the wrapper untouched, the warning in the report and as a warning:git-wrapper-retirement step in update history, and no owed step.

Negative control. A wrapper owned by a system package: exit 1, run failed, package rollback and package-backup-retention steps, the package back at 1.0.0, the wrapper untouched.

Red and green. With the base production files, 2 of the 3 new command-level cases in src/cli/update-cli.test.ts fail (the control passes) and 2 cases in src/cli/update-cli/update-command-post-update.test.ts fail. All pass on this branch.

Not proven.

  • No Windows run, no live update, no published-driver run.
  • A verified-restart wrapper failure is covered at the finisher level only.
  • Lost authority at the wrapper is covered at the function level only, by an existing test.
  • retireStandaloneGitWrapper returns at the first PATH entry it cannot inspect, before reaching a later real wrapper. That is unchanged from main.

Review. The autoreview helper does not run on this machine. Two fresh read-only agents reviewed the work. The first review's findings are why this is a warning and not an owed step. A further read of the production diff before opening this PR found nothing to change.

Commands and counts

Head b0215e16fdc, base eceb208abea (origin/main). The checks below ran on 5798ae3bc31 (same change on base 2a7ca163a57). The two commits main gained since then change worker preload resolution, the Doctor child's handling of predecessor writes, and docs/install/updating.md; none touches the update CLI finisher, the wrapper code, or this PR's files, so nothing was rerun.

On 5798ae3bc31:

  • pnpm tsgo:all: pass.
  • node scripts/run-vitest.mjs on 6 files, 186 tests passed: src/cli/update-cli.test.ts, src/cli/update-cli/update-command-post-update.test.ts, src/cli/update-cli/update-command-terminal-outcome.test.ts, src/cli/update-cli.git-service.test.ts, test/scripts/update-restart-module-outcome.test.ts, test/scripts/eager-import-closure.test.ts.
  • scripts/check-session-identity-ratchet.mts --base origin/main --no-merge-base: pass.
  • OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs: pass.
  • pnpm check:docs: pass.

Red runs used this branch's tests with the production files from ae31ea3be6d: src/cli/update-cli.test.ts -t "to a package install" 2 failed, 1 passed; update-command-post-update.test.ts 2 failed, 93 passed.

Test files audited in full: src/cli/update-cli.test.ts, src/cli/update-cli/update-command-post-update.test.ts. One finisher case was removed: "recovers and retains the package before reporting failed wrapper retirement" asserted the behavior this change reverses. The part of it that is still required (failed finalization, rollback, backup settled) is now asserted at command level in the system-package control.

… be removed

Switching a Git checkout to a package install removes the `openclaw` wrapper the installer wrote for the checkout. When that removal failed and no Gateway restart had been verified (`--no-restart`, or no Gateway service), the update exited 1, rolled the package back and reported that recovery could not prove a runnable installation. With a verified restart the same failure was already a warning.

The package install is now kept in both cases, with one warning that names the path. A wrapper owned by a system package still fails the update and rolls the package back, and an update that lost its authority still stops before it removes the wrapper.

The warning is not an owed step. Update history has no field for the wrapper path, so no later command could prove the wrapper is gone.

Update behavior: this step runs in the updater that started the update, so a switch started by an already installed version behaves as before. The change applies to switches started by a version that contains it.
@clawsweeper

clawsweeper Bot commented Nov 17, 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 cli CLI command changes size: M labels Nov 17, 2026
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) November 17, 2026 12:20
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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: 👀 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR keeps a completed package installation when removing the previous Git checkout’s CLI wrapper fails, reporting a warning instead of rolling back.

Example: A Git-to-package switch with --no-restart encounters EACCES removing /home/alex/.local/bin/openclaw.

  • Before: The update fails and rolls back the newly installed package.
  • After: The package stays installed and the update succeeds with a warning naming the leftover wrapper.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and source review found no defect, but harness results do not satisfy the required real-behavior proof.
Proof confidence 🧂 unranked krab (1/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: A completed package installation is undone because the previous Git checkout’s wrapper cannot be removed.
Reason: The maintainer-authored direction keeps a usable package installation and explicitly accepts a visible leftover-wrapper warning while retaining ownership refusals.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a source-confirmed rollback bug with a focused change, and no introduced correctness defect was found.

Priority: P2
Reviewed head: b0215e16fdce57df234976b7c729bdc48bb5fdbf

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output or logs from an isolated shipped-CLI Git-to-package switch with denied wrapper removal for --no-restart and absent service, plus a latest-stable upgrade showing settings and data intact.
Agent review details

How this fits together

The update CLI finalizer runs maintenance after package activation and optional Gateway verification, then publishes the result, settles package retention, and records update history.

flowchart TD
  A[Update CLI] --> B[Package activation]
  B --> C[Optional Gateway verification]
  C --> D[Post update maintenance]
  D --> E[Wrapper retirement]
  E --> F[Advisory or ownership refusal]
  F --> G[Terminal result and history]
Loading

Technical review

Best possible solution:

Keep wrapper filesystem failures advisory at the existing maintenance owner while preserving ownership refusals and the normal package-settlement path.

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

The pinned base returns wrapper-retirement-failed without verified activation and routes that result through rollback; the PR reports matching failing command regressions, but this review ran no target code.

Is this the best way to solve the issue?

The change fixes the classification at its existing owner, removes the obsolete downstream exceptions, and adds no parallel cleanup or retry mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main failure: The introduced diff replaces the base maintenance owner's wrapper-retirement failure with an advisory and removes both downstream special cases; the base still fails when activation was not verified. (src/cli/update-cli/update-command-post-update-maintenance.ts:251, b0215e16fdce)
  • Ownership and authority refusals remain errors: The unchanged retirement function performs system-package ownership inspection outside its filesystem-error catches and invokes assertCurrent before unlinking; these refusals cannot become the new advisory. (src/cli/update-cli/update-command-git.ts:75, b0215e16fdce)
  • Regression coverage and supplied proof: The added command cases check retained package version, untouched wrapper, successful history, and warning publication for --no-restart and absent service; the negative control checks rollback for system-package ownership. The full PR body reports red/green runs but explicitly excludes live and published-driver updates. (src/cli/update-cli.test.ts:272, b0215e16fdce)
  • Prior maintenance decision: fix(update): keep verified updates successful after maintenance errors #181166 deliberately kept verified updates successful after recognized maintenance failures while preserving authority refusals; this PR extends wrapper warnings to successful package switches without verified restarts and explains that choice. (src/cli/update-cli/update-command-terminal-publication.ts:251, 89ab73c2fd2e)
  • Policy and history inspection: Root and docs policies were read; no additional ancestor AGENTS.md or maintainer-notes directory was present. Scoped history and blame establish shared update ownership; one deeper symbol-history search stopped at an unavailable historical object, without affecting the verified base and head behavior. (AGENTS.md, b0215e16fdce)

Likely related people:

  • Jason (Json): Raw commit 97c7b35 adds src/cli/update-cli/update-command-post-update-maintenance.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 97c7b3593392; files: src/cli/update-cli/update-command-post-update-maintenance.ts)
  • Peter Steinberger: Raw commit 89ab73c adds src/cli/update-cli/update-command-terminal-publication.ts:242 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 89ab73c2fd2e; files: src/cli/update-cli/update-command-terminal-publication.ts)

PR surface

Source -27, Tests +83, Docs +5. Total +61 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 20 47 -27
Tests 2 133 50 +83
Docs 1 11 6 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 164 103 +61

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +20/-47; tests +133/-50 The patch removes special failure machinery; test growth covers package retention, warning propagation, and the ownership-refusal control.

Labels

Label changes:

  • add P2: The bug affects a limited Git-to-package transition when wrapper cleanup fails; it is an advanced CLI workflow with unnecessary rollback.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 affects a limited Git-to-package transition when wrapper cleanup fails; it is an advanced CLI workflow with unnecessary rollback.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 17, 2026, 7:30 AM ET / 12:30 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 176f2ff into openclaw:main Nov 17, 2026
137 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/update-keep-package-when-git-wrapper-stays branch November 17, 2026 12:44
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

RomneyDa added a commit that referenced this pull request Nov 17, 2026
… be removed (#200579)

Keep successful Git-to-package switches when optional wrapper removal fails, with a warning naming the remaining wrapper. Preserve system-package ownership and live-authority refusals. Adapt regressions to the existing stable rollback receipt without importing owed-step machinery.

(cherry picked from commit 176f2ff)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
… be removed (openclaw#200579)

Switching a Git checkout to a package install removes the `openclaw` wrapper the installer wrote for the checkout. When that removal failed and no Gateway restart had been verified (`--no-restart`, or no Gateway service), the update exited 1, rolled the package back and reported that recovery could not prove a runnable installation. With a verified restart the same failure was already a warning.

The package install is now kept in both cases, with one warning that names the path. A wrapper owned by a system package still fails the update and rolls the package back, and an update that lost its authority still stops before it removes the wrapper.

The warning is not an owed step. Update history has no field for the wrapper path, so no later command could prove the wrapper is gone.

Update behavior: this step runs in the updater that started the update, so a switch started by an already installed version behaves as before. The change applies to switches started by a version that contains it.
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…is never retried after an update (#200331)

* fix(update): a failed shell completion or service definition refresh is never retried after an update

* fix(update): keep a step owed when the update that took it over fails

A run that still owes a step now records its own row and leaves the earlier
run's row unchanged. The newest run that kept its result decides, so the
earlier run owes the step again if the later run fails or rolls back. Before,
the later run settled the earlier row when it took the step over, and a
failure after that dropped the step without a record.

The retry pass and `update status` group and match owed steps by key instead
of comparing update run ids.

* fix(update): report owed steps without changing the finalization status

* test(update): keep deliberately owed completion steps out of the shared ledger

(cherry picked from commit 89924a8)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 10f65fb6bddfad042a845bbe88fdb26cd3e91b5f)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…whole update back (#200507)

* fix(update): a plugin convergence failure rolls back an update that could keep its result

After a core update, plugin convergence that throws before publishing any record or config, or an updater failure around a started post-plugin Doctor, no longer rolls the package back. The update keeps its result, records the step as owed with its reason, exits 0, and the next update or repair retries it. Config refusals, Doctor refusals, unsettled package state, lost authority and Gateway readiness still fail the update.

* fix(update): owe plugin convergence only when its rollback restores the previous plugin set

Review follow-up. Plugin convergence is owed only when a plugin cohort deferred every package and record change, the pass carries no channel config that only this update can restore, and publication has not started. Already-current updates and repair commit installs plugin by plugin, so they keep failing as before. A plugin phase that ends in error owes nothing.

* test(update): prove blocking convergence failures still fail with a healthy cohort

Review follow-up. Adds rows for a refused config write, a revoked requester and an unsettled child, makes the no-cohort row replace a package for real, and corrects the docs on what the first update from an older updater does.

* docs(update): say the owed Doctor pass starts after plugin convergence

* fix(update): a plugin phase deferred by a config conflict settles no owed plugin step

* docs(update): a config-conflict deferral settles no owed plugin step

(cherry picked from commit c48b829)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c7e8a882e3e1503b3091ef079730d881462c10e2)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
`openclaw update repair` prepared uncertain-handoff recovery in the default per-user lease store, while package settlement then entered the lease store pinned by the package activation journal. When that journal pinned an existing historical store (such as the legacy /tmp/openclaw store) holding a stale uncertain triage lease, ordinary admission refused with "Another update executor owns this installation", so repair could never settle. Repair now reads the journal through the same reader settlement uses, runs its existing recovery checks against the pinned store, and reuses the admitted claim for settlement. Recovery checks and ordinary admission are unchanged; without a pinned store, repair behaves as before.

Fixes #200508
Reported-by: @garrietv

Co-authored-by: steipete <[email protected]>
(cherry picked from commit ae31ea3)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8d8ace39e6d59c2017d197ac460dc4d489c95a84)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…pdate left behind (#200550)

* fix(update): settle a killed package publication on the next update

An update killed between publishing its journal and installing the new
package left the next `openclaw update` and `openclaw update repair`
refusing with "Package publication is incomplete" until someone ran the
printed recovery command.

Settlement now first brings such a publication to rest with the recovery
that command runs, under a claim in the recorded lease store that proves
the original updater gone, then closes the aborted or published
operation through the existing settlement. It resumes only a journal
this build's own helper was sealed for, never replaces an installed
package, and never resumes under a caller-supplied claim. The update
records what it settled as a package-publication-recovery warning step.

Refusals that remain name their cause and a step that works: a lost
lease store and a changed installation now name the reinstall that
supersedes the operation.

* fix(ci): expect readable package modes in the installed recovery lane

Recovery keeps group/other read and execute access on retained package
contents and clears only write access (#193272). The installed recovery
lane still expected owner-only modes, so its first tree comparison
failed on every entry.

* test(update): keep the replaced launcher's inode distinct

Unlinking a link and creating it again can reuse the freed inode on
Linux, which leaves the launcher's recorded identity unchanged and the
publication legitimately resumable. The control now keeps the old link
under another name, so the new one always has a new identity.

* docs(update): say what repair does with a publication under its own claim

(cherry picked from commit 0ce9c77)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 2dd257b6ce71507101c2563df56ff6662376ace0)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…s stop (#200569)

During a Control UI update, the candidate Doctor admits its SQLite capture before stopping the supervised predecessor Gateway. The predecessor's graceful shutdown releases its gateway-owner lease in state/openclaw.sqlite, so the predecessor stop receipt then refused with "source changed after update capture". The whole update was reported as failed even though the new version served.

Writes made between capture admission and the receipt owner's exclusive maintenance custody now follow the existing initial-staleness policy: one warning, Doctor continues from current state, and automatic restoration of the stale backup stays permanently disabled. Changes made under custody or after the receipt are still refused.

Accepted edge case: a foreign write during the pre-custody stop interval also continues forward, with rollback disabled.

Fixes #198072
Fixes #200022
Reported-by: @zzs12345-web, @damzaru, @Lifaguang

Co-authored-by: steipete <[email protected]>
(cherry picked from commit 3447bee)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 79efce43c9d1b2e3e4ee0e0781d360238a89a293)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
… be removed (#200579)

Switching a Git checkout to a package install removes the `openclaw` wrapper the installer wrote for the checkout. When that removal failed and no Gateway restart had been verified (`--no-restart`, or no Gateway service), the update exited 1, rolled the package back and reported that recovery could not prove a runnable installation. With a verified restart the same failure was already a warning.

The package install is now kept in both cases, with one warning that names the path. A wrapper owned by a system package still fails the update and rolls the package back, and an update that lost its authority still stops before it removes the wrapper.

The warning is not an owed step. Update history has no field for the wrapper path, so no later command could prove the wrapper is gone.

Update behavior: this step runs in the updater that started the update, so a switch started by an already installed version behaves as before. The change applies to switches started by a version that contains it.

(cherry picked from commit 176f2ff)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 32f16217a1c4935ed90d5910d56afe9b204ba39a)
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…taged package (#200595)

Candidate Doctor checked dependency targets imported by the private rehearsal copy of user-installed plugins only against that private copy. On Windows npm-global installs, the private host links resolve into the staged candidate package, so its own nested node_modules/typebox was rejected as "outside the temporary update copy" and every update rolled back.

Dependency targets imported from the private copy may now resolve into the canonical staged candidate package as well. Plugin entries and repair writes stay private-only. Candidate-sourced references keep main's unchecked scope. Targets in the serving installation or user directories are still rejected.

Fixes #200573
Reported-by: @desksk

Co-authored-by: steipete <[email protected]>
(cherry picked from commit dab086c)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 4f2b2ed830c31eb7b6647bfbb3b3f197b52f62ec)
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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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