feat(depgraph): dominator, zone-SCC, and cohesion report summaries

Merged
TH
2mo ago
+540-10

Summary

Part of #3283 (workstream 7 of the architecture-quality umbrella #3276). Adds three report-only fields to pnpm depgraph, stacked on #3275's @statelyai/graph migration:

  • dominatorSummary — dominator tree of one entry's eager-load closure over value edges only (default src/daemon.ts, override with --dominator-entry <path>). Reproduces #3276's own numbers against the current tree: 621/1837 eager files, with request-binding.ts/replay-device-selection.ts pulling in all of maestro and provider-device-runtimes.ts pulling in all of provider-webdriver.
  • zoneSccSummary — strongly connected components of the zone graph over value zone-pairs only (same edge kind R4 keeps acyclic at file level). Reproduces the quoted 9-zone cycle (cli, commands, core, daemon-client, daemon-server, remote, sdk, plugins, (root)).
  • cohesionSummary — Louvain communities vs. declared zones scored with getModularity, plus per-zone cohesion share. Reproduces 0.373 (declared) vs 0.564 (detected) modularity and the five lowest per-zone shares (kernel 26%, contracts 29%, sdk 31%, (root) 37%, host-kit 38%).

Nothing in scripts/layering/ or scripts/check-affected/ reads these fields — no gate behavior changed. getModularity wants Community<N> (full node objects) but getLouvainCommunities returns bare ids; computeCohesionSummary maps ids back onto the graph's own nodes once, in the owning module, rather than at each call site (this mismatch is also one of the four upstream @statelyai/graph issues deliverable 2 of #3283 covers — not yet filed this round, tracked separately in #3283).

7 files touched, +506/-10 lines (git diff --stat), within budget.

pnpm depgraph
pnpm depgraph --dominator-entry src/cli/entry.ts

Validation

Tested at 8368e7b67:

  • pnpm depgraph:test — 37/37 pass (new structure-summary.test.ts wired into the script's explicit file list).
  • pnpm check:quick (lint + typecheck) — clean.
  • pnpm check:affected --run — all runnable checks passed (including fallow audit, which initially flagged main's cyclomatic complexity in build.ts; fixed by extracting a flagValue helper, then clean).
  • Manual run of pnpm depgraph against the current tree reproduces every number #3276 quotes, as evidence the new code measures what it claims to.

No device-facing or routing changes; docs-only risk is the README section added for the new fields.