Repository navigation
fix: avoid synchronous compiler files during plugin loading - #200193
Conversation
Compile verified captured source text and serve generated modules through load hooks. Prepare stable execution aliases at the existing capture owner and remove the temporary compiler tree. Extend the main-thread filesystem guard to catch direct writable opens. Record the measured retained-source memory and preparation costs in the PR.
|
🦞👀 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 Summary: ✅ CompletedThis 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 maintainer review before merge. What this changesThis PR compiles verified captured plugin text in memory and serves generated modules through Node load hooks. Example: Execute twenty TypeScript modules from the supplied 200-file plugin fixture.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-owned repair removes a concrete blocking compiler I/O path, and review found no introduced correctness or security defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherPlugin capture verifies source bytes and prepares private execution paths; instance admission resolves modules, and compiler hooks deliver executable JavaScript to Node. flowchart LR
A[Plugin source files] --> B[Capture and receipt verification]
B --> C[Verified text and execution paths]
C --> D[Instance admission and resolution]
D --> E[Compiler load hooks]
E --> F[Node module execution]
Technical reviewBest possible solution: Keep verified source custody and instance admission authoritative while supplying compiler output through the existing load hooks. Do we have a high-confidence way to reproduce the issue? Current main synchronously reads captured text and creates, writes, and removes compiler files; the supplied audit reports baseline failures, while this read-only review ran no target code or btrfs reproduction. Is this the best way to solve the issue? The patch follows the smallest complete repair: carry verified text from capture, preserve existing resolve-only paths and admission, delete the compiler tree, and retain compiler-process cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f4fa17a710be. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +76, Tests +81, Docs +3, Other +213. Total +373 across 18 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed November 16, 2026, 1:10 PM ET / 18:10 UTC (Revision 2). |
|
The previous review has zero open items. Final head 94e6bd6 includes the small HTTP-readiness fixture repair exposed by CI. Its identical failure reproduces on exact CI main parent 410c0dd and originates in #200038. The fixture now holds stat, with unchanged liveness/draining assertions; the focused case, affected types/lint and fresh Codex review pass. Compiler production and measured costs are unchanged. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#200193) * fix: avoid synchronous compiler files during plugin loading Compile verified captured source text and serve generated modules through load hooks. Prepare stable execution aliases at the existing capture owner and remove the temporary compiler tree. Extend the main-thread filesystem guard to catch direct writable opens. Record the measured retained-source memory and preparation costs in the PR. * test: hold the current runtime readiness filesystem operation
Related: #200136, #200162
What Problem This Solves
Fixes: loading captured TypeScript and JSX plugins can stall Gateway requests while synchronous compiler output writes wait for a filesystem transaction.
User Impact
Compilation consumes verified captured text and delivers generated modules through load hooks, eliminating the compiler's synchronous source opens, output writes, temporary directory creation, and cleanup. This trades memory for event-loop safety: the measured 13.1 MB source fixture retains about 13.2 MB more heap. Preparation still has separate synchronous metadata paths being repaired in follow-up work; this PR does not claim a globally filesystem-free loader.
Why This Change Was Made
The Team 25c9790 incident on 2026-11-16 at 05:02 PST showed a Gateway main-thread lock create blocked for 1.97 s in btrfs_create → start_transaction → wait_current_trans, producing a 2,002 ms event-loop stall during scheduler:update.remote-model-catalog. Back-to-back managed worktree removals triggered the filesystem commit. #200136 deleted that redundant catalog lock; this PR repairs the compiler boundary found by the same audit.
The existing capture traversal publishes stable typed-module execution paths and retains source text only after its existing hash/size verification. The compiler consumes those facts and supplies generated code through its existing hooks. Instance admission continues to own source resolution; only private generated helpers are resolved directly by the compiler. The temporary compiler tree and its lifetime are deleted. No new cache, configuration, schema, dependency, or protocol is added.
Production grows by 76 lines across nine existing modules. The growth carries verified text and execution paths through the existing capture projection and serves output/helper text in memory. It is a bounded representation change, separated from the larger capture-custody repair.
Evidence
The real compiler mutation guard fails before the change. The final regression prepares the artifact through its actual worker, removes its captured typed source, and still executes the expected result from verified retained text with zero compiler mutations. The source-reopen regression also fails before the change. The shared observer also distinguishes read-only opens from writable string/numeric flags, including O_RDONLY | O_CREAT. Its new actual-open regression is red on the previous observer; that regression and the final compiler process guard pass together. Existing mutation guard coverage now includes this flow.
Initial focused runs passed 50 cases in five files and 192 cases with one existing skip in four interop/snapshot files. An attempted source-resolution shortcut caused eight startup-condition failures; it was removed because it bypassed instance admission. Final focused proof passes all twelve selected cases covering those eight failures, three existing resolve/compile cases, and the actual process guard. Core types, touched type-aware lint, script lint, format, and diff checks pass. Isolated Codex autoreview is clean P0–P2.
Two full
pnpm check:changed --base HEADruns completed. Task-owned findings were repaired and their final focused gates rerun. The unchanged dead exports reproduce on exact parent 6670297 and were introduced by 24385a2 / #200056; they are a main regression, not a waived baseline. The complete command is not claimed green on final source. Exact-head PR CI remains the broad gate.Twenty serialized fresh Node 26.12.1 processes provide five A/A controls and five A/B pairs, with separate first-use and warm operations. The fixture contains 200 typed files totaling 13,107,200 UTF-8 bytes; each operation executes twenty modules and checks their results. The surrounding synthetic 35 GiB database, 5,000 sessions, and 62,000 workspace files are not queried by this compiler owner. No Team data was used. Measurements are on APFS, not btrfs; filesystem audit instrumentation was excluded from timings.
A/A owner medians were 1,219.16 / 1,228.81 ms; allocation 46.30 / 48.95 MB; heap growth 6.084 / 6.088 MB. Owner p95 was 1,331.97 → 1,474.92 ms. The 28.4% allocation increase and 33.6% retirement increase are accepted, measured costs: retained text accounts for about 13.23 MB and preparing all 200 aliases adds cleanup compared with twenty demand-created compiler files. No speedup or noise claim is made. Separate profiles show existing compiler child execution remains the dominant cost. The reproducible workload is included in this PR.
Twenty native alias canonicalization calls remain, as does a host-module Jiti lstat. Cold dependency loading, known plain JS/CommonJS native loading, legacy synchronous capture, and unknown runtime-selected imports remain explicit follow-up boundaries. Removing alias canonicalization by bypassing admission was demonstrated incorrect and is not part of this fix. Runtime UI import tracing found no changed module in the production or browser-test closures; no browser-facing Node import was introduced.
Initial CI 43921438718 failed only the HTTP runtime-readiness fixture. The identical case fails on exact CI main parent 410c0dd: #200038 / 5bd858c changed readiness from access to a probe plus stat without migrating this fixture. The included one-line-net test repair holds stat, returns its real identity, and preserves all liveness/draining assertions. The targeted case, affected types/lint, and fresh Codex review pass. This is a confirmed main regression repaired here, not ignored CI noise; production and measured compiler behavior are unchanged.
Final-head CI 43924328562 succeeded on94e6bd66b684c262b9c87e584aade952fd027880. Final ClawSweeper review6924654208 has zero open items; native review and preparation are complete. Landing is pending.