Repository navigation
perf: observe metadata synchronously in archive, copy, publish, and move paths - #248
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 11:04 AM ET / 15:04 UTC (Revision 2). ClawSweeper reviewWhat this changesMoves metadata checks to synchronous Node calls across archive, copy, publication, move, and supporting filesystem operations, and updates their tests and hash diagnostic. Merge readiness✅ Ready for maintainer review The optimization remains useful and is not implemented on current main. The new commit resolves the earlier hash-proof finding; no additional actionable defects were found. Priority: P2 Review scores
Verification
How this fits togetherfs-safe validates untrusted paths and retained file identities before applications read, publish, move, or remove files. This change alters how metadata is observed while preserving the surrounding asynchronous data transfers and filesystem mutations. flowchart TD
A[Paths and archive inputs] --> B[Metadata observations]
B --> C{Identity and containment valid?}
C -->|No| D[Reject operation]
C -->|Yes| E[Asynchronous data and mutation operations]
E --> F[Post-operation verification]
F --> G[Result or safety error]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the established synchronous-observation pattern consistent across Node paths while retaining adapter compatibility, asynchronous mutations, and independent safety checks. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this is an optimization supported by paired real extraction measurements; the earlier diagnostic defect is corrected in source. Is this the best way to solve the issue? Yes. The patch extends the already-merged observation pattern without removing safety checks or introducing a competing API, and preserves custom adapters' asynchronous contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 651df2e7b4fa. LabelsLabel 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)
|
Complete the synchronous-observation rule introduced in PR #238. Archive extraction, copy, publication, move, and directory-mode paths now use synchronous Node metadata observations, preserving native realpath spelling. This removes metadata work from the libuv queue while retaining asynchronous data and structural I/O.
Every existing containment, identity, hardlink, symlink, permission, ownership, deadline, and publication check remains in order. Error codes and application error messages are unchanged. Awaited production test hooks remain in place; no fsync, open, read, write, rename, mkdir, unlink, or close operation was converted or removed.
Scope and exceptions
The source-wide audit also covers sibling staging, temporary workspace cleanup, hashing, secret and secure reads, install paths, walking, lock acquisition/reclamation, queue ownership, and guarded move receipts. Custom filesystem adapters retain their asynchronous metadata contract; the real Node branch uses synchronous observations. Root capability stat calls retain their public async signatures and already use synchronous metadata internally. Linux procfs statfs authentication retains its existing awaited authority-lifetime checks. The default branch in replace-file-descriptor was already synchronous on the baseline and needed no edit.
CHANGELOG.md has one Unreleased entry, and docs/reading.md documents the expanded rule. No generated dist artifacts are committed.
20-file extraction budgets
The fixture contains 20 files in three directories. Counters include all fs/promises functions, async FileHandle methods, and FileHandle.close own properties. Both native auto and off run against the prepared native binding. The tests require zero async lstat, stat, realpath, and FileHandle.stat observations, and pin total async calls to the measured value plus 10 percent. Total filesystem calls are unchanged between baseline and this branch with the same instrumentation.
Backend / format / durability: async calls before to after; reduction
The 80 percent total-async-call reduction target was not reached. All targeted async metadata calls are gone; the remaining calls perform data or structural I/O. For default durable TAR, auto retains 73 opens, 93 close calls, 42 reads, 24 syncs, 23 mkdirs, and 13 other async calls. Off retains 94 opens, 114 close calls, 44 reads, 41 writes, 24 syncs, 66 mkdirs, 43 handle chmods, 20 renames, and nine other async calls.
Supplied 500-file benchmarks
Baseline: origin/main at 651df2e, built in a detached scratch worktree with the same dependencies, prepared WASM, and native artifact. Node 26.8.1, pnpm 11.25.0, macOS arm64. The supplied awaittime and arch harnesses were run in both native modes. The TAR fixture includes AppleDouble entries; the default durability pass still makes 1,023 sync calls. These are single paired runs, not statistical confidence estimates. The final branch measurements ran after the test and packaging jobs finished.
awaittime TAR wall time, milliseconds before to after:
arch warmed extraction, milliseconds per operation before to after:
The 30 percent wall-time target was met for the profiled off-mode default and durable:false runs and the warmed auto runs. It was missed for the profiled auto runs and warmed off runs. Remaining default-TAR costs include 53,136 native realpath observations in auto and 86,546 in off, taking 578 and 826 ms respectively; opens take 271 and 515 ms. The 1,023 sync calls accumulate 729 and 1462 ms of wait time respectively. Attribution overlaps during the bounded durability batches and must not be summed as exclusive wall time. No checks or durability calls were removed to chase the target.
Validation
Security-suite coordinator exception
The only security-suite edit is test/additional-boundary-bypass.test.ts, "captures exact directory identities for temp file cleanup": change the spy from fsp.lstat to fs.lstatSync. Both toHaveBeenCalledWith(target.dir, { bigint: true }) assertions and the intervening mockClear are byte-for-byte unchanged. The initial security run stopped on that mechanism-spy failure; the coordinator explicitly authorized this one-line change, after which all 226 security tests passed. No other security-suite test needed an exception.
Re-pointed tests and shared fixtures
All scenarios and parameterized cases are retained. Synthetic filesystem swaps inside synchronous spies use synchronous fixture operations at the same observation point.
The read-admission helper already intercepted both synchronous and asynchronous observations from PR #238; its read and archive-input identity matrices pass without changing the helper or dropping any cases.