Skip to content

refactor: close src/utils retirement and enforce no-regrowth #2149

Description

@thymikee

Parent: #2129

Blocked by: #2133, #2134, #2135, #2136, #2138, #2139, #2140, #2141, #2142, #2143, #2144, #2145, #2146, #2147, and #2148. Final wave only: every owner slice must be merged/reviewable before terminal cleanup.

Scope — exact terminal files

Update the existing enforcement/metadata files:

  • scripts/layering/model.ts
  • scripts/layering/model.test.ts
  • scripts/layering/check.ts
  • scripts/layering/check-wiring.test.ts
  • scripts/mutation/modules.ts
  • scripts/mutation/config.test.ts
  • scripts/mutation/selection.test.ts
  • scripts/mutation/ownership.test.ts only if the moved source/test topology changes its derived assertion
  • scripts/__tests__/test-file-size-ratchet.test.ts
  • stryker.config.json
  • fallow-baselines/health.json
  • src/__tests__/eager-closure-budgets.ts
  • packages/kernel/src/device.ts
  • packages/selectors/src/internal/parse.ts

Add the structural retirement rule and its tests:

  • scripts/layering/src-utils-retirement.ts
  • scripts/layering/src-utils-retirement.test.ts

The update child owns tsdown.config.ts and src/__tests__/update-check.test.ts; the surface child owns active output/help-conformance imports. Coordinate those edits rather than duplicating them here.

Required terminal changes

  1. Prove the final tracked tree with git ls-files 'src/utils/**' and fail by rule name if any tracked utility path remains, including a test or fixture. The new rule must be wired into LAYERING_RULE_IDS and LAYERING_RULES, report an actionable path, and have a synthetic planted-red test that fails on src/utils/regrown.ts before the final green run.
  2. Remove utils from TARGET_DAG_RANK; update the model assertion/comment so the old zone is not silently classified. Keep all remaining production zones deliberately ranked or unranked.
  3. Point the mutation registry/config/selection fixtures at the final src/snapshot/scroll-edge-state.ts owner and preserve derived ownership through src/commands/interaction/runtime/gestures.test.ts. Do not leave a Stryker glob or affected-selection fixture at the deleted path.
  4. Move/remove exact test-size pins after the output and daemon-client test relocations. A pin must follow a file only when that file still exists and remains over the tripwire; a split output test must not be pinned.
  5. Remove only stale fallow baseline keys for deleted utility paths, moving a key only when the same finding belongs to the exact destination. Do not bulk-regenerate or accept unrelated findings.
  6. Re-audit every remaining src/utils string. Keep deliberate synthetic fixture paths in depgraph/package-boundary tests only when the test is explicitly testing arbitrary path parsing; update stale production/comments/packaging references. The final report must distinguish retained test fixtures from stale metadata.

Behavior invariants

The terminal wave changes no command behavior, snapshot presentation policy, app-log/transport/provisioning/Swift/video policy, wire shape, errors, timeouts, retries, or lazy loading. It only closes the deletion invariant and keeps layering/mutation/test-size/fallow metadata truthful.

Focused and final validation

Run the new retirement test against the planted src/utils/regrown.ts fixture and record the named red result, then remove the fixture. Run:

  • pnpm vitest run scripts/layering/src-utils-retirement.test.ts scripts/layering/model.test.ts scripts/layering/check-wiring.test.ts
  • pnpm vitest run scripts/mutation/config.test.ts scripts/mutation/selection.test.ts scripts/mutation/ownership.test.ts
  • pnpm vitest run scripts/__tests__/test-file-size-ratchet.test.ts
  • pnpm check:affected --run
  • git ls-files 'src/utils/**' (must be empty)
  • the full affected check again after staging any new structural rule so the tracked-file layering scanner sees it

Planted-red proof

This child adds the no-regrowth rule. Before wiring the rule, add a temporary tracked fixture path src/utils/regrown.ts to the synthetic input and observe a failure containing the rule name R14 src-utils-retirement and the path. Then wire the rule, run the same planted-red test, remove the fixture, and record the final green result. Do not allowlist a path or use a filename-only heuristic.

Dependency order

No terminal cleanup is ready until every parent child has a complete owner decision and its old src/utils paths are gone. This child is the final closure/no-regrowth proof and must not be merged ahead of any owner move.

Shrink target

Final invariant: git ls-files 'src/utils/**' returns no paths; no old utility zone is ranked; no stale packaging, mutation, size-ratchet, or fallow metadata claims ownership of it; and the no-regrowth rule fails by name on a planted path. The terminal diff must delete metadata rather than replace it with a new shared registry, and the full program must have net production shrinkage after discounting physical moves.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions