search_text: snippets truncate inside the match, there is no exclude_tests, and path-only hits read as content hits #524

Closed
opened 2026-11-09 08:03:48 +01:00 by buildagent · 2 comments
Member

Summary

search_text is meant to replace rg -n, but its default output usually cannot be read without a second call. Three problems, all seen during the 2026-11-09 review:

  1. Snippets are cut too narrow, sometimes inside the match itself. The default context_tokens: 32 counts trigram tokens, so the result looks like … p\n (\<<attach_or_spawn_daemon>>`); th …. The highlighted match is truncated too: the query builtincame back as<>and<>, and LanguagePluginas<>/<>. Rows report snippet_origin: unlocated. An agent then needs line_text=trueorread_code` for every hit.
  2. There is no exclude_tests. A sweep for production .unwrap() or COMMIT returns mostly test hits, which the agent has to filter by hand through enclosing_symbol. find_references already has exclude_tests.
  3. Path-only hits look like content hits. Searching docs/operations returned the file with matches_in_file_unmeasured: literal_absent_from_body. A query with an embedded " returns total: 0; the separator_scan disclosure covers it, but the zero is still a trap.

Proposal

  • The default snippet is the matched source line (cut to 240 chars, the same rule as line_text), and a highlight is never truncated inside the match.
  • Add exclude_tests with the same test classifier find_references uses.
  • Mark path-only matches with match_in: "path" and keep them out of total, or count them separately.

Acceptance

  • On this repository, search_text "attach_or_spawn_daemon" rows show the full source line.
  • With exclude_tests=true, .unwrap() rows contain no #[cfg(test)]/tests/ hits.
  • Mutation tests for each change.

Found by three of the automated reviewers independently (2026-11-09).


Filed from a five-agent review of master @ e3ec6ead (bloat, robustness, agent usefulness, docs, architecture). Every finding was spot-checked in the main session before filing.

## Summary `search_text` is meant to replace `rg -n`, but its default output usually cannot be read without a second call. Three problems, all seen during the 2026-11-09 review: 1. **Snippets are cut too narrow, sometimes inside the match itself.** The default `context_tokens: 32` counts trigram tokens, so the result looks like `… p\n (\`<<attach_or_spawn_daemon>>\`); th …`. The highlighted match is truncated too: the query `builtin` came back as `<<bui>>` and `<<BUILTI>>`, and `LanguagePlugin` as `<<impl L>>`/`<<impl LanguagePlugi>>`. Rows report `snippet_origin: unlocated`. An agent then needs `line_text=true` or `read_code` for every hit. 2. **There is no `exclude_tests`.** A sweep for production `.unwrap()` or `COMMIT` returns mostly test hits, which the agent has to filter by hand through `enclosing_symbol`. `find_references` already has `exclude_tests`. 3. **Path-only hits look like content hits.** Searching `docs/operations` returned the file with `matches_in_file_unmeasured: literal_absent_from_body`. A query with an embedded `"` returns `total: 0`; the `separator_scan` disclosure covers it, but the zero is still a trap. ## Proposal - The default snippet is **the matched source line** (cut to 240 chars, the same rule as `line_text`), and a highlight is never truncated inside the match. - Add `exclude_tests` with the same test classifier `find_references` uses. - Mark path-only matches with `match_in: "path"` and keep them out of `total`, or count them separately. ## Acceptance - On this repository, `search_text "attach_or_spawn_daemon"` rows show the full source line. - With `exclude_tests=true`, `.unwrap()` rows contain no `#[cfg(test)]`/`tests/` hits. - Mutation tests for each change. Found by three of the automated reviewers independently (2026-11-09). --- _Filed from a five-agent review of master @ e3ec6ead (bloat, robustness, agent usefulness, docs, architecture). Every finding was spot-checked in the main session before filing._
Author
Member

Reproduced in every language on 2026-11-09:

  • Ruby: Sinatra::<<Bas>>; context_tokens:4 returns ' … etting … '.
  • Python: test_<<url_for>>_with_anchor under whole_word; on primary, <<supert>> for SUPERTYPE.
  • PHP: <<handle_facto>>.
  • C#: 3 of 5 snippets unlocated and cut mid-argument.
  • Rust: tests/<<gitignor>>.
  • TS: names starting with $ (core.$constructor() return '… .$construc …' with no highlight and snippet_origin: unlocated.
  • Not reproduced: Vue/Svelte/XAML (snippet_origin other_line reported correctly).
Reproduced in every language on 2026-11-09: - Ruby: `Sinatra::<<Bas>>`; `context_tokens:4` returns `' … etting … '`. - Python: `test_<<url_for>>_with_anchor` under `whole_word`; on primary, `<<supert>>` for `SUPERTYPE`. - PHP: `<<handle_facto>>`. - C#: 3 of 5 snippets `unlocated` and cut mid-argument. - Rust: `tests/<<gitignor>>`. - TS: names starting with `$` (`core.$constructor(`) return `'… .$construc …'` with **no highlight** and `snippet_origin: unlocated`. - Not reproduced: Vue/Svelte/XAML (snippet_origin `other_line` reported correctly).
Author
Member

Consolidated into #521 during the 2026-11-09 triage. The remaining scope of this issue is tracked there as a checklist item; this report stays as the detailed evidence.

Consolidated into **#521** during the 2026-11-09 triage. The remaining scope of this issue is tracked there as a checklist item; this report stays as the detailed evidence.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#524
No description provided.