[PR #6478] [CLOSED] fix(javascript): classify distinct source-to-bundle occurrences #7361

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6478
Author: @WenyuChiou
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/source-bundle-occurrences


📝 Commits (1)

  • ea94245 fix(javascript): classify distinct source-to-bundle occurrences

📊 Changes

5 files changed (+351 additions, -23 deletions)

View changed files

📝 docs/javascript-application-workflows.md (+10 -3)
📝 src/domain/javascript/sourceToBundleComparison.test.ts (+129 -0)
📝 src/domain/javascript/sourceToBundleComparison.ts (+49 -20)
📝 src/domain/javascript/sourceToBundleSignals.ts (+65 -0)
📝 tests/acceptance/applications/applicationWorkflowCli.test.ts (+98 -0)

📄 Description

Summary

Fixes #6456. Classify historical source mappings by distinct current source occurrences, rather than counting a file's asset, source-module, and export-binding graph representations as separate files.

Problem and expected behavior

A single main.js containing export const value = 1; was reported as duplicated when unchanged and split when its literal changed to 2. Both graphs contained only one JavaScript file. This makes source-retention summaries incorrectly report duplication or splitting even though the retained evidence identifies one file. The expected outcomes are unchanged and modified, while preserving all three candidate representations.

Change and scope

Project occurrence identity alongside existing candidate facts. Recognized whole-file assets and source-module/export-binding owners share an occurrence only when their evidence agrees on literal path and backing artifact digest without conflicting source digests. Supplemental export-return-shape observations remain validated. Source-map originals, bundled modules, conflicting bytes, and distinct literal paths are not blindly deduplicated. A content-addressed asset with several file observations retains multiple occurrences; location inference selects only matching paths.

Keep every admitted candidate and signal; map all admitted representations of selected occurrences. Preserve merged historical aliases and paged candidate mapped flags. Update the owning workflow documentation.

Ordinary correction within existing static comparison boundaries; new maintainer scope approval is not applicable. No provider, fetching, target execution, or mutation capability added.

Contract and boundary impact

  • Semantic owner: source-to-bundle candidate projection and classification.
  • CLI/MCP schemas and tool catalogs: unchanged; existing statuses and mapped node IDs are corrected.
  • Evidence/provenance: original nodes, candidate signals, scores, digests and paths retained.
  • Provider/platform/cleanup: no provider protocol, launch, ownership or cleanup changes.
  • Generated metadata/package/installation: none.

Expected existing workflow effects:

  • Read existing files or captured data.
  • Launch or attach to a process (existing owned static analysis workers).
  • Inject instrumentation or run target scripts/code.
  • Contact network services.
  • Recover protected code or work around protections.

Evidence and regression coverage

Executed on Linux with pinned Node 24.18.0 and npm 11.16.0, using inert synthetic local source files only.

  • Actual public CLI on unchanged production base e32a0494d42dedd5e79ca341d20c53f07479d9bb: changed → split (3 candidates), same → duplicated (3 candidates, 2 mapped).
  • Fixed public CLI: changed → modified, same → unchanged; both retain 3 candidates and map all 3.
  • Added compiled CLI regressions for exported literals and functions returning object shapes: unchanged, edited, genuine identical copies, and paged candidate mapping flags.
  • Domain regressions cover multi-observation content-addressed copies, matched-path filtering, conflicting source digests, independent bundled modules and merged historical aliases. Existing Unicode and source-map correspondence coverage retained.
  • No live browser/service, native analysis provider, target code, private artifact or credential used. Synthetic Linux coverage does not establish real-provider or other-platform behavior. No performance improvement claimed; resource/token costs were not benchmarked.

Validation performed

  • npm run build:cached — passed.
  • node_modules/.bin/vitest run --project acceptance tests/acceptance/applications/applicationWorkflowCli.test.ts -t 'compares file occurrences' — 2 passed; 36 unrelated tests skipped. Exercises compiled public CLI with literal and object-returning-function fixtures plus paged candidate inspection.
  • Focused domain and filesystem suites — 28 and 59 passed respectively. The initial filesystem run had one 30s timeout; its final rerun passed without changing the timeout configuration.
  • npm run test:focused -- src/domain/javascript/sourceToBundleComparison.test.ts tests/boundary/filesystem/sourceToBundlePaths.test.ts tests/boundary/mcp/sourceToBundleViewsMcp.test.ts — 88 passed, 1 existing MCP full-profile case timed out at the default 30s (no assertion failure). This default-budget combined run was not green.
  • node_modules/.bin/vitest run --project mcp-boundary tests/boundary/mcp/sourceToBundleViewsMcp.test.ts --testTimeout 60000 — isolated retry: 2 passed (26.7s full, 54.9s compact). No timeout configuration was committed.
  • npm run docs:check — passed.
  • npm run check — final pass: typecheck, lint (0 errors), formatting, knip, metadata, module boundaries and architecture guards. An initial test describe callback exceeded the lint line limit; separating the new occurrence tests resolved it, and the final domain suite passed 28/28 again.
  • git diff --check — passed. Independent read-only review of local commit 46becf812e53d26f097b30190086ff424cd334f6 / tree bee27d3199f1129dfd4dc612262792e35d1173ff found no remaining blockers; the reviewer did not independently rerun tests. Published commit ea94245d3333c8f637bdb1ff00634c9fc5122c37 has the identical verified tree.
  • Publication-time upstream advanced to 7f9a03d; the five intervening commits do not touch these comparison/test/doc files. Validation above is on the stated e32a049 base, not a claim of retesting upstream's newer unrelated changes.
  • The full deterministic suite and real-provider lanes were not run locally.

Compatibility, safety, and release

No schema migration or package change. Static correspondence is not runtime or behavioral equivalence. The full deterministic CI suite and real-provider lanes were not run locally.

Author readiness

Human owner: @WenyuChiou

  • 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.

Draft for human ownership/review; no merge requested or performed.


🔄 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/6478 **Author:** [@WenyuChiou](https://github.com/WenyuChiou) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/source-bundle-occurrences` --- ### 📝 Commits (1) - [`ea94245`](https://github.com/morluto/rea/commit/ea94245d3333c8f637bdb1ff00634c9fc5122c37) fix(javascript): classify distinct source-to-bundle occurrences ### 📊 Changes **5 files changed** (+351 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `docs/javascript-application-workflows.md` (+10 -3) 📝 `src/domain/javascript/sourceToBundleComparison.test.ts` (+129 -0) 📝 `src/domain/javascript/sourceToBundleComparison.ts` (+49 -20) 📝 `src/domain/javascript/sourceToBundleSignals.ts` (+65 -0) 📝 `tests/acceptance/applications/applicationWorkflowCli.test.ts` (+98 -0) </details> ### 📄 Description ## Summary Fixes #6456. Classify historical source mappings by distinct current source occurrences, rather than counting a file's asset, source-module, and export-binding graph representations as separate files. ## Problem and expected behavior A single `main.js` containing `export const value = 1;` was reported as `duplicated` when unchanged and `split` when its literal changed to 2. Both graphs contained only one JavaScript file. This makes source-retention summaries incorrectly report duplication or splitting even though the retained evidence identifies one file. The expected outcomes are `unchanged` and `modified`, while preserving all three candidate representations. ## Change and scope Project occurrence identity alongside existing candidate facts. Recognized whole-file assets and source-module/export-binding owners share an occurrence only when their evidence agrees on literal path and backing artifact digest without conflicting source digests. Supplemental export-return-shape observations remain validated. Source-map originals, bundled modules, conflicting bytes, and distinct literal paths are not blindly deduplicated. A content-addressed asset with several file observations retains multiple occurrences; location inference selects only matching paths. Keep every admitted candidate and signal; map all admitted representations of selected occurrences. Preserve merged historical aliases and paged candidate `mapped` flags. Update the owning workflow documentation. Ordinary correction within existing static comparison boundaries; new maintainer scope approval is not applicable. No provider, fetching, target execution, or mutation capability added. ## Contract and boundary impact - Semantic owner: source-to-bundle candidate projection and classification. - CLI/MCP schemas and tool catalogs: unchanged; existing statuses and mapped node IDs are corrected. - Evidence/provenance: original nodes, candidate signals, scores, digests and paths retained. - Provider/platform/cleanup: no provider protocol, launch, ownership or cleanup changes. - Generated metadata/package/installation: none. Expected existing workflow effects: - [x] Read existing files or captured data. - [x] Launch or attach to a process (existing owned static analysis workers). - [ ] Inject instrumentation or run target scripts/code. - [ ] Contact network services. - [ ] Recover protected code or work around protections. ## Evidence and regression coverage Executed on Linux with pinned Node 24.18.0 and npm 11.16.0, using inert synthetic local source files only. - Actual public CLI on unchanged production base `e32a0494d42dedd5e79ca341d20c53f07479d9bb`: changed → `split` (3 candidates), same → `duplicated` (3 candidates, 2 mapped). - Fixed public CLI: changed → `modified`, same → `unchanged`; both retain 3 candidates and map all 3. - Added compiled CLI regressions for exported literals and functions returning object shapes: unchanged, edited, genuine identical copies, and paged candidate mapping flags. - Domain regressions cover multi-observation content-addressed copies, matched-path filtering, conflicting source digests, independent bundled modules and merged historical aliases. Existing Unicode and source-map correspondence coverage retained. - No live browser/service, native analysis provider, target code, private artifact or credential used. Synthetic Linux coverage does not establish real-provider or other-platform behavior. No performance improvement claimed; resource/token costs were not benchmarked. ## Validation performed - `npm run build:cached` — passed. - `node_modules/.bin/vitest run --project acceptance tests/acceptance/applications/applicationWorkflowCli.test.ts -t 'compares file occurrences'` — 2 passed; 36 unrelated tests skipped. Exercises compiled public CLI with literal and object-returning-function fixtures plus paged candidate inspection. - Focused domain and filesystem suites — 28 and 59 passed respectively. The initial filesystem run had one 30s timeout; its final rerun passed without changing the timeout configuration. - `npm run test:focused -- src/domain/javascript/sourceToBundleComparison.test.ts tests/boundary/filesystem/sourceToBundlePaths.test.ts tests/boundary/mcp/sourceToBundleViewsMcp.test.ts` — 88 passed, 1 existing MCP full-profile case timed out at the default 30s (no assertion failure). This default-budget combined run was not green. - `node_modules/.bin/vitest run --project mcp-boundary tests/boundary/mcp/sourceToBundleViewsMcp.test.ts --testTimeout 60000` — isolated retry: 2 passed (26.7s full, 54.9s compact). No timeout configuration was committed. - `npm run docs:check` — passed. - `npm run check` — final pass: typecheck, lint (0 errors), formatting, knip, metadata, module boundaries and architecture guards. An initial test `describe` callback exceeded the lint line limit; separating the new occurrence tests resolved it, and the final domain suite passed 28/28 again. - `git diff --check` — passed. Independent read-only review of local commit `46becf812e53d26f097b30190086ff424cd334f6` / tree `bee27d3199f1129dfd4dc612262792e35d1173ff` found no remaining blockers; the reviewer did not independently rerun tests. Published commit `ea94245d3333c8f637bdb1ff00634c9fc5122c37` has the identical verified tree. - Publication-time upstream advanced to `7f9a03d`; the five intervening commits do not touch these comparison/test/doc files. Validation above is on the stated `e32a049` base, not a claim of retesting upstream's newer unrelated changes. - The full deterministic suite and real-provider lanes were not run locally. ## Compatibility, safety, and release No schema migration or package change. Static correspondence is not runtime or behavioral equivalence. The full deterministic CI suite and real-provider lanes were not run locally. ## Author readiness Human owner: @WenyuChiou - [ ] 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. Draft for human ownership/review; no merge requested or performed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:19 +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#7361
No description provided.