Skip to content

fix(update): skip pacman-owned installations - #169055

Merged
steipete merged 3 commits into
mainfrom
upd/upd-l1555
Oct 11, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/upd-l1555

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes npm update attempts against pacman-owned OpenClaw installations, which can fail with EACCES while staging under /usr/lib/node_modules.

Fixes #157338. Supersedes #157428, thanks @sahilsatralkar.

User Impact

openclaw update skips package-owned installations with guidance to use pacman -Syu or the owning AUR helper. FreeBSD pkg installations use the same protection and retain their pkg/Ports guidance. Package replacement and service handoff do not start for a verified system-package owner; inconclusive or unavailable inspections log a warning and continue. Only confirmed system-package ownership refuses OpenClaw-managed replacement. Missing or failing package-manager probes warn and preserve normal backup cleanup; confirmed ownership and real filesystem/identity failures retain the affected backups.

Older installed updaters must receive this fix through their system package manager first. Read-only update status may still advertise a newer upstream npm release; applying it now skips safely rather than attempting installation.

Why This Change Was Made

One table-driven system-package owner replaces the FreeBSD-specific error and inspection path throughout update admission, staging, activation, rollback, and cleanup. The existing bounded ownership inventory and symlink-entry protections are shared by pkg and pacman. Unavailable or failed probes leave ordinary installations on their existing update path, with a warning. The probe and warning sink are injectable, so tests do not rely on the host package manager. System-package refusals inherit the shared UpdatePreMutationError contract, preserving its name, reason, and failure facts without a CLI import cycle.

Cached ancestor resolution, shared platform-independent cleanup checks, and removal of a one-use layout wrapper offset the new owner support: production +407/-402 lines (net +5); tests/support +391/-256 (net +135). The latest cleanup correction removes 25 production lines and adds 47 test lines net; the remaining production growth is the shared error contract and injected probe/warning boundary. Two obsolete closed-mock baseline entries were removed. Release-note context: update reliability on Arch-based pacman installations; preserves FreeBSD file ownership; credited contributor @sahilsatralkar.

Evidence

Cleanup correction 79cb01a77366e875168ea473c9fb9e60ee763fec for the six failures on rebased head 1dff3fccb2d529ecdf96515eb2df383e7f0e03e1 (CI run): package-owner inspection warnings were incorrectly treated as a reason to stop cleanup. On Linux without pacman, this retained obsolete rename/backup directories, replaced identity advisories, and could turn a staging assertion into a package-update error. Both cleanup owners now use the shared warning-and-continue contract. Fresh ownership checks still run before each deletion; confirmed ownership, changed filesystem identities, and cleanup budgets keep their protections.

  • Read all three failing job logs once. The six failures were in package-update-steps.transaction.test.ts (interleaved staging cleanup), package-update-steps.test.ts (direct node_modules root), package-update-swap.test.ts (replacement/late/unrelated artifact retention), update-global.test.ts (rename cleanup), and both symlink/directory cases in update-retained-runtime.backups.test.ts.
  • Base/head attribution: all five original files passed on the pinned base f49b7cd0eb5f078c57cb44a08d160deccb87da26 (71 tests, 31.69s) and on the macOS head (71 tests, 15.35s). Injecting Linux plus missing/failed pacman into the existing cleanup and retained-runtime tests produced six failures on the old head (27.44s), while the same tests passed on the pinned base (36 tests, 31.12s). These regressions never call the host package manager.
  • Fixed Node proof: 104 focused tests in seven files passed (33.63s), including all five CI files, FreeBSD/pacman positive ownership, pre-deletion ownership refresh, identity retention, and cleanup budgets. The same 104 tests passed under Bun (28.53s). Bun emitted its nonfatal directory-mismatch diagnostic and exited zero.
  • Consumer proof: all direct/one-barrel consumers selected by the campaign search were exercised on the final source. 244 consumer tests across 19 additional files passed (46.19s infrastructure/triage run; 97.11s CLI run).
  • check:changed passed core production types and all 28 test-type graphs, ratchets, formatting, and preceding guards. Its dead-export scan failed on 19 unchanged UI/subagent exports; the exact same 19 full-tree findings were reproduced on pinned base f49b7cd0eb5f. The remaining targeted lint, schema/storage, sidecar, and import guards were run separately. Madge reported zero cycles; git diff --check is clean. No baseline or suppression was added.
  • Independent Codex autoreview returned HTTP 401 and produced no review; the lead must review the PR head. No merge or release was performed.
