fix(checks): stop ImportFanOutOutlier flagging shared utilities (CD-333) - #217
Merged
Conversation
Any successfully shared module is a fan-in outlier by construction, so the fan-in branch flagged leaf utilities for being reused. Measured across five local repos: 23 fan-in findings, every one a false positive — a button, a config module, a utils module, two type modules, a seeded PRNG, an API client, an error adapter, test helpers, a layout partial — and not one genuine god object. The check's stated target is a module with high fan-in AND high fan-out. The fan-in branch now requires fan-out to be an outlier too, rather than merely above the mean: these means sit near 1.7 to 2.2, so an above-the-mean bar means importing three things and suppresses barely a quarter of the false positives. Fan-in findings become rare by design, and the docs say so. A synthetic god module — both metrics outliers — is pinned by a test so the branch is not silently dead. The fan-out branch, which the field report found accurate, is untouched and its findings are unchanged on all five repos. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v
Criterion benchmark comparison (PR head vs base branch) |
# Conflicts: # CHANGELOG.md
Criterion benchmark comparison (PR head vs base branch) |
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.
The problem, measured across the estate
Design.ImportFanOutOutlierflags a file whose fan-in or fan-out is more than three standard deviations above the project mean. Any successfully shared module is a fan-in outlier by construction, so the fan-in half flags leaf utilities for being reused.Ran the current check against all five local repos that use cofferdam:
BaseHead.astro,Footer.astro,Header.astro,game-logic.tsui/button.tsx,config.ts,lib/utils.ts,types/hyrox.ts,types/workouts.tsButton.tsx,use-puzzle-state.ts,lib/api.ts,splitmix64.ts,wasm-bridge.tserror-adapter.ts,access.ts,errors.ts,test/helpers.ts,board-utils.ts,Base.astro,api-client.tsstrategyContext.ts,world.ts23 findings — a button, a config module, a PRNG, an API client, a test-helpers module, two type modules, a layout partial. Not one genuine over-centralised god object. The fan-out findings, by contrast, look right everywhere.
Why not the fix the ticket suggested
CD-333 proposed requiring fan-out to be above the mean. I measured that and it does not work: these means sit around 1.7 to 2.2, so clearing the bar means importing three things. On personal-blog it suppresses one of four known false positives.
Using the check's own stated definition instead — "high fan-in and high fan-out, pulling in half the project" — the fan-in branch now requires fan-out to be an outlier too, above the same three-sigma bar the fan-out branch already uses. Both thresholds were already computed; nothing new is calculated.
Result
Every fan-in false positive gone; fan-out findings identical, same files and same messages.
The honest consequence
No file in any of the five repos appears in both lists, so this silences the fan-in branch across the entire estate. That is deliberate and the docs say so plainly — fan-in findings are now rare by design, and the branch exists only to catch a hub that is also pulled in from everywhere.
To stop that becoming a silent deletion of half the check, a synthetic god module with both metrics as outliers is pinned by a unit test. A pre-existing test encoding the old behaviour failed as predicted and was updated in place rather than left red.
The alternative — retiring the fan-in half outright — is recorded on the ticket. It is simpler and arguably more honest about a signal that has never once been right in practice, but discarding the capability on five repos' evidence is a bigger step than tightening it, and remains easy to do later.
Verification
cargo build --workspace,cargo test --workspace(1430 passed),cargo clippy --workspace --all-targets -D warnings,cargo fmt --check,gen-docs --checkvia pre-commit, plus the five-repo run above.🤖 Generated with Claude Code
https://claude.ai/code/session_019afugU2bTYCtXn6Vy9dn1v