Repository navigation
feat: add neighbor candidate discovery (#364) - #364
Conversation
Problem: exact-id lookup and search results could identify canonical conversations, but did not expose an explainable way to inspect likely neighboring or near-duplicate candidates around a known conversation or fuzzy query. What changed: added the shared neighbor-candidate selector, reason model, archive operation, CLI command, MCP tool, JSON payloads, generated surfaces, and coverage for same-title, nearby-time, shared-query, and content-similar evidence. Verification: devtools verify. Closes #220
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new feature for discovering neighboring or near-duplicate conversations has been added. It includes a core discovery library with ranking and explainability, CLI and MCP surfaces, payload serialization, and comprehensive test coverage across command, core logic, and MCP tool validation. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User/CLI
participant CLI as neighbors_command
participant Ops as ArchiveSearchMixin
participant Lib as discover_neighbor_candidates
participant Store as ConversationStore
participant Output as JSON/Text Renderer
User->>CLI: neighbors --id target --query ...
CLI->>CLI: Validate (--id or --query)
CLI->>Ops: neighbor_candidates(conversation_id, query, ...)
Ops->>Lib: discover_neighbor_candidates(request)
Lib->>Store: Load target conversation (if id given)
Lib->>Store: List candidates by title/time/attachments/search
Lib->>Lib: Score candidates (same_title, nearby_time, content_similarity)
Lib->>Lib: Sort by rank & recency
Lib-->>Ops: List[ConversationNeighborCandidate]
Ops->>Store: Batch fetch message counts for candidates
Ops-->>CLI: Candidates with message counts
CLI->>Output: Serialize to JSON or plain-text
Output-->>User: Formatted neighbor results with reasons
sequenceDiagram
participant MCP as MCP Client
participant Tool as neighbor_candidates Tool
participant Server as mcp_server
participant Ops as Archive Operations
participant Payload as Payload Builder
MCP->>Tool: Call with id/query params
Tool->>Server: Invoke within MCP context
Server->>Ops: neighbor_candidates(id, query, limit, window_hours)
Ops-->>Server: List[ConversationNeighborCandidate]
Server->>Payload: conversation_neighbor_candidate_list_payload(candidates)
Payload->>Payload: Convert to MCPConversationNeighborCandidatePayload[]
Payload-->>Server: MCPConversationNeighborCandidateListPayload
Server-->>Tool: JSON serialized payload
Tool-->>MCP: {"root": [neighbor_candidate, ...]}
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes The review requires careful attention to: (1) the discovery algorithm's multi-strategy candidate ranking and scoring logic (567 lines), (2) proper validation and error handling in the CLI command, (3) correct payload serialization across surface/MCP layers, (4) integration between operations and the library, and (5) verification that test coverage validates core heuristics (same-title, proximity, content similarity). The changes are heterogeneous across multiple subsystems but follow consistent patterns. 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: 5644280158
ℹ️ 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".
Problem: adding the root neighbors command changed the deterministic tier-0 showcase help surface and introduced a new help exercise without a committed baseline. What changed: refreshed the showcase baselines so help-main includes neighbors and help-neighbors records the command-specific help output. Verification: devtools verify-showcase; pytest -q --ignore=tests/integration. Refs #220
## Summary Adds explainable neighboring-conversation discovery for known conversation IDs and fuzzy query seeds. The new `polylogue neighbors` CLI command and `neighbor_candidates` MCP tool return ranked candidates with explicit reasons such as same title, nearby time, shared attachment identity, query match, source-content search, and body content similarity. ## Problem Closes #220. Polylogue had canonical exact-ID retrieval and archival dedupe primitives, but users had no durable way to inspect nearby or near-duplicate candidates when several conversations looked plausible from title/date summaries alone. That pushed duplicate-like exploration into ad hoc search instead of an explainable retrieval surface. ## Solution - Added `polylogue/lib/neighbor_candidates.py` as the shared selector and evidence model. - Wired `ArchiveOperations.neighbor_candidates()` so surfaces share one substrate implementation. - Added root CLI command `polylogue neighbors` with plain and JSON output. - Added MCP tool `neighbor_candidates` plus shared CLI/MCP payload models. - Updated generated CLI/proof/reference surfaces for the new command. - Added tests for same-title-different-body candidates, nearby similar content, content-similar candidates outside the time window, query-seeded candidates, CLI JSON output, MCP payloads, command registration, and terminal help snapshots. - Added committed showcase help baselines for the new command after remote `showcase-verify` exposed the missing baseline. ## Verification ```text ruff check polylogue/lib/neighbor_candidates.py polylogue/operations/archive.py polylogue/surface_payloads.py polylogue/mcp/payloads.py polylogue/mcp/server_tools.py polylogue/cli/commands/neighbors.py polylogue/cli/click_command_registration.py tests/unit/core/test_neighbor_candidates.py tests/unit/cli/test_neighbors_command.py tests/unit/mcp/test_tool_contracts.py tests/infra/mcp.py mypy polylogue/lib/neighbor_candidates.py polylogue/operations/archive.py polylogue/surface_payloads.py polylogue/mcp/payloads.py polylogue/mcp/server_tools.py polylogue/cli/commands/neighbors.py tests/unit/core/test_neighbor_candidates.py tests/unit/cli/test_neighbors_command.py tests/unit/mcp/test_tool_contracts.py tests/infra/mcp.py pytest -q tests/unit/core/test_neighbor_candidates.py tests/unit/cli/test_neighbors_command.py tests/unit/mcp/test_tool_contracts.py devtools render-all --check pytest -q tests/unit/cli/test_click_app.py::TestCliMetadata::test_all_subcommands_registered tests/unit/cli/test_terminal_snapshots.py::TestHelpOutput::test_help_output_snapshot tests/unit/cli/test_terminal_snapshots.py::TestTerminalDimensions::test_help_at_narrow_width tests/unit/cli/test_terminal_snapshots.py::TestTerminalDimensions::test_help_at_wide_width devtools verify devtools verify-showcase pytest -q --ignore=tests/integration devtools verify --quick ``` `devtools verify` finished with `verify: all checks passed` before the showcase baseline follow-up. After refreshing baselines, `devtools verify-showcase` reported `All baselines match`, direct pytest reported `5108 passed in 173.83s`, and the pre-push hook ran `devtools verify --quick` with `verify: all checks passed`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added `polylogue neighbors` command to discover and display conversations similar to a target or matching a query, with detailed explainable reasoning for candidate matches. * **Documentation** * Updated documentation and CLI help to reflect the new neighbors command and its configuration options. * **Tests** * Added test coverage for the new neighbors command and discovery functionality. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Adds explainable neighboring-conversation discovery for known conversation IDs and fuzzy query seeds. The new
polylogue neighborsCLI command andneighbor_candidatesMCP tool return ranked candidates with explicit reasons such as same title, nearby time, shared attachment identity, query match, source-content search, and body content similarity.Problem
Closes #220. Polylogue had canonical exact-ID retrieval and archival dedupe primitives, but users had no durable way to inspect nearby or near-duplicate candidates when several conversations looked plausible from title/date summaries alone. That pushed duplicate-like exploration into ad hoc search instead of an explainable retrieval surface.
Solution
polylogue/lib/neighbor_candidates.pyas the shared selector and evidence model.ArchiveOperations.neighbor_candidates()so surfaces share one substrate implementation.polylogue neighborswith plain and JSON output.neighbor_candidatesplus shared CLI/MCP payload models.showcase-verifyexposed the missing baseline.Verification
devtools verifyfinished withverify: all checks passedbefore the showcase baseline follow-up. After refreshing baselines,devtools verify-showcasereportedAll baselines match, direct pytest reported5108 passed in 173.83s, and the pre-push hook randevtools verify --quickwithverify: all checks passed.Summary by CodeRabbit
New Features
polylogue neighborscommand to discover and display conversations similar to a target or matching a query, with detailed explainable reasoning for candidate matches.Documentation
Tests