Skip to content

fix(rank): share one file-classification signal across every surface - #209

Merged
sunerpy merged 2 commits into
mainfrom
fix/file-classification-predicates
Aug 19, 2026
Merged

sunerpy merged 2 commits into
mainfrom
fix/file-classification-predicates

Conversation

@sunerpy

@sunerpy sunerpy commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Three faces of one defect, found while triaging the 104 upstream commits past v1.5.0. All three are our own internal inconsistencies — the upstream issues only pointed at where to look.

is_test_file existed twice and disagreed in both directions

crates/codegraph-cli/src/main.rs:5834   … /e2e/ …      ← lacked _test.
crates/codegraph-mcp/src/engine.rs:2850 … _test. …     ← lacked /e2e/

Go's convention is foo_test.go, so affected reported no test coverage for a package whose test file it had just listed:

affected math.go →  affectedFiles: ["math_test.go"]
                    affectedTests: []

Measured before/after on a Go fixture:

before after
affectedTests [] ["e2e/flow.go", "math_test.go"]

The plain union would not have been enough. Both spellings matched /e2e/ with a leading slash, so a repo-root e2e/ tree missed on both sides — including the pattern the CLI supposedly had. Segment-anchored matching is a strict superset and closes that hole too:

e2e/flow.go       old CLI=false  old MCP=false   ← neither
sub/e2e/flow.go   old CLI=true   old MCP=false
math_test.go      old CLI=false  old MCP=true

A third, wider predicate (codegraph-graph/src/query/scoring.rs:481) answers a different question — FTS relevance damping, including NON_PRODUCTION_DIRS — and is deliberately left alone.

Generated-file demotion never reached explore

It was wired into find_symbol_matches and find_all_symbols but not into the explore selection path, so the same index answered two ways — and .pb.go was already a known pattern, so this was never a coverage miss:

before after
node ComputePay zz_real.go, a_gen.pb.go unchanged
explore ComputePay a_gen.pb.go, zz_real.go zz_real.go, a_gen.pb.go

The signal now enters ExploreSubgraph::finalize as (tier, not_generated, sym_count) — inside the tier, so a stub loses to the code it shadows without falling behind an unrelated file, and above symbol count, so a symbol-dense stub no longer wins on volume. It stays a ranking hint, never a filter: a generated file still renders when it is the only match, pinned by its own guard test.

The pattern set was 5 suffixes

Now covers upstream's table: Go mockgen (_mock.go, _mocks.go, mock_<name>.go), TS/JS codegen (.generated.*, .gen.*, *_pb.*, _grpc_pb.*), vendored .min.js, and Python/C++/C# protobuf. mock_<name>.go is anchored to the basename as upstream has it, and the table stays case-sensitive.

Content-header detection (files.generated, upstream #1500) is deliberately not here — it needs a schema column and gets its own review.

Verification

  • make ci green: 127 suites / 3172 passed / 0 failed (baseline 3156; the +16 are the new tests).
  • RED proven by isolated revert — pinning not_generated to a constant fails with the exact ordering, not a tautology: left: ["payroll/a_gen.pb.go", "payroll/zz_real.go"] / right: ["payroll/zz_real.go", "payroll/a_gen.pb.go"].
  • Hands-on QA on real fixtures for all three, including the "only match is generated" reachability guard.
  • reference/ untouched, CURRENT_EXTRACTION_VERSION still 5, no Cargo.toml change, guardrail passes.

Ranking and classification only — no extraction output changes.

Upstream refs: #1507 (Go affected), #1500-adjacent path table.

Three faces of one defect: a classification predicate that should be shared
was duplicated or only half-wired, so the same question got different answers
depending on which surface asked it.

`is_test_file` existed twice and disagreed in BOTH directions — the CLI knew
`/e2e/` but not `_test.`, the MCP side the reverse. So `affected` reported
`affectedTests: []` for a Go package whose `_test.go` file it had just listed
under `affectedFiles`, reading as "no coverage" for Go's entire convention.
Neither spelling covered a repo-root `e2e/` tree either, since both matched on
`/e2e/` with a leading slash: segment-anchored matching fixes a hole the plain
union would have left. A third, wider predicate in codegraph-graph answers a
different question (FTS relevance damping) and is deliberately left alone.

Generated-file demotion was wired into `find_symbol_matches` and
`find_all_symbols` but never into `explore`, so `codegraph node` ranked a real
implementation above its protobuf stub while `codegraph explore` did the
opposite on the same index — and `.pb.go` was already a known pattern. The
signal now enters `ExploreSubgraph::finalize` inside the tier, below relevance
and above symbol count, so a stub loses to the code it shadows without falling
behind an unrelated file, and still renders when it is the only match. It
remains a ranking hint, never a filter.

The pattern set itself covered 5 suffixes against upstream's table; it now
covers Go mockgen, TS/JS codegen, vendored minified bundles, and Python/C++/C#
protobuf. `mock_<name>.go` is anchored to the basename, as upstream has it,
and the table stays case-sensitive.

Ranking and classification only: extraction output, goldens, and
CURRENT_EXTRACTION_VERSION are untouched.
@codecov

codecov Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #209      +/-   ##
==========================================
+ Coverage   95.18%   95.22%   +0.03%     
==========================================
  Files         136      137       +1     
  Lines       73024    73336     +312     
==========================================
+ Hits        69510    69833     +323     
+ Misses       3514     3503      -11     
Files with missing lines Coverage Δ
crates/codegraph-cli/src/main.rs 90.55% <100.00%> (ø)
crates/codegraph-core/src/file_class.rs 100.00% <100.00%> (ø)
crates/codegraph-mcp/src/engine.rs 97.56% <100.00%> (+0.12%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

h2 accepted and queued empty DATA frames without limit, so a peer that never
drained a stream could drive unbounded memory growth or a length overflow
panic. Reachable here through hyper under axum, which `serve --http` uses.

Advisory published 2026-08-17 and patched in 0.4.16; we were pinned at 0.4.15,
so CI's audit job started failing on a lockfile we had not touched. Lockfile
only — no manifest change, hyper resolves it transitively.
@sunerpy
sunerpy merged commit 87dc548 into main Aug 19, 2026
7 checks passed
@sunerpy
sunerpy deleted the fix/file-classification-predicates branch August 19, 2026 03:20
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.

1 participant