Earlier-head evidence

Follow-up 01d70900cf84b50d2a9aa9e3dc0e2de179b7e8da for the failed Bun CI shard: both shared.command-runner.test.ts and update-command-target.n1-prefix.test.ts omitted the buffered ownership probe from their exec mocks. Both files now force the Linux path with explicit probe results: a deterministic query failure for the shared helpers and an unowned inventory for target selection. This preserves the intended Homebrew/unmanaged-install refusal and package-root selection. Both mocks preserve real exports. Positive ownership still blocks replacement; query, launch, timeout, and path-inspection failures warn once and continue.

  • Before repair: the deterministic Bun reproduction failed three assertions in shared.command-runner.test.ts (28 passed), matching the CI failure. The CI log also identified seven affected cases in the N1-prefix file.
  • After repair: all 113 focused tests across seven files passed on Node 26.11.1 (50.85s wall) and Bun 1.4.2 (43.53s wall). Both failing files are included. The ownership tests inject the probe and warning sink, prove the host command was not called, verify UpdatePreMutationError identity/name/reason for positive owners, and cover warning-and-continue behavior through CLI and RPC admission.
  • Current validation: check:changed passed, including production types, all 28 core test-type groups, core/script lint, mock-export and other ratchets, unused-export checks, and runtime import-cycle checks. Static import-cycle checking reported zero cycles; git diff --check passed.
  • Independent Codex autoreview was attempted again and returned HTTP 401, with no review produced. This still requires the lead's head review. No merge or release is requested.
Original-head validation (8d6a96b4)
  • Before the repair, the pacman admission regression resolved to npm instead of rejecting the system-owned root; the FreeBSD control passed.
  • Final focused proof: 74 tests passed across ownership, CLI and RPC admission, swap/rollback, and Bun/FreeBSD ownership siblings. The grouped run took 109.82 seconds, including compiler preparation.
  • Initial sibling run: 831 passed, one failure in Git-fixture setup before changed production code ran. The shared helper cloned and checked out a fixture for every case; a clone hit its fixed five-second command deadline. It now creates one seed per manifest per suite and makes independent close-on-exec copies. Both consumers passed afterward: 87 tests in 311.11 seconds with --maxWorkers=1. The previously failing case went from an 8.85-second setup failure to a 1.66-second pass; these are observations under different host load, not a controlled benchmark. No timeout or retry increase.
  • Full changed-file checks passed, including production types, all 28 core test-type groups, lint, ratchets, and unused exports. The fixture and transport delta checks also passed. All 131 dependency-selected direct and one-re-export test files were exercised across the grouped runs, retaining existing platform skips. The final real-npm E2E file passed all nine scenarios (306.62 seconds including a 3m 52s runtime build; 49.47 seconds for the Vitest invocation).
  • The shared Linux CLI transport now models absent pacman explicitly; all 19 service-authority tests passed. The wrapper-retirement assertion was updated for the shared guidance, and its ten tests passed.
  • Import-cycle check: zero cycles. No contributor code was checked out or executed.
  • Codex autoreview was unavailable (HTTP 401); this head requires the lead's review. Live Arch/pacman and FreeBSD hosts and the published-driver × candidate upgrade cell were not exercised; platform ownership probes were simulated on macOS. CI timing is not yet available.
Existing slow-test observations

