Repository navigation
perf(copy): reuse guarded directory admission within batches - #849
Conversation
Add explicit operation-scoped batch custody for canonical POSIX directory identities while preserving fresh file admission, exclusive creation, descriptor checks, and cleanup. Recheck every retained ancestor and bind initial leaf-parent receipts before caching. Windows and noncanonical spellings retain their existing resolver. Related: openclaw/openclaw#166526. Adds source/destination ancestor-swap regressions and a 3000-file comparison benchmark; no release or version change.
|
🦞👀 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 7, 2026, 8:31 PM ET / October 8, 2026, 00:31 UTC (Revision 3). ClawSweeper reviewWhat this changesAdds disposable synchronous file-copy batches that reuse checked directory identities while preserving per-file validation, with documentation, regression coverage, and comparison benchmarks. Merge readiness✅ Ready for maintainer review Keep open: current main lacks the batch API, and the branch retains useful, distinct work. This Codex review found no blocking correctness or security defect. Priority: P2 Review scores
Verification
How this fits togetherfs-safe’s guarded copy helpers accept source and destination paths within filesystem roots and return an owned destination descriptor. Directory admission protects path boundaries before the existing file-opening, transfer, and cleanup checks run. flowchart TD
A[Source and destination paths] --> B[Single copy or disposable batch]
B --> C[Directory admission cache]
C --> D[Recheck roots and ancestors]
D --> E[Fresh source and destination checks]
E --> F[Native transfer or bounded byte copy]
F --> G[Verify identities and return owned descriptor]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Provide operation-scoped directory reuse while retaining fresh per-file admission, explicit disposal, and the existing platform fallbacks. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: the captured body supplies a concrete filesystem benchmark for the performance improvement, and the benchmark implementation was inspected. Is this the best way to solve the issue? Yes. Explicit disposable batches bound cache lifetime, preserve the existing single-file API, and retain fresh identity checks instead of introducing a global cache or weaker policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eca24b4f32bb. 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
History |
What Problem This Solves
Copying thousands of files repeatedly resolves the same filesystem roots and ancestor paths; this dominates plugin source captures in OpenClaw Doctor (openclaw/openclaw#166526).
User Impact
createRootFileCopyBatchSync()onadvancedexposes a disposable batch whosecopyFile()accepts the existing guarded-copy options and returns the same owned descriptor. Canonical POSIX copies reuse directory admissions across files; ordinarycopyRootFileSyncalso reuses admission within its operation. Windows and noncanonical spellings retain their existing resolver. No version change or publication is included.Why This Change Was Made
The cache retains exact directory identities for one explicit operation and checks every retained ancestor before use, including symlink replacements pointing back to the original tree. It binds the initially admitted leaf parent before caching. Each file still goes through the existing no-follow source-open, root/fd/path identity checks, hardlink policy, exclusive destination creation, native dirfd transfer or bounded byte copy, permissions, and identity-checked cleanup. There is no policy-relaxation option, process-wide cache, or file-admission cache. Earlier successful copies remain caller-owned if a later file fails.
Evidence
pnpm check: 696 test files / 17,308 tests passed; 36 files / 787 platform-specific tests skipped. Docs, build, archive allocator, package/declaration/import checks passed;git diff --checkclean.OpenClaw consumption and end-to-end Doctor timing are a separate proof-only worktree, with no OpenClaw commit. A dependency release and caller adoption are needed for the explicit batch API; the Doctor issue should remain open until that result is established.
CHANGELOG.mdupdated when release-relevant