--- id: analysis/ordering name: Implement execution ordering functions (topologicalOrder, parallelGroups, criticalPath, reachableFrom) status: completed depends_on: - graph/flowgraph-class - graph/queries scope: narrow risk: low impact: component level: implementation --- ## Description Implement the standalone analysis functions for execution ordering. These are pure functions operating on FlowGraph instances, delegating to graphology-dag algorithms. ## Acceptance Criteria - [ ] `topologicalOrder(graph: FlowGraph): string[]` — uses graphology-dag topologicalSort, throws CycleError on cycles - [ ] `parallelGroups(graph: FlowGraph): string[][]` — groups by dependency depth (group 0 = roots, group 1 = dependents of group 0, etc.) - [ ] `criticalPath(graph: FlowGraph): string[]` — longest path through DAG - [ ] `reachableFrom(graph: FlowGraph, nodeIds: string[]): Set` — BFS/DFS from starting nodes - [ ] `ancestors(graph: FlowGraph, nodeId: string): string[]` and `descendants(graph: FlowGraph, nodeId: string): string[]` - [ ] All functions are standalone (not FlowGraph methods), in `src/analysis/` - [ ] O(V + E) complexity for all — documented in JSDoc - [ ] Unit tests: known DAGs produce expected orderings, parallel groups, critical paths ## References - docs/architecture/analysis.md — execution ordering functions, performance characteristics - docs/architecture/flowgraph-api.md — convenience delegation from FlowGraph to standalone functions ## Notes > To be filled by implementation agent ## Summary > To be filled on completion