refactor(depgraph): run graph traversals on @statelyai/graph

Merged
TH
2mo ago
+273-142

Summary

Moves scripts/depgraph/ traversals (report and pnpm depgraph affected) from hand-rolled adjacency maps and BFS walks to @statelyai/graph. Import extraction still uses the layering gate's oxc edge model.

  • import-graph.ts builds one library graph, filtered by edge kind. Its NUL-separated importEdgeId is the single file-pair identity.
  • The transitive-reachability flag comes from the library's transitive reduction and is computed only in the report. On a value-import cycle the report lists the cycle and leaves that count uncomputed; affected still answers.
  • Levels use postorder; dependents and handler closures use BFS.
  • Adds dev dependency @statelyai/graph@2.4.0; 2.5.1 is younger than the minimum release age.

9 files. Findings and next steps: #3276.

Validation

At e2a049f00:

  • pnpm check:affected --run (full set, due to lockfile) and pnpm check:tooling passed; device and replay lanes are GitHub-authoritative.
  • pnpm depgraph:test 29/29, including unambiguous ids and buildGraph on a value cycle (fails if marking moves back into buildGraph).
  • With a value cycle planted in the tree, the report shows value-import cycles (R4): 1 and affected still answers.
  • On the current tree, graph.json and depgraph affected --json (three sample files) are byte-identical to main. Runtime 2.0 s โ†’ 1.5 s.

๐Ÿค– Generated with Claude Code