Repository navigation
feat: harden atomic replacement and output staging - #62
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 10:45 PM ET / July 27, 2026, 02:45 UTC. ClawSweeper reviewWhat this changesThis PR adds opt-in hardlink rejection and original-content restoration to atomic replacement, and adds sibling-directory staging as an atomic-output mode for externally produced files. Merge readiness⛔ Blocked until real behavior proof is added - 4 items remain Keep this PR open for targeted validation: it materially expands security-sensitive public filesystem-write behavior, while both Windows Node check jobs are failing and the PR body provides result claims rather than inspectable after-fix runtime evidence. Likely related people: steipete is the available recent area contributor signal (low confidence, based on this single implementation commit); broader current-main ownership could not be established from the available read-only inspection path. Priority: P2 Review scores
Verification
How this fits together
flowchart LR
A[Caller content or external producer] --> B[Temporary staged file]
B --> C[Identity and link checks]
C --> D[Atomic rename or copy fallback]
D --> E[Rooted destination]
E --> F[Durability and cleanup receipt]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Resolve the Windows failures, then provide redacted after-fix terminal or runtime evidence exercising copy-fallback restoration and sibling staging on their relevant platforms, while preserving the existing default workspace-staging and non-restoring fallback contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds opt-in APIs rather than reporting a pre-existing bug. The relevant validation is an after-fix platform exercise of the Windows permission fallback and sibling-directory commit path. Is this the best way to solve the issue? Unclear: the proposed guarded staging and pinned-handle approach is directionally appropriate, but it is not yet the best confirmed solution until the failed Windows checks and real after-fix behavior evidence support its platform-specific safety claims. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b1be2a119986. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: feat: harden atomic replacement and output staging This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
destinationHardlinks: "reject"checks to async and sync atomic replacementcopyFallbackRestore: "restore-original"recovery with typedrestored/restore-failedcleanup receiptswriteExternalFileWithinRoot({ staging: "sibling" })for fsynced same-filesystem atomic replacement, while retaining private workspace staging as the defaultfallbackFileNamefor both external-output staging modesConsumers
OpenClaw's exec-approvals write path can use the restore and hardlink policies when a Windows permission fallback would otherwise risk leaving state partially written. Callers delegating output production through
writeExternalFileWithinRoot()can now choose sibling staging when the destination directory is the writable boundary and atomic overwrite is required.Safety model
The restore path snapshots and rewrites through the same pinned destination handle, enforces an explicit restore-byte budget before mutation, fsyncs both the replacement and any recovery, and reports whether recovery succeeded. Sibling output staging pins and validates the producer file, rejects symlink/hardlink/size violations, guards the target parent identity, then renames over the destination without following an existing symlink entry.
Proof
pnpm check— 55 files, 597 passed, 7 platform skips; build, boundary lint, file-size lint, and package check passedpnpm test:security— 5 files, 59 passedpnpm pack:check— passedThis PR is intended for the unreleased 0.5.0 line. It does not publish or release anything.