Skip to content

fix(windows): preflight exclusive creation leaves - #824

Merged
steipete merged 5 commits into
mainfrom
fix/windows-exclusive-leaf-preflight
Oct 2, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/windows-exclusive-leaf-preflight

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Windows Node exclusive opens can follow an existing dangling file symlink. Portable standalone file creation can create the missing referent before descriptor admission rejects the link, unrooted file-lock creation can write the lock record through it, and cross-volume exclusive copy publication can write the source contents before rejecting the destination. Add a shared final-leaf preflight that preserves exclusive-create collision behavior and keeps metadata-inspection failures outside the lock-open denial retry classifier.

Apply the same check to portable create-only writes and internal staging/copy creation. Staging names are random or live in fresh workspaces; these checks harden their existing creation boundary. Descriptor admission and identity-bound cleanup remain in place, and concurrent replacement between preflight and open retains the documented best-effort limitation.

Extend the writable-leaf regression with absolute and relative outside targets plus Windows UNC/device targets. Real Windows comparison before and after #823 shows those outside Root targets were already rejected by path admission without creating a referent. The confirmed outside-directory cases are standalone creators, unrooted locks, and exclusive copy publication; the changelog distinguishes them from #823's in-Root writable-leaf behavior.

Validation: real Windows AWS with Node 24.21.0 and pnpm 12.4.2 compared the parent of #823, main, and the candidate across 160 cases per revision. The fixed candidate created no dangling referent. Another Windows run checked the final production source and passed 177 focused tests (eight existing platform skips). An actual second NTFS volume reproduced the exclusive-copy case on main for absolute and relative targets; the fix kept both referents absent, and 97 focused tests passed. Local pnpm check passes with 13,410 tests. Codex autoreview is clean through P2. The exclusive-creation source is unchanged from the Windows-tested candidate. Main's separate directory-identity correction in #825 is now integrated, and 174 focused tests pass with both corrections present. Exact-head all-OS CI, coverage, and CodeQL passed on integrated head f7faca5. The earlier Windows coverage failure was resolved by the separate exact-directory-identity fix in #825; its integration is P2-clean.

Reject observed symlink leaves before portable exclusive creation while preserving collision and lock-denial provenance. Cover outside-target Root admission, standalone creators, lock records, and shared staging; document the best-effort concurrent replacement boundary.
@steipete
steipete requested a review from a team as a code owner October 2, 2026 01:01
@clawsweeper

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. 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 Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 10:43 PM ET / October 2, 2026, 02:43 UTC (Revision 3).

ClawSweeper review

What this changes

The PR checks Windows destination symlinks before exclusive file creation, adds regression coverage, and documents the portable creation boundary.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main lacks the exclusive-creation checks for standalone creators, fallback locks, and copy publication. No blocking introduced defect was found, and the related merged fixes address different paths.

Priority: P2
Reviewed head: f7faca5d42f6ef339c162f6796616af59637387d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable safety correction with useful reported Windows validation and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. The captured body reports real Windows before/after creation and lock checks plus actual second-volume copy publication; GitHub comparison confirms the tested exclusive-creation source survived main integration unchanged. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. The captured body reports real Windows before/after creation and lock checks plus actual second-volume copy publication; GitHub comparison confirms the tested exclusive-creation source survived main integration unchanged. No stored-data contract changes.
Evidence reviewed 13 items Introduced patch reviewed: Read the complete pinned main-to-head diff across all 23 changed files. The changes add shared Windows leaf inspection without changing dependencies, publishing workflows, public exports, or stored formats.
Fail-closed leaf inspection: The helper is Windows-only, reports observed symlinks as EEXIST, and suppresses only ENOENT. Other metadata failures propagate before opening or writing.
Lock failure provenance preserved: The asynchronous lock path retains native creation first and places portable metadata inspection outside the open-denial classifier. The synchronous and Root lock paths follow the same separation.
Findings None None.
Security None None.

How this fits together

fs-safe turns caller-selected filesystem paths into guarded creation, writing, locking, and publication operations. These checks reject existing symlink destinations before a portable open can create or write their missing targets.

flowchart TD
  A[Caller-selected path] --> B[Path and parent admission]
  B --> C{Native creation available}
  C -->|Yes| D[Native exclusive creation]
  C -->|Portable fallback| E[Inspect destination leaf]
  E -->|Symlink| F[Report existing destination]
  E -->|Absent| G[Exclusive open and descriptor checks]
  D --> H[Guarded file operation]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +76/-5; tests +150/-11 Production growth supports one shared preflight and its creation call sites, with focused filesystem regression coverage.

Technical review

Best possible solution:

Use the shared Windows preflight throughout portable exclusive creation while retaining native paths, descriptor admission, collision semantics, and the documented concurrency limit.

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

Yes: the reported Windows reproduction uses an unchanged dangling destination symlink with portable standalone creation, unrooted locks, or cross-volume copy publication. Main's source confirms these opens precede destination admission; this review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: a shared preflight is a narrow correction for unchanged dangling links, and existing collision mapping and post-open identity checks remain intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P2: This is a bounded Windows creation-safety correction with no demonstrated emergency or broad runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. The captured body reports real Windows before/after creation and lock checks plus actual second-volume copy publication; GitHub comparison confirms the tested exclusive-creation source survived main integration unchanged. No stored-data contract changes.

Evidence

What I checked:

  • Introduced patch reviewed: Read the complete pinned main-to-head diff across all 23 changed files. The changes add shared Windows leaf inspection without changing dependencies, publishing workflows, public exports, or stored formats. (f7faca5d42f6)
  • Fail-closed leaf inspection: The helper is Windows-only, reports observed symlinks as EEXIST, and suppresses only ENOENT. Other metadata failures propagate before opening or writing. (src/exclusive-create.ts:14, f7faca5d42f6)
  • Lock failure provenance preserved: The asynchronous lock path retains native creation first and places portable metadata inspection outside the open-denial classifier. The synchronous and Root lock paths follow the same separation. (src/sidecar-lock-acquire.ts:294, f7faca5d42f6)
  • Current main still needs the fix: Main's standalone creator opens the destination directly before descriptor admission; exclusive copy publication likewise opens its destination without the new leaf inspection. The shared helper is absent from main. (src/create.ts:140, 61cb5f1b889b)
  • Existing exclusive-creation contract: The public creation documentation requires an existing entry to produce already-exists rather than adoption or repair. The patch preserves that contract through the existing collision mapping. (docs/creation.md:5, f7faca5d42f6)
  • Regression coverage: Added cases inspect the missing referent and preserved symlink after Root creation, standalone creation, locks, pinned writes, and atomic staging. Publication coverage selects EXDEV but uses real subsequent filesystem operations; it is supplemental test evidence. (test/windows-exclusive-create-dangling.test.ts:35, f7faca5d42f6)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-10-02T01:05:03.528Z sha 85fc8e2 :: needs changes before merge. :: none
  • reviewed 2026-10-02T01:12:33.051Z sha a5b5bc7 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient Contributor real behavior proof is sufficient. label Oct 2, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient Contributor real behavior proof is sufficient. label Oct 2, 2026
@steipete
steipete merged commit dfad376 into main Oct 2, 2026
50 checks passed
@steipete
steipete deleted the fix/windows-exclusive-leaf-preflight branch October 2, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant