Skip to content

fix(definitions): count a match as a definition only when it starts at the declared name - #940

Open
gustav-fff wants to merge 2 commits into
codex/definition-formsfrom
codex/definition-name-start
Open

gustav-fff wants to merge 2 commits into
codex/definition-formsfrom
codex/definition-name-start

Conversation

@gustav-fff

@gustav-fff gustav-fff commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

A match is a definition only when it starts at the declared name, so Value no longer returns ArgValueCompletion or FromValue. Leading underscores in the name are skipped, and fuzzy matching does not change. MCP definitions_only pages now default to 30 matches, because real declarations are rarer and each page reads more files.


Line Query Before After
pub enum Value { Value definition definition
pub enum ValueKind { Value definition definition
pub struct ArgValueCompletion<'a> { Value definition other match
function handle(ctrl: UserController) { UserController other match other match
struct _xmlDict { xmlDict definition definition
function M.setup(opts) M.setup definition definition

59 "where is X defined" queries on nushell, ghostty, opencode, ffmpeg and Chromium, MCP definitions_only with default arguments:

#932 This PR
Lines where the query sits inside a longer name 1,788 2
Real declaration is the first file 20/59 30/59
Body of the real declaration shown 33/59 48/59
Real declaration not on page 1 7 7
Median output 4.6 KB 2.2 KB
Median latency, 4 smaller repos 6 ms 6 ms
Median / max latency, Chromium 222 / 1,104 ms 213 / 938 ms

Note

The classifier is shared, so Neovim live grep, the definition_only grep mode and the SDK classifyDefinitions modes use the same rule. A typed name prefix still marks the declaration. Ordinary grep pages keep the same matches; fewer lines get the definition label.

Important

With 100-match pages, this rule made Chromium definitions_only 3–5x slower (median 0.9 s, max 2.5 s), because 100 real declarations take more files to collect. The 30-match default keeps today's latency with the same quality. An explicit maxResults still wins. multi_grep and Pi already default to 20.

Stacked on #932. #933 now stacks on this PR.

Stack merge order: #924, #925, #927, #928, #930, #931, #932, #940, #933, #934.

Summary by CodeRabbit

  • New Features
    • Definition-only searches now return 30 matches by default. Other searches continue to return up to 100, with a maximum of 200.
    • Definition matching now requires the match to start at the declared name, ignoring leading underscores when determining the start. Fuzzy Rust matching remains available.
    • Explicit result limits continue to be honored.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7182134-5ea0-473f-8df0-c63a7d29e3e7
📥 Commits

Reviewing files that changed from the base of the PR and between b25dcfa and 285366e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 202d5ce3-3ca7-44f2-92d4-d886f5872714
📥 Commits

Reviewing files that changed from the base of the PR and between 51b755b and 730e883.

📒 Files selected for processing: 6
  • README.md
  • crates/fff-core/benches/definition_bench.rs
  • crates/fff-core/src/definition/mod.rs
  • crates/fff-core/src/definition/rules.rs
  • crates/fff-mcp/src/instructions.md
  • crates/fff-mcp/src/server.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Definition matching now requires a match to start at the declared name, with leading underscores handled as a special case. Definition-only Grep searches use a default page size of 30; other searches retain the 100-result default.

Changes: Definition-aware Grep

Layer / File(s) Summary
Declared-name matching
crates/fff-core/src/definition/rules.rs, crates/fff-core/src/definition/mod.rs, README.md, crates/fff-core/benches/definition_bench.rs
Non-fuzzy matches must include the declared name’s first byte, skipping leading underscores unless the name contains only underscores. Tests and examples cover positive and negative cases. The benchmark now places user_file at the start of generated identifiers.
Definition-only page size
crates/fff-mcp/src/server.rs, README.md, crates/fff-mcp/src/instructions.md
Definition-only searches default to 30 results; other searches default to 100. Explicit maxResults values remain in effect, subject to the existing 200-result cap. Documentation and tests reflect these defaults.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: dmtrkovalenko, dkovalenko-oai

Merge Risk: ⚪ Minimal · up to 730e8

No merge-blocking issue is identified; this change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and accurately states the main change: definition matches must start at the declared name.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dmtrKovalenko
dmtrKovalenko force-pushed the codex/definition-name-start branch from b25dcfa to 285366e Compare October 17, 2026 00:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants