Skip to content
1 min read · 200 words

Function: routesBetween()

ts
function routesBetween(
  view: RawPlanView | PlanGraphView,
  fromId: string,
  toId: string,
): string[][];

Defined in: src/batteries/orchestration/plan.ts:270

All distinct simple paths from one node to another.

Parameters

ParameterTypeDescription
view| RawPlanView | PlanGraphViewThe graph to search.
fromIdstringThe start node id.
toIdstringThe target node id.

Returns

string[][]

Every distinct simple path from fromId to toId, truncated at MAX_ROUTES.

Remarks

A simple path is a route that visits no node twice. This is used to derive a join's required (the number of fork→join routes) and to validate the diamond topology. The result is a list of node-id sequences, each starting at fromId and ending at toId.

Blowup guard. The number of simple paths in a DAG can be exponential in the node count, so this enumerates at most MAX_ROUTES paths and stops. A caller that needs an exact count (a join's required) must treat a truncated result as "too many to count" and refuse the graph rather than trust a partial count — the freeze validator does exactly that. The cap is a documented safety valve, not a correctness knob.