[PR #7012] [MERGED] fix(verifiers): load shared source without compiler processes #7571

Closed
opened 2026-11-03 13:38:48 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7012
Author: @gensokyo-dev
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @gensokyo-dev

Base: main ← Head: fix/verifier-source-loader-20261024


📝 Commits (1)

  • 309e282 fix(verifiers): load shared source without compiler processes

📊 Changes

3 files changed (+349 additions, -13 deletions)

View changed files

📝 docs/testing.md (+10 -0)
📝 scripts/lib/verifier-source-loader.mjs (+110 -13)
➕ tests/boundary/process/verifierSourceLoading.test.ts (+229 -0)

📄 Description

Problem and outcome

Cold source loading left an esbuild process after verifier commands closed, causing agentenv's real cleanup check to fail. Main subsequently added a shared loader that calls esbuild's global stop(). Against that latest implementation, executed regressions show three remaining failures: the generic adapter retains its compiler, generic/package errors have different class identities, and loading a verifier invalidates a caller-owned esbuild context.

All five adapters now use main's shared loader entrypoint. Replace its unsafe global compiler shutdown with in-process source transformation. Node transforms this checkout's TypeScript in process, with one URL-keyed source graph. Scoped hooks retain native resolution/loading and validation, map missing relative .js/.mjs aliases to existing source, and preserve existing JavaScript, foreign module failures, ESM/CommonJS formats, import attributes, query strings and fragments. Node owns the process-lifetime module cache; no transformed output is persisted across Node versions. Cleanup checks remain strict. Production analysis, public schemas and target authority are unchanged.

Executed validation

Linux x64, pinned Node 24.22.1 / npm 11.16.0, two CPUs:

  • Latest-main loader d361c53c5: three assertion failures, independently proving the remaining compiler, split identities and destroyed external compiler context (6.25 s wall / 7.03 s CPU / 483.9 MiB sampled family RSS). Source mutations were restored.

  • Final related suite: 82 passed in 11 files, including real commands, PTY cancellation, late/denied cleanup, retry, file ownership and Python parsing (107.23 s / 110.44 s CPU / 909.5 MiB).

  • Minimum supported Node 22.23.4 (official archive SHA-256 verified): 36 passed in four files (27.22 s / 26.55 s CPU / 660.6 MiB). The scoped loader regression covers native JavaScript priority, foreign imports, parameter properties/enums, CommonJS, malformed attributes, syntax failures, source identity and selected URI components.

  • Rebased on 3d84215bb: the four loader cases plus the new request-verifier ownership test passed (5 tests, 28.31 s wall / 37.64 s CPU / 1181.6 MiB, including artifact preparation). Final npm run check and git diff --check passed (23.77 / 44.84 s / 2754.5 MiB).

  • npm run docs:check: passed on the final head, including nine README conformance tests (15.72 s / 19.67 s CPU / 752.9 MiB). npm run verify:test-discovery: all 2406 files discovered exactly once (1.11 s / 1.20 s CPU / 294.3 MiB).

  • After rebasing on de088fcec, 16 tests in four files passed, including main's new native source ownership and model-fixture finalization tests (58.65 s wall / 65.09 s CPU / 1171.8 MiB, including build preparation). The four retained loader/ownership cases also passed on Node 22.23.4 using the already prepared artifacts (6.20 s / 7.42 s CPU / 449.1 MiB). Updated npm run check passed (26.50 s / 48.90 s CPU / 2656.8 MiB), as did git diff --check. An attempted test:local selection was correctly rejected before execution because these are built boundary tests; it is not counted as a passing test run.

Equivalent completed bootstrap tasks (fresh Node processes, same package command, cleanup and live lineage check, cold then warm module load; three runs per implementation; OS file cache not controlled):

Metric Main loader In-process loader
Median whole-task wall time 1.781 s 1.554 s
Median process-family CPU 1.763 s 1.762 s
Median cold module phase 1231 ms 1038 ms
Median warm module phase 472 ms 418 ms
Maximum sampled family RSS 122.4 MiB 168.3 MiB

This small bootstrap task gets faster with essentially unchanged CPU, while peak RSS grows by 45.9 MiB. It is not an analysis speedup claim. Agent tokens were not measured; runtime payloads are unchanged. Source transformation uses Node's supported module APIs; output is never reused across Node versions.

The pre-rebase ccf06a6b head passed the real agentenv workflow: framework 0.9.1334 exported and executed the smoke environment task and returned a verified cleanup receipt. This was dispatched explicitly because the ordinary path classifier did not select agentenv. The local agent-env executable is unavailable. Windows' root lineage observer explicitly reports unavailable; its source/command boundaries remain covered by the Windows CI lane. RSS sums descendants at 100 ms intervals and may double-count shared pages or miss brief/reparented processes; it is not a hard aggregate cap. Tests had a 3 GiB sampled stop, builds/static/docs an 8 GiB stop, elapsed guards and CPU affinity; no OOM occurred.

Codex and Greptile reviewed ccf06a6b and reported no actionable findings. That head's real agentenv workflow passed. Main then independently adopted the generic adapter change and added a cold generic-loader regression; this PR was rebased on de088fcec and removes its duplicate generic-only scenario while retaining shared constructor identity and external-compiler ownership coverage. Codex and Greptile also completed review of the updated 309e2828 head without actionable findings. Its real agentenv run passed; ordinary CI also completed successfully: 32,521 tests passed, zero failed, 233 skipped, all eight built shards, source tests, static/docs and native package checks passed.

Author readiness

Human owner: @gensokyo-dev

The owner explicitly delegated readiness declarations and agent-managed review. Inspection and execution were performed by Codex; no separate human inspection is claimed.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7012 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `fix/verifier-source-loader-20261024` --- ### 📝 Commits (1) - [`309e282`](https://github.com/morluto/rea/commit/309e282856cdf868c1357748160acf458ed43180) fix(verifiers): load shared source without compiler processes ### 📊 Changes **3 files changed** (+349 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/testing.md` (+10 -0) 📝 `scripts/lib/verifier-source-loader.mjs` (+110 -13) ➕ `tests/boundary/process/verifierSourceLoading.test.ts` (+229 -0) </details> ### 📄 Description ## Problem and outcome Cold source loading left an esbuild process after verifier commands closed, causing [agentenv's real cleanup check](https://github.com/morluto/rea/actions/runs/40089760299/job/120860434550) to fail. Main subsequently added a shared loader that calls esbuild's global `stop()`. Against that latest implementation, executed regressions show three remaining failures: the generic adapter retains its compiler, generic/package errors have different class identities, and loading a verifier invalidates a caller-owned esbuild context. All five adapters now use main's shared loader entrypoint. Replace its unsafe global compiler shutdown with in-process source transformation. Node transforms this checkout's TypeScript in process, with one URL-keyed source graph. Scoped hooks retain native resolution/loading and validation, map missing relative `.js`/`.mjs` aliases to existing source, and preserve existing JavaScript, foreign module failures, ESM/CommonJS formats, import attributes, query strings and fragments. Node owns the process-lifetime module cache; no transformed output is persisted across Node versions. Cleanup checks remain strict. Production analysis, public schemas and target authority are unchanged. ## Executed validation Linux x64, pinned Node 24.22.1 / npm 11.16.0, two CPUs: - Latest-main loader `d361c53c5`: **three assertion failures**, independently proving the remaining compiler, split identities and destroyed external compiler context (6.25 s wall / 7.03 s CPU / 483.9 MiB sampled family RSS). Source mutations were restored. - Final related suite: **82 passed in 11 files**, including real commands, PTY cancellation, late/denied cleanup, retry, file ownership and Python parsing (107.23 s / 110.44 s CPU / 909.5 MiB). - Minimum supported Node **22.23.4** (official archive SHA-256 verified): **36 passed in four files** (27.22 s / 26.55 s CPU / 660.6 MiB). The scoped loader regression covers native JavaScript priority, foreign imports, parameter properties/enums, CommonJS, malformed attributes, syntax failures, source identity and selected URI components. - Rebased on `3d84215bb`: the four loader cases plus the new request-verifier ownership test passed (**5 tests**, 28.31 s wall / 37.64 s CPU / 1181.6 MiB, including artifact preparation). Final `npm run check` and `git diff --check` passed (23.77 / 44.84 s / 2754.5 MiB). - `npm run docs:check`: passed on the final head, including nine README conformance tests (15.72 s / 19.67 s CPU / 752.9 MiB). `npm run verify:test-discovery`: all **2406 files discovered exactly once** (1.11 s / 1.20 s CPU / 294.3 MiB). - After rebasing on `de088fcec`, **16 tests in four files passed**, including main's new native source ownership and model-fixture finalization tests (58.65 s wall / 65.09 s CPU / 1171.8 MiB, including build preparation). The four retained loader/ownership cases also passed on Node 22.23.4 using the already prepared artifacts (6.20 s / 7.42 s CPU / 449.1 MiB). Updated `npm run check` passed (26.50 s / 48.90 s CPU / 2656.8 MiB), as did `git diff --check`. An attempted `test:local` selection was correctly rejected before execution because these are built boundary tests; it is not counted as a passing test run. Equivalent completed bootstrap tasks (fresh Node processes, same package command, cleanup and live lineage check, cold then warm module load; three runs per implementation; OS file cache not controlled): | Metric | Main loader | In-process loader | | --- | ---: | ---: | | Median whole-task wall time | 1.781 s | 1.554 s | | Median process-family CPU | 1.763 s | 1.762 s | | Median cold module phase | 1231 ms | 1038 ms | | Median warm module phase | 472 ms | 418 ms | | Maximum sampled family RSS | 122.4 MiB | 168.3 MiB | This small bootstrap task gets faster with essentially unchanged CPU, while peak RSS grows by 45.9 MiB. It is not an analysis speedup claim. Agent tokens were not measured; runtime payloads are unchanged. Source transformation uses [Node's supported module APIs](https://github.com/nodejs/node/blob/v22.x/doc/api/module.md); output is never reused across Node versions. The pre-rebase `ccf06a6b` head passed the [real agentenv workflow](https://github.com/morluto/rea/actions/runs/40102185630): framework 0.9.1334 exported and executed the smoke environment task and returned a verified cleanup receipt. This was dispatched explicitly because the ordinary path classifier did not select agentenv. The local agent-env executable is unavailable. Windows' root lineage observer explicitly reports unavailable; its source/command boundaries remain covered by the Windows CI lane. RSS sums descendants at 100 ms intervals and may double-count shared pages or miss brief/reparented processes; it is not a hard aggregate cap. Tests had a 3 GiB sampled stop, builds/static/docs an 8 GiB stop, elapsed guards and CPU affinity; no OOM occurred. Codex and Greptile reviewed `ccf06a6b` and reported no actionable findings. That head's real agentenv workflow passed. Main then independently adopted the generic adapter change and added a cold generic-loader regression; this PR was rebased on `de088fcec` and removes its duplicate generic-only scenario while retaining shared constructor identity and external-compiler ownership coverage. Codex and Greptile also completed review of the updated `309e2828` head without actionable findings. Its [real agentenv run](https://github.com/morluto/rea/actions/runs/40103376608) passed; [ordinary CI](https://github.com/morluto/rea/actions/runs/40103378850) also completed successfully: **32,521 tests passed, zero failed, 233 skipped**, all eight built shards, source tests, static/docs and native package checks passed. ## Author readiness Human owner: @gensokyo-dev The owner explicitly delegated readiness declarations and agent-managed review. Inspection and execution were performed by Codex; no separate human inspection is claimed. - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:38:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7571
No description provided.