#637

perf(du): restore bounded ordered metadata read-ahead

Openasafyishwants to merge intofrom

Closes https://github.com/vercel-labs/just-bash/issues/632

Add opt-in metadata read-ahead to the existing traversal owner and enable it only for du. Reads settle before exit; traversal and diagnostics remain ordered, with the existing budgets charged before I/O.

21 du/traversal tests pass, including a complete 205-file listing, bounded overlap and a metadata-error cleanup regression.

Activity

5
vercel[bot]12d ago

@asafyish is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

auto-maintain[bot]12d ago

🤖 auto-maintain review

Automated, advisory triage for @asafyish's PR. Facts below are read from the GitHub API.

CheckResult
Author's merged PRs (this repo)1
Account established✅ (age 5391d · 13 followers · 7 public repos)
Commits signed/verified⚠️ 0/2
Changeset included⚠️

Review panel: 🟢 low highest severity

just-bash maintainer code review: 🟢 low

No actionable correctness or maintainability issues found in the complete diff.

General code review: 🟢 low

No actionable correctness or maintainability issues found in the complete diff.

Adversarial security: 🟢 low

No actionable adversarial security issues found in the complete diff.

Adversarial security (second opinion): 🟢 low

Bounded, order-preserving metadata read-ahead confined to du; budgets are charged before I/O, batches fully settle before errors propagate, visit order and symlink/cycle handling are unchanged, and no new network, process, dependency, or sandbox surface is introduced. No actionable findings.

Standard Bash and host portability: 🟢 low

No actionable Bash or host portability issues found.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

asafyish11d ago

Fixed the synchronous-throw finding in 8eb37cb6. A regression with an earlier pending lstat and a later synchronous throw failed before the fix (the walk returned while the read was pending) and passes afterward. The change is just an async callback in the existing Promise.allSettled batch. 41 du/traversal/filesystem tests pass.

The security conclusion needs qualification. I tested this sequence against the real ReadWriteFs: cache /child as a directory with lstat, replace it with a symlink to a directory outside the sandbox, then call readdir('/child'). The read is rejected with both allowSymlinks: false and true. readdirWithFileTypes resolves and validates the path independently, and the default configuration also checks for symlinks before reading. Cached traversal metadata does not bypass those checks.

Concurrent mutation of an explicitly symlink-enabled, in-root tree can still make a non-atomic walk observe stale metadata. That is a traversal-consistency limitation, not demonstrated access outside the sandbox. Another traversal-level lstat would leave a check/use race and duplicate the default backend's existing check. I have left that broader mutation behavior unchanged in this du performance PR.