Skip to content

test(structure): per-package eager-closure budgets — the ADR-0019 loading-shape probe (#1739) - #1965

Open
thymikee wants to merge 3 commits into
mainfrom
test/1960-eager-closure-budgets
Open

test(structure): per-package eager-closure budgets — the ADR-0019 loading-shape probe (#1739)#1965
thymikee wants to merge 3 commits into
mainfrom
test/1960-eager-closure-budgets

Conversation

@thymikee

@thymikee thymikee commented Aug 22, 2026

Copy link
Copy Markdown
Member

Summary

ADR-0019's "Implementation-laziness" section requires platform-package façades to stay implementation-lazy and is explicit that a startup threshold alone is not a substitute for preserving the loading shape: "the tracking issue owns the exact probe and planted-red procedure." #1950 built the AST-level walker (eager-import-closure.fixtures.ts); #1959/#1969 fixed two more instances of the regression class by hand. This PR generalizes the proof into a data-driven budget table so every workspace-package entry surface — and any designated hub module — gets an eager-closure ceiling without a bespoke test file.

Three files:

  • src/__tests__/eager-closure-budgets.ts — the data module: the budget table, the platform-implementation patterns, manifest-derived entry discovery, and the import-chain formatter.
  • src/__tests__/eager-closure-budgets.test.ts — iterates the table and asserts.
  • src/__tests__/eager-import-closure.fixtures.ts — gains eagerClosureGraphOf (predecessor-recording BFS) and per-file edge memoization; eagerClosureOf keeps its contract and is expressed in terms of it.

Discovery has one owner, shared with R11

facadeEntryFiles(repoRoot) lives in scripts/layering/package-boundaries.ts, and both R11's façade gate and this budget table call it — it is one function, not two implementations of the same rule. It takes each package's package.json exports targets, then adds every production source under a src/facades/ directory, walking recursively so a nested façade file cannot be covered by one gate and missed by the other.

(The first version of this PR claimed to share R11's discovery while actually carrying its own one-level readdir. That scan missed nested façade files, and missed every manifest-only entry surface — including all six platform façades. It is now genuinely one owner, and R11's façade test is green on it.)

This matters concretely: the six packages/platform-*/src/index.ts façades — the exact subject of ADR-0019's implementation-laziness rule — have no facades/ directory at all. A directory-only scan omits them, and the gate would claim to prove the loading shape while never looking at it. A dedicated non-vacuity test asserts all six are discovered.

Each platform façade evaluates exactly one module: itself. Its metadata is inline, its contract imports are import type (erased), and every implementation loads behind a function-scoped await import. A budget of 1 is the tightest possible statement of "metadata-eager and implementation-lazy", and a single static value import would destroy it while every other gate stayed green — R3/R13 govern import direction, never evaluation weight.

Pins are exact ratchets, asserted with equality

Every pin equals the measured closure size on 04e4c23b9, asserted with equality, not <=. Growing fails, and shrinking also fails until the row is lowered in the same PR — which is what "only ever ratchets down" requires, and what <= does not give: under <=, the moment an entry legitimately shrinks the unchanged row silently becomes headroom for the next regression. No slack in either direction. This matches how the repo pins R9 type-cycle size, R10 writer/owner counts, and test-file line counts — "existing pins only shrink; a new pin requires measured justification" (docs/agents/testing.md). Slack is not neutral for this gate: the regression it catches is a single static import dragging a subtree in, measured by #1969 at 5–12% of suite import work each, and a ceiling carrying "a few files" of spare room silently absorbs the small end of exactly that. Growth stays allowed — it just has to be a visible number change in the diff of the PR that causes it.

103 rows: 95 package entry surfaces + 8 designated hubs. The table is two Record<string, number> literals keyed by entry path, so a duplicate row inside either is a TypeScript error (TS1117) rather than something a later Set conversion would swallow. Notable values — platform-{apple,android,harmonyos,vega,linux,web} 1 each; contracts/facades/platform.ts 42; contracts/facades/interaction.ts 25; most granularized contracts entries 15; maestro 104; src/cli.ts 361; src/platform-runtime.ts 31 (the ADR-0019 composition root); src/daemon/session-teardown.ts 89. The hub set includes the five #1969 moved off the wide façades (dispatch, capabilities, registry, platform-execution-entry, register-builtins).

Violations name a bounded offending route

eagerClosureGraphOf records which file first pulled each module in. A failure prints the entry's heaviest direct edges — ranked by how many modules enter through each, capped at 4 edges and 2 representative routes apiece — so a newly added import is the first thing on screen instead of one chain per evaluated module (which would be 361 lines at src/cli.ts scale):

Where the weight comes from (heaviest direct edges, capped -- this attributes by shortest
import route, it does not diff against a recorded baseline):
  packages/platform-apple/src/index.ts -- 58 module(s) enter through this edge:
    src/platform-runtime.ts
      -> packages/platform-apple/src/index.ts
      -> packages/platform-apple/src/runtime.ts
      -> packages/platform-apple/src/logs/runtime.ts
      ...
  (+2 more direct edge(s), smaller)

What it does not do is diff against a recorded baseline: this gate persists each entry's module count, not its module identity, so it attributes by shortest import route rather than naming which modules are new. For the common case — a new import on the entry itself — that edge is new, its whole subtree is attributed to it, and it sorts first. For a regression deep inside an already-large subtree it names the top-level edge containing the growth. Storing a true delta would mean checking in ~1,500 module paths and rewriting them on every contracts refactor; the docstring states this trade explicitly rather than implying precision the data does not support.

The walk is breadth-first, so every printed chain is the shortest route to that file. Memoizing per-file edges also cut the existing pins' runtime (cli-startup-import-closure 2336ms → ~550ms).

Every rule has a failing-direction test

A real tree that satisfies its pins cannot distinguish a correct rule from a vacuous one, so each rule the gate rests on carries its own planted-red test: the equality ratchet (sabotage: ===<=), the bounded attribution (cap 4 → 999), recursive discovery (recursive → one-level, against a temp fixture tree with a nested façade), and row uniqueness (same path in both records; plus TS1117 for a duplicate key within one). All four were observed red and reverted.

Per the lane rule

Planted-red proof (reverted before commit)

Replaced the lazy await import('./runtime.ts') in packages/platform-apple/src/index.ts with a static namespace import — the flagship regression this gate exists to catch. Three tests fired:

× 'packages/platform-apple/src/index.ts' evaluates at most 1 modules
  → evaluates 65 modules on import, over its budget of 1.

× 'packages/platform-apple/src/index.ts' never evaluates a concrete platform implementation
  → packages/platform-apple/src/index.ts
        -> packages/platform-apple/src/runtime.ts
        -> packages/platform-apple/src/logs/runtime.ts
        -> packages/platform-apple/src/logs/backend.ts

× 'src/platform-runtime.ts' evaluates at most 31 modules
  → evaluates 80 modules on import, over its budget of 31.

The third is the composition root picking up the blast radius through its own chain — the cascade a flat offender set would not have explained. Sabotage reverted; the diff contains only the three intended files.

On #1969

#1969 is merged and this branch is rebased on it. Its contracts-entry-closure.test.ts is left in place: both of its tests state properties this table cannot (a specific hub must not reach two named façades; no source file value-imports them — a whole-tree scan, not an entry walk). The five hubs it names are now also budgeted here, so they carry both the specific pin and the general ceiling.

Validation

  • pnpm vitest run --project unit-core on the new file — 206/206 passing in ~700ms.
  • Together with the three existing closure pins — 230/230 passing, no slow-test gate output.
  • pnpm typecheck — clean.
  • pnpm check:layering — 181/181 passing (R11's façade gate now runs on the shared facadeEntryFiles); R11 reports 95 exported subpaths.
  • pnpm check:fallow — no issues in the changed files.
  • pnpm check:affected --run — all runnable checks passed.
  • Planted-red proof performed and reverted (above).

Closes #1960

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 2.37 MB 2.37 MB 0 B
JS gzip 794.8 kB 794.8 kB 0 B
npm tarball 916.5 kB 916.5 kB 0 B
npm unpacked 3.18 MB 3.18 MB 0 B

npm unpacked components

Component Base Current Diff
JS / dist source 2.51 MB 2.51 MB 0 B
Apple runner source/project 564.2 kB 564.2 kB 0 B
macOS helper source 54.5 kB 54.5 kB 0 B
Android helper artifacts 0 B 0 B 0 B
Other package files 44.5 kB 44.5 kB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.0 ms 26.3 ms +0.4 ms
CLI --help 71.9 ms 70.9 ms -1.0 ms

Top changed chunks: no changes in the largest emitted chunks.

Top changed packed files

No changed packed files.

@thymikee

Copy link
Copy Markdown
Member Author

Not ready at 0352dba3 despite green CI:

  1. discoverFacadeFiles() scans only packages/*/src/facades/*.ts, while the repository's actual workspace-façade gate starts from every package manifest export target and then adds /src/facades/. This misses platform package entry façades such as packages/platform-*/src/index.ts, so the generalized ADR-0019 loading-shape claim is incomplete and the body’s “same discovery” statement is false.
  2. The budgets are seeded before perf(contracts): granularize entry surfaces so hub importers stop evaluating the facade clump #1969. Merging both unchanged leaves stale slack (platform 42/48, interaction 25/30) large enough to reintroduce the clump perf(contracts): granularize entry surfaces so hub importers stop evaluating the facade clump #1969 removes. Rebase/stack after perf(contracts): granularize entry surfaces so hub importers stop evaluating the facade clump #1969 and reseed tight budgets.
  3. test(structure): per-package eager-closure budgets — the ADR-0019 loading-shape probe (#1739) #1960 asks for the offending edge chain; current failures print only a sorted closure/offender set, which does not identify the transitive import path.

Please derive façade roots from manifest ownership, add predecessor-chain diagnostics, and reseed post-#1969 with minimal headroom.

thymikee added a commit that referenced this pull request Aug 22, 2026
… reseed tight

Review findings on #1965:

1. Discovery scanned only `packages/*/src/facades/*.ts`, which omits every
   package that publishes its entry surface straight from the manifest —
   including all six `packages/platform-*/src/index.ts` façades, the exact
   subject of ADR-0019's implementation-laziness rule. Discovery now derives
   from `readWorkspacePackages(...).exportTargets` and then adds `/src/facades/`
   files, reusing the R11 helper rather than reimplementing it so the two gates
   cannot disagree about what an entry surface is. The table grows from 14
   façades + 2 hubs to 95 entry surfaces + 8 hubs.

2. Budgets carried a few files of slack each. They are now exact ratchets with
   no headroom, matching how the repo pins R9/R10 and test-file size: growth is
   allowed, it just has to be a visible number change in the diff of the PR that
   causes it. Every budget is reseeded from post-#1969 measurement.

3. Violations printed a flat sorted set, which named the offender but not the
   route. `eagerClosureGraphOf` records each file's discoverer, so failures now
   print the transitive chain entry -> ... -> offender. `eagerClosureOf` keeps
   its contract and is expressed in terms of the new walk; per-file edges are
   memoized, which also cuts the existing pins' runtime (cli closure test
   2336ms -> ~550ms).

The platform-package façades evaluate exactly one module each — themselves —
so their budget of 1 is the tightest statement of "metadata-eager,
implementation-lazy" the walker can make.
@thymikee
thymikee force-pushed the test/1960-eager-closure-budgets branch from 0352dba to 55d4846 Compare August 22, 2026 13:50
@thymikee

Copy link
Copy Markdown
Member Author

All three addressed in 55d4846, rebased onto 03c398406 (#1969 merged). PR body corrected too — the "same discovery" claim was wrong as written, and I've replaced it rather than softened it.

1. Discovery now derives from manifest ownership

You were right that this was a correctness gap and not just a wording problem. discoverFacadeEntryFiles now starts from readWorkspacePackages(...).exportTargets and then adds /src/facades/ files — the same composition R11 uses, and importing the same helper rather than reimplementing it, so the two gates cannot drift into disagreeing about what an entry surface is.

The omission was worse than "incomplete": all six packages/platform-*/src/index.ts façades have no facades/ directory at all, so the previous scan never looked at the exact files ADR-0019's implementation-laziness rule is about. The gate claimed to prove the loading shape while missing its actual subject.

What they measure is the payoff — each platform façade evaluates exactly one module: itself. Metadata inline, contract imports all import type (erased), every implementation behind a function-scoped await import. So those six budgets are 1, which is the tightest statement of "metadata-eager and implementation-lazy" the walker can make. There's a dedicated non-vacuity test asserting all six are discovered, so the gate can't quietly lose its subject again.

Table grew 14 façades + 2 hubs → 95 entry surfaces + 8 hubs.

2. Budgets reseeded post-#1969, with zero headroom

Reseeded from measurement on 03c398406, and I dropped the headroom concept entirely rather than tightening it — budgets are now exact ratchets asserted as <=. That matches how the repo already pins R9, R10, and test-file size, and docs/agents/testing.md's "existing pins only shrink; a new pin requires measured justification".

Your point about slack not being neutral is the reason: the regression class is a single static import dragging a subtree in, #1969 measured it at 5–12% of suite import work per instance, and "a few files" of spare room silently absorbs the small end of exactly that. Growth is still fine — it just has to show up as a number change in the diff of the PR causing it.

facades/platform.ts is now pinned at its true 42 and interaction.ts at 25 (both unchanged by #1969 — it moved consumers off them rather than shrinking them). src/cli.ts 386 → 361 and session-teardown.ts 121 → 89 did move, which is exactly the stale-seed problem you flagged.

I also added the five hubs #1969 moved off the wide façades (dispatch, capabilities, registry, platform-execution-entry, register-builtins) plus src/platform-runtime.ts, the composition root.

3. Edge chains, not offender sets

Added eagerClosureGraphOf to the shared fixture — a predecessor-recording BFS — and failures now print the transitive route:

packages/platform-apple/src/index.ts
    -> packages/platform-apple/src/runtime.ts
    -> packages/platform-apple/src/logs/runtime.ts
    -> packages/platform-apple/src/logs/backend.ts

Breadth-first, so each chain is the shortest route to that file. eagerClosureOf keeps its contract and is now expressed in terms of the graph walk; iteration order went depth- → breadth-first, which nothing depended on (documented on the function, and the three existing pins verify it).

I also memoized per-file edges while I was in there, since ~100 entries share most of their subtrees. Side benefit: cli-startup-import-closure went 2336ms → ~550ms, and the whole 201-test budget file runs in ~430ms — comfortably inside the 2.5s per-test unit budget you warned about. My scan walks closures from entries rather than parsing the whole tree, so it doesn't need the text-filter your #1969 test does.

Planted red, re-run

Replaced the lazy await import('./runtime.ts') in packages/platform-apple/src/index.ts with a static namespace import. Three tests fired:

× 'packages/platform-apple/src/index.ts' evaluates at most 1 modules
  → evaluates 65 modules on import, over its budget of 1.

× 'packages/platform-apple/src/index.ts' never evaluates a concrete platform implementation
  → (chain above)

× 'src/platform-runtime.ts' evaluates at most 31 modules
  → evaluates 80 modules on import, over its budget of 31.

The third is the composition root picking up the blast radius through its own chain — the cascade a flat offender set wouldn't have explained, which is a fair argument for your finding 3. Sabotage reverted; diff is three files.

One thing I did not do

Left contracts-entry-closure.test.ts in place. Both its tests state properties this table can't: a named hub must not reach two specific façades, and no source file value-imports them — a whole-tree scan rather than an entry walk. Its five hubs are now budgeted here too, so they carry both the specific pin and the general ceiling. Happy to fold it in if you'd rather have one mechanism, but it looked like a genuine loss of coverage rather than duplication.

CI green (27/27).

@thymikee

Copy link
Copy Markdown
Member Author

Not ready at 55d48467. The rebase/reseed, manifest targets, and predecessor chains fix important prior gaps, but four correctness holes remain in the gate itself: (1) graph.size <= budget does not enforce an exact ratchet—after any shrink it leaves silent headroom; require equality or fail under-budget rows too. (2) Numeric over-budget failures dump chains for every closure module, not the newly offending edge; record baseline identity/edges or emit a bounded delta-oriented route. (3) discovery still duplicates only immediate src/facades/*.ts scanning while R11 walks recursively; reuse one canonical discovery owner so nested façades cannot drift out. (4) Set-based exhaustiveness collapses duplicate budget rows; explicitly detect duplicate ids/paths. Exact-head CI is green and the slice is test-only, but these gaps allow the structural proof to pass vacuously or with stale slack.

@thymikee

Copy link
Copy Markdown
Member Author

The primary static-import planted red is credible and CI is green, but the generalized gate still has four correctness holes:

  1. Rows are documented as exact ratchets, but the assertion is graph.size <= budget; a shrink silently creates future headroom. Require equality or fail under-budget rows until deliberately reseeded.
  2. An over-budget failure prints chains for every evaluated module (hundreds for src/cli.ts) rather than the new offending delta. Persist enough baseline identity/edge data to report a bounded offending route.
  3. discoverFacadeEntryFiles reimplements a one-level src/facades scan, while canonical R11 discovery is recursive. Nested façade files can be covered by R11 yet silently omitted here; reuse one discovery owner.
  4. Converting budget rows to Sets hides duplicate ids/entry paths despite the “exactly one” claim. Assert duplicates explicitly or encode uniqueness structurally.

Please add planted-red/non-vacuity tests for these failure modes and correct the PR text that currently claims exactness and shared R11 discovery.

ADR-0019 requires platform-package façades to stay implementation-lazy
and is explicit that a startup threshold alone is not a substitute for
preserving the loading shape. #1950 built the AST-level walker
(eager-import-closure.fixtures.ts) and proved the planted-red
procedure on one file (session-teardown.ts's android-helper
denylist); this generalizes it into a data-driven budget table so any
workspace-package façade -- or a designated hub module -- can get an
eager-closure ceiling without a bespoke test.

Seeds a budget for every packages/*/src/facades/*.ts file (discovered
the same way package-boundaries.test.ts discovers façades, not
hand-listed) from its measured current closure size, plus a
platform-implementation denylist for façades whose contract is
implementation-neutral vocabulary. Also demonstrates the mechanism on
two designated hub modules (cli.ts, session-teardown.ts) alongside
their existing, more specific ad hoc pins.

Closes #1960
… reseed tight

Review findings on #1965:

1. Discovery scanned only `packages/*/src/facades/*.ts`, which omits every
   package that publishes its entry surface straight from the manifest —
   including all six `packages/platform-*/src/index.ts` façades, the exact
   subject of ADR-0019's implementation-laziness rule. Discovery now derives
   from `readWorkspacePackages(...).exportTargets` and then adds `/src/facades/`
   files, reusing the R11 helper rather than reimplementing it so the two gates
   cannot disagree about what an entry surface is. The table grows from 14
   façades + 2 hubs to 95 entry surfaces + 8 hubs.

2. Budgets carried a few files of slack each. They are now exact ratchets with
   no headroom, matching how the repo pins R9/R10 and test-file size: growth is
   allowed, it just has to be a visible number change in the diff of the PR that
   causes it. Every budget is reseeded from post-#1969 measurement.

3. Violations printed a flat sorted set, which named the offender but not the
   route. `eagerClosureGraphOf` records each file's discoverer, so failures now
   print the transitive chain entry -> ... -> offender. `eagerClosureOf` keeps
   its contract and is expressed in terms of the new walk; per-file edges are
   memoized, which also cuts the existing pins' runtime (cli closure test
   2336ms -> ~550ms).

The platform-package façades evaluate exactly one module each — themselves —
so their budget of 1 is the tightest statement of "metadata-eager,
implementation-lazy" the walker can make.
…le-owner

Second review pass on #1965 found four holes, two of which were places the
PR text claimed a property the code did not have.

1. Rows were documented as exact ratchets but asserted with `<=`, so a shrink
   silently became headroom a later regression could grow back into. The
   comparison is now equality, in a pure `classifyBudget` with a separate
   message for each direction ("lower its pin to N in this PR so the ratchet
   keeps the gain"), matching test-file-size-ratchet.ts and the R9/R10 pins.

2. An over-pin failure printed a chain per evaluated module — 361 of them for
   src/cli.ts. It now prints a bounded attribution: the entry's heaviest direct
   edges (capped at 4) with a couple of representative deep routes each, ranked
   so a newly added import sorts first. The comment states plainly that this
   attributes by shortest import route and does NOT diff against a recorded
   baseline; naming a true delta would mean checking in ~1,500 module paths and
   rewriting them on every contracts refactor.

3. Discovery reimplemented a one-level `src/facades` scan while canonical R11
   discovery is recursive, so a nested façade file could be covered by R11 and
   silently missing here. `facadeEntryFiles` is now a single exported owner in
   package-boundaries.ts that both R11's façade gate and this table consume.

4. Rows were converted to Sets before any uniqueness check, so a duplicate was
   unobservable. The table is now two `Record<string, number>` literals keyed by
   path, making an in-record duplicate a TypeScript error (ts1117); the only
   remaining case — one path in both records — is asserted on the array.

Each of the four holes gets a test that fails when the rule is broken, since a
tree that happens to satisfy its pins cannot distinguish a correct rule from a
vacuous one. Writing those found a real bug in the duplicate check itself
(`Set.add` returns the Set, so the filter never matched).

Pins reseeded on 04e4c23.
@thymikee
thymikee force-pushed the test/1960-eager-closure-budgets branch from 55d4846 to 6d337d2 Compare August 22, 2026 16:35
@thymikee

Copy link
Copy Markdown
Member Author

All four fixed in 6d337d27f, rebased onto 04e4c23b9. Taking the two false-claim ones first, since you're right that those are the worse category — I wrote "exact ratchets" and "same discovery as R11" over code that did neither.

1. "Exact ratchet" is now actually equality

It was graph.size <= budget. So a shrink passed silently and converted the gain into headroom, which is the opposite of a ratchet — exactly what you said.

Now classifyBudget(id, actual, budget) is a pure comparator asserting equality, with a separate message per direction, modelled on test-file-size-ratchet.test.ts:

x.ts evaluates 40 modules on import, pinned at 42. It shrank -- lower its pin to 40 in this
PR so the ratchet keeps the gain instead of leaving headroom a later regression could grow
back into.

Pulling the rule into a pure function is what makes it testable in its failing direction, which matters here: over the real tree, <= and === are indistinguishable while every entry happens to match its pin.

2. Bounded attribution instead of a chain dump

You're right that 361 chains for src/cli.ts is not a diagnostic. Failures now print the entry's heaviest direct edges — ranked by how many modules enter through them, capped at 4 edges × 2 routes — so the offending import is the first thing on screen. From the re-run planted red on the composition root:

src/platform-runtime.ts evaluates 80 modules on import, pinned at 31. ...

Where the weight comes from (heaviest direct edges, capped -- this attributes by shortest
import route, it does not diff against a recorded baseline):
  packages/platform-apple/src/index.ts -- 58 module(s) enter through this edge:
    src/platform-runtime.ts
      -> packages/platform-apple/src/index.ts
      -> packages/platform-apple/src/runtime.ts
      -> packages/platform-apple/src/logs/runtime.ts
      -> packages/capture-kit/src/index.ts
      ...
  src/platform-runtime-gateway.ts -- 8 module(s) enter through this edge:
    ...
  (+2 more direct edge(s), smaller)

One place I did not follow the direction, and want your call. You asked me to persist per-row module identity so the failure can name the newly added modules. I didn't, and the docstring says so in those words rather than implying a delta it can't compute. The reason: naming a true delta means checking in ~1,500 module paths (that's the sum of all 103 closures) and rewriting them on every contracts refactor — a second source of truth with real churn, right after #1969 moved 259 imports. What I shipped attributes by shortest import route instead, which lands on the same answer for the common case (a new import on the entry is a new edge, so its whole subtree is attributed to it and it sorts first) and degrades to "this top-level edge contains the growth" for a regression deep inside an existing subtree.

If you'd rather have the exact delta and accept the baseline file, say so and I'll add it — the walker already produces the data, it's a fallow-baselines/-shaped artifact.

3. One discovery owner, and it's the recursive one

facadeEntryFiles(repoRoot) now lives in scripts/layering/package-boundaries.ts next to readWorkspacePackages, and both R11's façade gate and the budget table call it. My module just re-exports it. The recursive walkTsFiles it uses is the one already in that file, filtered to production sources so facades/x.test.ts doesn't become an entry surface.

R11's façade test is 13/13 green on the shared function, and the full layering suite is 181/181.

4. Duplicates are now unwritable, not merely unasserted

The table is two Readonly<Record<string, number>> literals keyed by entry path. A repeated key inside one is a TypeScript error, so it can't be committed — verified by planting one:

src/__tests__/eager-closure-budgets.ts(236,3): error TS1117: An object literal cannot have
multiple properties with the same name.

The one duplicate still expressible is the same path in both records, and that's asserted on the array before any Set.

Planted red for each of the four

Added a failing-direction test per hole, since "a hole no test can fail" was your objection:

Sabotage Test that fired
===<= the ratchet fails an entry that SHRANK, not only one that grew
REPORTED_EDGES 4 → 999 closure pressure is attributed to the heaviest direct edges and is bounded
recursive → one-level scan discovery is recursive, so a NESTED facade file cannot hide from the gate
same path in both records no entry path is budgeted twice, checked before any Set could absorb it
duplicate key in one record pnpm typecheck (TS1117)

Each was observed red, then reverted. The nested-façade one runs against a fixture tree in a temp dir, so it holds even though the real repo has no nested façade today.

Worth flagging: writing #4's sabotage found a bug in my own check — I had ids.filter((id) => !seen.add(id)), and Set.add returns the Set, so the filter never matched anything and the test passed with a duplicate present. It only surfaced because I planted the duplicate instead of trusting the green. Fixed to an explicit loop.

Also

describeClosurePressure has a case for entries that evaluate only themselves — the six platform façades — so they print "(no eager edges: this entry evaluates only itself)" rather than an empty section.

Validation

pnpm typecheck, pnpm check:layering (181/181), pnpm check:fallow, pnpm run lint, pnpm run format:check, and pnpm check:affected --run all pass. The budget file is 206 tests in ~700ms; together with the three existing closure pins, 230 tests with no slow-test gate output.

CI: one Smoke Tests shard failed on the live iOS simulator scenario (click id="automation-close-sheet"selector_not_found in smoke:automation-input), which is a live-device lane flake unrelated to this diff — the branch changes no production code at all, only src/__tests__/ and scripts/layering/. I've re-run that job; will confirm when it lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(structure): per-package eager-closure budgets — the ADR-0019 loading-shape probe (#1739)

1 participant