The initial broad run exercised existing install/recovery compositions. These passed but exceeded 30 seconds under host load; no timeout, retry, or assertion was weakened. Runtime compilation also took 8m 43.5s before this test batch and is separate from test time.

  • src/cli/update-cli.target-schema.test.ts > update-cli > refuses a service-only incompatible package-to-git target before any mutable preparation — 48.279s.
  • src/cli/update-cli/update-command-original-service.test.ts > keeps B facts and current data through split-root failure: same-version — 38.388s.
  • src/cli/update-cli/update-command-original-service.test.ts > keeps B facts and current data through split-root failure: same-build-finalize — 40.520s.
  • src/cli/update-cli/update-command-original-service.test.ts > keeps B facts and current data through split-root failure: package-root-missing — 42.522s.
  • src/cli/update-cli.target-schema.test.ts > update-cli > reports unavailable plugins without refusing the core update (dryRun=false) — 63.303s.
  • src/cli/update-cli/update-command-original-service.test.ts > keeps B facts and current data through split-root failure: windows-autostart — 35.815s.
  • src/cli/update-cli/update-command-original-service.test.ts > keeps B facts and current data through split-root failure: windows-autostart-health-failed — 47.908s.
  • src/cli/update-cli.target-schema.test.ts > update-cli > preserves control-plane update sentinel consumption on restart health failure — 48.155s.
  • src/cli/update-cli.target-schema.test.ts > update-cli > merges current auth refs with captured service selectors for updated install refresh — 34.618s.
  • src/cli/update-cli/update-command-original-service.test.ts > pre-stop qualification keeps retained A recoverable: fingerprint-timeout — 30.309s.
  • src/cli/update-cli/update-command-fresh-overrides.test.ts > preserves local files through real fresh-profile staging (replay=false) — 30.412s.

@clawsweeper

clawsweeper Bot commented Oct 11, 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: L labels Oct 11, 2026
@clawsweeper clawsweeper Bot added 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. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR shares pacman and FreeBSD pkg ownership inspection and skips confirmed package-owned installations with package-manager guidance.

Example: Run openclaw update for pacman-owned /usr/lib/node_modules/openclaw.

  • Before: The updater selects npm and attempts staging in the system directory, potentially failing with EACCES.
  • After: Admission skips replacement and recommends pacman -Syu or the owning AUR helper.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value and substantial harness coverage, but required native update proof is absent and two concrete blockers remain.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Distribution-installed OpenClaw attempts an npm update in package-owned system directories instead of directing users to their package manager.
Reason: The documented ownership failure justifies the maintainer-authored repair, but the linked report's incorrect status classification and npm update offers remain unchanged; retain that remainder with Related rather than claiming full closure.

Merge readiness

⛔ Needs changes before merge - 2 items remain

This PR addresses a concrete upstream bug, but the prior Linux mutation-boundary finding remains unresolved and current-head CI exposes additional cleanup-fixture failures.

Priority: P2
Reviewed head: 1dff3fccb2d529ecdf96515eb2df383e7f0e03e1

Before merge

  • Apply shared ownership checks at Linux activation and rollback (P1) - The prior finding remains unresolved: this check, the post-preparation check at line 419, and the rollback check at line 151 still run only on FreeBSD. An unowned /usr/lib/node_modules/openclaw root with a pacman-owned /usr/bin/openclaw launcher passes root admission, then Linux publication replaces the launcher without inspecting its ownership. Linux also misses ownership changes during preparation or before rollback. Generalize these existing calls to the inspector's supported platforms and extend the existing swap regressions to Linux.
  • Supply explicit unowned inventories in cleanup fixtures (P2) - The new Linux cleanup inspection reaches the host pacman command in five existing suites. On the current CI host pacman is absent, so the deliberate uncertainty-retention path runs instead of ordinary cleanup, producing six failing assertions across three jobs. Supply a deterministic successful unowned inventory in update-global.test.ts, package-update-swap.test.ts, package-update-steps.test.ts, package-update-steps.transaction.test.ts, and update-retained-runtime.backups.test.ts, preserving separate coverage of unavailable-inspection retention rather than weakening cleanup assertions.

Findings

  • [P1] Apply shared ownership checks at Linux activation and rollback — src/infra/package-update-swap.ts:407-408
  • [P2] Supply explicit unowned inventories in cleanup fixtures — src/infra/update-global.test.ts:641-645

