Repository navigation
Conversation
`query sweep_widget_state` missed `public.sweep_widget_state()` even though `explain` on the same name found it. The full-query tier only fires when the joined query tokens equal or prefix the label, so a leading `public` defeated it, and the per-token tiers handed the seed slots to unrelated nodes whose whole label is one of the query's tokens (`SWEEP`, `WIDGET`, `State`). Add a tier between exact and prefix for labels of the shape `<qualifier><sep><rest>` where the query names exactly `<rest>`: dotted, `::`, `/`, `:` and `@` segments, plus a CamelCase qualifier on the last segment. It is scaled down by the qualifier's token count and capped at four tokens, so `public.f()` is trusted more than `a.b.c.d.f()`. Trailing file-extension and numeric segments are skipped, so `lib/foo/bar.py` is the name `bar` rather than `py`. Nothing changes for a query that already equals or prefixes a label, or for plain snake_case identifiers: those never reach the new branch. Fixes #5080 Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @sunhouy. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: \_score\_query (vacuous: never exercised).
Graphify review — findings
Adds a qualified-name tier to query scoring, so a label like public.sweep_widget_state() or fmt.Println matches a query that names only its tail and outranks unrelated nodes whose whole label equals one query token (#5080). _score_query adds _QUALIFIED_MATCH_BONUS, scaled down by qualifier length, when _qualified_tail returns a tail equal to the joined query. The bonus stays below the exact-label tier, and labels with more than four qualifier tokens or no matching tail fall through to the existing per-token tiers. The CamelCase split in _qualified_tail works on the already-lowercased norm_label, and _name_key keeps parameter lists in the tail, so those label shapes drop back to per-token scoring.
Worth a look
- CamelCase-qualifier branch never runs because it is fed a lowercased norm_label —
graphify/serve.py:400· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
- CamelCase qualified tails are collapsed instead of tokenized —
graphify/serve.py:408· Escalate · medium- NOT verified (no proof, no reproducing execution) — needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 928 functions depend on the 468 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_query_graph_text()— 52 callers, 7 callees - worse:
_score_query()— 23 callers, 8 callees
Verification — 928 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: 703 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
26 of 532 test file(s) selected (5%) via static blast radius.
tests/test_4874_jvm_resolution.py— impacttests/test_affected_cli.py— impacttests/test_affected_path_file_node.py— impacttests/test_affected_seed_reference_forms.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_confidence_score_output.py— impacttests/test_edge_also_seen.py— impacttests/test_explain_same_file_tie.py— impacttests/test_extract.py— impacttests/test_file_label_disambiguation.py— impacttests/test_mcp_graph_view_cache.py— impacttests/test_path_cli.py— impacttests/test_path_confidence.py— impacttests/test_path_type_member.py— impacttests/test_query_induced_edges.py— impacttests/test_query_mcp_direction.py— impacttests/test_query_names_its_graph.py— impacttests/test_query_seed_order.py— impacttests/test_query_seeds.py— impacttests/test_query_source_first.py— impacttests/test_serve.py— impact, changed-testtests/test_serve_http.py— impacttests/test_terraform.py— impacttests/test_truncation_full_answer.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
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: no capturable inputs from the test suite; property tier: not verifiable: all 47 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)
· 2 more finding(s) on lines outside this diff (see the check run).
…ied-tail doc Fold the Markdown mention change (#5093) into #5098's AST schema-41 comment with a chained prior (40), since both change per-file extractor output and share one release window. Correct the _qualified_tail docstring example (a dotted tail is one token, not CamelCase-split) and note the CamelCase fallback only fires on cased input the lowercased-norm_label callers never pass (#5095 tweak). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
What does this PR do?
graphify query sweep_widget_statedoes not findpublic.sweep_widget_state(), whilegraphify explain sweep_widget_statelists it. The query came back seeded onSWEEP,WIDGETandState— nodes whose whole label happens to be one of the query's tokens.Why: the full-query tier in
_score_queryonly fires when the joined query tokens equal or prefix the label. With a schema prefix the label's token string ispublic sweep widget state, which neither equals nor is prefixed bysweep widget state, so the function falls back to the per-token tiers. There a single-token exact label scores_EXACT_MATCH_BONUS, more than the target can collect from four substring hits, and_pick_seedsthen drops everything below 20% of the top score.The fix adds a tier between exact and prefix for the case the user cannot avoid typing: the label is
<qualifier><sep><rest>and the query names exactly<rest>. The schema is usually implied, so the match is on the name the user actually typed..,::,/,\,:and@, plus a CamelCase qualifier on the last segment (Index.ClientLive->client live), sofmt.Println,Widget::sweepand dotted SQL names all work.public.f()is trusted more thana.b.c.d.f().lib/foo/bar.pyis the namebar, notpy, and3.14is not a qualified name.Nothing changes when the query equals or prefixes a label, or for plain snake_case identifiers — neither reaches the new branch.
explainandpathgo through_score_nodes, the same code, so they pick up the same ordering.Fixes #5080
Type of change
Verification & Invariants
The invariant is that the existing tiers keep their meaning: exact label > qualified name > prefix > per-token bag-of-words. A query that previously resolved to an exact or prefix label resolves to the same node; the new branch is only reachable when both of those miss, which is exactly the case that used to fall through to the token tiers.
No generated or persisted state is involved — this is pure scoring at query time, so no cache or index can be invalidated. The trigram prefilter's candidate set is unchanged (
norm_terms + [joined]); the new tier only re-ranks candidates that were already being scored.Limitations, on purpose:
a.b.c.f()matches a query forf; a query naming an intermediate segment is still only handled when the label starts with it (prefix tier).query public sweep_widget_statealready matches through the exact/prefix case, which scores above it.How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.Skillgen not run: nothing under
graphify/skills/ortools/skillgen/changed.Who can review?
Whoever owns
serve.pyscoring — happy to change the bonus weight or the cap if you'd rather keep the tier tighter.