Skip to content

fix(write): align Windows create-on-directory errors and document final-link modes - #745

Merged
steipete merged 4 commits into
mainfrom
codex/fix-windows-create-directory-20260927
Sep 28, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/fix-windows-create-directory-20260927

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

create("existingDirectory", ...) must report already-exists: docs/errors.md explicitly includes an existing file or directory, and the writing guide promises that code when the target exists. Windows legacy buffered creation already honors that contract; the shared pinned preflight incorrectly returned not-file. Admit directories only to the existing collision rejection, preserving non-regular type, hardlink, boundary and policy checks. No destination is opened or changed.

Add a public differential replay covering eight create-only variants in separate off/auto/require processes, and compare their error code/category and unchanged directory contents. The replay also records Windows final-link and parent-junction behavior for omitted policy, explicit rejection and rename-identity compatibility. Run it under both Node and Bun in native CI, including windows-latest and windows-2022. Existing Windows legacy target-reauthorization tests remain unchanged.

The writing/security/native documentation now states the actual Windows modes. With omitted mutationSymlinks, the native pinned writer rejects a final link (path-alias) and parent junctions can fail with invalid-path; the legacy JS writer can use an unchanged contained final-link target or an admitted parent-junction target. Explicit mutationSymlinks: "reject" supplies uniform rejection.

Contract finding for coordinator decision: the previous unqualified “omitting preserves existing behavior” language and native guide's “public policy does not change with the selected mechanism” promise do not describe those existing differences. Read as cross-implementation guarantees, native rejection is the divergence from the established Windows legacy contract. This PR documents current results and leaves native behavior unchanged; it does not settle whether a future native path should honor that legacy behavior.

Validation:

  • Baseline at a386202bcbaf0229397df7dc37ddc673f8e2ef34: node scripts/root-create-directory-proof.mjs off fails because it receives not-file instead of documented already-exists.
  • Candidate node scripts/root-create-directory-proof.mjs and bun scripts/root-create-directory-proof.mjs: all eight create variants agree in off/auto/require (48 local mode/runtime cases).
  • pnpm test test/root-create-directory-differential.test.ts test/root-create-only-preflight.test.ts test/root-windows-legacy-policy-boundaries.test.ts --maxWorkers=1: 4 passed, 13 Windows-only skips on the macOS host.
  • pnpm docs:check, git diff --check, independent Codex P2 review: passed.
  • Local pnpm check stops at the known Homebrew Rust WASM-target mismatch; the approved packaged WASM asset was used for local focused tests. Exact-head hosted CI and coverage are green at 0939ed36393688d5b39ac5cb4aeb2a49cb639394. Both Windows latest and Windows 2022 native jobs passed the Node and Bun differential replay steps, including the documented link modes.

Supersedes the rejected blanket-admission candidate #741, now closed with its branch retained. No changelog edit for this bug-hunt round. Do not merge; coordinator review and landing remain separate.

@clawsweeper

clawsweeper Bot commented Sep 28, 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 requested a review from a team as a code owner September 28, 2026 03:36
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 1:41 AM ET / 05:41 UTC (Revision 4).

ClawSweeper review

What this changes

The branch changes Root create-only writes to report an existing directory as already-exists, adds cross-mode filesystem proof, and documents existing Windows native and JavaScript link behavior.

Merge readiness

⛔ Blocked before merge - 4 items remain

Current main still returns the wrong error for create-only writes to an existing directory, so this focused PR remains useful. Its Windows link documentation also changes how a public policy guarantee is described and needs an explicit maintainer decision.

Priority: P2
Reviewed head: cc938684a56c2f720005b6f3078c8d8c9dde4481
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair has strong real-filesystem proof, with a release-note omission and an unresolved public link-policy decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed Root write admission is exercised through the built public API against real temporary directories. At the tested pre-merge head, Windows 2022 and latest hosted Node and Bun replay steps passed assertions for eight collision variants, unchanged contents, and documented link modes. No stored-data format or schema changes.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed Root write admission is exercised through the built public API against real temporary directories. At the tested pre-merge head, Windows 2022 and latest hosted Node and Bun replay steps passed assertions for eight collision variants, unchanged contents, and documented link modes. No stored-data format or schema changes.
Evidence reviewed 11 items Current-main defect: Current main sends every non-file target, including a directory, to not-file before reaching the collision error.
Existing error contract: The current-main error reference already says an existing file or directory at a create destination is already-exists.
Introduced repair: The pinned preflight now routes directories to the existing collision rejection while retaining the non-regular-type and file-hardlink checks.
Findings 1 actionable finding [P3] Add an Unreleased note for the public error-code correction
Security None None.

