[PR #1789] [MERGED] perf(javascript): skip the repeated-prefix scan on first capture visits #4819

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

📋 Pull Request Information

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

Base: main ← Head: fix/javascript-alias-prefix-scan


📝 Commits (1)

  • dd12543 perf(javascript): skip the repeated-prefix scan on first capture visits

📊 Changes

1 file changed (+9 additions, -2 deletions)

View changed files

📝 src/domain/javascript/javascriptSemanticMemberMutations.ts (+9 -2)

📄 Description

Summary

Follow-up to #1767. That PR was merged before this commit, which answers the
review comment on the suffix scan, reached the branch.

collectSemanticMemberMutationsSteps searched every suffix of the current path
for an earlier visit, even on a binding's first visit at a capture, where no
earlier visit can exist. The scan now runs only when the capture is already on
the alias chain.

Problem and expected behavior

For a deep write through many aliases with no projection
(const a1 = a0; …; aB.p1…pL = 1), each alias is a first visit. The scan still
sliced and serialized all L suffixes per alias, which is Θ(L²) per alias.
Expected: a first visit does no suffix work.

Change and scope

Add a capture key to the alias chain's lifetime set and skip the scan when the
capture is absent. Behavior is unchanged: a suffix can only match an earlier
visit of the same capture.

Not included: the finite path expansion that dominates long self-alias chains
(see the measurements in #1767). It predates #1767 and needs its own fix.

Contract and boundary impact

  • Semantic owner and earliest changed stage: domain JavaScript member-mutation collection.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none; identical results.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: none. The change removes work without changing
    results, and the existing self-alias and lifetime cases cover the scan's
    outcomes.
  • Base reproduction or other evidence: 300 aliases × path depth 300, on macOS
    with Node 24.18.0: 1.75 s on origin/main and 1.73 s with this change. The
    scan is not the dominant cost at this size; the change removes its
    quadratic term.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: no benchmark covers sizes where the scan would dominate.

For evidence-bearing changes:

  • 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

  • npx vitest run src/domain/javascript/ — 43 files, 821 passed
  • npm run check:fast — passed

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; macOS only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: removes avoidable work on untrusted input.

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.

🤖 Generated with Claude Code


🔄 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/1789 **Author:** [@flitzrrr](https://github.com/flitzrrr) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/javascript-alias-prefix-scan` --- ### 📝 Commits (1) - [`dd12543`](https://github.com/morluto/rea/commit/dd12543c8615cffc16a8b85a1fce754f5e2e756d) perf(javascript): skip the repeated-prefix scan on first capture visits ### 📊 Changes **1 file changed** (+9 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/javascript/javascriptSemanticMemberMutations.ts` (+9 -2) </details> ### 📄 Description ## Summary Follow-up to #1767. That PR was merged before this commit, which answers the review comment on the suffix scan, reached the branch. `collectSemanticMemberMutationsSteps` searched every suffix of the current path for an earlier visit, even on a binding's first visit at a capture, where no earlier visit can exist. The scan now runs only when the capture is already on the alias chain. ## Problem and expected behavior For a deep write through many aliases with no projection (`const a1 = a0; …; aB.p1…pL = 1`), each alias is a first visit. The scan still sliced and serialized all `L` suffixes per alias, which is Θ(L²) per alias. Expected: a first visit does no suffix work. ## Change and scope Add a capture key to the alias chain's lifetime set and skip the scan when the capture is absent. Behavior is unchanged: a suffix can only match an earlier visit of the same capture. Not included: the finite path expansion that dominates long self-alias chains (see the measurements in #1767). It predates #1767 and needs its own fix. ## Contract and boundary impact - Semantic owner and earliest changed stage: domain JavaScript member-mutation collection. - CLI and MCP/tool-catalog contract: none. - Provider, bridge, target-format, or platform compatibility: none. - Evidence, artifact, provenance, or reconstruction contract: none; identical results. - Process execution, authorization, cleanup, or containment impact: none. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: none. The change removes work without changing results, and the existing self-alias and lifetime cases cover the scan's outcomes. - Base reproduction or other evidence: 300 aliases × path depth 300, on macOS with Node 24.18.0: 1.75 s on origin/main and 1.73 s with this change. The scan is not the dominant cost at this size; the change removes its quadratic term. - User-visible CLI/MCP output (if applicable): none. - Remaining proof gaps: no benchmark covers sizes where the scan would dominate. For evidence-bearing changes: - [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 - `npx vitest run src/domain/javascript/` — 43 files, 821 passed - `npm run check:fast` — passed ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; macOS only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: removes avoidable work on untrusted input. ## 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:22 +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#4819
No description provided.