chore(gates): name the added modules and import paths when an eager closure grows
What changed
The eager-closure NO-GROWTH gate (scripts/__tests__/eager-closure-budgets.ts +
.test.ts) has good bones — it already names the shortest import chain to a growth —
but its message shape sent reviewers the wrong way on #2423. This is a small
diagnostics-only change; the verdict logic (when an entry is flagged as grown) is
identical.
describeClosureGrowthnow lists every newly-added module (bounded to 10, with
a count of any more), each with the shortest static import route from the entry —
not just the first one.- New
describeSharedGrowthHomes, run once after every entry is evaluated: for each
added module that two or more grown entries share, it prints one block naming
those entries with how much each grew, and the modules exactly those entries already
evaluate at the merge-base, scoped to the added module's own package. Labeled
neutrally as candidate homes, not a verdict. classifyGrowth's closing advice no longer prescribes one fix. It now states the
two common causes (a new static edge, or something that used to load lazily) and
the two remedies (give the symbol a home in a module already in the closure, or
make the new edge lazy), leaving the choice to the reader.
Two properties the aggregation keeps, from this PR's review round:
- Only net growth aggregates. Entries carry their head closure size and the
grouping applies the same conditionclassifyGrowthdoes. A closure that swapped one
module for another, or shrank while adding one, has newly evaluated modules and no
growth, so it never appears and never fails the aggregate. - One block per added module, never a union. Homes common to one group's entries say
nothing about another group's, so groups stay separate all the way into the message
and the label names the group ("Entries that grew by<module>…") instead of
claiming every failing entry.
Motivated by the review rounds on #2423.
Why
#2423's growth was one new tiny constants module reached from several platform-apple
facades through runner-cache-metadata.ts. The old message named only the first
added module and always said "move it behind a dynamic import" — which sent five
reviewers toward a dynamic import for a constant, when the right fix was a home in a
module every affected facade already had in its closure. Nothing in any single
entry's own failure could show that the "new" modules across five separate CI
failures were mostly the same one.
Evidence: before / after on a real planted growth
Planted an unused import './toolchain-probe-budget.ts'; (a new, empty module) into
packages/platform-apple/src/runner/runner-cache-metadata.ts — the same shape as
#2423: one new module reached by several platform-apple facades through the same
file. Ran the gate, captured the message, then discarded the plant (git diff was
back to just the two files below before committing).
Before (one entry's failure — packages/platform-apple/src/runner/index.ts):
packages/platform-apple/src/runner/index.ts evaluates 14 modules on import; the merge-base evaluated 13. Something that used to load on demand now loads eagerly, or a new static edge was added: move it behind a function-scoped `await import`.
First newly evaluated module, by shortest import route:
packages/platform-apple/src/runner/index.ts
-> packages/platform-apple/src/runner/runner-cache-metadata.ts
-> packages/platform-apple/src/runner/toolchain-probe-budget.ts
That one entry was one of seven that failed the same way — app-lifecycle-facade,
app-resolution-facade, doctor-facade, perf-facade, physical-device-facade,
runner-operations-facade, and runner/index.ts itself — each printing its own
version of the same chain, with nothing tying them together.
After (same entry):
packages/platform-apple/src/runner/index.ts evaluates 14 modules on import; the merge-base evaluated 13. That means either a new static edge was added, or something that used to load on demand now loads eagerly. The fix is either to give the new code a home in a module the closure already evaluates, or to move the new edge behind a function-scoped `await import` -- see the added module(s) below for which one fits.
Newly evaluated module(s), each by shortest import route from the entry:
packages/platform-apple/src/runner/index.ts → packages/platform-apple/src/runner/runner-cache-metadata.ts → packages/platform-apple/src/runner/toolchain-probe-budget.ts
After, printed once for the whole run (the new aggregation, one block per added
module, re-captured after the review round):
More than one entry grew by the same new module -- see the shared homes below instead of chasing each entry's own diagnostic separately:
packages/platform-apple/src/runner/toolchain-probe-budget.ts -- newly evaluated by packages/platform-apple/src/app-lifecycle-facade.ts (+1), packages/platform-apple/src/app-resolution-facade.ts (+1), packages/platform-apple/src/doctor-facade.ts (+1), packages/platform-apple/src/perf-facade.ts (+1), packages/platform-apple/src/physical-device-facade.ts (+1), packages/platform-apple/src/runner-operations-facade.ts (+1), packages/platform-apple/src/runner/index.ts (+1)
Entries that grew by packages/platform-apple/src/runner/toolchain-probe-budget.ts already evaluate these modules at the merge-base (possible homes for a shared symbol; not a statement of ownership):
packages/platform-apple/src/runner/apple-runner-platform.ts
packages/platform-apple/src/runner/host.ts
packages/platform-apple/src/runner/runner-provider.ts
packages/platform-apple/src/runner/runner-sequence.ts
packages/platform-apple/src/runner/runner-source.ts
packages/platform-apple/src/runner/index.ts
packages/platform-apple/src/runner/runner-cache-metadata.ts
That is the shape #2423 needed: one line pointing at the modules already common to
every affected facade, instead of five people independently reverse-engineering the
same pattern from five separate CI failures. Here there is one added module, so one
block; two independent added modules would print two, each with only its own entries
and homes.
Test plan
-
pnpm vitest run --project unit-core scripts/__tests__/eager-closure-budgets.test.ts— 588 passed, including the added-module listing (with a route), the shared-homes aggregation (two entries sharing one added module, the no-op single-entry case), and this round's two regressions:an equal-size replacement is not growth, so the aggregate stays silentanddisjoint growth groups keep their own entries and homes in separate blocks. Both were confirmed non-vacuous by re-introducing the two defects (theadded.length > 0filter, and one merged homes list) and watching each fail. -
pnpm check:fallow --base origin/main— no issues in 2 changed files; every function in the split grouping is under the complexity thresholds. -
pnpm typecheck— clean (the earlier--untilfailure was #2472's, now on main). -
pnpm lint— clean. -
pnpm check:layering— clean.