Skip to content

fix(recorders): a flat dependency graph is not a ranking (#2556) - #2688

Merged
squid-protocol merged 1 commit into
mainfrom
fix/2556-flat-graph-pillars
Sep 3, 2026
Merged

fix(recorders): a flat dependency graph is not a ranking (#2556)#2688
squid-protocol merged 1 commit into
mainfrom
fix/2556-flat-graph-pillars

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

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:

pillars = sorted(parsed_files, key=lambda x: x.get("telemetry", {}).get("popularity", 0), reverse=True)[:5]

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.md and README.md as the load-bearing infrastructure of a COBOL
application. 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

Why are documentation files surfacing first among all-zero candidates? Is it alphabetical
tie-breaking?

No — it's scan order. Python's sorted is stable, so when every key is 0 the input order is
preserved 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

  • Full suite 7467 passed; audit_check all clear.
  • 3 new tests; the two negative ones fail on origin/main, and the third proves the guard fires
    only on an all-zero graph — a single connection anywhere restores both rankings.
  • No golden-master impact: the crucible fixtures are the audit JSON, which carries no LLM brief.
    Recorder layer only, so no bless and no corpus rebless.
  • One ruff baseline key rekeyed 1018 → 1049 by audit_check.py --regenerate, which classified it
    as 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

"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>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit aa79a00 into main Sep 3, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the fix/2556-flat-graph-pillars branch September 3, 2026 02:51
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.

LLM brief Top 5 Structural Pillars promotes zero-connection markdown files on flat-graph repos

1 participant