Skip to content

fix(windows): preserve Unicode permission checks and encoded appends - #303

Merged
steipete merged 1 commit into
mainfrom
codex/windows-fs-stress
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/windows-fs-stress

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where consumers inspecting permissions or securely reading ordinary Unicode Windows paths would receive an unverified-permissions error when the native binding was disabled. icacls can replace pathname and account-name characters before Node receives its output.

Also fixes Root append inserting a duplicate newline into UTF-16LE text that already ends in a newline, or missing a separator after a different character whose final byte happens to be 0a.

Why This Change Was Made

The existing Windows .NET owner query now returns SID and numeric DACL facts in the same response. Coarse inspection and the advanced ACL inspector share those facts, eliminating display-name translation and extra subprocesses. The captured-output parser and remediation builders remain public; explicit advanced classification and translation-failure options retain their behavior. Malformed or unsupported descriptors remain unverified, and error diagnostics retain their original cause and process deadline.

Root append compares the complete encoded newline before writing. Buffer append behavior and the existing mutation/disposal checks remain unchanged.

User Impact

Unicode filenames and directory names work in Windows fallback permission inspection and secure reads. UTF-16LE newline insertion works on Windows and other platforms. No package version, dependency, default, or public signature changes.

Evidence

  • Exact real Windows Unicode secure-read/inspection regression fails on the original owner files and passes after repair; the negative run restores the candidate files in finally. ASCII and Unicode public inspection both pass in native and fallback modes.
  • Exact append regression fails before repair in native-off and auto modes, then passes. Covers an existing newline, a missing newline, a leading appended newline, and U+0A00.
  • Candidate public-API stress: NTFS/ReFS × native off/required, 28/28 operation groups passed. Each cell checks 24 atomic writes with 48 readers, 96 concurrent append records, 48 stream writes and 24 locked JSON updates, 24 exclusive lock holders, 100 walk entries with early-return/cancellation disposal, ZIP roundtrips, and 24 temporary workspaces with repeated cleanup.
  • Broader unchanged ReFS copy stress passed file-size boundaries, Unicode paths, cross-volume policies, 12 concurrent cancellations with settled cleanup and immediate reuse, and 12 writer/alternate-stream failure/retry cases. Three 2,000-directory clones returned to baseline handle counts; directory cloning temporarily retains handles proportional to directory count.
  • Baseline all-method runs passed: 341 fallback cases and 346 native cases, accounting for all 294 callable exports/methods. These are executable surface checks, not exhaustive branch coverage.
  • Focused permission suites: 78 passed, 11 platform skips; five unchanged local cases fail while creating symlink fixtures because this host denies file-symlink creation. No new skips or weakened assertions were added.
  • Full local pnpm check: lint, build, and documentation checks passed; tests reported 7,638 passed, 68 failed, 1,232 skipped, and one unhandled symlink EPERM. Every failure also exists in the baseline: 62 direct symlink EPERM failures, two secondary failures from the same host restriction, three test-harness mock failures, and one unchanged intermediate-directory expectation. No new failure names, skips, or weakened assertions. Hosted CI provides the clean Windows runner gate.
  • Rebased onto current main, rebuilt the Windows native binding, and passed pnpm pack:check (tarball contents, imports, declarations, and public API checks).
  • Additional Windows Node 24 concurrent-create checks: 40 rounds across NTFS/ReFS, fallback/required native modes, public Root.create, and the existing CI writer entry point. All 1,280 attempts produced exactly one intact winner and 31 expected collisions per round. The preexisting main-branch CI failure did not reproduce locally or in this PR's native CI lane.
  • Hosted CI passed on the reviewed commit: Node 22/24 checks on Windows, macOS, and Linux; native checks; package smoke; benchmarks; CodeQL; and combined coverage. CI run, coverage run. Fresh ClawSweeper review also found no actionable issues.
  • Independent P0–P2 autoreview: scoped clean, no actionable findings.

Captured candidate ReFS/native stdout:

{"name":"atomic","status":"passed","ms":44,"writes":24,"reads":48}
{"name":"append","status":"passed","ms":55,"records":96}
{"name":"store","status":"passed","ms":551,"updates":24,"streamWrites":48}
{"name":"locks","status":"passed","ms":369,"holders":24}
{"name":"walk","status":"passed","ms":84,"entries":100}
{"name":"archive","status":"passed","ms":254,"extracts":4}
{"name":"temp","status":"passed","ms":97,"workspaces":24}
{"mode":"require","smoke":false,"passed":7,"failed":0}
  • Tests added or updated when behavior changed
  • Security and compatibility impact considered
  • CHANGELOG.md updated when release-relevant
  • No credentials, private paths, private hosts, or sensitive contents included

@steipete
steipete requested a review from a team as a code owner September 13, 2026 04:09
@clawsweeper

