Repository navigation
feat(copy): bind copyRootFileSync to an expected source identity - #841
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 6, 2026, 5:06 AM ET / 09:06 UTC. ClawSweeper reviewWhat this changesAdds an optional expected source identity to synchronous guarded file copies and returns the verified source identity alongside the destination identity. Merge readiness✅ Ready for maintainer review This PR remains useful: current main lacks caller-pinned source identity binding, and the additive implementation preserves existing copy safeguards. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherfs-safe's synchronous copier accepts source and destination paths within filesystem roots and creates an exclusive destination. Callers receive an owned destination descriptor and identity facts for subsequent reads and receipts. flowchart TD
A[Source and destination paths] --> B[Guarded path admission]
C[Optional pinned source identity] --> D[Exact source identity check]
B --> D
D --> E[Exclusive native or byte copy]
E --> F[Source and destination verification]
F --> G[Owned destination and identity facts]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the optional identity constraint in the existing guarded copier, with exact bigint checks and unchanged descriptor ownership and omission behavior. Do we have a high-confidence way to reproduce the issue? Not applicable as a new API capability; source inspection establishes that current main cannot bind copy admission to a caller's existing pin. No runtime reproduction was executed. Is this the best way to solve the issue? Yes: reusing the existing exact identity inspector before both destination-creation paths is a narrow solution that retains the established copy and cleanup owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec6206308912. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
OpenClaw synchronous plugin captures pin a source before copying and record its identity in a receipt. If that pathname is replaced before
copyRootFileSyncreopens it, the previous API could copy a different inode. This additive refinement to #839 lets callers bind fs-safe's own admission to their existing pin.expectedSourceIdentityis snapshotted before filesystem observations and checked by the existing bigint identity inspector before destination creation. A mismatch throwspath-mismatch. Every successful copy returns a frozensourceIdentity, verified by the existing source checks through completion. Omission preserves the existing admission behavior. fs-safe still owns its source descriptor; copy policies, byte bounds, modes, cleanup, and destination ownership are unchanged.Final API additions
The existing
identityremains the destination identity, andfdremains its owned readable/writable descriptor.OpenClaw migration sketch
For openclaw/openclaw#161739, keep the successful
openRootFileSyncsource pin and existing source fingerprint/content checks. Derive the expectation from that descriptor with bigint inspection, never from the numeric stat receipt or a new pathname stat. Keep the caller's descriptor open until the copy returns:Use the returned source identity to bind the copy's source facts to the already-pinned receipt record. Keep hashing actual destination bytes through
copied.fd, with bounded reads. Preserve thetoo-largetranslation, ordinary mode0o600 | (source.mode & 0o100), native materialization branch, source hardlink acceptance, later destination verification, and receipt framing. The owner must prove destination freshness before adopting the existing create-only helper.For captured aliases, pin the retained capture inside the capture directory, pass that descriptor's bigint identity as
expectedSourceIdentity, and verify the returnedsourceIdentityagainst that snapshot. Continue recording the original plugin source identity in the ordered receipt; the alias copy's source identity refers to the retained capture inode. Preserve its bytes and mode even if the installed original changed. This library change does not itself modify the OpenClaw call sites.Validation
Final head:
6707c9f840628c8cf8ec61a4e50e46190a4956c2.pnpm checkpassed: 694 test files and 17,220 tests passed, plus lint, build, WASM allocator tests, documentation examples, and installed-package/declaration checks. Used the repository's serial test setting.pnpm pack:checkpassed.pnpm public-api:updateregenerated the export-name/error-code snapshot without a diff, as expected for new type members; installed-package declaration assertions cover both new members.The initial local package build selected Homebrew Rust, whose sysroot lacked the WASM target. Using the documented rustup toolchain resolved this without repository changes. No release.