import type { ModelGraph } from "../loader/model-graph.js"; import type { ModelNode } from "../schema/index.js"; /** * Reusable model-slice join (Proposal 006 A5). Given a start node id and a * traversal depth, produce the connected task-relevant sub-graph: * flow→loops/junctions/sub-flows, loop→junctions/scenarios/parent/effective * constraints, junction→loops/scenarios, scenario→referrers/applies_to. * * This is deliberately factored out of the `inspect` CLI command so the * Phase 2 query family (`model impact`/`plan`/`scenario`/`evidence`) reuses * one traversal + one summary/truncation module (proposal 001 §4.2), rather * than each command re-deriving "what's related to X". */ export interface SliceNode { id: string; kind: ModelNode["kind"]; /** Shortest hop distance from the root (root = 0). */ depth: number; node: ModelNode; /** * For loops only: scenario ids that apply via `applies_to` (effective * constraints, Decision 004 技术点 2) — computed at query time, not * hand-listed on the node. Undefined for non-loop kinds. */ effectiveConstraints?: string[]; } /** A neighbor one hop past the traversal frontier, surfaced as a pointer (not expanded). */ export interface FrontierPointer { id: string; kind: ModelNode["kind"]; /** An in-slice node that references this pointer (so the user knows where it hangs off). */ fromId: string; } export interface ModelSlice { rootId: string; rootKind: ModelNode["kind"]; maxDepth: number; /** Reached nodes, ordered by (depth, id). Includes the root at depth 0. */ nodes: SliceNode[]; /** Neighbors beyond `maxDepth` that were not expanded — expand with `--depth`. */ frontierPointers: FrontierPointer[]; } /** * Depth-limited breadth-first slice from `rootId`. Returns undefined if the * root id isn't a node in the graph (the CLI turns that into an "unknown id" * error). * * Standard mark-at-enqueue BFS: a node is added to `enqueued` the moment it's * first discovered, so (a) each node is enqueued exactly once and recorded at * its shortest distance from the root, and (b) any node reachable within * `maxDepth` is marked (via its shallower parent, which the depth-ordered FIFO * dequeues first) before a depth==maxDepth sibling could add it to the * frontier — so `frontierPointers` and the in-slice node set never overlap by * construction, no post-hoc reconciliation needed. */ export declare function sliceModel(graph: ModelGraph, rootId: string, maxDepth: number): ModelSlice | undefined; //# sourceMappingURL=slice.d.ts.map