feat(enforcers): orphan/dead-module gate (knip ∩ dependency-cruiser)#228
Open
HeadyMe wants to merge 1 commit into
Open
feat(enforcers): orphan/dead-module gate (knip ∩ dependency-cruiser)#228HeadyMe wants to merge 1 commit into
HeadyMe wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 failingrebuild.tooling/enforcers/test/orphans.test.mjs— 4node:testcases on the pure parse/intersection logic (a CLI entry flagged by only one tool is not confirmed).orphans(installs deps, always--diffso the baseline never fails a push);heady-orphansbin;scan:orphansnpm script.Verification
confirmed↑); removed it → green.--diff origin/rebuild(CI) → exit 0, 8 baseline deferred.--all(local cleanup) → exit 2 on the 8.orphans.mjsscans 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