[PR #5938] [CLOSED] fix(trace): retain linear call path traversal state #7112

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5938
Author: @dakjdakd
Created: 10/21/2026
Status: ❌ Closed

Base: main ← Head: fix/trace-call-path-memory


📝 Commits (1)

  • 66a755d fix(trace): retain linear call path traversal state

📊 Changes

2 files changed (+118 additions, -10 deletions)

View changed files

📝 src/application/CallPathTracing.ts (+21 -10)
📝 tests/composition/callPathParserOperation.test.ts (+97 -0)

📄 Description

Summary

Fixes #5931

Replace per-node copied path arrays in trace_call_path with parent pointers. The traversal now retains linear state and reconstructs only the selected goal path, preserving BFS behavior, relationship coverage, cancellation, and serialized output.

Problem and expected behavior

The previous traversal state stored a complete path array for every visited address. Discovering a child copied the full parent path before appending the child. A long linear graph consequently retained duplicate prefixes for every node, creating quadratic memory growth.

The expected representation is one parent address and one depth per visited node. When a goal is reached, the implementation follows parent pointers back to the start and reverses that sequence once. A traversal without a goal must still examine the same relationships and return the same complete result.

Change and scope

  • Changed the visited-state record from { depth, path } to { depth, parent }.
  • Added goal-time path reconstruction from the parent chain.
  • Kept the existing BFS queue, duplicate suppression, edge recording, depth checks, forward/backward traversal, sorting, cancellation, and failure reporting.
  • Added long-chain coverage for no-goal and final-goal traversals, including cycles and duplicate edges.
  • Compared complete serialized results before and after the change to ensure the output contract remains unchanged.

No graph-size cap, provider behavior, output field, or MCP/CLI contract was changed. The fix only removes redundant internal path copies.

Contract and boundary impact

  • Semantic owner and earliest changed stage: internal call-path traversal state.
  • Contribution scope: routine memory-efficiency fix within an existing analysis operation.
  • CLI and MCP/tool-catalog contract: no change.
  • Provider, bridge, target-format, or platform compatibility: no change.
  • Evidence, artifact, or reconstruction contract: no change to returned evidence or relationship coverage.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only.
  • Not sure yet.

Evidence and regression coverage

  • Added 16,384-node no-goal and goal traversal coverage.
  • Added forward and backward cycle and duplicate-edge cases.
  • Verified that complete serialized output hashes remain identical before and after the implementation change.
  • Measured the same synthetic traversal under equal heap settings; the fixed representation completes with substantially lower retained memory.

Validation performed

  • Call-path source and MCP boundary regression suites — passed.
  • npm run check:fast — passed.
  • Long-chain memory verification — completed with byte-identical output.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real provider or target interaction: not applicable to this internal traversal-state change.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new authority or target interaction is introduced.

Author readiness

Human owner: @dakjdakd

  • 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.
  • Material scope and authority questions are resolved for this routine performance fix.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • The final diff was checked for unrelated cleanup.

🔄 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/5938 **Author:** [@dakjdakd](https://github.com/dakjdakd) **Created:** 10/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/trace-call-path-memory` --- ### 📝 Commits (1) - [`66a755d`](https://github.com/morluto/rea/commit/66a755dce45dc24228c3703a4935ff76220eedd5) fix(trace): retain linear call path traversal state ### 📊 Changes **2 files changed** (+118 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/application/CallPathTracing.ts` (+21 -10) 📝 `tests/composition/callPathParserOperation.test.ts` (+97 -0) </details> ### 📄 Description ## Summary Fixes #5931 Replace per-node copied path arrays in `trace_call_path` with parent pointers. The traversal now retains linear state and reconstructs only the selected goal path, preserving BFS behavior, relationship coverage, cancellation, and serialized output. ## Problem and expected behavior The previous traversal state stored a complete path array for every visited address. Discovering a child copied the full parent path before appending the child. A long linear graph consequently retained duplicate prefixes for every node, creating quadratic memory growth. The expected representation is one parent address and one depth per visited node. When a goal is reached, the implementation follows parent pointers back to the start and reverses that sequence once. A traversal without a goal must still examine the same relationships and return the same complete result. ## Change and scope - Changed the visited-state record from `{ depth, path }` to `{ depth, parent }`. - Added goal-time path reconstruction from the parent chain. - Kept the existing BFS queue, duplicate suppression, edge recording, depth checks, forward/backward traversal, sorting, cancellation, and failure reporting. - Added long-chain coverage for no-goal and final-goal traversals, including cycles and duplicate edges. - Compared complete serialized results before and after the change to ensure the output contract remains unchanged. No graph-size cap, provider behavior, output field, or MCP/CLI contract was changed. The fix only removes redundant internal path copies. ## Contract and boundary impact - Semantic owner and earliest changed stage: internal call-path traversal state. - Contribution scope: routine memory-efficiency fix within an existing analysis operation. - CLI and MCP/tool-catalog contract: no change. - Provider, bridge, target-format, or platform compatibility: no change. - Evidence, artifact, or reconstruction contract: no change to returned evidence or relationship coverage. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only. - [ ] Not sure yet. ## Evidence and regression coverage - Added 16,384-node no-goal and goal traversal coverage. - Added forward and backward cycle and duplicate-edge cases. - Verified that complete serialized output hashes remain identical before and after the implementation change. - Measured the same synthetic traversal under equal heap settings; the fixed representation completes with substantially lower retained memory. ## Validation performed - Call-path source and MCP boundary regression suites — passed. - `npm run check:fast` — passed. - Long-chain memory verification — completed with byte-identical output. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real provider or target interaction: not applicable to this internal traversal-state change. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new authority or target interaction is introduced. ## Author readiness Human owner: @dakjdakd - [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. - [x] Material scope and authority questions are resolved for this routine performance fix. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] The final diff was checked for unrelated cleanup. --- <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:28 +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#7112
No description provided.