Skip to content

feat(enforcers): orphan/dead-module gate (knip ∩ dependency-cruiser)#228

Open
HeadyMe wants to merge 1 commit into
rebuildfrom
claude/orphan-gate-gfl0f4
Open

feat(enforcers): orphan/dead-module gate (knip ∩ dependency-cruiser)#228
HeadyMe wants to merge 1 commit into
rebuildfrom
claude/orphan-gate-gfl0f4

Conversation

@HeadyMe

@HeadyMe HeadyMe commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Wires knip + dependency-cruiser into the governance gate as a confirmed-orphan / dead-module detector. A file counts as dead only when flagged by both tools — dependency-cruiser (graph-orphan) knip (unused file). The intersection filters out CLI entry points that depcruise alone misreads (nothing imports coherence.mjs, but it's run directly), so the signal is high-confidence.

What's added

  • knip.json + .dependency-cruiser.cjs — scoped to the clean ESM trees (packages/, tooling/).
  • tooling/enforcers/orphans.mjs — runs both, reports the intersection. Diff-aware (selectFiles, same pattern as the other enforcers): only new dead files fail; the existing baseline is advisory (baselineDeferred), so the line is armed without retroactively failing rebuild.
  • tooling/enforcers/test/orphans.test.mjs — 4 node:test cases on the pure parse/intersection logic (a CLI entry flagged by only one tool is not confirmed).
  • New CI job orphans (installs deps, always --diff so the baseline never fails a push); heady-orphans bin; scan:orphans npm script.

Verification

  • Planted a genuinely dead file → gate exits 2 (confirmed↑); removed it → green.
  • --diff origin/rebuild (CI) → exit 0, 8 baseline deferred. --all (local cleanup) → exit 2 on the 8.
  • All 18 enforcer tests pass; orphans.mjs scans clean against the glass-box/localhost rule sets.

Baseline dead files surfaced (advisory — to clean in a follow-up, not deleted here)

packages/embedding/src/core.d.ts, tooling/decomposition/src/decompose.mjs, tooling/doc-hydrator/scripts/fetch-infra-state.mjs, tooling/report-templates/bindings/{coherence,ledger}.mjs, tooling/skill-registry/{register,sync-workflows,validate}.mjs. (knip wasn't wired before, so these were previously invisible.)

Closes the orphan-detection gap noted in the ecosystem audit's FILE_MANIFEST.md.

Co-Authored-By: Claude Opus 4.8 (1M context)

🤖 Generated with Claude Code

https://claude.ai/code/session_016WqBXQGJkjhG9RdAFiL2MZ


Generated by Claude Code

Wire knip + dependency-cruiser into the governance gate as a confirmed-orphan
detector. A file is dead only when flagged by BOTH: dependency-cruiser
(graph-orphan) AND knip (unused file) — the intersection filters out CLI entry
points that depcruise alone misreads (coherence.mjs etc.).

- knip.json + .dependency-cruiser.cjs scoped to the clean ESM trees (packages, tooling)
- tooling/enforcers/orphans.mjs: runs both, reports the intersection; diff-aware
  (selectFiles) so only NEW dead files fail — the 8 known baseline orphans are
  advisory (baselineDeferred), arming the line without failing the rebuild
- node:test (4 cases) on the pure intersection logic; verified: planted dead file
  trips the gate (exit 2), removal returns green; --all flags the 8 baseline
- new CI job 'orphans' (installs deps, always --diff); heady-orphans bin; scan:orphans script

Baseline confirmed-dead (advisory, to clean later): packages/embedding/src/core.d.ts,
tooling/{decomposition/src/decompose,doc-hydrator/scripts/fetch-infra-state}.mjs,
tooling/report-templates/bindings/{coherence,ledger}.mjs,
tooling/skill-registry/{register,sync-workflows,validate}.mjs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WqBXQGJkjhG9RdAFiL2MZ
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.

2 participants