/** * v1.3.2 §9.2 — domain-agnostic directed-graph core. * * Shared by agent-manager (delegation graph built from `collaborators`/ * `used_by`) and workflow-manager (stage graph built from `depends_on`). * * Cycle detection is Kahn's algorithm (topological peel, O(V+E)) to find the * set of nodes that participate in *some* cycle; a bounded DFS over that * subgraph then recovers concrete node paths so callers can report * "a → b → a" rather than a bare "a cycle exists". */ export interface GraphNode { id: string; } export interface GraphEdge { from: string; to: string; /** Provenance label for diagnostics (which field declared the edge). */ field?: string; } /** * Return every distinct simple cycle as an ordered node-id path with the * entry node repeated at the end (e.g. `["a","b","a"]`). A self-loop `a→a` * comes back as `["a","a"]`. Empty result ⇒ the graph is a DAG. */ export declare function detectCycles(nodes: GraphNode[], edges: GraphEdge[]): string[][]; /** Node ids reachable from none of `roots` (orphans). */ export declare function findUnreachable(roots: string[], nodes: GraphNode[], edges: GraphEdge[]): string[]; /** * Longest path length (in edges) reachable from `roots`. Returns `Infinity` * if a cycle is reachable — callers should run {@link detectCycles} first and * only trust this on a DAG. Used for the delegation depth cap. */ export declare function maxDepth(roots: string[], nodes: GraphNode[], edges: GraphEdge[]): number;