Skip to content

[Feature]: query starts from tests and docs instead of the code the question is about #4983

Closed

Description

@rohit-jsfreaky

Problem or use case

graphify query often starts from tests, docs and config instead of the code the question is about, and then lists nodes by hop and degree, so the right file is cut off by the budget.

query scores node names only. A test named after a bug repeats the question's words in its own name (UsernameValidatorsTests, test_sqlmigrate_for_non_transactional_databases), so it wins the exact-name tier.

Measured with graphify benchmark --questions (#4342) on 177 SWE-bench Lite issues (question = issue title, answer = non-test files of the gold patch): 43% of start nodes were tests, and an expected file is in the first 5 files shown only 49% of the time on v8 (293 Lite + Verified questions).

Proposed solution

Inside query only:

  1. Rank source above tests, docs and config (x0.3 weight via the existing paths._is_test_path), unless the question asks about tests or docs. The per-term seed guarantee stays.
  2. List the answer file by file, best file first, so the budget keeps the most relevant files.

path, explain, traversal and the budget are unchanged. Result on 293 questions: top-5 49% -> 56% (26 gained, 4 lost, paired p = 6e-5), same answer size. PR: #4982.

Alternatives considered

Indexing words inside function bodies gives a much larger gain (top-5 ~73% on held-out questions, smaller answers) but stores ~15% more in graph.json; better as a separate follow-up on top of this. Open ranking PRs (#3417, #2403, #4504, ...) were measured on the same questions; the best reached 51% top-5.

Area

Graph building or querying

Are you willing to submit a PR?

Yes, PR #4982 is open.

Compatibility / behavior impact

Only the query answer order and its seeds change. No change to node/edge ids, graph.json, cache, MCP tool signatures, path, explain or incremental builds. An agent that relied on tests appearing first in query sees source first unless the question mentions tests.

Additional context

Benchmark questions and scripts: SWE-bench Lite + Verified issues, one graph per base commit, graphify benchmark --questions from #4342.

Activity

  1. github-actions commented on Nov 3, 2026

    @github-actions

    Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Nov 3, 2026

    @safishamsi
    Member

    Fixed in 0.9.102 (published to PyPI) via #4982. Query ranks source above tests and docs (a soft weight, not exclusion) and answers file-first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions