Skip to content

fix(javascript): index repeated graph observations before final sorting - #1759

Merged
N0zoM1z0 merged 2 commits into
mainfrom
fix/javascript-observation-accumulation
Oct 11, 2026
Merged

N0zoM1z0 merged 2 commits into
mainfrom
fix/javascript-observation-accumulation

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Retain stable live nodes and observation arrays while avoiding quadratic
collection rebuilds. Preserve duplicate handling and canonical output.

Fixes #1748

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T08:05:15.662876Z ffd3eb6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@N0zoM1z0 N0zoM1z0 added area: evidence Evidence, artifacts, and reconstruction bug Something isn't working P2: medium Medium priority issue performance Performance regressions, scaling limits, and bounded-resource work labels Oct 11, 2026

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact synchronized head ffd3eb61fd169d5f2c669b794b7e1116c86f6496; independent local Luna review found no material issue and verified the final patch matches the reviewed two-file fix. Live node/array references, last-write deduplication and post-materialization index updates are retained. 25 focused tests, static checks, complete CLI output/identity comparison, and 4 integration tests with the merged cancellation fix passed. CPU comparison includes final sorting (8k medians down 88.6%); CI runs on this head before merge. Maintainer self-review comment, not independent GitHub approval.

@N0zoM1z0
N0zoM1z0 merged commit 6d5d71f into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/javascript-observation-accumulation branch October 11, 2026 08:16
@N0zoM1z0

Copy link
Copy Markdown
Collaborator Author

Independent verification after merge 6d5d71fa: audited the complete merge tree against its actual parent 713db4dc plus reviewed source head ffd3eb61, including both changed blobs.

Fresh merged runtime and all 25 focused tests passed. Ran the real public CLI against the same small inert directory application containing 300 fetch('/same') references, using the already freshly compiled actual parent as baseline. Both complete outputs authenticate with parseEvidence and are deeply equal, including Evidence ID, normalized result, every observation/range and graph coverage: 7 nodes, 306 edges, 306 observations, complete coverage, 1,937,259 output bytes.

This independently validates public CLI result preservation; it does not independently measure the author's accumulator speedup or establish a CLI/MCP end-to-end speedup. Private build/generated outputs were removed after verification; shared dependencies/caches were preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working P2: medium Medium priority issue performance Performance regressions, scaling limits, and bounded-resource work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Repeated endpoint observations cause quadratic JavaScript graph accumulation

1 participant