Skip to content

follow-up: fuzzy file-target matching has no disambiguation when multiple real files match #2583

Open

Description

@carlos-alm

Context

Discovered during Greptile review round 4 of PR #2582 (issue #2530).

Description

findFileNodes(db, '%${target}%') — used identically by context, dependencies, fn-impact, symbol-lookup, and exports (all in src/domain/analysis/) — is a deliberate, repo-wide partial-path matching feature: typing utils.js resolves to src/utils.js without needing the full path. This is intentional and predates any of these commands' more specific bug fixes.

When a target ambiguously matches multiple distinct real files (e.g. foo/bar.ts matching both src/foo/bar.ts and test/foo/bar.ts), there's no disambiguation — whichever file the unordered LIKE scan (or, for exports since #2530, the first plausible candidate) returns first silently wins, and its data is reported as if it were unambiguously "the" file. Greptile's PR #2582 round 4 review flagged one instance of this (a target that doesn't exist as a top-level file happening to be the path-suffix of one real, different file) as if it were a novel bug in exports's new fileFound field — but this exact "arbitrary first match wins" behavior is pre-existing across every command listed above and predates #2530 entirely (verified: reproduced the identical LIKE lookup against the pre-PR base commit).

Suggested follow-up

Decide, in a dedicated design pass covering all five affected commands, whether ambiguous multi-file matches should:

  • surface a "did you mean: X, Y, Z?" disambiguation prompt/error, or
  • prefer the shortest/most-specific matching path deterministically, or
  • remain as-is (arbitrary-but-stable) with documentation of the caveat.

This needs one consistent policy applied across context, dependencies, fn-impact, symbol-lookup, and exports — not a narrow fix in just one of them.

Activity

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