Skip to content

fix(plugins): Windows plugin updates fail when a scanner holds a plugin file - #189451

Merged
steipete merged 2 commits into
mainfrom
codex/plugin-install-windows-retry
Oct 31, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/plugin-install-windows-retry

Conversation

@steipete

@steipete steipete commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #188498

What Problem This Solves

Fixes: on Windows, updating an npm-installed plugin (including plugin convergence during openclaw update) fails when an antivirus scanner or indexer briefly holds one file in the installed plugin.

User Impact

User impact: Windows updates of npm-installed plugins now wait out a briefly held file instead of failing, and a file that stays held fails cleanly with the old plugin intact and a message naming the next step.

Why This Change Was Made

Plugin installs moved the live plugin, the staged install and the rollback backup with fs-safe's movePathWithCopyFallback. For the package-manager policy (sourceHardlinks: "allow"), a Windows EPERM on rename makes fs-safe copy the tree and then delete the source, and deleting the held file fails, so the install aborts. #188498 already gave package updates a single owner for these moves (movePackageRoot) with bounded, identity-checked Windows rename retries. Plugin installs now use that helper; it gains an optional rename precondition, the publication receipt, and the caller's hardlink policy.

Scope boundary: plugins installed with sourceHardlinks: "reject" (no runtime dependencies) keep fs-safe's fresh-copy publication on every platform. That policy deliberately never renames, so a hardlink created after a preflight cannot become the published tree; an independent review caught that the first revision of this PR bypassed it. Those installs still fail on a held file, as on main.

Production: +46/-32. Tests: +45.

Evidence

Native Windows (Crabbox AWS cbx_db2ca9c1807f, Windows NT 10.0.26100, Node 24.19.0, secretless, lease released). installPackageDir update of a plugin whose dist/index.js was held open by a PowerShell child with read access and read-only sharing, bundled from main and from this branch:

Policy, file held main this PR
package-manager, 4 s Fails in 0.0 s: EBUSY ... unlink dist\index.js; old plugin restored Updated after 5 retries in 8.5 s
package-manager, 75 s Same failure in 0.0 s Fails after 16 attempts in 59.1 s with Windows package plugin backup rename failed after 16 attempts ... Close processes holding this installation; old plugin intact, no backup left
reject, 4 s Fails in 0.0 s with EBUSY Unchanged: fs-safe fresh copy, same EBUSY failure

An earlier run on cbx_39725346b02d (first revision, default policy) showed the same retry timing: 4 s held → updated in 7.8 s, 75 s → clean failure in 58.7 s.

Focused tests:

  • install-package-dir.rollback.test.ts retries a Windows plugin backup rename held by a scanner: transient (installs after 2 denied renames) and persistent (fails after 16 attempts, old plugin intact) fail with main's install code; rejected hardlinks pins that the reject policy never takes the rename path.
  • 342/342 across the install-package-dir, package-update-swap and package-update-filesystem suites and consumer suites (hooks installs/update, plugin install compensation, plugins update authority, update service-unavailable, Doctor missing plugin install, publication boundary).
  • tsgo:core, tsgo:core:test, type-aware core oxlint and oxfmt clean; test-lines ratchet passes.

Reviews on head 7d0176bcd83: Codex autoreview scoped-clean. The independent read-only Codex review of the first revision found the hardlink-policy bypass, fixed here.

Gap: installed updaters run the first hop, so users get this on the update after it ships.

Plugin installs and updates moved the live plugin, the staged install and
the rollback backup with fs-safe's copy fallback. On Windows a scanner
holding one plugin file turned the rename EPERM into a copy that then
failed deleting the held file, so plugin installs and update plugin
convergence failed.

Plugin install moves now go through movePackageRoot, which on Windows
uses the bounded identity-checked rename retries the package swap already
uses and reports a publication receipt; other platforms keep the copy
fallback.
@clawsweeper

clawsweeper Bot commented Oct 31, 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.

@steipete
steipete marked this pull request as ready for review October 31, 2026 14:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T14:53:26.021195Z 7d0176b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR routes plugin installation, backup, and restoration through bounded Windows rename retries.

