[PR #4984] fix(call-path): bound inline shortest-path enumeration #6711

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4984
Author: @DeryFerd
Created: 10/18/2026
Status: 🔄 Open

Base: main ← Head: fix/call-path-enumeration-bound


📝 Commits (1)

  • 954ffb1 fix(call-path): bound inline shortest-path enumeration

📊 Changes

4 files changed (+428 additions, -26 deletions)

View changed files

📝 src/contracts/sessionToolContracts.ts (+1 -1)
📝 src/domain/callPath.test.ts (+199 -6)
📝 src/domain/callPath.ts (+168 -12)
📝 src/domain/callPathSchemas.ts (+60 -7)

📄 Description

Summary

build_call_path could allocate every shortest path before response-budget enforcement. Bound a conservative serialized upper estimate of the cited paths field to 2 MiB before retaining path/node/edge copies, and stop enumeration once this representation budget or the caller's max_paths preference is reached.

The arbitrary 4,096-path maximum is removed; max_paths accepts positive safe integers. If the first path cannot fit, retain the graph finding and report explicitly that no path was inlined, with truncation and byte-limit facts.

The 2 MiB budget bounds the duplicated path representation. It does not guarantee that the complete MCP response fits: other fields, including functions and evidence links, have independent sizes and retain their normal transport/provenance semantics.

Validation

Node 24.18.0/npm 11.16.0: 37 focused call-path tests passed, including a 131,072-path lattice, giant deep path and oversized first-path cases. npm run check:fast and npm run docs:check passed, with 5 README consistency tests.

This change uses dossier-derived graph facts; no real provider was executed. Whole CLI/MCP latency, agent-token cost and process-family peak memory were not measured in this pass.

Author readiness

Human owner: @DeryFerd

  • 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/4984 **Author:** [@DeryFerd](https://github.com/DeryFerd) **Created:** 10/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/call-path-enumeration-bound` --- ### 📝 Commits (1) - [`954ffb1`](https://github.com/morluto/rea/commit/954ffb11c890d3a1a2a0b70a6299d7ea0b42b6a6) fix(call-path): bound inline shortest-path enumeration ### 📊 Changes **4 files changed** (+428 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src/contracts/sessionToolContracts.ts` (+1 -1) 📝 `src/domain/callPath.test.ts` (+199 -6) 📝 `src/domain/callPath.ts` (+168 -12) 📝 `src/domain/callPathSchemas.ts` (+60 -7) </details> ### 📄 Description ## Summary `build_call_path` could allocate every shortest path before response-budget enforcement. Bound a conservative serialized upper estimate of the cited `paths` field to 2 MiB before retaining path/node/edge copies, and stop enumeration once this representation budget or the caller's `max_paths` preference is reached. The arbitrary 4,096-path maximum is removed; `max_paths` accepts positive safe integers. If the first path cannot fit, retain the graph finding and report explicitly that no path was inlined, with truncation and byte-limit facts. The 2 MiB budget bounds the duplicated path representation. It does not guarantee that the complete MCP response fits: other fields, including functions and evidence links, have independent sizes and retain their normal transport/provenance semantics. ## Validation Node 24.18.0/npm 11.16.0: 37 focused call-path tests passed, including a 131,072-path lattice, giant deep path and oversized first-path cases. `npm run check:fast` and `npm run docs:check` passed, with 5 README consistency tests. This change uses dossier-derived graph facts; no real provider was executed. Whole CLI/MCP latency, agent-token cost and process-family peak memory were not measured in this pass. ## Author readiness Human owner: @DeryFerd - [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 - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6711
No description provided.