Skip to content

explore/query relevance: a project-name token in the query inflates lexically-matching frontend class, burying backend symbols (compounds #647 PascalCase bias) #720

@MiNuo1

Description

@MiNuo1

Version: @colbymchenry/codegraph@0.9.9 (latest). Mixed-stack repo: GoFrame backend + a single-file JS frontend SPA.

Symptom: For a backend question, codegraph query (and therefore codegraph_explore, which inherits the ranking) surfaces the frontend SPA file, not the backend route/controller code. The agent then Reads the correct Go files anyway — the same read-back failure mode #564 fought, but driven by cross-stack ranking rather than polymorphic-sibling sizing.

Minimal repro — same query, one token removed, ranking flips stacks:

$ codegraph query "SuperBizAgent backend /api routes registered and bound to controller methods" -l 6 -j
37.4 SuperBizAgentFrontend/app.js toggleModeDropdown
37.4 SuperBizAgentFrontend/app.js toggleToolsMenu
32.3 SuperBizAgentFrontend/app.js constructor
32.3 SuperBizAgentFrontend/app.js initMarkdown
32.3 SuperBizAgentFrontend/app.js initializeElements
32.3 SuperBizAgentFrontend/app.js bindEvents ← all frontend; backend controllers not in top 6
$ codegraph query "backend /api routes registered and bound to controller methods" -l 6 -j
20.8 internal/controller/chat/chat_v1_ai_ops.go AIOps
20.8 internal/controller/chat/chat_v1_chat.go Chat
20.8 internal/controller/chat/chat_v1_chat_stream.go ChatStream
20.8 internal/controller/chat/chat_v1_file_upload.go FileUpload
18.4 internal/controller/chat/chat_new.go ControllerV1
15.1 SuperBizAgentFrontend/app.js toggleModeDropdown ← correct backend now on top
The single token SuperBizAgent (the project name, which users naturally include) ~doubles the score of every SuperBizAgentFrontend/app.js symbol because it lexically matches the frontend class SuperBizAgentApp / path SuperBizAgentFrontend.

Why the backend can't compete: the real route binding is GoFrame-reflective —

s.Group("/api", func(g *ghttp.RouterGroup) { g.Bind(chat.NewV1()) }) // main.go
// + struct tags: g.Meta path:"/chat" method:"post" (api/chat/v1/chat.go)
There is no literal "/api/chat" string and no call-graph edge from path → controller method, so route-registration symbols score low and have nothing to win on. (Analogous to the Zustand/handler-map coverage you added in #647, but for GoFrame route metadata.)

Suggestions (non-prescriptive):

Down-weight query tokens that match the repo/project name or appear in a large fraction of indexed paths (they carry ~no discriminative signal but currently dominate).
Consider excluding the project-name token from the #647 PascalCase-type bias.
Coverage: index GoFrame route metadata (g.Meta path: + RouterGroup.Bind(controller)) as route→method edges, so "where are routes registered/bound" resolves structurally instead of lexically.
Repro condition (general): any repo where the project name is also a substring of a symbol/path on one stack — that stack gets boosted whenever the user mentions the project by name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions