Skip to content

fix: avoid synchronous compiler files during plugin loading - #200193

Merged
steipete merged 2 commits into
mainfrom
steipete/lane2535-plugin-compiler
Nov 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/lane2535-plugin-compiler

Conversation

@steipete

@steipete steipete commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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 HEAD runs 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.

Warm median Before After
Preparation 953.86 ms 1,010.38 ms
Compile 247.36 ms 240.02 ms
Retirement 10.95 ms 14.63 ms
Total owner time 1,214.18 ms 1,255.91 ms
Main-thread CPU 83.80 ms 82.12 ms
Node process CPU 1,061.33 ms 1,153.37 ms
Main-isolate allocation 48.41 MB 62.17 MB
Prepared heap growth 6.10 MB 19.33 MB
Compiler mutation API calls 42 0
Compiler readFileSync / openSync calls 40 / 40 0 / 0

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.

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.
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T17:46:34.500938Z 3e30039 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The reported compiler audit records 42 filesystem mutations and 40 synchronous source reads.
  • After: The reported audit records zero compiler mutations or source reads, with approximately 13.2 MB more retained heap.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with no actionable findings; confidence rests on source review and reported compiler-boundary proof while final-head CI remains pending.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the contributor proof gate; its reported production-owner measurements and subprocess regression support the compiler change, while the supplied screenshots concern a different UI change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Loading captured TypeScript or JSX plugins can block unrelated Gateway requests while synchronous compiler filesystem operations wait.
Reason: The maintainer-authored direction removes unnecessary compiler I/O and explicitly accepts its measured memory and preparation costs.

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
Reviewed head: 94e6bd66b684c262b9c87e584aade952fd027880

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied measurements exercise capture and compilation directly; no shipped CLI or Gateway execution of the changed path is shown.
Agent review details

How this fits together

Plugin 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]
Loading

Technical review

Best 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

  • Compiler execution and shutdown keeps the original intent (a25c1f3: Use one-shot esbuild execution so compilation leaves no resident service or synchronous API worker.)
  • Demand-created compiler paths changes intended behavior with a stated reason (fa7f5f9: Avoid creating outputs for unused TypeScript sources while preserving stable resolve-only paths.)
  • Verified capture and recovery custody keeps the original intent (4fe38b9: Reuse immutable source custody while keeping private execution files and independent callback lifetimes.)
  • Main-thread filesystem observer keeps the original intent (db4b2ed: Detect synchronous filesystem work that can block Gateway runtime checks.)
  • HTTP readiness fixture keeps the original intent (db4b2ed: Prove HTTP liveness and current draining state while runtime preparation waits for filesystem I/O.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a25c1f3 adds src/plugins/plugin-source-build.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a25c1f3868aa; files: src/plugins/plugin-source-build.ts)
  • Dallin Romney: Raw commit d0e09e4 adds src/plugins/plugin-generation-capture.ts:123 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d0e09e419d7e; files: src/plugins/plugin-generation-capture.ts)
  • Vincent Koc: Raw commit 720f842 adds src/plugins/plugin-generation-capture.ts:98 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 720f8423c8cd; files: src/plugins/plugin-generation-capture.ts)

PR surface

Source +76, Tests +81, Docs +3, Other +213. Total +373 across 18 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 9 351 275 +76
Tests 7 113 32 +81
Docs 1 6 3 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 213 0 +213
Total 18 683 310 +373

Preflight source

Source 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

Metric Value Why it matters
Runtime versus regression growth Production +76 net lines; tests and support +81 net lines Production growth carries verified text and stable execution paths through existing owners; tests cover compiler mutations, source-independent execution, writable-open detection, and the inherited readiness fixture.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Removes a concrete filesystem-blocking path during plugin compilation without claiming to resolve every Gateway stall.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-16T17:59:07.389Z sha 3e30039 :: needs maintainer review before merge. :: none

Reviewed November 16, 2026, 1:10 PM ET / 18:10 UTC (Revision 2).

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Nov 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 16, 2026
@steipete
steipete merged commit ec025eb into main Nov 16, 2026
151 of 154 checks passed
@steipete
steipete deleted the steipete/lane2535-plugin-compiler branch November 16, 2026 18:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant