[PR #932] [MERGED] perf(javascript): analyze member chains without recursive copying #2509

Closed
opened 2026-10-17 21:06:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: codex/semantic-member-depth


📝 Commits (4)

  • 6828459 fix(javascript): traverse deep semantic member chains iteratively
  • 04c0042 chore: merge main and retain named reference analysis
  • cc28e18 chore: merge latest main for optimization validation
  • 58c42c5 fix(javascript): preserve deep initializer and pattern analysis

📊 Changes

7 files changed (+287 additions, -116 deletions)

View changed files

📝 src/domain/javascript/electronStaticAnalysisNative.ts (+7 -8)
➕ src/domain/javascript/javascriptSemanticAnalysis.member_depth.test.ts (+154 -0)
📝 src/domain/javascript/javascriptSemanticMemberMutations.ts (+12 -5)
📝 src/domain/javascript/javascriptSemanticProjection.ts (+11 -38)
➕ src/domain/javascript/javascriptSemanticRequireOrigin.ts (+38 -0)
📝 src/domain/javascript/javascriptSemanticValues.ts (+49 -53)
📝 src/domain/javascript/javascriptStaticAnalysisHelpers.ts (+16 -12)

📄 Description

A parser-admitted JavaScript member chain can overflow REA’s semantic analysis or the native-addon detector that runs on every initializer. This prevents application reconstruction even when the initializer has no native dependency. Alias provenance also repeatedly copies an expanding member path, while reference collection repeatedly copies and scans ancestry for non-reference property keys.

Walk member chains iteratively in require-origin recovery, values, provenance, mutation targets, callee naming, and native-addon detection. Share the canonical lexical require resolver and collect complete module paths once. Skip reference ancestry work only when the existing pattern classifier cannot assign that key a binding role. Preserve exact path order, empty keys, dynamic-key uncertainty, shadowing, unknown diagnostics, call locations, and unrelated values after mutations.

Five alternating local full-analysis samples on Node 24.18.0/macOS arm64: a 3,000-property alias initializer falls from 287.3 ms to 17.8 ms; unbound and literal-require initializers fall from 220.9 to 18.9 ms and 104.8 to 18.0 ms. All completed result digests match. Three 12,000-property cases previously throw RangeError and now complete in 74–78 ms. These are synthetic full-analysis workloads, not whole-application speed estimates. The 480,937-byte installed Babel parser produces identical complete semantic IR; its timings do not establish a material general-purpose speedup.

Validation:

  • Build, npm run check:fast, and npm run docs:check pass.
  • 18 focused JavaScript suites: 416 tests pass, including 19 new deep-member/static-analysis regressions.
  • 252 ordinary fixtures: exact complete semantic IR, static analysis, AST fingerprint, and export comparisons; real Babel complete IR matches byte for byte.
  • Compiled CLI and stdio MCP successfully reconstruct the same 12,000-property application fixture with identical normalized evidence; application version, feature-trace, and export-shape verification passes on two fixture versions. The SDK test client uses an explicit 128 MiB receive buffer for this complete graph; its default 10 MiB buffer rejects that large response. No production buffer or output limits changed.
  • Independent Standards and Spec reviews are clean.

No tool contract or output cap changes. JavaScript remains parsed as data. Other recursive expression families and parser-internal depth limits are outside this fix. Real Hopper/Ghidra verification was not performed because these changes concern JavaScript analysis.


🔄 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/932 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/semantic-member-depth` --- ### 📝 Commits (4) - [`6828459`](https://github.com/morluto/rea/commit/68284590da3e0dcede091e4488234f7bcddc393d) fix(javascript): traverse deep semantic member chains iteratively - [`04c0042`](https://github.com/morluto/rea/commit/04c00428d611abe52d37c469d5b8b734b80e76c9) chore: merge main and retain named reference analysis - [`cc28e18`](https://github.com/morluto/rea/commit/cc28e18cdf16f32d9609f5005481af9d44ebdc1f) chore: merge latest main for optimization validation - [`58c42c5`](https://github.com/morluto/rea/commit/58c42c5990548f2e9b9bb72b6710890461ec9feb) fix(javascript): preserve deep initializer and pattern analysis ### 📊 Changes **7 files changed** (+287 additions, -116 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/electronStaticAnalysisNative.ts` (+7 -8) ➕ `src/domain/javascript/javascriptSemanticAnalysis.member_depth.test.ts` (+154 -0) 📝 `src/domain/javascript/javascriptSemanticMemberMutations.ts` (+12 -5) 📝 `src/domain/javascript/javascriptSemanticProjection.ts` (+11 -38) ➕ `src/domain/javascript/javascriptSemanticRequireOrigin.ts` (+38 -0) 📝 `src/domain/javascript/javascriptSemanticValues.ts` (+49 -53) 📝 `src/domain/javascript/javascriptStaticAnalysisHelpers.ts` (+16 -12) </details> ### 📄 Description A parser-admitted JavaScript member chain can overflow REA’s semantic analysis or the native-addon detector that runs on every initializer. This prevents application reconstruction even when the initializer has no native dependency. Alias provenance also repeatedly copies an expanding member path, while reference collection repeatedly copies and scans ancestry for non-reference property keys. Walk member chains iteratively in require-origin recovery, values, provenance, mutation targets, callee naming, and native-addon detection. Share the canonical lexical require resolver and collect complete module paths once. Skip reference ancestry work only when the existing pattern classifier cannot assign that key a binding role. Preserve exact path order, empty keys, dynamic-key uncertainty, shadowing, unknown diagnostics, call locations, and unrelated values after mutations. Five alternating local full-analysis samples on Node 24.18.0/macOS arm64: a 3,000-property alias initializer falls from 287.3 ms to 17.8 ms; unbound and literal-require initializers fall from 220.9 to 18.9 ms and 104.8 to 18.0 ms. All completed result digests match. Three 12,000-property cases previously throw RangeError and now complete in 74–78 ms. These are synthetic full-analysis workloads, not whole-application speed estimates. The 480,937-byte installed Babel parser produces identical complete semantic IR; its timings do not establish a material general-purpose speedup. Validation: - Build, `npm run check:fast`, and `npm run docs:check` pass. - 18 focused JavaScript suites: 416 tests pass, including 19 new deep-member/static-analysis regressions. - 252 ordinary fixtures: exact complete semantic IR, static analysis, AST fingerprint, and export comparisons; real Babel complete IR matches byte for byte. - Compiled CLI and stdio MCP successfully reconstruct the same 12,000-property application fixture with identical normalized evidence; application version, feature-trace, and export-shape verification passes on two fixture versions. The SDK test client uses an explicit 128 MiB receive buffer for this complete graph; its default 10 MiB buffer rejects that large response. No production buffer or output limits changed. - Independent Standards and Spec reviews are clean. No tool contract or output cap changes. JavaScript remains parsed as data. Other recursive expression families and parser-internal depth limits are outside this fix. Real Hopper/Ghidra verification was not performed because these changes concern JavaScript analysis. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:06:58 +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#2509
No description provided.