Example: A Windows scanner holds an installed plugin’s dist/index.js open for 4 seconds.

  • Before: The update fails while deleting the held source file after copying a backup.
  • After: The reported native Windows experiment completes the update after five retries.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful native filesystem evidence supports the repair, but the introduced hardlink-policy bypass blocks landing.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its native Windows experiment exercises installPackageDir with real held-file handles, but supplies no shipped-command or latest-stable upgrade capture.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A temporary scanner lock aborts a Windows plugin install or update.
Reason: The maintainer-authored direction addresses a demonstrated failure through an existing owner without adding configuration or public APIs.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: the Windows repair is useful, but its new publication path bypasses the existing hardlink rejection policy.

Priority: P1
Reviewed head: 262084ba3cdaf82ffd2572d76d21db0db5990816

Before merge

  • [P1] Preserve hardlink rejection in the Windows move branch (P1) - installPackageDir passes sourceHardlinks: "reject" for generic and dependency-free installs, but this branch never reads that option. A Windows stage containing a file hardlinked outside the stage is now renamed into the live installation and reported successful, retaining the external inode alias. Previously fs-safe rejected existing hardlinks and deliberately copied reject-policy sources into fresh inodes before publication. The existing staged-hardlink regression describes this input but skips Windows. Preserve that guarded reject-policy path, or provide equivalent rejection and inode isolation, rather than applying package-manager rename semantics to every plugin move.
  • Resolve security concern: Published plugin bytes can retain an external inode alias - Changing the file through its other hardlink can change published bytes after validation; the previous reject-policy publication prevented that alias from surviving.
  • Explain or restore the original intent of Generic installation hardlink rejection - fix(update): allow package-manager hardlinks in swaps #85569: Hardlink allowance was explicitly scoped to package-manager roots while generic plugin and hook moves remained fail-closed.

Findings

  • [P1] [P1] Preserve hardlink rejection in the Windows move branch — src/infra/package-update-filesystem.ts:142-146
  • [medium] Published plugin bytes can retain an external inode alias — src/infra/package-update-filesystem.ts:142

Provenance

Tests

  • Missing end-to-end proof: The supplied native owner experiment does not demonstrate the shipped Windows plugin command or a latest-stable upgrade preserving existing settings and data.
Agent review details

How this fits together

The package-directory installer prepares plugin and hook packages, publishes them into canonical installation roots, and retains receipts for rollback through the shared filesystem owner.

flowchart TD
  A[Plugin and hook installers] --> B[Package directory transaction]
  B --> C[Shared package filesystem owner]
  C --> D[Windows rename retries]
  C --> E[Guarded copy fallback]
  D --> F[Installed package and backup]
  E --> F
Loading

Technical review

Best possible solution:

Reuse the existing retry owner while preserving guarded hardlink rejection and inode isolation for generic plugin and hook publication.

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

Current-main source and the dependency contract establish the held-file copy-and-unlink failure, corroborated by the author’s native Windows experiment.

Is this the best way to solve the issue?

Sharing the existing retry owner is appropriate, but its package-manager assumptions must not replace generic installation safety contracts.

Full review comments:

  • [P1] [P1] Preserve hardlink rejection in the Windows move branch — src/infra/package-update-filesystem.ts:142-146
    installPackageDir passes sourceHardlinks: "reject" for generic and dependency-free installs, but this branch never reads that option. A Windows stage containing a file hardlinked outside the stage is now renamed into the live installation and reported successful, retaining the external inode alias. Previously fs-safe rejected existing hardlinks and deliberately copied reject-policy sources into fresh inodes before publication. The existing staged-hardlink regression describes this input but skips Windows. Preserve that guarded reject-policy path, or provide equivalent rejection and inode isolation, rather than applying package-manager rename semantics to every plugin move.
    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 e6aa04477b30.

Provenance checked

  • Windows move policy keeps the original intent (3140acb: Package-manager updates use exact rename retries to avoid publishing a copy before held-source cleanup fails.)
  • Publication receipts and rollback ownership keeps the original intent (eaa614a: Record publication before subsequent failures and retain exact identities and current lifecycle authority for recovery.)

Testing

Proof path: in-process harness.

Security

Needs attention: Windows publication no longer enforces the caller’s hardlink boundary.

Evidence

Security concerns:

  • [medium] Published plugin bytes can retain an external inode alias — src/infra/package-update-filesystem.ts:142
    Changing the file through its other hardlink can change published bytes after validation; the previous reject-policy publication prevented that alias from surviving.
    Confidence: 0.99

