Repository navigation
Description
First, thanks for _QUERY_STOPWORDS in 0.9.48. Measured on a ~3,600-node graph, our natural-language hit rate went 1/6 → 4/6 on a fixed benchmark. This report is about what survives it, and I've checked it against #2381 and #2507 — see "Not a duplicate" below.
Summary
_score_nodes weights a term that begins a label 100× one that merely contains it (_PREFIX_MATCH_BONUS = 100.0 vs _SUBSTRING_MATCH_BONUS = 1.0). Docstring headings are indexed as nodes carrying the same flat label field as identifiers, and docstrings are sentences — so they begin with verbs.
_QUERY_STOPWORDS removes question words. Ordinary descriptive verbs are not stopwords, and arguably cannot become stopwords: computes, creates, returns, stored are legitimate content words and frequently real function names. So any query phrased with a verb that also opens a docstring seeds on that docstring, regardless of subject.
Not a duplicate
- query seeds can be hijacked by test/doc rationale nodes — make seed-path exclusion configurable with tests/ as the default #2381 proposes seed-path exclusion defaulting to
tests/. Our hijacking seeds are in production service files, so path exclusion cannot address them without excluding the application code itself. - query: relational-intent verbs ("calls"/"uses") survive stopwording, prefix-match unrelated identifiers, and the #1445 per-term guarantee seats the junk match as a seed #2507 (closed) covers relational-intent verbs that
_CONTEXT_HINTSalready recognises.computes/creates/storedcarry no relational intent, so that path never fires — and this reproduces on 0.9.48, after that fix.
Reproduction
Graph contains 20 nodes matching ROAS, including kpi_service.py / kpi.py, which are what actually compute it.
$ graphify query "what computes ROAS"
Start: ['Computes and upserts reconciliation comparison rows for the given YYYY-MM…',
'Computes the closing balance for a SKU for a given YYYY-MM month. Formula…',
'Computes and upserts all available reconciliation rows for a given YYYY-MM…',
'roasX()']
$ graphify query "ROAS"
Start: ['roasX()', 'roasColor()']
The three top seeds share only the word "computes" with the query, and all three are docstrings in unrelated production services (month-end reconciliation). Reproducing the scorer against our graph:
| node | tier | score |
|---|---|---|
Computes the closing balance for a SKU… |
PREFIX × idf(computes)=6.585 |
658.5 |
Returns ROAS and TACOS per month… (kpi_service.py, correct) |
SUBSTRING × idf(roas)=5.154 |
5.2 |
128:1 in favour of the wrong node.
The #1445 per-term guarantee does fire here and rescues a roas seed into 4th place — but it seats whichever roas node scored highest, which is roasX(), a chart-axis helper in a JSX page (src/pages/sales/AdTrendsPage.jsx). The service that actually computes ROAS is never seeded. So the per-term guarantee limits the damage without addressing it: the three dominant seeds still steer the traversal into month-end reconciliation.
Two more, same shape, different verbs — all production files:
$ graphify query "where are NE thresholds stored"
Start: ['test_backfill_resanitizes_stored_rows()', …] # correct: stock_threshold_repository.py
$ graphify query "why does the quality label say CONFIRMED"
Start: ['Say()', …] # a 3-char function beats "quality" + "label" + "CONFIRMED"
Suggested fix — the signal is already in the graph
Every node already carries file_type: code, rationale (docstrings), document (markdown). _score_nodes never consults it.
In our graph 40.6% of nodes are non-code, and 701 rationale nodes live inside src/ itself — so, unlike #2381's population, they cannot be excluded by path without excluding the code.
Two options, either of which removes the class:
- Type-weight the seeds — scale
codeup, orrationale/documentdown, during scoring. A docstring should stay reachable but should not outrank the symbol it documents. This composes with query seeds can be hijacked by test/doc rationale nodes — make seed-path exclusion configurable with tests/ as the default #2381 rather than competing: that issue filters by location, this one by kind. - Narrow the prefix/substring gap — 100:1 makes a single shared leading word insurmountable. Something like 10:1 keeps prefix preference without letting grammar beat subject.
(1) looks more principled: the defect is that a description of a thing outranks the thing.
Environment
- graphifyy 0.9.48 (also reproduced on 0.8.37, far worse there)
- Python 3.12, Windows
- ~3,600 nodes / ~7,300 edges, 357 files, Python + JS/JSX + Markdown
- AST-only extraction, no semantic/LLM pass
Workaround in use
We wrap graphify query and flag any result whose top seed shares nothing with the query but a generic verb or container noun, then re-ask without it and show that alongside. On 12 held-out queries this turned 5 silent wrong answers into flagged ones with working suggestions, with 0 false alarms. It's detection, not correction — it can't recover terms the user never typed.
Activity
LYSIN-SE commentedon Aug 24, 2026
Thanks for the quick turnaround, @hopstreax. I'm the reporter — before this merges and auto-closes the issue, I applied the patch to 0.9.48 and re-ran it against the same ~3,600-node graph the report was measured on. Two findings.
1. The headline query in the issue is still wrong, just differently.
graphify query "what computes ROAS"now seeds['roasX()', 'roasColor()', 'Computes and upserts reconciliation comparison rows...']. The rationale hijack from reconciliation docstrings is gone — but of the 20roas-matching nodes in this graph, the only four in the prefix tier are JSX chart-axis helpers (roasX(),roasColor()). Every node that actually computes ROAS (kpi_service.py,kpi.py) isfile_type: "rationale", reachable only by substring. So downweighting rationale prefixes clears the field for an unopposed code-prefix helper instead —kpi_service.pyis absent from the result set both before and after this patch. The PR's own "Real Behavior Proof" graph has the correct answer as a code identifier (roas_report), which is the case this fix handles; it isn't the only shape this bug takes.2.
closes #2962would close it about a third addressed. The original report bundled three reproductions as "same shape, different verbs" — on re-check that grouping was my mistake. The other two are untouched by this patch because they don't seed on rationale nodes:"where are NE thresholds stored"→test_backfill_resanitizes_stored_rows()(file_type: code)"why does the quality label say CONFIRMED"→Say()(file_type: code)Both are byte-identical before/after. These are the raw 100:1 prefix-bonus gap (option 2 in the original report), which this PR explicitly and reasonably scopes out — but the issue shouldn't auto-close on that account.
No regression found — the symbol-lookup workflow this project depends on as a fallback is unchanged 4/4, and
next_engine_connector execute_requestactually improved (identifiers lead now, reaching.execute_request()directly instead of a docstring). I'd merge this on its own merits; I'd just unlink the auto-close, or open a follow-up for the code-node case before closing.