Skip to content

feat(root): support atomic creation and required file flushing - #486

Merged
steipete merged 4 commits into
mainfrom
codex/fs-safe-atomic-create-20260918
Sep 18, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/fs-safe-atomic-create-20260918

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Consumers that seed files need exclusive creation that keeps incomplete content invisible, even without the native addon, and an explicit way to require file flushing.

User Impact

Root.create() and createJson() now accept atomic: true for complete-content publication and durable: "file" to require successful file fsync. Streamed creation remains staged. Existing buffered defaults and boolean durability behavior remain compatible.

The JavaScript atomic fallback requires same-volume hardlinks. Directory synchronization remains best effort. Errors can follow complete publication; cleanup and publication receipts preserve that distinction.

Why This Change Was Made

Reuse the existing staging and no-clobber publication owners, with shared settlement that retains operation, cleanup, and close failures. Final authority callbacks are followed by descriptor and pathname identity checks before publication. This also preserves complete published files when later mode, sync, or verification work fails.

Related: #482

Evidence

  • Full pnpm check: 13,348 tests passed, 586 skipped; package imports, declarations, documentation examples, and Python protocol checks passed.

  • Real macOS filesystem proof through the compiled public APIs in native off and require modes: atomic buffer/JSON creation, required file flushing, existing-entry preservation, and independent-process publication observers.

  • Regression probes reproduced callback-driven stage replacement on both native publication paths before the fix and pass afterward.

  • Fresh Linux VM: native/WASM build, 267 focused tests, npm/pnpm package smoke with normal and omitted optional dependencies, then a separate installed public-API probe in native off and require modes. Complete 700,018-byte payloads and JSON round-trips passed; independent 1 MiB create races produced one complete single-link winner. This used 91bf3e7; later changes affect test fixtures and upstream docs only.

  • The macOS installed npm/pnpm package checks passed with and without the addon. Full Bun native suite: 1,048 passed, 46 skipped.

  • CI exposed two fixture issues: binding initialization during Windows emulation, and Windows refusing a parent rename with an open child. The fixtures now install the binding before Root construction and replace the empty parent before stage creation. Removing the parent identity fence demonstrably makes the repaired test fail; all original assertions remain.

  • Independent reviews found no actionable P0–P2 issues. Final head 476c36c has 31 successful checks and no failures: CI, coverage, and public mutation proof.

  • 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 18, 2026 20:29
@clawsweeper

clawsweeper Bot commented Sep 18, 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 18, 2026, 4:52 PM ET / 20:52 UTC (Revision 3).

ClawSweeper review

What this changes

Adds optional atomic buffered creation and required file flushing, with shared cleanup reporting and stronger checks before publishing files.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this remains useful work absent from main and the latest release. No actionable patch defect was found, but the previously requested inspectable runtime proof remains outstanding.

Priority: P2
Reviewed head: 476c36cd63ed39fc41a8f470ef798f9893fa4cd0

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent implementation with substantial regression coverage remains gated on inspectable runtime evidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The body reports installed public-API runs through JavaScript and native creation on macOS and Linux, including complete payloads and race winners, but supplies no inspectable transcript or artifact demonstrating visibility and required-flush results; the previous proof request remains unresolved. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The body reports installed public-API runs through JavaScript and native creation on macOS and Linux, including complete payloads and race winners, but supplies no inspectable transcript or artifact demonstrating visibility and required-flush results; the previous proof request remains unresolved. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Repository policy: Read the complete root AGENTS.md and CONTRIBUTING.md. No nested AGENTS.md or maintainer-notes directory was found. Applied filesystem-boundary, compatibility, regression-test, and changelog guidance; did not execute repository helpers or artifact-producing checks.
Main and release still lack these options: Both the pinned main and v0.15.0 source define creation options without atomic or durable: "file". The release API confirms v0.15.0 remains latest. Existing streamed creation does not replace the requested buffered options.
Existing guarded publication is reused: Atomic buffers select staged publication; ordinary buffers retain the direct fallback. The staged writer requires file synchronization when requested, publishes through the existing exclusive hardlink helper, and settles cleanup and close failures.
Findings None None.
Security None None.

How this fits together

