[PR #1921] [MERGED] fix(javascript): preserve graphs within parent capacity #4911

Closed
opened 2026-10-31 00:56:42 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1921
Author: @N0zoM1z0
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @morluto

Base: main ← Head: fix/1911-javascript-checkpoint-reserve


📝 Commits (1)

  • e11aa90 fix(javascript): preserve graphs within parent capacity

📊 Changes

2 files changed (+163 additions, -12 deletions)

View changed files

📝 src/javascript/analysis/JavaScriptAnalysisWorker.ts (+31 -12)
➕ tests/acceptance/applications/javascriptCheckpointReserveCli.test.ts (+132 -0)

📄 Description

Summary

Two JavaScript source files could lose the earlier file's completed semantic graph because the parent reserved 80% of its original result budget while another source remained. Reserve the next sequential static checkpoint using the existing protocol bound and retention accounting, so useful graphs survive within the available capacity. Fixes #1911.

Problem and expected behavior

An inert 400-function ES module followed by a small module returned no semantic functions for the earlier source. A directory with ten later small sources has the same problem. Admission should protect the next checkpoint and enforce actual retained/live-heap capacity rather than an arbitrary fraction of the original budget.

Change and scope

The worker owner reserves one maximum 8-MiB checkpoint at its existing retained expansion of six, matching the sequential producer. Previously retained facts stay charged to the existing ledger. Remove the superseded static-reserve ledger. Genuine parent-side rejections now report effective available capacity and module/graph retention estimates, and point callers to the facts that survived.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScriptAnalysisWorker, at parent checkpoint and transfer admission.
  • CLI and MCP/tool-catalog contract: unchanged requests and schemas; additive diagnostic limit fields and producer-specific recovery guidance.
  • Provider, bridge, target-format, or platform compatibility: existing JavaScript worker protocol and execution limits retained.
  • Evidence, artifact, provenance, or reconstruction contract: preserve exact artifact identities, existing static/module facts, explicit partial coverage and semantic unknowns.
  • Process execution, authorization, cleanup, or containment impact: existing owned-process, heap, decode, transfer, cancellation and cleanup protections retained.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Add public CLI cases for one and ten later sources, plus a 600-function source under a 448-MiB parent heap that must reject the graph while preserving static/module facts and accurate recovery guidance. The negative case exceeds even the otherwise-empty parent's available budget, so acceptance cannot depend on GC timing.

  • Base replay fails the earlier-source semantic preservation assertion.

  • Representative failure now includes parent_available_result_budget_bytes, module_retention_estimate_bytes and graph_retention_estimate_bytes; remediation explains that increasing the worker heap alone does not increase parent capacity.

  • Real Linux CLI and fresh stdio MCP checks on two generated modules of 439,680 and 438,705 bytes complete without worker-heap failure or parent-budget rejection. CLI retains 20,000 semantic nodes from each source. Semantic coverage remains explicitly partial.

  • Remaining proof gaps: the manual resource-limited workflow was run on Linux/Node, not Bun or other operating systems. The heap-specific CLI cases explicitly skip Bun, whose runtime does not enforce the V8 flags.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • Public CLI capacity, worker lifecycle, stdio MCP resource/cancellation and tool-effects wording tests: 21 passed across six files on the refreshed main base.
  • Actual generated-module CLI analysis on the final rebased source: completed in 35.35 seconds, process-tree peak 1,002,668,032 bytes, zero OOM events, unchanged input digests.
  • Fresh stdio MCP summary, retained module views, Evidence bundle and subsequent ping on the final rebased source: passed in 32.02 seconds with unchanged input digests.
  • npm run check — typecheck, lint, formatting, unused-code, metadata and architecture guards passed.
  • npm run verify:test-discovery — all 862 test files discovered exactly once; final CLI cases also passed after test typing corrections and deterministic capacity sizing.
  • Initial CI identified the main-base static-tool wording failure, independently fixed upstream by #1917. This branch includes that main fix; no tool-effects change is included in this PR.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux Node.js 24.18.0 JavaScript CLI/MCP; native/browser providers are outside this change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: inert source analysis; no target execution, new authority, installation, or increased worker heap limits.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed; no request/schema change requires regenerated documentation.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/1921 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/1911-javascript-checkpoint-reserve` --- ### 📝 Commits (1) - [`e11aa90`](https://github.com/morluto/rea/commit/e11aa90ff1064db52a0ef6fbca92f9a21edcea02) fix(javascript): preserve graphs within parent capacity ### 📊 Changes **2 files changed** (+163 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src/javascript/analysis/JavaScriptAnalysisWorker.ts` (+31 -12) ➕ `tests/acceptance/applications/javascriptCheckpointReserveCli.test.ts` (+132 -0) </details> ### 📄 Description ## Summary Two JavaScript source files could lose the earlier file's completed semantic graph because the parent reserved 80% of its original result budget while another source remained. Reserve the next sequential static checkpoint using the existing protocol bound and retention accounting, so useful graphs survive within the available capacity. Fixes #1911. ## Problem and expected behavior An inert 400-function ES module followed by a small module returned no semantic functions for the earlier source. A directory with ten later small sources has the same problem. Admission should protect the next checkpoint and enforce actual retained/live-heap capacity rather than an arbitrary fraction of the original budget. ## Change and scope The worker owner reserves one maximum 8-MiB checkpoint at its existing retained expansion of six, matching the sequential producer. Previously retained facts stay charged to the existing ledger. Remove the superseded static-reserve ledger. Genuine parent-side rejections now report effective available capacity and module/graph retention estimates, and point callers to the facts that survived. ## Contract and boundary impact - Semantic owner and earliest changed stage: `JavaScriptAnalysisWorker`, at parent checkpoint and transfer admission. - CLI and MCP/tool-catalog contract: unchanged requests and schemas; additive diagnostic limit fields and producer-specific recovery guidance. - Provider, bridge, target-format, or platform compatibility: existing JavaScript worker protocol and execution limits retained. - Evidence, artifact, provenance, or reconstruction contract: preserve exact artifact identities, existing static/module facts, explicit partial coverage and semantic unknowns. - Process execution, authorization, cleanup, or containment impact: existing owned-process, heap, decode, transfer, cancellation and cleanup protections retained. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Add public CLI cases for one and ten later sources, plus a 600-function source under a 448-MiB parent heap that must reject the graph while preserving static/module facts and accurate recovery guidance. The negative case exceeds even the otherwise-empty parent's available budget, so acceptance cannot depend on GC timing. - Base replay fails the earlier-source semantic preservation assertion. - Representative failure now includes `parent_available_result_budget_bytes`, `module_retention_estimate_bytes` and `graph_retention_estimate_bytes`; remediation explains that increasing the worker heap alone does not increase parent capacity. - Real Linux CLI and fresh stdio MCP checks on two generated modules of 439,680 and 438,705 bytes complete without worker-heap failure or parent-budget rejection. CLI retains 20,000 semantic nodes from each source. Semantic coverage remains explicitly partial. - Remaining proof gaps: the manual resource-limited workflow was run on Linux/Node, not Bun or other operating systems. The heap-specific CLI cases explicitly skip Bun, whose runtime does not enforce the V8 flags. - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - Public CLI capacity, worker lifecycle, stdio MCP resource/cancellation and tool-effects wording tests: 21 passed across six files on the refreshed main base. - Actual generated-module CLI analysis on the final rebased source: completed in 35.35 seconds, process-tree peak 1,002,668,032 bytes, zero OOM events, unchanged input digests. - Fresh stdio MCP summary, retained module views, Evidence bundle and subsequent ping on the final rebased source: passed in 32.02 seconds with unchanged input digests. - `npm run check` — typecheck, lint, formatting, unused-code, metadata and architecture guards passed. - `npm run verify:test-discovery` — all 862 test files discovered exactly once; final CLI cases also passed after test typing corrections and deterministic capacity sizing. - Initial CI identified the main-base static-tool wording failure, independently fixed upstream by #1917. This branch includes that main fix; no tool-effects change is included in this PR. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: Linux Node.js 24.18.0 JavaScript CLI/MCP; native/browser providers are outside this change. - Package or release metadata impact: none. - Security, privacy, process, or containment review: inert source analysis; no target execution, new authority, installation, or increased worker heap limits. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed; no request/schema change requires regenerated documentation. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:56:42 +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#4911
No description provided.