Tests

  • Missing end-to-end proof: Native pacman/pkg owned and unowned outcomes, Linux launcher preservation, and a latest-stable driver × candidate/system-package upgrade with settings and data intact remain unproven.
Agent review details

How this fits together

CLI and Gateway update admission inspect installation ownership before selecting package or Git update paths; staging, publication, rollback, and cleanup consume those ownership checks.

flowchart TD
  A[CLI or Gateway update request] --> B[System package ownership inspector]
  B --> C[Confirmed owner guidance]
  B --> D[Existing package or Git updater]
  D --> E[Staged candidate validation]
  E --> F[Package and launcher publication]
  F --> G[Rollback or verified cleanup]
Loading

Technical review

Best possible solution:

Use the shared inspector at Linux activation and rollback boundaries while preserving the recorded best-effort policy and package-manager guidance.

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

The report's pacman ownership and EACCES traces match current main's missing pacman admission check; the remaining mutation defect is source-reproducible and the cleanup-fixture failures are observed in current-head CI.

Is this the best way to solve the issue?

Sharing the existing native-package inspector is appropriate, but its Linux callers must include activation and rollback; read-only status and npm availability remain outside this patch.

Full review comments:

  • [P1] Apply shared ownership checks at Linux activation and rollback — src/infra/package-update-swap.ts:407-408
    The prior finding remains unresolved: this check, the post-preparation check at line 419, and the rollback check at line 151 still run only on FreeBSD. An unowned /usr/lib/node_modules/openclaw root with a pacman-owned /usr/bin/openclaw launcher passes root admission, then Linux publication replaces the launcher without inspecting its ownership. Linux also misses ownership changes during preparation or before rollback. Generalize these existing calls to the inspector's supported platforms and extend the existing swap regressions to Linux.
    Confidence: 0.99
  • [P2] Supply explicit unowned inventories in cleanup fixtures — src/infra/update-global.test.ts:641-645
    The new Linux cleanup inspection reaches the host pacman command in five existing suites. On the current CI host pacman is absent, so the deliberate uncertainty-retention path runs instead of ordinary cleanup, producing six failing assertions across three jobs. Supply a deterministic successful unowned inventory in update-global.test.ts, package-update-swap.test.ts, package-update-steps.test.ts, package-update-steps.transaction.test.ts, and update-retained-runtime.backups.test.ts, preserving separate coverage of unavailable-inspection retention rather than weakening cleanup assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native-package inspection and unavailable-query policy changes intended behavior with a stated reason (dfaec13: Protect pkg-owned installation and launcher entries, refusing incomplete inspection; this PR explicitly changes uncertainty to warning-and-continue.)
  • Activation and rollback ownership checks keeps the original intent (dfaec13: Reinspect roots and launcher entries before replacement and recovery, including ownership changes during service preparation.)
  • Historical package backup retirement keeps the original intent (9a62cc8: Retire only captured obsolete backup objects after verified activation while preserving unrelated checkouts and recovery evidence.)
  • Shared pre-mutation error contract keeps the original intent (9db3171: Preserve structured pre-mutation refusals and safe recovery across installation switches; relocation retains the existing fields and identity.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/infra/package-update-swap.freebsd.test.ts --maxWorkers=1
  • pnpm test src/infra/update-global.test.ts src/infra/package-update-swap.test.ts src/infra/package-update-steps.test.ts src/infra/package-update-steps.transaction.test.ts src/infra/update-retained-runtime.backups.test.ts --maxWorkers=1
  • pnpm test src/infra/update-freebsd-pkg-ownership.test.ts src/cli/update-cli/update-command-freebsd-pkg.test.ts src/gateway/server-methods/update-freebsd-pkg.test.ts --maxWorkers=1
  • pnpm check:changed
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9a62cc8 adds src/infra/package-update-swap.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9a62cc8e644d; files: src/infra/package-update-swap.ts)
  • Vincent Koc: Raw commit dfaec13 adds src/infra/package-update-swap.ts:188 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dfaec136991a; files: src/infra/package-update-swap.ts)

