fix(recorders): a flat dependency graph is not a ranking (#2556) - #2688
Merged
Conversation
"Top 5 Structural Pillars (Highest 'Imported By' / Blast Radius)" sorted by
popularity and took the first five with no check that the maximum was above
zero. On a repo with no resolvable internal imports that emits five files
with 0 inbound connections under a heading calling them "the most
interconnected files" -- the scan that found it listed Changes.md,
MAINTAINERS.md and README.md as the load-bearing infrastructure of a COBOL
application.
The neighbouring "Top 5 Orchestrators" section had the identical defect,
which the issue does not mention: with no resolvable imports anywhere it
called five files with 0 outbound dependencies "highly coupled and fragile
to API changes". Both are guarded here.
Both replacements say what a flat graph actually means -- either the
codebase has no internal dependency structure, or the engine does not
resolve that language's import style -- and tell the reader not to infer
that any file is load-bearing. That matters more than suppressing the list,
because this brief is written to be consumed by an LLM that will otherwise
repeat the ranking as fact.
Also answers the issue's secondary question ("why are documentation files
surfacing first?"): it is not alphabetical tie-breaking. Python's sort is
stable, so when every key is 0 the output is simply scan order.
Note the trigger is rarer than it was: #2668 fixed relative imports that
carry an extension, which was the reason whole javascript/shell/yaml/
powershell ecosystems presented as flat graphs. A repo with genuinely no
internal imports still reaches this path, so the guard is still needed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
27 tasks
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.
Closes #2556.
The defect
"Top 5 Structural Pillars (Highest 'Imported By' / Blast Radius)" sorts by popularity and takes the
first five, with no check that the maximum is above zero:
On a repo with no resolvable internal imports that emits five files with 0 inbound connections
under a heading calling them "the most interconnected files". The scan on the issue listed
Changes.md,MAINTAINERS.mdandREADME.mdas the load-bearing infrastructure of a COBOLapplication. This brief is written to be consumed by an LLM, which will repeat the ranking as fact.
What this changes
Both sections, not one. The neighbouring "Top 5 Orchestrators" list has the identical defect,
which the issue does not mention — with no resolvable imports anywhere it calls five files with 0
outbound dependencies "highly coupled and fragile to API changes". Guarding only the pillar list
would have left the same false claim two paragraphs down.
Each replacement says what a flat graph actually means — either the codebase genuinely has no
internal dependency structure (scripts, documents, configuration rather than a coupled system), or
its import style is one the engine does not resolve for that language — and tells the reader not to
infer that any file is load-bearing. Stating the finding is more useful than silently emitting
nothing, given the audience.
The headings stay, so the brief's section structure is unchanged.
The issue's secondary question
No — it's scan order. Python's
sortedis stable, so when every key is 0 the input order ispreserved untouched. Nothing is choosing documentation; it just tends to come first.
Scope note
The trigger is rarer than when this was filed: #2668 (merged as #2685) fixed relative imports that
carry an extension, which was why whole javascript / shell / yaml / powershell ecosystems presented
as flat graphs. A repo with genuinely no internal imports still reaches this path, so the guard is
still needed — but expect it to fire less often than the issue implies.
Verification
audit_checkall clear.origin/main, and the third proves the guard firesonly on an all-zero graph — a single connection anywhere restores both rankings.
Recorder layer only, so no bless and no corpus rebless.
1018 → 1049byaudit_check.py --regenerate, which classified itas a pure line-shift (the SIM102 finding from Ruff SIM102: remaining nested-if findings (llm_recorder, security_lens, network/binary tools) #493, untouched by this PR).
🤖 Generated with Claude Code