Repository navigation
feat: add evidence-bearing search hits - #360
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis pull request implements evidence-bearing search hits across storage, repository, CLI, MCP, and library layers. It adds data models for search hits with match evidence (rank, lane, surface, message ID, snippet), integrates ranked FTS search with snippet generation into the query path, and exposes these enriched results through CLI formatting and MCP payloads. Documentation is updated to reflect the new result contracts. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI Query<br/>Executor
participant Plan as Query Plan<br/>Analyzer
participant Storage as Search<br/>Storage
participant Repo as Repository<br/>Hydration
participant Output as Output<br/>Formatter
CLI->>Plan: Check for search evidence<br/>(fts_terms or similar_text)
Plan-->>CLI: Evidence present?
alt Evidence Found
CLI->>Storage: search_hints_for_plan()<br/>(with query terms)
Storage->>Storage: Ranked FTS search<br/>+ snippet generation
Storage-->>CLI: list[ConversationSearchHit]
CLI->>Repo: get_message_counts_batch()<br/>(for context enrichment)
Repo-->>CLI: message counts dict
CLI->>Output: output_search_hits()<br/>(hits + format spec)
Output->>Output: Format per output_format<br/>(JSON/YAML/CSV/text)
Output-->>CLI: Rendered results
CLI-->>User: Search results with evidence
else No Evidence
CLI->>CLI: Fall back to<br/>summary list path
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc2744ca34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if output_diagnostics is None and (plan.output.list_mode or len(projected_results) > 1): | ||
| search_hits = await _search_hits_for_execution_plan(repo, plan, vector_provider=vector_provider) | ||
| if search_hits is not None: | ||
| await _query_output.output_search_hits(env, search_hits, plan.output, repo) | ||
| return |
There was a problem hiding this comment.
Route multi-hit search output through standard output dispatch
This new branch returns early via output_search_hits(...) for search-like queries with multiple results, which bypasses the normal output_results(...) path. In practice that drops delivery behaviors handled by _send_output (e.g. --output file/browser/clipboard) and skips the already-projected result set, so users can get stdout-only output and unprojected list data for the same query shape.
Useful? React with 👍 / 👎.
| if selected: | ||
| data = [{key: value for key, value in item.items() if key in selected} for item in data] |
There was a problem hiding this comment.
Preserve
--fields semantics for search-hit machine output
Field filtering is applied to the top-level search-hit payload object, but those objects only expose conversation and match; the documented list fields like id, title, and provider now get filtered out entirely. For JSON/YAML search-hit output, requests such as --fields id,title can therefore degrade to empty objects instead of narrowed rows.
Useful? React with 👍 / 👎.
Summary
ConversationSearchHitcontract for CLI, MCP, and archive operations.searchwhile leavinglist_conversationson compact summaries.Problem
Closes #216.
Search and discovery surfaces returned conversation identities without explaining why each result matched. That made downstream retrieval work hard to verify, because CLI and MCP consumers could not inspect the matched message or distinguish the retrieval lane/surface that produced a hit.
Solution
polylogue/lib/search_hits.pyandpolylogue/lib/query_search_hits.pyas the shared search-hit model and plan execution adapter.ConversationSearchEvidenceHitandsearch_conversation_evidence_hits()in the storage query layer so FTS-ranked message searches keep their witness metadata before summary hydration.ConversationSearchHitPayloadand MCP list/no-result payloads for search results.Verification
Pre-push hook also ran
devtools verify --quicksuccessfully during branch push.Summary by CodeRabbit
Release Notes
Documentation
New Features
Tests