PR surface

Source +30, Tests +88, Docs +9, Other -2. Total +125 across 31 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 16 427 397 +30
Tests 13 299 211 +88
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 31 735 610 +125

Review metrics

Metric Value Why it matters
Production versus test growth Production +427/-397; tests/support +299/-211 The small net production increase accommodates pacman in the existing ownership owner and relocates the shared error contract; test growth covers platform and best-effort outcomes.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157338
Summary: The linked issue establishes the pacman ownership defect; this PR is a maintained replacement candidate with narrower status coverage.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This fixes a documented update failure on distribution-managed installations with a limited platform-specific blast radius.
  • merge-risk: 🚨 compatibility: Native-package mutation and recovery behavior changes; uncertain inspection now continues by recorded owner choice, while incomplete Linux boundary checks can overwrite package-owned launchers.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-11T10:01:03.808Z sha 8d6a96b40f393fc4a38e3ef05e6f056dabf40fb6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T10:07:47.326Z sha 8d6a96b40f393fc4a38e3ef05e6f056dabf40fb6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T11:58:53.768Z sha 01d70900cf84b50d2a9aa9e3dc0e2de179b7e8da :: needs changes before merge. :: [P1] Apply shared ownership checks at Linux activation and rollback

Reviewed October 11, 2026, 8:11 AM ET / 12:11 UTC (Revision 4).

@steipete
steipete marked this pull request as ready for review October 11, 2026 10:02
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 11, 2026
steipete and others added 2 commits October 11, 2026 04:59
Share system package ownership admission between FreeBSD pkg and pacman,
including the existing staging, activation, rollback, and cleanup checks.
Return package-manager guidance without attempting npm replacement.

Reuse seeded Git test fixtures instead of cloning per case, and model
absent pacman in the shared Linux CLI transport fixture.

Fixes #157338
Supersedes #157428

Co-authored-by: Sahil Satralkar <[email protected]>
Keep system-package refusals in the shared UpdatePreMutationError contract.
Move that contract below the CLI to avoid a dependency cycle, and expose
probe and warning injection at the ownership boundary.

Continue updates with a warning after unavailable ownership inspection,
while preserving confirmed-owner refusals and uncertain backup retention.
Make the failing Linux fixtures explicit under both Node and Bun, and
remove their two obsolete closed-mock baseline entries.
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
Continue obsolete-backup cleanup after inconclusive package-manager probes while retaining fresh ownership checks, filesystem identity checks, and cleanup budgets. Exercise missing and failing pacman probes at the cleanup and retained-runtime boundaries.
@steipete
steipete merged commit 5d9a5ff into main Oct 11, 2026
143 of 145 checks passed
@steipete
steipete deleted the upd/upd-l1555 branch October 11, 2026 13:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…an and FreeBSD pkg) (openclaw#169055)

openclaw update only recognized FreeBSD pkg ownership, so Arch/pacman-packaged installs could be overwritten by npm. One shared system-package owner check now covers FreeBSD pkg and pacman: confirmed ownership skips with package-manager guidance, an inconclusive probe warns and continues without affecting backup cleanup. Production net negative. Fixes openclaw#157338. Supersedes openclaw#157428, thanks @sahilsatralkar.
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
…an and FreeBSD pkg) (#169055)

openclaw update only recognized FreeBSD pkg ownership, so Arch/pacman-packaged installs could be overwritten by npm. One shared system-package owner check now covers FreeBSD pkg and pacman: confirmed ownership skips with package-manager guidance, an inconclusive probe warns and continues without affecting backup cleanup. Production net negative. Fixes #157338. Supersedes #157428, thanks @sahilsatralkar.

(cherry picked from commit 5d9a5ff)

Release-branch adaptation: createUnexpectedUpdateFailureResult stays synchronous because
this branch records update-run diagnostics through the synchronous ledger; the owned-install
skip is unchanged from main.
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Updater treats pacman-managed installation as npm and fails with EACCES

1 participant