mirror of
https://github.com/morluto/rea.git
synced 2026-11-30 10:27:42 +00:00
* fix(call-path): bound inline shortest-path enumeration build_call_path could allocate every shortest path before response-budget enforcement. Count the exact total with a capped BigInt pass over the distance graph instead, and bound enumeration itself: max_paths (default 64) is a caller-selected count preference while a 2 MiB serialized paths-field budget is the resource bound, checked before each cited path is formed. The representation accounting measures each string with the rules JSON.stringify applies instead of charging six bytes per code unit, so an ASCII address or Evidence id is no longer billed six times what it writes, and the paths-array brackets the per-path accounting excludes are reserved. A path that serializes to 469,497 bytes is no longer refused as over the budget. Results report total_shortest_paths, total_shortest_paths_capped, paths_truncated and paths_limited_by_bytes so exact counts, representation limits and completeness stay distinguishable, and a found result whose single path cannot fit still reports the known path with byte-budget truncation. * fix(call-path): always return the first shortest path and measure cited paths The byte budget dropped a sole shortest path whose citations exceeded 2 MiB, although that path is linear in the supplied Evidence; only path count grows exponentially, and max_paths bounds it. Always return the first path and let the budget bound the paths after it. Measure each cited path with JSON.stringify instead of a hand-written estimator that duplicated citePath's shape and JSON escaping (it also charged U+007F-U+009F as escaped). The found result again requires at least one path. * refactor(call-path): measure cited paths from cached parts before assembling A candidate path was cited and serialized in full before the byte check, so a rejected path still built its representation. Move citation into CitedPathParts, which builds each node and edge record once per graph position with its exact JSON size. Enumeration sums a candidate from those parts and assembles only an accepted path, which shares the cached records. The path skeleton is measured from the same record constructor, so size and output cannot drift. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>