What I checked:

  • Introduced hardlink-policy bypass: Plugin moves now pass their hardlink policy to movePackageRoot, but its Windows branch calls the rename helper without consulting sourceHardlinks; only the non-Windows branch forwards that policy. (src/infra/package-update-filesystem.ts:142, 262084ba3cda)
  • Applicable dependency contract: OpenClaw directly imports @openclaw/fs-safe/atomic and pins 0.27.0, establishing applicability. Its complete repository policy and tagged move implementation were read: reject mode checks hardlinks and deliberately publishes fresh copied inodes rather than renaming the source tree. (src/move-path.ts, 67dee5ef4c03)
  • Explicit historical boundary: fix(update): allow package-manager hardlinks in swaps #85569 explicitly limited hardlink allowance to package-manager roots and preserved generic rejection. Current install tests cover rejecting hardlinked existing and staged packages, but skip these cases on Windows. (src/infra/install-package-dir.test.ts:323, 262084ba3cda)
  • Current-main behavior and related repair: Fetched main retains the guarded fs-safe calls for plugin moves. fix(update): retry Windows pnpm/bun project moves instead of copying a held tree #188498 introduced the reusable package-update retry owner and explicitly excluded plugin installs. (src/infra/install-package-dir.ts:639, e6aa04477b30)
  • Supplied Windows evidence: The full body reports native Windows installPackageDir experiments with real held-file handles, transient recovery, and persistent-lock failure preserving the old plugin. The captured body identity is 9e9a4af158cb6ddf6fe86158395d35bdea18739251265a795bfd866d1c5a7c7b; this review did not execute target code. (262084ba3cda)
  • Exact-head checks and checkout: All paginated check runs were completed without failures, and the aggregate CI gate succeeded for the reviewed head; GitHub reported a clean merge. The checkout remained clean. (262084ba3cda)

Likely related people:

  • Peter Steinberger: Raw commit 3140acb adds src/infra/package-update-filesystem.ts:119 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3140acb54221; files: src/infra/package-update-filesystem.ts)
  • Patrick Erichsen: Raw commit db0d3d0 adds src/infra/install-package-dir.ts:278 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: db0d3d00ce53; files: src/infra/install-package-dir.ts)

PR surface

Source +12, Tests +42. Total +54 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 45 33 +12
Tests 1 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 87 33 +54

Labels

Label changes:

  • add P1: Scanner locks break Windows plugin updates, and the proposed repair introduces a publication-boundary regression.
  • add merge-risk: 🚨 security-boundary: Windows publication can retain external inode aliases despite the caller’s explicit hardlink rejection policy.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: Scanner locks break Windows plugin updates, and the proposed repair introduces a publication-boundary regression.
  • merge-risk: 🚨 security-boundary: Windows publication can retain external inode aliases despite the caller’s explicit hardlink rejection policy.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • 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 execution lanes are retired.

Reviewed October 31, 2026, 10:39 AM ET / 14:39 UTC.

@steipete steipete changed the title fix(plugins): Windows plugin installs fail when a scanner holds a plugin file fix(plugins): Windows plugin updates fail when a scanner holds a plugin file Oct 31, 2026
@steipete
steipete merged commit 4f9c852 into main Oct 31, 2026
125 checks passed
@steipete
steipete deleted the codex/plugin-install-windows-retry branch October 31, 2026 15:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…in file (openclaw#189451)

* fix(plugins): retry Windows plugin install renames instead of copying

Plugin installs and updates moved the live plugin, the staged install and
the rollback backup with fs-safe's copy fallback. On Windows a scanner
holding one plugin file turned the rename EPERM into a copy that then
failed deleting the held file, so plugin installs and update plugin
convergence failed.

Plugin install moves now go through movePackageRoot, which on Windows
uses the bounded identity-checked rename retries the package swap already
uses and reports a publication receipt; other platforms keep the copy
fallback.

* fix(plugins): keep rejected hardlinks on fs-safe's fresh-copy publication

Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Backport #188498 and its explicitly selected #189451 companion from
3140acb and
4f9c852.

Preserve retained lifecycle authority, publication receipts, and
fresh-copy handling for rejected hardlinks.

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

Labels

merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

1 participant