How this fits together

Root receives a caller's path, write options, and data, then checks the path and policy before selecting a pinned or legacy writer. The admission step determines whether creation proceeds or returns an error without changing an existing destination.

flowchart LR
A[Create-only request] --> B[Root path and policy checks]
B --> C{Existing target}
C -->|File or directory| D[Already exists error]
C -->|Other type| E[Not file error]
C -->|Missing| F[Pinned or legacy writer]
F --> G[New file]
Loading

Decision needed

Question Recommendation
May the public docs treat omitted mutationSymlinks on Windows as implementation-dependent for final links and parent junctions, with explicit reject as the uniform policy? Accept the documented exception: Keep this narrow create fix and explicitly support the existing Windows mode split while directing callers who need uniform rejection to set mutationSymlinks: "reject".

Why: The observed native and legacy behavior differs under an existing public policy promise; choosing the supported security and compatibility contract requires maintainer intent.

Before merge

  • Add an Unreleased note for the public error-code correction (P3) - This public create() error-code change still leaves Unreleased empty. AGENTS.md and CONTRIBUTING.md call for a concise user-facing entry for behavior changes. This finding remains from the earlier review.
  • Resolve merge risk (P1) - The PR would publish implementation-dependent Windows final-link and junction behavior for omitted mutationSymlinks, qualifying an earlier mechanism-independent policy promise. A maintainer must accept that public compatibility exception or choose a different contract before merge.
  • Complete next step (P2) - Add a concise Unreleased Fixes entry and obtain maintainer approval for the documented Windows omitted-policy link exception.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P3] Add an Unreleased note for the public error-code correction — src/root-write-admission.ts:407-409
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code footprint production +2/-2; test and proof +145/-2 The production change is small; most added executable code exercises real filesystem behavior across modes.

Root-cause cluster

Relationship: canonical
Canonical: #745
Summary: This is the narrower live follow-up to the closed, unmerged Windows admission candidate.

Members:

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

Merge-risk options

Maintainer options:

  1. Approve the Windows exception (recommended)
    Explicitly accept the documented existing mode split as the public compatibility contract, with uniform rejection available through the explicit policy.
  2. Hold for uniform behavior
    Pause this contract change until a separate native and legacy alignment has reviewed filesystem authority and upgrade behavior.

Technical review

Best possible solution:

Keep create-only collision errors consistent across backends, preserve existing confinement and legacy authorization checks, and publish a maintainer-approved Windows link contract with a concise release note.

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

Yes. The submitted baseline replay reports not-file for an existing directory, and current main retains that exact preflight branch; I did not execute the replay on this checkout.

Is this the best way to solve the issue?

Yes for the create-only defect: the branch changes the narrow collision preflight and verifies unchanged destinations. The long-term Windows link contract still needs a maintainer decision.

Full review comments:

  • [P3] Add an Unreleased note for the public error-code correction — src/root-write-admission.ts:407-409
    This public create() error-code change still leaves Unreleased empty. AGENTS.md and CONTRIBUTING.md call for a concise user-facing entry for behavior changes. This finding remains from the earlier review.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 85474b5e9cb5.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This corrects a documented error-code mismatch for a bounded Root create-only case.
  • merge-risk: 🚨 compatibility: The documentation would make an existing Windows mutation-policy promise explicitly dependent on the selected writer.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 changed Root write admission is exercised through the built public API against real temporary directories. At the tested pre-merge head, Windows 2022 and latest hosted Node and Bun replay steps passed assertions for eight collision variants, unchanged contents, and documented link modes. No stored-data format or schema changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Root write admission is exercised through the built public API against real temporary directories. At the tested pre-merge head, Windows 2022 and latest hosted Node and Bun replay steps passed assertions for eight collision variants, unchanged contents, and documented link modes. No stored-data format or schema changes.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a concise Unreleased Fixes entry for the observable error-code correction.
  • Record the maintainer decision on the Windows omitted-policy link contract.

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 (3 earlier review cycles)
  • reviewed 2026-09-28T03:40:54.860Z sha 16490f3 :: blocked before merge. :: [P3] Add an Unreleased note for the public error-code fix
  • reviewed 2026-09-28T04:00:32.323Z sha 0939ed3 :: blocked before merge. :: [P3] Add an Unreleased note for the error-code correction
  • reviewed 2026-09-28T04:33:46.169Z sha 0939ed3 :: blocked before merge. :: [P3] Add an Unreleased note for the public error-code fix

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@steipete
steipete merged commit a3ccbc4 into main Sep 28, 2026
47 checks passed
@steipete
steipete deleted the codex/fix-windows-create-directory-20260927 branch September 28, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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