Commit Graph

2 Commits

Author SHA1 Message Date
Claude 2c519cd562 experiment: analysis-only depgraph, to test whether it clears the gate unexempted
NOT a finished change — pushed so the comparison behind a pending decision is
reproducible rather than a claim in a chat log. PR #1409 still carries the viewer.

Question: the viewer's productive output turned out to be the JSON, not the
render. Every finding this session came from numeric queries; the render was never
opened to make a decision. So: does an analysis-only version meet the repo's bar
WITHOUT the Fallow exemption that PR #1409 needs?

Method: delete viewer.{js,css,html} and the geometry (clusterLayout,
layeredLayout), keep computeLevels (it is analysis, not layout), emit JSON plus the
text summary, and REMOVE scripts/depgraph/** from ignorePatterns.

Result, with zero exemptions:

                        with viewer   analysis only
  complexity findings   23 (1 CRIT)   2
  unused files          2             0
  unused exports        3             0
  clone groups          1             0
  lines                 2811          ~590

Identical output: 898 files, 4627 edges, 1338 redundant value edges, 8 non-gated
cycles, R6 42 (matching the gate's baseline). So the numeric part can meet the
repo's bar unexempted; viewer.js — 920 lines with a CRITICAL-complexity `draw` —
never could.

Fixed along the way rather than suppressed: extracted `valueSuccessors` (the
value-edge adjacency was built identically in markRedundantEdges and
computeLevels — a real clone), extracted `edgeKindCode`/`edgeFlags` from a nested
ternary with CRAP 42, un-exported buildPayload/main, and deleted `fileGroup` and
the `group` node field, both dead once the cluster layout went.

Still open if this direction is chosen: split `buildGraph` (81 lines, 20
cyclomatic) and `markRedundantEdges` — the last 2 complexity findings, ordinary
functions rather than a canvas renderer. README is rewritten to match the
report-only shape; the when-to-use guidance carries over unchanged, since it was
already about numeric queries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bfu8HofkhybiAm5LECfqur
2026-07-27 08:34:23 +00:00
Claude cd19a73c55 feat(scripts): interactive dependency-graph viewer, with when-to-use guidance
Renders every production file under src/ as a pannable graph in one self-contained
HTML file — no external requests, no runtime dependency, layouts precomputed at
build time so the viewer never runs a physics simulation on a phone.

  pnpm depgraph          # -> .tmp/depgraph/index.html (+ index.json)
  pnpm depgraph:test

It reuses the layering gate's model (`listSourceFiles`, `resolveImportEdges`,
`zoneRank`) rather than extracting its own graph. That matters more than it
sounds: a separate extractor with its own resolution behaviour would draw a graph
nobody enforces. Because the model is shared, its R6 count reproduces
TYPE_INVERSION_BASELINE exactly, which doubles as a self-check.

The README now documents WHEN it is productive, because the honest answer is
"for three questions, and it misleads on a fourth":

- what am I about to break (dependent counts, including the type-only and dynamic
  edges a grep for `from '...'` misses);
- where is the debt concentrated (zone-level counts);
- what is wrong that CI does not enforce — ~1300 transitively redundant value
  edges and 8 type-only/dynamic cycles, both outside the gate by design.

The fourth: a cluster's SIZE IS NOT ITS DIFFICULTY. `commands -> client` looked
like the obvious win at 28 edges into one file; moving that file down took the
gate from 42 to 48, because the vocabulary it holds depends on commands/, metro/,
core/ and remote/. The render shows an edge's weight, not whether it can be
reversed — so the README pairs every visual question with the numeric query that
answers "can this actually move?", verified against the real output rather than
written from memory.

Also states plainly that `pnpm check:layering` is authoritative and nothing here
gates a merge: it is an instrument, not a rule.

scripts/depgraph/** joins scripts/layering/**, scripts/perf/** and
scripts/maestro-conformance/** in Fallow's ignorePatterns, which is how this repo
already treats tooling trees. Worth knowing rather than discovering: that exempts
viewer.js from the complexity gate, and its `draw` function would fail it.

Two exports added to scripts/layering/model.ts: `zoneRank` (the viewer colours
nodes by rank, so an inversion reads as an edge pointing the wrong way down the
ramp) and `targetDagZone`, previously module-private.

`pnpm check` green, 4488 unit tests. Verified against current main: 898 files,
4627 edges, 25 zones, R6 count matching the gate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bfu8HofkhybiAm5LECfqur
2026-07-27 06:54:46 +00:00