Repository navigation
Conversation
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Downweights prefix-match bonuses for file_type == "rationale" nodes in _score_query via a new _RATIONALE_PREFIX_FACTOR (0.01), so docstring action verbs like "Computes…" no longer out-seed production code symbols (#2962). Applies the factor to the joined-prefix, per-term prefix, and singleton-prefix tiers only; exact, substring, and code-node scoring are untouched. Adds six tests covering the scaled prefix behavior plus unchanged code-prefix, exact-rationale, and substring paths.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 557 functions depend on the 335 functions this change touches.
Health — this change adds coupling hotspots:
- new:
dispatch_command()— 2 callers, 119 callees - new:
_query_graph_text()— 20 callers, 9 callees - new:
_score_query()— 20 callers, 5 callees - new:
_query_terms()— 25 callers, 3 callees - new:
run_benchmark()— 16 callers, 3 callees - new:
_build_server()— 2 callers, 16 callees - new:
_load_graph()— 9 callers, 3 callees - new:
_query_subgraph_tokens()— 7 callers, 3 callees - …and 9 more — each is listed as a finding
Verification — 557 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 399 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify \_score\_query.
The verifier did not have enough to check \_score\_query, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: not verifiable: all 45 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
· 17 more finding(s) on lines outside this diff (see the check run).
Summary
closes #2962
Natural-language docstrings/rationale nodes could dominate query seed selection when a query term matched the beginning of the docstring.
For example:
could rank:
above the production code responsible for ROAS because prefix matches receive a 100× bonus over substring matches.
This change makes that prefix signal type-aware without changing code-symbol scoring.
Root Cause
_score_query()applies the same prefix-match bonus to all node types.Rationale nodes are natural-language descriptions and commonly begin with verbs such as:
Computes ...Returns ...Creates ...Stored ...These sentence-initial words can therefore receive the same identifier-oriented prefix bonus as a code symbol.
The problem was amplified by the separate multi-word joined-prefix tier and the
best_by_termsingleton scoring used by the per-term seed guarantee.file_typewas already available on query-time nodes but was not used by the scorer.Solution
Introduce a rationale-specific prefix factor:
For
file_type == "rationale"nodes, the factor is applied consistently to:Code nodes retain the existing prefix scoring.
Exact matches, substring matches, source matches, coverage, seed-gap selection, and the per-term guarantee remain unchanged.
Other node types are also left unchanged.
Why 0.01?
The existing prefix bonus is:
Reducing rationale prefixes by
0.01makes their effective prefix contribution equivalent to the existing substring scale while preserving the prefix signal for code identifiers.In the reproduced multi-word case, higher factors such as
0.05and0.10still allowed the rationale node to dominate.0.01was sufficient to allow the relevant production code node to become the primary seed.Tests
Added focused regression coverage for:
Validation
Full suite:
Static checks:
Pyright also reports no errors in the changed scoring code.
Real Behavior Proof
Command:
Before:
After:
The production code node is now the primary seed while the rationale node remains available as a secondary seed.
Scope
This change is intentionally limited to rationale-node prefix scoring. It does not alter the global prefix bonus or unrelated query-ranking behavior.