[PR #6128] [MERGED] perf(javascript): query selected source-to-bundle facts #7153

Closed
opened 2026-11-01 21:45:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6128
Author: @gensokyo-dev
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @gensokyo-dev

Base: main ← Head: perf/6112-source-bundle-views


📝 Commits (4)

  • 543b273 perf(javascript): query selected source-to-bundle facts
  • cbf11f0 fix(cli): preserve source comparison error responses
  • 3b66135 fix(javascript): admit and cancel source comparisons before session writes
  • d3d8ee7 fix(javascript): preserve reference file provenance and cancellation scope

📊 Changes

29 files changed (+3527 additions, -129 deletions)

View changed files

📝 docs/mcp-contracts.md (+29 -0)
➕ experiments/analysis-efficiency/source-to-bundle-costs.py (+34 -0)
➕ experiments/analysis-efficiency/source-to-bundle-oracle.py (+63 -0)
➕ experiments/analysis-efficiency/source-to-bundle-output-off.json (+548 -0)
➕ experiments/analysis-efficiency/source-to-bundle-prepare.py (+51 -0)
➕ experiments/analysis-efficiency/source-to-bundle.json (+916 -0)
➕ experiments/analysis-efficiency/source-to-bundle.md (+210 -0)
➕ experiments/analysis-efficiency/source-to-bundle.mjs (+251 -0)
➕ src/application/JsonAuthenticationHeadroom.test.ts (+44 -0)
➕ src/application/JsonAuthenticationHeadroom.ts (+58 -0)
📝 src/application/JsonFiles.ts (+25 -3)
📝 src/application/analysisView/evidenceFileSource.test.ts (+1 -33)
📝 src/application/analysisView/evidenceFileSource.ts (+7 -54)
📝 src/application/javascript/JavaScriptApplicationWorkflowService.ts (+6 -1)
➕ src/application/javascript/SourceToBundleReference.ts (+93 -0)
📝 src/cli/applicationCommands.ts (+2 -14)
➕ src/cli/sourceToBundleCommand.ts (+74 -0)
📝 src/contracts/applicationToolContracts.ts (+11 -2)
📝 src/contracts/javascript/applicationWorkflowInputContracts.ts (+32 -6)
📝 src/domain/analysisView/analysisView.ts (+26 -0)

...and 9 more files

📄 Description

Summary

Fixes #6112. Compare a committed historical graph from a local JSON file and request selected mappings/candidates without sending the full graph or receiving every row. Existing inline requests retain their complete Evidence; file requests preserve the same normalized facts and record the selected file origin.

Change and scope

  • Add exact path/identity/status filters, field selection and stable pages to the existing analysis-view owner. Global classification precedes selection; source coverage and partial/unknown semantics remain separate from pagination. Mandatory identities include mapping/source indices and candidate/node indices with a mapped flag; signals are opt-in.
  • MCP supports an initial summary/page and retains its complete parent before delivery. CLI accepts the same reference-file alternative; saved complete Evidence uses the shared inspect-analysis-view projector.
  • The file owner supplies the absolute selected path; parameters.reference_source preserves it and the exact requested path. POSIX ../symlink semantics remain intact. Distinct chosen files have distinct Evidence IDs, while normalized facts/mapping IDs remain composable.
  • Reuse bounded regular-file reading, commitment validation and one shared live-heap admission owner. File-I/O cancellation reports the comparison operation with its original cause. Compute the comparison/view, dispatch cancellation, then commit session facts. No file cache or new target-execution authority.

Evidence and measured costs

Public Redux Toolkit 2.2.7: 180 source files, 99 embedded source nodes, 210 candidate relations, checked independently with Python JSON/SHA-256/path joins. Every requested fact agrees with its full retained parent: 33 split, 147 unknown. All embedded source strings differ from the published sources; no semantic-equivalence or removal claim.

Three alternating complete-task pairs per output-profile configuration include catalog, arguments, all replies, preparation, extra candidate query and Evidence export. Archived full-output estimates are 152,592 → 54,765 cl100k tokens (64.1% less), with a cold SDK tradeoff: wall median 11.899 → 14.733 s, CPU 11.551 → 14.377 s, process-family peak 666.6 → 950.7 MiB. With the existing explicit output-schema off setting on both sides, estimates are 152,668 → 54,841; wall 11.597 → 10.890 s, CPU 11.244 → 10.569 s, peak 628.7 → 626.0 MiB. Ranges overlap, so no stable speedup claim. Server canonical validation remains enabled; defaults are unchanged.

Final post-provenance verifications estimate 54,896 tokens, retain all oracle facts and the new origin metadata, and preserve legacy inline Evidence exactly. Same-origin CLI and MCP file Evidence agree exactly. Historical paired medians predate later guard/provenance fixes; final source hashes and separate receipts are explicit in experiments/analysis-efficiency/source-to-bundle*.json / .md.

Both cohorts explicitly select the existing semantic cap of one for source/map correspondence. Comparison facts agree with a separately observed default-semantic run; semantic coverage does not. Reference import is separately measured; acquisition/build are excluded. All measured tasks release their processes with no OOM/resource stop. Actual model usage is unmeasured; the verified existing CLI/code-composition control can already select locally, so there is no universal native-client saving claim.

Validation performed

  • npm run build:cached, npm run check, npm run docs:check — passed.
  • Original retained-Evidence/path suites — 66 passed; later guard/path/page run — 65 passed.
  • Shared authentication/Evidence-reader coverage — 7 passed; final provenance/MCP/guard suites — 6 passed; selected CLI/shared JSON ownership suites — 29 passed (37 unrelated cases skipped).
  • Actual SDK cancellation during validation/comparison leaves the entire session unchanged and the server usable. Negative controls without admission/cancellation gates fail all 3 new guard cases; removing provenance/cancellation attribution fails 3 more as expected.
  • Cross-source pages over candidate counts 2/1/2 check original indices, filtered totals and next offsets. Real-file tests distinguish weak candidates (mapped: false), preserve relative caller paths, and give identical graphs at different chosen paths distinct provenance.
  • Public-package CLI inline output exactly equals baseline; file CLI/MCP output and selected rows agree, with provenance retained. Legacy semantic-error JSON is unchanged.

Linux verified. Final-head CI/review remain the merge gate. Windows runtime and actual model/native-client context usage are unmeasured; no GUI/deep provider or cross-provider qualification is claimed.

Contract and boundary impact

Matching/scoring stay in the domain owner; both adapters share file resolution, Evidence construction and view projection. Contracts are additive: reference-file transport, optional MCP view and completed-comparison views; complete output remains the default. File origin is provenance metadata, not a change to mapping semantics. Contribution scope: existing static analysis/Evidence boundaries; maintainer execution/mutation decision not applicable.

Effects: read selected files, existing REA static helper processes and caller-selected Evidence export. No target execution, attachment, instrumentation, configuration changes, network access or protection recovery. Owning docs updated; generated catalogs/skills/build outputs remain untracked.

Author readiness

Declarations entered under the user's explicit direction and authorization in this session.

Human owner: @gensokyo-dev

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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/6128 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `perf/6112-source-bundle-views` --- ### 📝 Commits (4) - [`543b273`](https://github.com/morluto/rea/commit/543b273d7adf581f6fd52c2938020207e455d3df) perf(javascript): query selected source-to-bundle facts - [`cbf11f0`](https://github.com/morluto/rea/commit/cbf11f0046ed0c67fba00fa74e47a6bea70e78e6) fix(cli): preserve source comparison error responses - [`3b66135`](https://github.com/morluto/rea/commit/3b66135e2a604368c13b2fbbcae0c1c9a75e80ec) fix(javascript): admit and cancel source comparisons before session writes - [`d3d8ee7`](https://github.com/morluto/rea/commit/d3d8ee78fd3b1226a40bfc7392aacaa96de4bc5d) fix(javascript): preserve reference file provenance and cancellation scope ### 📊 Changes **29 files changed** (+3527 additions, -129 deletions) <details> <summary>View changed files</summary> 📝 `docs/mcp-contracts.md` (+29 -0) ➕ `experiments/analysis-efficiency/source-to-bundle-costs.py` (+34 -0) ➕ `experiments/analysis-efficiency/source-to-bundle-oracle.py` (+63 -0) ➕ `experiments/analysis-efficiency/source-to-bundle-output-off.json` (+548 -0) ➕ `experiments/analysis-efficiency/source-to-bundle-prepare.py` (+51 -0) ➕ `experiments/analysis-efficiency/source-to-bundle.json` (+916 -0) ➕ `experiments/analysis-efficiency/source-to-bundle.md` (+210 -0) ➕ `experiments/analysis-efficiency/source-to-bundle.mjs` (+251 -0) ➕ `src/application/JsonAuthenticationHeadroom.test.ts` (+44 -0) ➕ `src/application/JsonAuthenticationHeadroom.ts` (+58 -0) 📝 `src/application/JsonFiles.ts` (+25 -3) 📝 `src/application/analysisView/evidenceFileSource.test.ts` (+1 -33) 📝 `src/application/analysisView/evidenceFileSource.ts` (+7 -54) 📝 `src/application/javascript/JavaScriptApplicationWorkflowService.ts` (+6 -1) ➕ `src/application/javascript/SourceToBundleReference.ts` (+93 -0) 📝 `src/cli/applicationCommands.ts` (+2 -14) ➕ `src/cli/sourceToBundleCommand.ts` (+74 -0) 📝 `src/contracts/applicationToolContracts.ts` (+11 -2) 📝 `src/contracts/javascript/applicationWorkflowInputContracts.ts` (+32 -6) 📝 `src/domain/analysisView/analysisView.ts` (+26 -0) _...and 9 more files_ </details> ### 📄 Description ## Summary Fixes #6112. Compare a committed historical graph from a local JSON file and request selected mappings/candidates without sending the full graph or receiving every row. Existing inline requests retain their complete Evidence; file requests preserve the same normalized facts and record the selected file origin. ## Change and scope - Add exact path/identity/status filters, field selection and stable pages to the existing analysis-view owner. Global classification precedes selection; source coverage and partial/unknown semantics remain separate from pagination. Mandatory identities include mapping/source indices and candidate/node indices with a mapped flag; signals are opt-in. - MCP supports an initial summary/page and retains its complete parent before delivery. CLI accepts the same reference-file alternative; saved complete Evidence uses the shared `inspect-analysis-view` projector. - The file owner supplies the absolute selected path; `parameters.reference_source` preserves it and the exact requested path. POSIX `..`/symlink semantics remain intact. Distinct chosen files have distinct Evidence IDs, while normalized facts/mapping IDs remain composable. - Reuse bounded regular-file reading, commitment validation and one shared live-heap admission owner. File-I/O cancellation reports the comparison operation with its original cause. Compute the comparison/view, dispatch cancellation, then commit session facts. No file cache or new target-execution authority. ## Evidence and measured costs Public Redux Toolkit 2.2.7: **180 source files, 99 embedded source nodes, 210 candidate relations**, checked independently with Python JSON/SHA-256/path joins. Every requested fact agrees with its full retained parent: 33 split, 147 unknown. All embedded source strings differ from the published sources; no semantic-equivalence or removal claim. Three alternating complete-task pairs per output-profile configuration include catalog, arguments, all replies, preparation, extra candidate query and Evidence export. Archived full-output estimates are **152,592 → 54,765 cl100k tokens (64.1% less)**, with a cold SDK tradeoff: wall median **11.899 → 14.733 s**, CPU **11.551 → 14.377 s**, process-family peak **666.6 → 950.7 MiB**. With the existing explicit output-schema off setting on both sides, estimates are **152,668 → 54,841**; wall **11.597 → 10.890 s**, CPU **11.244 → 10.569 s**, peak **628.7 → 626.0 MiB**. Ranges overlap, so no stable speedup claim. Server canonical validation remains enabled; defaults are unchanged. Final post-provenance verifications estimate **54,896 tokens**, retain all oracle facts and the new origin metadata, and preserve legacy inline Evidence exactly. Same-origin CLI and MCP file Evidence agree exactly. Historical paired medians predate later guard/provenance fixes; final source hashes and separate receipts are explicit in `experiments/analysis-efficiency/source-to-bundle*.json` / `.md`. Both cohorts explicitly select the existing semantic cap of one for source/map correspondence. Comparison facts agree with a separately observed default-semantic run; semantic coverage does not. Reference import is separately measured; acquisition/build are excluded. All measured tasks release their processes with no OOM/resource stop. Actual model usage is unmeasured; the verified existing CLI/code-composition control can already select locally, so there is no universal native-client saving claim. ## Validation performed - `npm run build:cached`, `npm run check`, `npm run docs:check` — passed. - Original retained-Evidence/path suites — 66 passed; later guard/path/page run — 65 passed. - Shared authentication/Evidence-reader coverage — 7 passed; final provenance/MCP/guard suites — 6 passed; selected CLI/shared JSON ownership suites — 29 passed (37 unrelated cases skipped). - Actual SDK cancellation during validation/comparison leaves the entire session unchanged and the server usable. Negative controls without admission/cancellation gates fail all 3 new guard cases; removing provenance/cancellation attribution fails 3 more as expected. - Cross-source pages over candidate counts 2/1/2 check original indices, filtered totals and next offsets. Real-file tests distinguish weak candidates (`mapped: false`), preserve relative caller paths, and give identical graphs at different chosen paths distinct provenance. - Public-package CLI inline output exactly equals baseline; file CLI/MCP output and selected rows agree, with provenance retained. Legacy semantic-error JSON is unchanged. Linux verified. Final-head CI/review remain the merge gate. Windows runtime and actual model/native-client context usage are unmeasured; no GUI/deep provider or cross-provider qualification is claimed. ## Contract and boundary impact Matching/scoring stay in the domain owner; both adapters share file resolution, Evidence construction and view projection. Contracts are additive: reference-file transport, optional MCP view and completed-comparison views; complete output remains the default. File origin is provenance metadata, not a change to mapping semantics. Contribution scope: existing static analysis/Evidence boundaries; maintainer execution/mutation decision not applicable. Effects: read selected files, existing REA static helper processes and caller-selected Evidence export. No target execution, attachment, instrumentation, configuration changes, network access or protection recovery. Owning docs updated; generated catalogs/skills/build outputs remain untracked. ## Author readiness Declarations entered under the user's explicit direction and authorization in this session. Human owner: @gensokyo-dev - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [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-11-01 21:45: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#7153
No description provided.