Repository navigation
refactor(atomic): share sync and async resource ownership - #772
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 11:14 PM ET / October 1, 2026, 03:14 UTC (Revision 28). ClawSweeper reviewWhat this changesThe branch shares synchronous and asynchronous atomic-write staging, restoration, and cleanup procedures, updates their callers and regression coverage, and fixes clock-dependent ZIP benchmark fixtures. Merge readiness✅ Ready for maintainer review Keep open: current main still has separate atomic-write owners, and the related merged work does not replace this contribution. No actionable introduced defect was found; the recorded performance acceptance still covers this patch. Likely related people: steipete — recent atomic-area contributor, high confidence. Priority: P2 Review scores
Verification
How this fits togetherfs-safe’s atomic writer receives file content, destination paths, and optional authority checks from applications and higher-level storage helpers. It stages and verifies files before publication, then settles descriptor ownership and temporary-file cleanup. flowchart TD
A[Content and destination] --> B[Path and option admission]
B --> C[Shared atomic writer]
D[Caller authority checks] --> C
C --> E[Owned temporary file]
E --> F[Rename or copy fallback]
F --> G[Publication verification]
G --> H[Cleanup and result]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep one internal atomic owner for both modes while preserving identity-gated cleanup and the existing public durability, restoration, and authority contracts. Do we have a high-confidence way to reproduce the issue? Not applicable to the internal consolidation; no introduced bug was established. The ZIP fixture regression supplies a concrete triggering timestamp. Is this the best way to solve the issue? Yes: the shared procedures remove parallel ownership implementations without adding public API or configuration surface, and the fixture repair leaves archive admission unchanged. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fce1668bc3bc. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (27 earlier review cycles; latest 8 shown)
|
|
The coordinator has lifted the performance hold for this refactor after the independent adversarial review found no P0/P1 and no demonstrated P2 runtime defect. The measured costs were approximately 4–5% on the opt-in copy/restore fallback paths, reached only after rename fails with EPERM/EEXIST; these are small absolute costs on filesystem synchronization-bound operations. Hot native-on and native-off paths showed no meaningful slowdown. Those fallback costs do not justify blocking the 501-line production consolidation. The historical measurements remain in the PR body; this decision changes the landing criterion, not the data. Three intentional behavior differences were reviewed:
All eight commits have been rebased onto main at |
9d1a45d to
be3e9ab
Compare
c6c06df to
d5d507a
Compare
d5d507a to
acc540c
Compare
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: refactor(atomic): share sync and async resource ownership This is item 1/1 in the current shard. Shard 0/1. This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Drop internal switches, an injected filesystem, and a type re-export that lost their last real use in #772's atomic consolidation; reuse errorCauseOptions and hasNodeErrorCode for exactly equivalent hand-written checks; correct two comments that misdescribed publication visibility and staging cleanup. Branch selection, sync/async boundaries, errors and causes are unchanged; net -12 production lines.
Synchronous and asynchronous atomic writes maintained separate staging, retry, copy, restoration, and cleanup procedures. This change gives them a shared internal I/O adapter and temporary-file owner while preserving the public entry points and filesystem guards. FileStore writes, JSON directory synchronization, sibling temporary files, and temporary case probing reuse those procedures.
The complete candidate removes 501 production lines under the unchanged whole-project counter: 56,952 → 56,451. All adapters and callers are counted. Cleanup registration now receives removal authority from an admitted identity or retained-owner callback, avoiding a lookup of the not-yet-created temporary path. Public APIs and migration requirements are unchanged.
Candidate
9d1a45daremoves forwarding generators around metadata inspection and chunk I/O. Synchronous calls consume ordinary values; asynchronous calls retain their await boundaries. Exact identity checks, forced-synchronous builtin admission, mutation authority, restoration, and cleanup/error precedence remain in place. Three public adapter regressions exercise real FileHandles and preserve short-write offsets, the two positive write-result observations, zero-progress rejection after one observation, and one read-result observation per bounded snapshot chunk.Performance hold: lifted by the coordinator. The independent adversarial review found no demonstrated runtime defect and no meaningful hot-path slowdown. The approximately 4–5% measured costs are confined to opt-in copy/restore fallback after rename fails with EPERM/EEXIST, with small absolute costs on synchronization-bound operations. The coordinator accepts this tradeoff for the 501-line production consolidation; the old fixed 5% fallback criterion no longer blocks landing. Historical measurements follow unchanged.
The preceding
1979deb2candidate passed its fixed 128-workload Linux Node 24/native-off exploratory screen's correctness checks, but did not establish the final 5% non-regression requirement. Guarded no-restore sync fallback was +5.342% (+14.801 µs), sync short-write fallback +3.946%, and async short-write fallback +5.350% (+114.312 µs), with upward control drift in the last case. Several ordinary sync paths improved, but those results do not offset slower endpoints. All samples and earlier experiments are retained separately, without pooling.Validation for
9d1a45da:pnpm check, including its package tail, passed 16,785 tests with 691 skips.d1549ea9, which adds only main's separate watch fix; target atomic files are unchanged. The dedicated proof above and head-pinned package receipts separately attest frozen F2/treee55b6e10.Historical status before the coordinator decision: the new A/F performance comparison was being prepared with the same fixed 128-workload design on a replacement 16-CPU runner. No F performance result is claimed yet.
A separate six-call A/D syscall diagnostic confirmed that the earlier cleanup change removes one missing-temp lookup while preserving the remaining observed filesystem sequence, including file fsync → rename → directory fsync. It is diagnostic evidence, not latency qualification for the latest candidate.
The landing gates are final rebased-head cross-platform correctness/package qualification, coverage, mutation, independent P0–P2 review, and CodeQL; their completed results are recorded below. The coordinator has lifted the additional performance hold as explained above.
Intentional reviewed differences: internal
registerTempPathForExitnow requires an admitted identity or retained-owner callback rather than adopting an entry by name; all production callers already supply one. Injected syncfchmodSyncis invoked unbound instead of receiving undocumented internal parameter objects asthis. Microtask scheduling differs, but the final authority assertion still directly precedes every mutation without yielding. Public API signatures remain unchanged.First rebased candidate
be3e9ab3(onto main851bd85a): all eight commits retained. Range comparison confirms source and test patches are unchanged; the only integration edit moves the cleanup note toUnreleased → Performanceand adds the PR link. Released 0.21.3 and 0.22.0 sections are untouched.Local qualification: frozen install passed. Build passed with the installed Rust compiler explicitly selected after the default compiler lacked its WASM target. Focused atomic/FileStore/JSON/copy/sibling/case/cleanup/settlement tests passed: 79 files, 1,744 tests, 57 platform skips. Full
pnpm checkpassed lint, boundary, build, allocator-artifact build and documentation checks, then finished with 13,145 passing tests and one five-second ZIP extraction timeout under heavy host contention. The complete archive file passed all 17 tests at its unchanged timeout on isolated retry. The package-check tail passed separately.git diff --checkand the 500-line test-file gate pass (largest changed test: 474 lines).Independent managed Codex review of the complete rebased diff and supplied adversarial context is scoped-clean at P0–P2, with no findings. The first rebased head completed CI, coverage, mutation, and an explicitly dispatched CodeQL run successfully. The first automatic CodeQL event was cancelled/skipped during the ready transition.
Latest landing candidate:
acc540cd, rebased onto mainfce1668bafter #770, #769, #760, #765, #782, #781, #783, and #784 landed. All eight original commits are retained, plus the bounded benchmark fixture fix below. The rebases preserve all source/test patches; conflicts were confined to changelog placement. The final UNC-admission integration applied without conflict and retains the new guard before filesystem access. CurrentUnreleasedcontains this PR's atomic cleanup note under Performance, alongside #760; released sections remain untouched. Previous heads completed all required hosted gates before subsequent main changes required another rebase.CI on intermediate head
58c1e9f4found a pre-existing clock-dependent ZIP benchmark fixture failure in the Windows native lane (run 36793426311). At UTC 00:02:02, the DOS timestamp value 65 completed a false end-of-central-directory record in the dense payload; the parser correctly rejected the resulting ambiguous archive. The fixture and parser were unchanged by the atomic refactor. The benchmark now uses a fixed timestamp, and a regression using the triggering clock fails before the fix and passes afterward. The fixture helper is shared with that regression. No archive admission behavior changed.The complete latest diff is independently scoped-clean at P0–P2. A fresh Linux runner fetched and verified
acc540cd, installed frozen dependencies, built the native binding and WASM from source, and passed uninterruptedpnpm check: 700 files and 17,017 tests passed, with 729 platform skips, including the package-check tail. The same runner passed 1,930 focused tests with 30 platform skips. Final local build, file-size and whitespace gates pass, and the final local focused run passed 1,886 tests with 63 platform skips without retries. Earlier local full-check and focused timeout attempts on superseded heads passed unchanged-file retries; those attempts are not described as uninterrupted passes.Final-head hosted qualification: CI, coverage, mutation, and CodeQL. All required jobs passed on this exact head: nine Node checks, all nine native lanes, both GNU ABI-floor lanes, six package smoke jobs, workflow lint and Cargo checks, five coverage jobs including merged thresholds, three mutation proof jobs, and both CodeQL analyses. The final head passed on attempt 1. The separate benchmark workflow also passed. Manual-only secure-file jobs were skipped by workflow design. No admin bypass has been used. The superseded
c6c06df5coverage run completed its macOS tests/upload but cancelled Windows with no reported assertion failure (exit 130), then remained stuck in the running state. Normal cancel and force-cancel returned HTTP 409 while rerun returned HTTP 403/already running. A fresh coverage dispatch on that identical head was the first executed retry: run 36805912548; it passed all platform coverage jobs and merged thresholds before #783 required the latest rebase.