clawsweeper Bot commented Sep 13, 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. 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. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:20 AM ET / 04:20 UTC.

ClawSweeper review

What this changes

The PR replaces Windows fallback ACL display-text parsing with structured security facts and makes Root append recognize complete encoded newlines.

Merge readiness

✅ Ready for maintainer review

Keep open: both fixes remain necessary on pinned main. The introduced changes are coherent, supported by reported Windows before/after verification, and have no identified blocking defect.

Priority: P2
Reviewed head: b4968440ea1aee37530b6bc93ec93b72f8725dee

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant real Windows verification, boundary tests, and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.
Evidence reviewed 9 items Main still contains the append defect: Pinned main compares only the final byte with LF, which misidentifies UTF-16LE newlines and characters such as U+0A00.
Main still uses console-text ACL inspection: The fallback on pinned main invokes icacls, parses its display output, and translates unresolved principal names; the branch replaces that runtime path rather than duplicating an existing fallback implementation.
Structured descriptor validation: The query transports the pathname through base64 and returns canonical SIDs and unsigned masks. Unsupported ACE layouts mark the response incomplete; the parser validates descriptor completeness and every access-rule field.
Findings None None.
Security None None.

How this fits together

fs-safe checks filesystem ownership and permissions before returning sensitive file contents to Node.js callers. Its Root API also performs guarded file mutations, including appending text with an optional newline separator.

flowchart TD
  A[Windows path] --> B[Structured owner and ACL query]
  B --> C[Ownership and permission checks]
  C --> D[Return contents or reject read]
  E[Text and encoding] --> F[Guarded append and newline check]
  F --> G[Updated file]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +80/-144; tests +137/-471 The reduction removes principal-translation machinery and consolidates its fixtures while retaining targeted permission-boundary coverage.

Technical review

Best possible solution:

Use structured Windows security facts for fallback inspection and compare encoded newline bytes within the existing guarded append path.

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

Yes: pinned main's one-byte check explains both UTF-16LE failures, and the supplied Windows before/after account identifies the Unicode fallback failure through real public APIs; no reproduction was executed during this review.

Is this the best way to solve the issue?

Yes: extending the existing owner query removes the lossy display-text boundary, and the append change narrowly corrects encoding handling while preserving mutation guards.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs bounded Windows fallback inspection and encoded-append defects without evidence of an urgent widespread outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.

Label justifications:

  • P2: This repairs bounded Windows fallback inspection and encoded-append defects without evidence of an urgent widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Windows before/after results exercise the changed permission-query owner through Unicode inspection and secure reads, and the changed append path through all four UTF-16LE scenarios in off/auto modes; reported candidate outcomes pass, with NTFS/ReFS runtime output providing supplemental coverage.

Evidence

What I checked:

  • Main still contains the append defect: Pinned main compares only the final byte with LF, which misidentifies UTF-16LE newlines and characters such as U+0A00. (src/root-impl.ts:964, da0b2c43fd19)
  • Main still uses console-text ACL inspection: The fallback on pinned main invokes icacls, parses its display output, and translates unresolved principal names; the branch replaces that runtime path rather than duplicating an existing fallback implementation. (src/permissions-windows.ts:295, da0b2c43fd19)
  • Structured descriptor validation: The query transports the pathname through base64 and returns canonical SIDs and unsigned masks. Unsupported ACE layouts mark the response incomplete; the parser validates descriptor completeness and every access-rule field. (src/windows-owner.ts:45, b4968440ea1a)
  • Rejection remains before content reads: Secure reads reject unknown permission facts, foreign owners, and prohibited world/group grants before invoking the file-content reader. The new ACL summary preserves conservative allow-grant classification without subtracting deny entries. (src/secure-file.ts:176, b4968440ea1a)
  • Focused boundary coverage: Updated tests cover malformed descriptors, null versus empty DACLs, inherit-only grants, deny entries, explicit classification overrides, and original diagnostic causes. Secure-read tests retain foreign-owner and unsafe-grant rejection. (test/permissions-failures.test.ts:98, b4968440ea1a)
  • Contributor runtime evidence: The complete supplied PR body reports Windows Unicode inspection and secure-read failures with original files followed by successful candidate runs, plus before/after append verification in native-off and auto modes. It also supplies candidate ReFS/native operation output and reports 28/28 NTFS/ReFS operation groups passing. Captured context sourceRevision: ee48accbc9a3099a13f8fe67bb186b248629ab48093b7b0afbf3b8082709ed21. These are contributor observations; this read-only review did not rerun them. (b4968440ea1a)

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.

@steipete
steipete merged commit 1aa2149 into main Sep 13, 2026
28 of 29 checks passed
@vincentkoc
vincentkoc deleted the codex/windows-fs-stress branch September 25, 2026 11:15
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. 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