[PR #1759] [MERGED] fix(javascript): index repeated graph observations before final sorting #4799

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

📋 Pull Request Information

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

Base: main ← Head: fix/javascript-observation-accumulation


📝 Commits (2)

  • 9ed3e37 fix(javascript): index repeated graph observations before final sorting
  • ffd3eb6 chore: sync main for evidence import cancellation verification

📊 Changes

2 files changed (+162 additions, -26 deletions)

View changed files

➕ src/application/javascript/JavaScriptArtifactGraphAccumulator.test.ts (+97 -0)
📝 src/application/javascript/JavaScriptArtifactGraphAccumulator.ts (+65 -26)

📄 Description

Summary

Fixes #1748. Repeated JavaScript endpoint observations now merge through a node-owned index instead of copying and sorting the growing collection on every addition. Complete output and Evidence identities remain unchanged.

Problem and expected behavior

A source with many calls to the same endpoint produces distinct observations on one node. Previously, each merge rebuilt a Map and sorted every retained observation, producing quadratic accumulation CPU. Retain all authenticated observations and canonical output without repeatedly rebuilding that collection.

Change and scope

Append or replace observations by their semantic-ID index. Finalize dirty arrays once when nodes() materializes output, preserving the live node/array references and rebuilding indices for subsequent additions. Preserve first-input duplicates and their last-occurrence deduplication on a later merge. Current construction consumers use node IDs/edges; none depends on intermediate observation ordering.

Contract and boundary impact

  • Semantic owner and earliest changed stage: application graph accumulation; domain factories still validate inputs and derive IDs.
  • CLI and MCP/tool-catalog contract: unchanged schemas and results.
  • Provider, bridge, target-format, or platform compatibility: provider-neutral JavaScript artifact graph; no native bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: retained observations, canonical order, graph IDs and complete coverage unchanged.
  • Process execution, authorization, cleanup, or containment impact: none; no new target execution or limits.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added: stable live node/array identity, last-write deduplication, canonical output, first-input duplicates, incoming duplicates, and additions/updates after materialization.
  • Base evidence: copied compiled baseline accumulator with only relative imports resolved to absolute unchanged domain modules; shared domain module SHA verified. Four serialized unprofiled runs alternate baseline/fixed and ascending/descending sizes. Timed scope includes accumulation and final materialization; input construction and full graph validation are outside it.
  • CPU observations (ms; two runs each):
Observations Baseline Fixed
1,000 374.933 / 189.273 263.731 / 72.961
2,000 570.624 / 515.117 266.705 / 149.577
4,000 1885.180 / 1638.835 407.282 / 437.746
8,000 7859.723 / 7916.633 758.102 / 1045.085
  • Every size retained identical ordered observation checksums, graph IDs, counts and complete coverage. At 8k, the two-run CPU medians decrease 88.6%; this is host-specific accumulation evidence, not an end-to-end speedup claim.

  • User-visible output: the real 1k-call CLI fixture retains identical complete normalized result and Evidence ID. Existing CLI/MCP long-value workflows pass.

  • Flameox 0.2.9: paired 8k profiles corroborate the removed merge work (addNode self samples 1601/2567 baseline versus 2/445 fixed); samples are not timing or allocation measurements.

  • Remaining proof gaps: no allocation measurement, no claim for capped/partial 4k public-CLI graphs or native providers. Internal construction observations may be unsorted until nodes(); canonical published output 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

  • npm run test:focused -- src/application/javascript/JavaScriptArtifactGraphAccumulator.test.ts tests/acceptance/applications/javascriptEndpointPayload.test.ts tests/boundary/filesystem/javascriptArtifactGraphObservationLookup.test.ts src/application/javascript/JavaScriptApplicationEmptyLiterals.test.ts — 25 tests passed.
  • npm run check — passed typecheck, lint, format, knip, metadata and architecture checks.
  • npm run verify:test-discovery — new regression included exactly once; after main synchronization all 815 files discovered exactly once.
  • Integrated head ffd3eb61fd169d5f2c669b794b7e1116c86f6496: focused SDK cancellation, CLI/MCP endpoint and accumulator regressions — 4 tests passed across 3 files.
  • Real CLI analyze-javascript-application <1k-call fixture> --artifact-format directory --max-heap-mb 512 --json — complete normalized output and Evidence ID match the base output.
  • Production accumulator probe and paired Flameox profiles — serialized on one CPU, 512 MiB V8 old-space, results above; no fragile wall-time CI assertions added.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for public CLI/MCP. Internal construction ordering is explicitly finalized by nodes().
  • Real Hopper/Ghidra, browser, or OS coverage: real Linux CLI/MCP exercised; no providers invoked. Platform CI supplies other OS checks.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: caller values and authenticated Evidence unchanged; no new target execution or environment persistence.

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, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • 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/1759 **Author:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@N0zoM1z0](https://github.com/N0zoM1z0) **Base:** `main` ← **Head:** `fix/javascript-observation-accumulation` --- ### 📝 Commits (2) - [`9ed3e37`](https://github.com/morluto/rea/commit/9ed3e37937960e3223aac6c639337aadfce36162) fix(javascript): index repeated graph observations before final sorting - [`ffd3eb6`](https://github.com/morluto/rea/commit/ffd3eb61fd169d5f2c669b794b7e1116c86f6496) chore: sync main for evidence import cancellation verification ### 📊 Changes **2 files changed** (+162 additions, -26 deletions) <details> <summary>View changed files</summary> ➕ `src/application/javascript/JavaScriptArtifactGraphAccumulator.test.ts` (+97 -0) 📝 `src/application/javascript/JavaScriptArtifactGraphAccumulator.ts` (+65 -26) </details> ### 📄 Description ## Summary Fixes #1748. Repeated JavaScript endpoint observations now merge through a node-owned index instead of copying and sorting the growing collection on every addition. Complete output and Evidence identities remain unchanged. ## Problem and expected behavior A source with many calls to the same endpoint produces distinct observations on one node. Previously, each merge rebuilt a Map and sorted every retained observation, producing quadratic accumulation CPU. Retain all authenticated observations and canonical output without repeatedly rebuilding that collection. ## Change and scope Append or replace observations by their semantic-ID index. Finalize dirty arrays once when `nodes()` materializes output, preserving the live node/array references and rebuilding indices for subsequent additions. Preserve first-input duplicates and their last-occurrence deduplication on a later merge. Current construction consumers use node IDs/edges; none depends on intermediate observation ordering. ## Contract and boundary impact - Semantic owner and earliest changed stage: application graph accumulation; domain factories still validate inputs and derive IDs. - CLI and MCP/tool-catalog contract: unchanged schemas and results. - Provider, bridge, target-format, or platform compatibility: provider-neutral JavaScript artifact graph; no native bridge changes. - Evidence, artifact, provenance, or reconstruction contract: retained observations, canonical order, graph IDs and complete coverage unchanged. - Process execution, authorization, cleanup, or containment impact: none; no new target execution or limits. - Generated metadata, package, or installation impact: none. ## Evidence and regression coverage - Tests added: stable live node/array identity, last-write deduplication, canonical output, first-input duplicates, incoming duplicates, and additions/updates after materialization. - Base evidence: copied compiled baseline accumulator with only relative imports resolved to absolute unchanged domain modules; shared domain module SHA verified. Four serialized unprofiled runs alternate baseline/fixed and ascending/descending sizes. Timed scope includes accumulation **and final materialization**; input construction and full graph validation are outside it. - CPU observations (ms; two runs each): | Observations | Baseline | Fixed | | --- | --- | --- | | 1,000 | 374.933 / 189.273 | 263.731 / 72.961 | | 2,000 | 570.624 / 515.117 | 266.705 / 149.577 | | 4,000 | 1885.180 / 1638.835 | 407.282 / 437.746 | | 8,000 | 7859.723 / 7916.633 | 758.102 / 1045.085 | - Every size retained identical ordered observation checksums, graph IDs, counts and complete coverage. At 8k, the two-run CPU medians decrease 88.6%; this is host-specific accumulation evidence, not an end-to-end speedup claim. - User-visible output: the real 1k-call CLI fixture retains identical complete normalized result and Evidence ID. Existing CLI/MCP long-value workflows pass. - Flameox 0.2.9: paired 8k profiles corroborate the removed merge work (`addNode` self samples 1601/2567 baseline versus 2/445 fixed); samples are not timing or allocation measurements. - Remaining proof gaps: no allocation measurement, no claim for capped/partial 4k public-CLI graphs or native providers. Internal construction observations may be unsorted until `nodes()`; canonical published output 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 - `npm run test:focused -- src/application/javascript/JavaScriptArtifactGraphAccumulator.test.ts tests/acceptance/applications/javascriptEndpointPayload.test.ts tests/boundary/filesystem/javascriptArtifactGraphObservationLookup.test.ts src/application/javascript/JavaScriptApplicationEmptyLiterals.test.ts` — 25 tests passed. - `npm run check` — passed typecheck, lint, format, knip, metadata and architecture checks. - `npm run verify:test-discovery` — new regression included exactly once; after main synchronization all 815 files discovered exactly once. - Integrated head `ffd3eb61fd169d5f2c669b794b7e1116c86f6496`: focused SDK cancellation, CLI/MCP endpoint and accumulator regressions — 4 tests passed across 3 files. - Real CLI `analyze-javascript-application <1k-call fixture> --artifact-format directory --max-heap-mb 512 --json` — complete normalized output and Evidence ID match the base output. - Production accumulator probe and paired Flameox profiles — serialized on one CPU, 512 MiB V8 old-space, results above; no fragile wall-time CI assertions added. ## Compatibility, safety, and release - Breaking changes or migration steps: none for public CLI/MCP. Internal construction ordering is explicitly finalized by `nodes()`. - Real Hopper/Ghidra, browser, or OS coverage: real Linux CLI/MCP exercised; no providers invoked. Platform CI supplies other OS checks. - Package or release metadata impact: none. - Security, privacy, process, or containment review: caller values and authenticated Evidence unchanged; no new target execution or environment persistence. ## 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, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [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:55:10 +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#4799
No description provided.