[PR #1112] [MERGED] perf(javascript): reuse validated immutable graphs #2660

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

📋 Pull Request Information

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

Base: main ← Head: perf/javascript-owned-graph-validation


📝 Commits (3)

  • a62499f perf(javascript): reuse validated immutable graphs
  • f985932 Merge remote-tracking branch 'origin/main' into perf/javascript-owned-graph-validation
  • ae0c8ec fix(ci): follow the moved process CLI boundary test

📊 Changes

11 files changed (+582 additions, -117 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -1)
📝 docs/mcp-contracts.md (+6 -3)
📝 src/application/javascript/JavaScriptApplicationCancellation.test.ts (+2 -0)
📝 src/application/javascript/JavaScriptApplicationService.ts (+11 -7)
📝 src/application/javascript/JavaScriptArtifactGraphBuilder.ts (+23 -3)
📝 src/application/javascript/JavaScriptArtifactReconstruction.ts (+27 -4)
📝 src/application/javascript/JavaScriptSemanticGraphBuilder.ts (+88 -63)
📝 src/domain/javascript/javascriptApplicationAnalysis.ts (+107 -36)
➕ src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts (+267 -0)
📝 src/domain/javascript/javascriptApplicationGraph.ts (+25 -0)
📝 src/domain/javascript/javascriptSemanticGraph.ts (+25 -0)

📄 Description

Summary

Final JavaScript application result validation revalidated, rehashed and cloned complete graphs that their constructors had already validated. Reuse the exact owned graphs after complete immutable sealing, while retaining metadata validation and every application/root/node binding check.

Continues T2 in #1065. Source parsing and graph construction remain follow-up work.

Problem and expected behavior

Full Notion and Obsidian ASAR analyses spent approximately 10.6–14.9 seconds in synchronous final result validation. The final boundary should reuse already validated immutable data, remain cancellable during wide binding checks, and preserve all complete result fields and Evidence commitments. Imported data must still receive full validation.

Change and scope

  • Add owned graph factories that synchronously clone/normalize/validate inputs, then return cooperative sealing steps. Ordinary graph constructors retain their mutable behavior.
  • Authenticate only exact graph roots after sealing completes, using private identity sets. IDs, shallow freezes, JSON immutability, nested objects and abandoned iterators cannot confer graph validity.
  • Reuse both authenticated graphs in final result validation, clone/validate metadata, and cooperatively check cross-graph bindings. Imported graphs use the existing public schema. The final complete Evidence JSON-depth validation remains active.
  • Keep projection source data file-local and clear semantic builder maps after the validating factory has detached its inputs. Report graph sealing separately from graph construction.
  • Follow main's process-test directory migration in the native Apple CI workflow, fixing its deterministic missing-file failure.

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript graph construction/ownership, followed by the shared application result boundary.
  • CLI and MCP/tool-catalog contract: complete fields, canonical inventory, named bindings and public input/output schemas preserved.
  • Provider, bridge, target-format, or platform compatibility: no provider protocol changes; directory and ASAR workflows exercised through production paths.
  • Evidence, artifact, provenance, or reconstruction contract: exact normalized-result and complete-Evidence canonical digests and IDs preserved in all paired real Linux analyses.
  • Process execution, authorization, cleanup, or containment impact: no workers or new authority; abandoned sealing/binding iterators are closed and provisional graphs are not published.
  • Generated metadata, package, or installation impact: generated checks pass; no generated output committed.

Evidence and regression coverage

103 distinct deterministic tests passed across graph construction/querying, owned proof/fallback validation, malformed metadata, stale commitments, cross-graph mismatches, cancellation, CLI and pinned-SDK MCP boundaries. Catalog tests validate every advertised schema and retain the #919 object-root/depth compatibility profile.

Actual full Notion 7.6.1 and Obsidian 1.12.7 artifacts, two paired runs each with two CPUs and a 1.5 GiB heap:

Target Final validation before → after Complete analysis before → after Sampled family peak before → after
Notion, pair 1 11.189 s → 23.129 ms 93.626 s → 65.721 s 1,616,846,848 → 1,316,249,600 bytes
Notion, pair 2 10.616 s → 16.207 ms 75.880 s → 59.794 s 1,468,342,272 → 1,393,192,960 bytes
Obsidian, pair 1 13.268 s → 28.261 ms 104.610 s → 100.162 s 1,734,422,528 → 1,758,691,328 bytes
Obsidian, pair 2 14.870 s → 16.913 ms 116.832 s → 103.016 s 1,759,350,784 → 1,747,341,312 bytes

Every pair preserves the exact Evidence ID, normalized-result digest and independent complete-Evidence digest. These are observed runs, not universal speedup claims; Obsidian memory peaks are essentially unchanged. Final-validation CPU dropped from 12.1–18.0 seconds to 24–55 ms. No resource reserve guard stopped a run. Compact proofs are retained and the temporary baseline worktree was removed after verification.

Native Windows isolated package verification used the exact same cc0ee2ed main base and dependency versions. Complete Obsidian MCP analysis measured 164.997 s before and 127.293 s after; the selected module trace is exactly equal. The complete 429,265,076-byte exported bundle is byte-identical, independently verified across every field/tree/record. Default framing returns a retained reference, the selected trace is usable inline, and close/empty/stale-reference checks pass. Sampled process-family peaks were 1,673,297,920 and 1,586,888,704 bytes. Both large exports were deleted after proof.

Full native Windows Notion cancellation 300 ms into semantic-graph sealing stopped the actual server in 9.875 ms; subsequent ping took 2.544 ms. Prior Evidence was preserved, a subsequent analysis succeeded, and close emptied the ledger. Family peak was 1,212,207,104 bytes. Native analyses used extended client deadlines; the default waiting policy is unchanged.

  • 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

  • Initial focused domain/application/composition/CLI/MCP tests: 103 distinct tests passed. After synchronizing main at ae0c8ecf, 18 focused files passed with 161 tests and four Linux-skipped Darwin-only tests; the corrected native Apple CI lane passed. Relevant checks include the moved process CLI test and current TypeScript dialect boundaries.
  • npm run check -- --concurrency=1: typecheck, lint/module boundaries, formatting, knip and metadata passed.
  • npm run docs:check, npm run jscpd, npm run scan:todos: passed.
  • Eight complete paired real Linux analyses with exact content/identity commitments and phase/process CPU/RSS measurements at the recorded cc0ee2ed baseline. Two additional full analyses after synchronizing main preserved those same commitments (Notion 61.886 s, Obsidian 103.973 s; final validation 16.410 and 24.218 ms).
  • Isolated native Windows baseline/candidate packages, all seven modified-module byte checks, full Obsidian analysis/trace/export parity and real Notion cancellation/recovery.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; complete caller-visible contracts and ordinary synchronous domain constructors remain available.
  • Real Hopper/Ghidra, browser, or OS coverage: real Linux and native Windows JavaScript workflows verified; Hopper/Ghidra/browser workflows were not run for this JavaScript-only change.
  • Package or release metadata impact: performance fix; no version edit or generated outputs committed.
  • Security, privacy, process, or containment review: inert artifact parsing only, no target execution or ambient-environment persistence. Public measurements omit private host paths.

Review checklist

  • One focused outcome and conventional PR title.
  • Related roadmap linked without prematurely closing it.
  • Changed behavior and meaningful failure paths covered.
  • Owning documentation and generated checks updated.
  • Final native Windows verification complete.
  • Final diff and ready-for-review checks complete.

🔄 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/1112 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `perf/javascript-owned-graph-validation` --- ### 📝 Commits (3) - [`a62499f`](https://github.com/morluto/rea/commit/a62499f25271bef2cf7e5600641cb608267d5dbc) perf(javascript): reuse validated immutable graphs - [`f985932`](https://github.com/morluto/rea/commit/f985932e7be35ce186f2443931d7d1db90b92c05) Merge remote-tracking branch 'origin/main' into perf/javascript-owned-graph-validation - [`ae0c8ec`](https://github.com/morluto/rea/commit/ae0c8ecfae7872511714fa4098b446514385769c) fix(ci): follow the moved process CLI boundary test ### 📊 Changes **11 files changed** (+582 additions, -117 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -1) 📝 `docs/mcp-contracts.md` (+6 -3) 📝 `src/application/javascript/JavaScriptApplicationCancellation.test.ts` (+2 -0) 📝 `src/application/javascript/JavaScriptApplicationService.ts` (+11 -7) 📝 `src/application/javascript/JavaScriptArtifactGraphBuilder.ts` (+23 -3) 📝 `src/application/javascript/JavaScriptArtifactReconstruction.ts` (+27 -4) 📝 `src/application/javascript/JavaScriptSemanticGraphBuilder.ts` (+88 -63) 📝 `src/domain/javascript/javascriptApplicationAnalysis.ts` (+107 -36) ➕ `src/domain/javascript/javascriptApplicationAnalysisSteps.test.ts` (+267 -0) 📝 `src/domain/javascript/javascriptApplicationGraph.ts` (+25 -0) 📝 `src/domain/javascript/javascriptSemanticGraph.ts` (+25 -0) </details> ### 📄 Description ## Summary Final JavaScript application result validation revalidated, rehashed and cloned complete graphs that their constructors had already validated. Reuse the exact owned graphs after complete immutable sealing, while retaining metadata validation and every application/root/node binding check. Continues T2 in #1065. Source parsing and graph construction remain follow-up work. ## Problem and expected behavior Full Notion and Obsidian ASAR analyses spent approximately 10.6–14.9 seconds in synchronous final result validation. The final boundary should reuse already validated immutable data, remain cancellable during wide binding checks, and preserve all complete result fields and Evidence commitments. Imported data must still receive full validation. ## Change and scope - Add owned graph factories that synchronously clone/normalize/validate inputs, then return cooperative sealing steps. Ordinary graph constructors retain their mutable behavior. - Authenticate only exact graph roots after sealing completes, using private identity sets. IDs, shallow freezes, JSON immutability, nested objects and abandoned iterators cannot confer graph validity. - Reuse both authenticated graphs in final result validation, clone/validate metadata, and cooperatively check cross-graph bindings. Imported graphs use the existing public schema. The final complete Evidence JSON-depth validation remains active. - Keep projection source data file-local and clear semantic builder maps after the validating factory has detached its inputs. Report graph sealing separately from graph construction. - Follow main's process-test directory migration in the native Apple CI workflow, fixing its deterministic missing-file failure. ## Contract and boundary impact - Semantic owner and earliest changed stage: JavaScript graph construction/ownership, followed by the shared application result boundary. - CLI and MCP/tool-catalog contract: complete fields, canonical inventory, named bindings and public input/output schemas preserved. - Provider, bridge, target-format, or platform compatibility: no provider protocol changes; directory and ASAR workflows exercised through production paths. - Evidence, artifact, provenance, or reconstruction contract: exact normalized-result and complete-Evidence canonical digests and IDs preserved in all paired real Linux analyses. - Process execution, authorization, cleanup, or containment impact: no workers or new authority; abandoned sealing/binding iterators are closed and provisional graphs are not published. - Generated metadata, package, or installation impact: generated checks pass; no generated output committed. ## Evidence and regression coverage 103 distinct deterministic tests passed across graph construction/querying, owned proof/fallback validation, malformed metadata, stale commitments, cross-graph mismatches, cancellation, CLI and pinned-SDK MCP boundaries. Catalog tests validate every advertised schema and retain the #919 object-root/depth compatibility profile. Actual full Notion 7.6.1 and Obsidian 1.12.7 artifacts, two paired runs each with two CPUs and a 1.5 GiB heap: | Target | Final validation before → after | Complete analysis before → after | Sampled family peak before → after | | --- | --- | --- | --- | | Notion, pair 1 | 11.189 s → 23.129 ms | 93.626 s → 65.721 s | 1,616,846,848 → 1,316,249,600 bytes | | Notion, pair 2 | 10.616 s → 16.207 ms | 75.880 s → 59.794 s | 1,468,342,272 → 1,393,192,960 bytes | | Obsidian, pair 1 | 13.268 s → 28.261 ms | 104.610 s → 100.162 s | 1,734,422,528 → 1,758,691,328 bytes | | Obsidian, pair 2 | 14.870 s → 16.913 ms | 116.832 s → 103.016 s | 1,759,350,784 → 1,747,341,312 bytes | Every pair preserves the exact Evidence ID, normalized-result digest and independent complete-Evidence digest. These are observed runs, not universal speedup claims; Obsidian memory peaks are essentially unchanged. Final-validation CPU dropped from 12.1–18.0 seconds to 24–55 ms. No resource reserve guard stopped a run. Compact proofs are retained and the temporary baseline worktree was removed after verification. Native Windows isolated package verification used the exact same `cc0ee2ed` main base and dependency versions. Complete Obsidian MCP analysis measured 164.997 s before and 127.293 s after; the selected module trace is exactly equal. The complete 429,265,076-byte exported bundle is byte-identical, independently verified across every field/tree/record. Default framing returns a retained reference, the selected trace is usable inline, and close/empty/stale-reference checks pass. Sampled process-family peaks were 1,673,297,920 and 1,586,888,704 bytes. Both large exports were deleted after proof. Full native Windows Notion cancellation 300 ms into semantic-graph sealing stopped the actual server in 9.875 ms; subsequent ping took 2.544 ms. Prior Evidence was preserved, a subsequent analysis succeeded, and close emptied the ledger. Family peak was 1,212,207,104 bytes. Native analyses used extended client deadlines; the default waiting policy is unchanged. - [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 - Initial focused domain/application/composition/CLI/MCP tests: 103 distinct tests passed. After synchronizing main at `ae0c8ecf`, 18 focused files passed with 161 tests and four Linux-skipped Darwin-only tests; the corrected native Apple CI lane passed. Relevant checks include the moved process CLI test and current TypeScript dialect boundaries. - `npm run check -- --concurrency=1`: typecheck, lint/module boundaries, formatting, knip and metadata passed. - `npm run docs:check`, `npm run jscpd`, `npm run scan:todos`: passed. - Eight complete paired real Linux analyses with exact content/identity commitments and phase/process CPU/RSS measurements at the recorded `cc0ee2ed` baseline. Two additional full analyses after synchronizing main preserved those same commitments (Notion 61.886 s, Obsidian 103.973 s; final validation 16.410 and 24.218 ms). - Isolated native Windows baseline/candidate packages, all seven modified-module byte checks, full Obsidian analysis/trace/export parity and real Notion cancellation/recovery. ## Compatibility, safety, and release - Breaking changes or migration steps: none; complete caller-visible contracts and ordinary synchronous domain constructors remain available. - Real Hopper/Ghidra, browser, or OS coverage: real Linux and native Windows JavaScript workflows verified; Hopper/Ghidra/browser workflows were not run for this JavaScript-only change. - Package or release metadata impact: performance fix; no version edit or generated outputs committed. - Security, privacy, process, or containment review: inert artifact parsing only, no target execution or ambient-environment persistence. Public measurements omit private host paths. ## Review checklist - [x] One focused outcome and conventional PR title. - [x] Related roadmap linked without prematurely closing it. - [x] Changed behavior and meaningful failure paths covered. - [x] Owning documentation and generated checks updated. - [x] Final native Windows verification complete. - [x] Final diff and ready-for-review checks complete. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:08:46 +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#2660
No description provided.