Skip to content

Improve pattern search exclusions and ranked overflow results - #1752

Open
ilganeli wants to merge 5 commits into
oraios:mainfrom
ilganeli:bou-2356-serena-search-ranking
Open

Improve pattern search exclusions and ranked overflow results#1752
ilganeli wants to merge 5 commits into
oraios:mainfrom
ilganeli:bou-2356-serena-search-ranking

Conversation

@ilganeli

@ilganeli ilganeli commented Jul 24, 2026

Copy link
Copy Markdown

Why

In large repos with extensive documentation, serena had insufficiently flexible configuration for what to exclude as relevant and was crashing out, blowing up context.

Summary

  • add paths_exclude_globs while preserving the existing singular exclusion parameter; both forms combine additively
  • add ordered paths_priority_globs for deterministic live-path-first pattern searches
  • return a budget-aware ranked excerpt with shown/total match and file counts before falling back to smaller summaries
  • keep unprioritized result ordering compatible with existing behavior

Compatibility and behavior

The existing paths_exclude_glob schema and behavior are unchanged. New list exclusions are optional and additive.

Priority ranking is also opt-in. When supplied, matches are ordered by the first matching priority glob, normalized path, and matched line. When omitted, Serena preserves its existing source ordering.

Oversized ranked excerpts contain whole match entries and report how many matches and files were shown versus omitted. The implementation sizes the excerpt linearly and serializes only the full result and final excerpt.

Verification

  • uv run poe test -q -k 'search_for_pattern or TestSearchText or TestSearchFiles or TestGlobMatch' — 93 passed, 1 skipped
  • uv run poe lint — passed
  • uv run poe type-check — passed
  • 20,000-match regression verifies excerpt rendering performs only two JSON serializations

Checklist

  • This PR follows the guidelines in CONTRIBUTING.md regarding the scope of PRs.
  • For changes that add features or fix problems, I have added an entry to CHANGELOG.md, which concisely describes the change.

Comment on lines 585 to +589
:param paths_include_glob: optional glob (relative to project root, e.g. ``"src/**/*.ts"``) restricting which files are searched.
:param paths_exclude_glob: optional glob to exclude files; takes precedence over `paths_include_glob`.
:param paths_exclude_globs: additional optional globs to exclude files; additive with `paths_exclude_glob`.
:param paths_priority_globs: optional ordered globs that rank matching paths before unmatched paths.
The first matching glob determines a path's priority.

@opcode81 opcode81 Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having both paths_exclude_glob and paths_exclude_globs is not reasonable.
To generalise the interface, we can use a list-based interface for both inclusions and exclusions.

The priority feature is a new addition, but it's unlikely to be useful in the vast majority of circumstances.
@MischaPanch what are you thoughts regarding the usefulness of the priority feature? Worth keeping?

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