Skip to content

explore returns 260 symbols / 124 files for a 6-word natural-language query on a 636-file project #1046

Description

@jcrabapple

codegraph explore returns excessive results on broad natural-language queries — 260 symbols for a 636-file project

Related: #765 (explore noise on multi-language repos), #982 (generic token name-match overboosting). This report adds a data point from a single-language project where the noise is not from cross-language conflation but from query breadth.

Reproduction

# Project: Android Mastodon client, 636 Java source files (27k total including XML resources)
codegraph init .
codegraph explore "publish status to mastodon API"

Result

Found 260 symbols across 124 files.

That's 40% of the project's Java files (124/636) and includes clearly unrelated symbols:

  • GetNotificationsV1 — notification fetching, not status publishing
  • GetOauthToken — OAuth, not status publishing
  • BarcodeScanner / Status (Google Play Services com.google.android.gms.common.api.Status) — barcode scanner API, not Mastodon status
  • SetPrivateNote — unrelated API request
  • ModuleInstallResponse / ModuleAvailabilityResponse — Google Play Services module installation

The correct symbols (ComposeFragment.publish, actuallyPublish, CreateStatus, EditStatus) are present and ranked first, but a user or agent has to wade through 260 symbols to confirm there's nothing else relevant.

Contrast with targeted queries

The same tool with a symbol-name query works well:

codegraph explore "actuallyPublish send status to API endpoint"
# → Found 171 symbols across 89 files — still broad, but the dynamic boundary
#   detection correctly identifies the Otto event bus dispatch
codegraph callers publish
# → 3 callers, all correct. Tight and accurate.

Analysis

The issue is that codegraph_explore's token matching is too permissive for natural-language queries. Words like "status", "publish", "API" match a large fraction of symbols in any API-heavy codebase. The existing isDistinctiveIdentifier demotion (#982) fires for single common words but doesn't adequately constrain the result set when multiple common words combine.

Suggestion

Two non-exclusive options:

  1. Tighter initial filter: When the query is natural-language (vs known symbol names), apply a higher relevance threshold before returning results. The 260→171 drop from adding one specific token ("actuallyPublish") suggests the filter is binary (match/no-match) rather than graduated.

  2. Result cap with expansion hint: Cap at N symbols (e.g., 50) with a note: "Showing top 50 of 260 matches. Refine your query or use codegraph_search for broader results." This prevents context bloat when the agent is using the MCP tool.

Environment

  • CodeGraph v1.1.2 (linux-x64, bundled install)
  • Project: Moshidon/Tootsie fork (Mastodon Android client), 636 Java files

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