Repository navigation
fix(atomic): retain parent preparation errors when close fails - #820
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 October 1, 2026, 4:32 PM ET / 20:32 UTC (Revision 2). ClawSweeper reviewWhat this changesAtomic file replacement now reports parent-directory preparation and close failures together, with regression coverage and updated documentation. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main and v0.22.0 still replace preparation failures with close failures. The introduced patch has no actionable correctness findings. Priority: P2 Review scores
Verification
How this fits togetherAtomic replacement prepares and verifies the destination’s parent directory before creating a temporary file and publishing its contents. Preparation failures stop publication and are returned to the caller after descriptor cleanup. flowchart TD
A[Replacement request] --> B[Verify parent directory]
B --> C[Apply directory mode]
C --> D[Close parent descriptor]
D --> E{Preparation succeeded?}
E -->|Yes| F[Stage and publish replacement]
E -->|No| G[Report preparation and close errors]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain operation-first error aggregation while preserving fail-closed parent admission, descriptor lifetime, and publication ordering. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the trigger: a parent stat or chmod failure followed by a close failure causes current main to report only the latter. The added public-API regression covers that path; this review did not execute it. Is this the best way to solve the issue? Yes, aggregating only simultaneous failures is a narrow repair consistent with existing atomic temporary-file error handling. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7a520c1b6883. 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 (1 earlier review cycle)
|
|
Merged as b4c0815 after verifying and pinning head 999af02 in the squash-merge API call. The regression fails on main for both sync and async replacement: parent stat/chmod throws, close throws, and the preparation error was discarded. The fix retains the errors in operation-first order, including falsy primary values, closes once, and prevents temp creation/publication after failed preparation. Validation: 101 focused atomic tests passed; Codex autoreview clean through P2; 38 exact-head checks passed with only intentionally skipped jobs. CI: https://github.com/openclaw/fs-safe/actions/runs/36921637485 . CodeQL: https://github.com/openclaw/fs-safe/actions/runs/36921637676 . The first green head required an ordinary base update because strict branch protection required current main; the updated head was fully revalidated. No admin bypass, tag, release, or publication. |
Add bounded transition checks for small pending-hint budgets, missing descendants, case and Unicode aliases, undecodable names, exclusions, directory lifecycle, scope replacement and subscription isolation. Verify invalidation-only cache convergence and calibrate failure cleanup and four-pass polling bounds. Add seeded TypeScript reference properties, 65,536 Rust Pending operations, and sync/async atomic fault-injection coverage. Include the finite corpus in the nightly five-runner stress workflow. No new dependency or test-only restructuring. Validated with 500 poll and 500 event seeds on Linux, APFS macOS and NTFS Windows, focused properties and Rust checks on each OS, plus exact-head all-OS CI and CodeQL. Parent-close precedence and Windows dangling-leaf creation were fixed separately in #820 and #823.
When atomic replacement encounters a parent-directory preparation failure and closing that directory also fails, both APIs currently discard the preparation error. For example, an injected
EIOfrom the parent descriptor's stat followed byEPERMfrom close reports onlyEPERM.Preserve both failures in an
AggregateError, with the operation error first and close error second. This covers async admission, async mode application, and sync preparation, including falsy thrown values. A close failure on its own remains unchanged. Preparation failure still prevents temporary-file creation and publication, and each descriptor is closed once.Validation:
8b6c276bfor both sync and async APIs.Includes atomic-write documentation and an Unreleased Fixes entry. No release or publication.