Skip to content

fix(explore): tests and examples the engine knows stay out of explore's answer - #2557

Merged
colbymchenry merged 1 commit into
mainfrom
worktree-explore-low-value-tests
Oct 14, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
worktree-explore-low-value-tests

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

What

codegraph_explore decides which files are low value (tests, plus icons and i18n) to drop them before the score floor, halve their rank, and break ties against them. db/queries.ts likewise keeps tests and generated files out of the dominant-file, top-route-file and routing-manifest candidates. Both kept a regex list of their own, written before the engine's isTestFile learned most of what it knows. They missed:

On LLVM-style and Google-style C++ repos, a unit test that calls the code an agent asked about took a file slot in explore's answer.

Both now build on isTestFile, the same reading explore's gather already dampens scores by (×0.3 and a 15% node cap in the context builder). They keep their own extras:

  • explore keeps icons and i18n;
  • queries keeps generated files;
  • both keep the singular __test__/ folder the old lists matched and isTestFile doesn't.

The old lowercase suffix patterns go, along with their false positives: Latest.java, Contest.swift and contest.cs read as tests.

Follow-up from #2484's chip.

Validation: deterministic explore A/B (base main 1753472 vs this change)

  • Method: both builds ran codegraph_explore on the same indexes (the change is query-time only). Each repo got the README suite's flow question or an agent-style one, plus three symbol-bag queries.
  • Repos: django, excalidraw, okhttp, tokio, gin, alamofire; protobuf and glog (Google unittests); and llvm-project 50eb53f0's clang-tools-extra/clangd and lldb/{include,source,unittests,tools}.
  • "Named" counts query tokens with a production definition whose file rendered.
repo queries changed test / example files rendered named
django, excalidraw, okhttp, gin, alamofire 0 of 20 0 → 0 59/62 → 59/62
tokio 1 of 4 1 → 0 (tokio-test/src/task.rs) 9/12 → 9/12
protobuf 3 of 4 4 → 0 14/14 → 14/14
glog 3 of 4 3 → 0 (src/logging_unittest.cc) 8/8 → 8/8
clangd 3 of 4 2 → 0 11/11 → 11/11
lldb 2 of 4 1 → 0 11/11 → 11/11
total 12 of 40 11 → 0 112/118 → 112/118
  • Where the freed slots went. In protobuf, DescriptorPool BuildFile FindMessageTypeByName had rendered descriptor_unittest.cc, code_generator_unittest.cc and internal_feature_helper_test.cc. Those slots now go to the PHP, C# and Ruby DescriptorPool implementations. TextFormat Printer Print traded examples/ListPeople.java for Descriptors.java. clangd traded unittests/SymbolCollectorTests.cpp for index/Ref.h. Every other change only dropped a test file, or moved bytes between the same files.
  • No response tells the agent to use Read, in either build.
  • Budgets: the explore budgets are untouched.

Agent A/B not run. A nested claude -p on this machine fails with "OAuth session expired and could not be refreshed", the same blocker #2447 hit. Re-logging the CLI is the maintainer's call. The deterministic A/B above is the evidence for now; the change only removes files the gather already scores at 0.3× from the answer, and backfills from production files.

Tests

__tests__/explore-low-value-tests.test.ts (new):

  • explore answers Parser parseExpression parseStatement Lexer nextToken from src/parser.cc without rendering an LLVM-style unittests/Parse/ParserHarness.h, a parser_unittest.cc or a ParserTest.cpp;
  • getTopRouteFile() names the app's src/routes.js, not an e2e/mock-server.js with more routes.

Both fail on main: explore rendered unittests/Parse/ParserHarness.h, and the route file was e2e/mock-server.js. The 40 explore, context and route-related test files pass (475 tests).

Full suite on Windows: 6,663 passed. 6 failed in the parallel run (daemon-pid-reuse, git-index-currency, mcp-daemon), and all three files pass when rerun serially (35/35); the notes on this box list them as load-sensitive. The 404 skipped are the native-kernel suites, which skip because no kernel was built in this worktree; this change doesn't touch extraction.

🤖 Generated with Claude Code

…'s answer

codegraph_explore's low-value check (the hard filter, the rank penalty and
the comparator key) and the dominant-file, route-file and routing-manifest
filter in db/queries.ts each kept a regex list of their own. They missed
every test convention isTestFile learned since: C++ `foo_test.cc` and
`FooTest.cpp`, Google's `foo_unittest.cc`, LLVM's `unittests/`, `testing/`,
`e2e/`, `__mocks__/`, Gradle `foo-test/` modules, Kotlin source sets, and
the examples, samples, fixtures and benchmarks that explore's gather already
dampens through isTestFile.

Both now build on isTestFile, keeping icons/i18n (explore) and generated
files (queries), plus the singular `__test__/` the old lists matched.
Dropping their lowercase suffix patterns also ends false positives such as
`Latest.java` and `contest.cs`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit 5da4a41 into main Oct 14, 2026
@colbymchenry
colbymchenry deleted the worktree-explore-low-value-tests branch October 14, 2026 08:56
bompus added a commit to bompus/codegraph that referenced this pull request Oct 14, 2026
…est (#500)

isTestPath matched /__tests__/ only below another directory, so
__tests__/foo.ts was taken for production code while src/__tests__/foo.ts was
not. After upstream colbymchenry#2557 moved the dominant-file and explore filters onto
isTestFile, the old start-of-path match for __tests__/ was lost.
danusha2345 pushed a commit to danusha2345/codegraph that referenced this pull request Oct 15, 2026
…t JSX by import, sync through barrels, colbymchenry#2557 explore)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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