Repository navigation
fix(root): keep POSIX read admission off the event loop - #1055
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR moves built-in POSIX root acquisition and read admission to asynchronous filesystem operations while retaining synchronous and Windows paths. Example: A POSIX application awaits Root.readText("value") while metadata lookup takes 500 ms.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain Keep open: this PR addresses blocking filesystem work that remains on main, but change-related test failures need repair before merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherRoot and root-file helpers turn untrusted paths into confined reads or pinned descriptors after canonicalization, exact identity checks, and hardlink and symlink policy checks. flowchart TD
A[Caller path] --> B[Root acquisition and traversal]
B --> C[Pinned descriptor open]
C --> D[Exact descriptor identity]
D --> E[Final root and pathname admission]
E --> F[Read bytes or transfer descriptor]
Technical reviewBest possible solution: Retain the shared admission procedures, repair their affected test consumers and exact budget oracles, and verify confined reads and rejected replacements through the installed package. Do we have a high-confidence way to reproduce the issue? Main directly invokes synchronous filesystem operations during awaited root acquisition and final read admission; the PR also reports exact-base failures of its delayed-filesystem regressions, which were not rerun in this read-only review. Is this the best way to solve the issue? Reusing the existing procedures and identity verifiers is a sound approach, but the affected identity fixtures and scheduling budgets must follow the new I/O owners without weakening their assertions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ea225ba262cf. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete confinement bypass was found, but the new awaited authorization boundaries need final-effect verification. EvidenceSecurity concerns:
What I checked:
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 2, 2026, 7:56 AM ET / 12:56 UTC. |
What Problem This Solves
Fixes: POSIX root acquisition and guarded reads can block the JavaScript event loop while synchronous filesystem metadata or open calls wait on storage, even when the caller awaits the API.
User Impact
Built-in POSIX
root(),openRootFile(), andRoot.open()/read admission now await filesystem work. The same descriptor remains pinned through the ordered root/path identity checks, and no Root read consumes bytes or transfers the handle before final admission succeeds.Windows keeps its existing synchronous admission and native namespace/delete-sharing behavior. Explicit synchronous APIs and custom
ioFsadapters keep their contracts. Stat/list/walk observation guards and other mutation/durability paths remain outside this change; the native addon may still load synchronously on first use. No version or dependency changes, release, or publication.Why This Change Was Made
The existing async traversal stopped at synchronous root acquisition and final admission. Shared procedures now drive the same validation through async POSIX or retained sync owners. Numeric descriptors use callback filesystem operations so a temporary
FileHandlecannot later close a transferred descriptor. Bun's native canonicalization moves to the existing native task executor without replacing its physical-path, permissions, socket, or record-lock semantics. Home expansion and bounded-read size observations use async filesystem calls too.The final fence remains an ordered, best-effort detection fence, not an atomic namespace primitive. Tests preserve exact bigint comparisons, same-FD custody, rejection of replacements during awaited observations, no data reads before admission, and cleanup after failure. A Windows control retains the no-yield final fence.
There is an idle overhead tradeoff. On a synthetic eight-component, 8.8 KB skill file using Node 24.22.1/macOS, serial A/A and interleaved A/B runs (250 operations/sample, three samples per revision) gave these medians:
Allocation sampling ran separately from timing. The first two identical-base controls differed by -8.6%, -6.9%, and -10.0% in wall time respectively. Candidate wall samples ranged 37–83 µs, 520–908 µs, and 457–815 µs; host variability prevents treating the medians as a precise effect-size estimate. These are owner-level warm measurements, not a production-shaped end-to-end performance claim. The benefit is avoiding event-loop stalls under slow storage, not improving unloaded latency.
Production source changes are +267/-139 lines (net +128); tests/config are +464/-92 (net +372). The growth retains shipped synchronous and Windows contracts while sharing admission logic rather than introducing a second validation owner. No cache or configuration option is added.
Evidence
Delayed-filesystem regression: all four cases fail on exact base
ea225ba262cf4ab86edc12abe374dfc9068833ffand pass on the candidate. Root acquisition, root-file descriptor open, Root read, and first home expansion observe zero tracked sync filesystem calls while a 500 ms metadata delay permits the event-loop heartbeat to progress.Focused ordered-admission, await-swap, replacement-root, pinned-open/close, bounded-read, exact-identity, raw-path/root-spelling, failure-receipt, and realpath consumer tests pass. Updated the Bun native CI selection to include the new root/read regressions.
File-size and filesystem-boundary checks, TypeScript build, and
git diff --checkpass.pnpm checkstops at the mandatory WASM build because local Cargo is unavailable. The initial-head CI compiled the native implementation on Linux/macOS and passed the new Bun 1.4.4 responsiveness/custody tests and Windows runtime/native/package matrix. It found two repaired defects (missing retained identity must fail closed; the FreeBSD subset has no task executor) and stale sync-only test injections/resource classifications. The complete exact-head CI run passes at27bc0a7f5e482317ef9fff339ea04061363fb3e0, including Linux, macOS, Windows, FreeBSD, native/Bun, and bundled-package checks.The CI-produced portable WASM and macOS native artifact enabled focused local archive/resource proof without installing toolchains. All 54 native-mode resource rows pass. Exact-base archive comparisons retain identical syscall totals (for example TAR nondurable 3,908 → 3,908; ZIP durable 4,713 → 4,713). Aggregate syscall ceilings remain unchanged; explicit resource formulas account for offloading existing observations (+11 promises/+1 request per root guard, +9/+1 per portable directory guard).
Independent Codex autoreview: no actionable P0–P2 findings.
Tests added or updated when behavior changed
Security and compatibility impact considered
CHANGELOG.mdupdated when release-relevantNo credentials, private paths, private hosts, or sensitive contents included