Repository navigation
Description
#1064 measured 13/55 on loomster and found the fallbacks cascade. 15 files fail directly on process, 10 more fail on params because they import those, 5 more behind those. Roughly 30 of 42 trace to one authoring pattern.
The fallback report today is flat. A flat list of 42 files says 42 problems. The real content is that fixing one file unblocks thirty.
Why dominators
The import graph is a DAG, not a tree. A file is reachable by many paths, so naively counting "files downstream of X" double-counts every diamond and the totals stop meaning anything.
Immediate dominators are the principled fix. File d dominates n when every import path reaching n passes through d. Retained count is then the number of files that would fold if d folded, and every file lands in exactly one dominator subtree, so the counts sum to the total with nothing counted twice.
Prior art in a sibling repo. spicypath computes exactly this over heap object graphs (src/heap-dominators.js, Cooper–Harvey–Kennedy) and gets the same conservation property over a graph that is cyclic and irreducible. Different domain, same math, and an import graph is the easier case.
Scope
- Compute immediate dominators over the module graph discovery already builds, with fold outcome per file as the input.
- Rank blockers by retained count. A root cause with 30 retained outranks 12 unrelated leaves.
- Report the ranking from
chant build --foldalongside the existing per-file reasons. - Export the dominator tree in Brendan Gregg collapsed format, weighted by retained count, so it renders in any flame or icicle viewer with no chant-specific tooling. The seam stays at the file format.
AC
-
chant build --foldreports blockers ranked by how many files each would unblock, not just a flat fallback list. - loomster's
src/loom-db/params.tsranks first with retained around 30. - Retained is conserved. Summing over top-level blockers equals the total fallback count, and no file is counted twice through a diamond.
- A file with two independent blockers is handled without inflating either.
- Collapsed-format export, weighted by retained count.
Stays useful after #1064 lands, because resolving process.env promotes whatever is behind it to the top of the same ranking.
Relates #1062 (generate the inventory rather than hand-maintain it), #1064 (the finding), #1019 (epic).
Activity
lex00 commentedon Jul 27, 2026
Dependency correction after checking current state.
#1054 is a hard blocker, not a relation. This ranking keys on fold-failure reasons, and #1090 documents that reasons are currently unreliable to attribute — two wordings exist for the same rejection (
function call as a valueandcall expression as a value), and reasons embed the entire multi-line source node, so line-based grepping silently miscounts. Root-cause grouping inherits that defect directly. Land #1054 first, and parse whole blocks rather than lines.#1062 landed (closed 2026-07-26). No overlap. #1062 publishes what folds and keeps the inventory generated. This ranks what doesn't fold by blast radius. The generated inventory is a reasonable input rather than something to rebuild.
lex00 commentedon Jul 27, 2026
Two gaps found while tracing this to the goal.
The only concrete AC is now stale. It asserts
src/loom-db/params.tsranks first with retained around 30. That number is pre-migration. loomster#156 merged, migrating those files offprocess.envto build-time parameters, so params.ts should no longer be a blocker at all and the AC as written may be unsatisfiable. Replace it with a re-measured target once the post-migration ratio is posted on #1064.No freshness guard. #1062 exists because a hand-maintained inventory went stale within an hour of the merge it described, and its AC required CI to fail on divergence. This issue produces a ranking with no equivalent requirement, so it decays the same way. Add an AC that the ranking is generated and guarded, in the shape of the post-synth barrel guard #1062 cites as precedent.
lex00 commentedon Jul 27, 2026
Model gap found while measuring loomster (numbers on #1064).
This issue assumes contagion flows one way — a file fails because its imports failed, so dominators over the import graph rank blockers by how many importers they unblock.
Fold has a second rule in the opposite direction.
params.tspost-migration reports:So a perfectly foldable file falls back because an importer fell back. Contagion is bidirectional, and a dominator tree over import edges alone cannot express it. Ranking built on the one-way model would credit a fix with unblocking files that stay blocked by the reverse rule.
Whatever this becomes, it has to model both directions, and the retained-count semantics need restating. "Files that would fold if this one folded" is no longer a subtree over import edges.
This may also be the more valuable version of the issue. On the current numbers the reverse rule looks like it dominates the outcome, which is exactly the kind of thing a blast-radius ranking should surface and a flat reason list cannot.
lex00 commentedon Jul 27, 2026
Measured data for the model correction (full context: #1064 (comment)). On loomster under 0.20.0, the reverse-contagion edge blocks exactly 2 files; the dominant blockers on real src (0/40 foldable) are exported helper function declarations (>=9 files) and their unresolved-identifier cascade (>=10). The prior AC (params.ts ranks first with retained ~30) is unsatisfiable under any discovery scope — params.ts now folds in isolation and only 2 files are held back by the reverse edge. If this issue proceeds after #1054, the ranking should treat exported-function-declaration sites as the seeds and model both edge directions, with the reverse direction expected to contribute little on current loomster.
lex00 commentedon Aug 26, 2026
Re-scoping this before implementation, based on the measurements recorded on #1064/#1090 and the thread above:
Blocker cleared. #1054 closed via PR #1109 — reasons are now attributable, so the ranking's input is reliable.
AC replacement. The concrete AC (
params.tsranks first, retained ~30) is confirmed unsatisfiable and is dropped. Replacement acceptance criteria:--foldbuild and reports blockers ordered by dominator retained-count; retained is conserved (sums to total run-labeled files) and files with two independent blockers are not double-counted.feat(core): rank fold blockers by dominator retained-count (INTENTIUS…