Skip to content

query: a snake_case name with a schema prefix (public.<name>()) loses to single-token labels; explain finds it #5080

Closed

Description

@Larrynguyen191

Summary: graphify query <snake_case name> does not find a SQL function whose label carries a schema prefix (public.<name>()), while explain on the same name finds it. The full-query tier of _score_query only fires when the joined query tokens equal or prefix the label, so the leading public token defeats it, and nodes whose whole label is one of the query's tokens take the seeds instead.

Version: observed on 0.9.93 against a private code graph (names changed below). The same logic is on v8 / v0.9.103 by reading graphify/serve.py, _score_query (~617), the if joined: block (~705-713).

Shape of the graph (names changed):

  • a SQL migration defines public.sweep_widget_state() (node label public.sweep_widget_state(), source_file migrations/042_widget_sweep.sql); it appears in four migrations in total;
  • elsewhere in the graph there are nodes whose whole label is one of the tokens: SWEEP (a constant), WIDGET (a constant), State (a type).
$ graphify query sweep_widget_state
# exit 0; Start: ['SWEEP', 'WIDGET', 'State']; 55 nodes shown, none of them public.sweep_widget_state()
# (--budget 20000 and 80000: 82 nodes shown, still none)
$ graphify explain sweep_widget_state
# exit 3; lists the four public.sweep_widget_state() nodes with their path::symbol forms
$ graphify query public.sweep_widget_state
# exit 3 (query's own name refusal), the same four nodes listed

_search_tokens turns the query into sweep widget state and the label into public sweep widget state. joined in (norm_label, bare_label, label_tokens, nid_lower) is false and label_tokens.startswith(joined) is false, so the function gets only the per-token tiers, where an exact single-token label (SWEEP) outscores it. Another public.-prefixed function in the same graph, whose tokens are no other node's whole label, ranks fine, so the miss needs both: the qualifier defeating the full-query tier, and other nodes whose whole label is one of the tokens.

Expected: a query whose tokens equal the label's tokens after a leading qualifier (schema, namespace, module) gets the full-query bonus, or at least the prefix-tier bonus, so query sweep_widget_state seeds on public.sweep_widget_state() as explain resolves it. For example, also accept label_tokens.endswith(" " + joined) (a token-aligned suffix) in that block, maybe weighted between the exact and prefix tiers.

Related: #4511 (query refusing an ambiguous exact name), #5027 (per-term seeds).

Activity

  1. github-actions commented on Nov 7, 2026

    @github-actions

    Thanks for opening this issue, @Larrynguyen191. 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. houyunsun commented on Nov 8, 2026

    @houyunsun
    Contributor

    本轮提交 1 个 PR:#5095(修 #5080)。

    问题:graphify query sweep_widget_state 找不到 public.sweep_widget_state(),而 explain 同名却能找到。根因是 _score_query 的全查询层只在“等于/前缀”时给分,标签的 token 串带了 public 前缀,于是落到逐词层——那里单 token 完全相等的 SWEEP/WIDGET/State 拿满分,把目标挤出种子。

    修复:在 exact 与 prefix 之间新增“限定词尾部”层级,标签为 <限定词><分隔符><名字> 且查询正好是 <名字> 时给分(分隔符含 . :: / : @,另支持 CamelCase 末尾段;按限定词 token 数衰减、上限 4;跳过扩展名和纯数字段)。改动 2 文件 +173/−0。

    验证:修复前种子 ['SWEEP','State','WIDGET'] → 修复后 ['public.sweep_widget_state()',...];只回滚源码时 2 failed,修复后 4 passed;全量 381 failed → 379 failed,差值恰为两个新用例。PR 状态 open / mergeable=clean,11 项 check 全绿。

    需要说明的决定:原本在 huggingface/transformers 上完成了 DynamicCache 混合层 batch_select_indices 的完整修复与测试,但其 PR 模板有 Code Agent Policy(首次贡献者须确认代码非 LLM 所写、自主 agent 不应提 PR),与该约束冲突,故整份放弃、未提交、未在 issue 留言。另:autogen 当日 5 个优质 bug 已全部被他人开 PR;crewAI、transformers #50470 也均被认领。

  3. added a commit that references this issue on Nov 9, 2026
    3192fdf
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