Root is fs-safe’s filesystem capability for handling untrusted relative paths. Its guarded writers turn buffers, JSON, or streams into files while checking filesystem identity and caller authority.

flowchart TD
  A[Buffer or JSON input] --> B[Root creation options]
  B --> C{Atomic publication requested}
  C -->|No| D[Existing buffered writer]
  C -->|Yes| E[Complete staged file]
  E --> F[Authority and identity checks]
  F --> G[Exclusive publication]
  G --> H[File or settlement error]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The body reports installed public-API runs through JavaScript and native creation on macOS and Linux, including complete payloads and race winners, but supplies no inspectable transcript or artifact demonstrating visibility and required-flush results; the previous proof request remains unresolved. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Attach the reported filesystem transcript or artifact showing atomic visibility, collision preservation, and required-flush results. Terminal screenshots or recordings are welcome; copied output and logs also count. Redact private paths, endpoints, and credentials. Update the PR body to trigger another review; if needed, ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +287 net (+611/-324); tests +725 net (+728/-3) Production growth implements the requested options and shared settlement; tests cover publication, durability, and failure handling.

Technical review

Best possible solution:

Retain the opt-in guarantees through shared guarded writers, with auditable filesystem evidence for complete publication and strict file flushing.

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

Not applicable: this adds explicit creation guarantees; main and release source establish that these options are currently absent.

Is this the best way to solve the issue?

Yes: extending existing guarded staging and preserving defaults is a focused approach consistent with the direction described in #482.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded creation-API improvement without evidence of an active user-facing emergency.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The body reports installed public-API runs through JavaScript and native creation on macOS and Linux, including complete payloads and race winners, but supplies no inspectable transcript or artifact demonstrating visibility and required-flush results; the previous proof request remains unresolved. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and CONTRIBUTING.md. No nested AGENTS.md or maintainer-notes directory was found. Applied filesystem-boundary, compatibility, regression-test, and changelog guidance; did not execute repository helpers or artifact-producing checks. (AGENTS.md:24, 476c36cd63ed)
  • Main and release still lack these options: Both the pinned main and v0.15.0 source define creation options without atomic or durable: "file". The release API confirms v0.15.0 remains latest. Existing streamed creation does not replace the requested buffered options. (src/root-options.ts:66, 880372e0ed74)
  • Existing guarded publication is reused: Atomic buffers select staged publication; ordinary buffers retain the direct fallback. The staged writer requires file synchronization when requested, publishes through the existing exclusive hardlink helper, and settles cleanup and close failures. (src/pinned-write-staged.ts:59, 476c36cd63ed)
  • Publication boundary checks: JavaScript and native publication recheck retained identities after the final authority callback. Regression coverage includes revoked authority, substituted stages and parents, existing-entry preservation, failed flushing, and preservation after completed publication. (src/native-staged-file.ts:275, 476c36cd63ed)
  • Proof and review continuity: The supplied sourceRevision 7a11d60a70e867f892d8474b6bd476b2c143fdb7fdd6032ebe33b8c1a6d7818e contains reported macOS runs and Linux observations of complete 700,018-byte payloads and single-link race winners. The live body matched that snapshot. Neither provides a transcript or linked artifact showing atomic visibility and required-flush outcomes. The previous review requested that evidence and recorded no code findings. (476c36cd63ed)
  • Reported validation revision remains relevant: Compared GitHub recursive tree records for 91bf3e7 and the reviewed head: all 266 src entries have identical object identities. The reported Linux run therefore targets the same production source. Local inspection of the previous reviewed commit was unavailable; GitHub tree comparison independently established this narrower fact. (91bf3e7110d2)

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.

  • Attach the reported public-API filesystem transcript or artifact showing atomic visibility, collision preservation, and required-flush outcomes in native off and require modes.

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-09-18T20:32:08.802Z sha 91bf3e7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-18T20:39:21.302Z sha 5d0d8f0 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/fs-safe-atomic-create-20260918 branch from 5d0d8f0 to 476c36c Compare September 18, 2026 20:48
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 18, 2026
@steipete
steipete merged commit 50a23bf into main Sep 18, 2026
39 checks passed
@vincentkoc
vincentkoc deleted the codex/fs-safe-atomic-create-20260918 branch September 25, 2026 11:14
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant