Skip to content

feat: add neighboring and near-duplicate conversation discovery #220

Closed

Description

@Sinity

Outcome

Polylogue should help users inspect likely neighboring or near-duplicate conversations when exact confirmation is difficult.

Examples:

  • same provider, same period, similar title
  • same title but different body
  • nearby conversation around a known hit
  • conversations that are semantically similar enough to be plausible candidates

Problem or opportunity

The archive currently has strong canonical identity and archival dedupe primitives, but weaker user-facing support for "show me the other likely candidates around this one".

That matters in exactly the cases where title/date/message-count summaries are not enough to confirm identity. Similar vault-analysis or verification chats can cluster closely in time and topic, leaving the user with several plausible hits and little help exploring the local neighborhood.

Expected scope

  • retrieval/query planning under polylogue/lib/
  • storage/query helpers for nearby/similar candidate selection
  • CLI and MCP surfaces for neighboring/duplicate-like exploration
  • tests for similarity/neighborhood candidate behavior

Constraints and invariants

  • Do not conflate neighboring conversations with archival dedupe or automatic merge candidates.
  • Preserve exact-id retrieval as the primary canonical lookup path.
  • Any duplicate-like classification should explain its basis clearly enough for users to judge it.

Acceptance criteria

  • Polylogue exposes a way to retrieve nearby or near-duplicate candidate conversations for a known conversation or fuzzy query.
  • Candidate results explain why they are being suggested, such as same title, nearby time window, shared attachment identity, or content similarity.
  • CLI and/or MCP coverage exists for this exploration flow.
  • Tests cover at least one same-title-different-body case and one nearby-similar-content case.

Verification plan

  • add retrieval tests for candidate selection heuristics
  • add CLI/MCP surface tests for neighboring-conversation output
  • run devtools verify

Context and evidence

Relevant code and observations:

  • content-hash and duplicate-health checks already exist, but they are archival/health oriented rather than user-facing exploration
  • summary-only result lists make local candidate comparison harder than it should be

Non-goals or explicitly deferred work

  • Automatic duplicate deletion or merging.
  • Global relevance/ranking rewrite in one step.
  • Full absence diagnosis, which is tracked separately.

Activity

  1. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #220 on feature/feat/neighbor-candidates.

    Working scope:

    • add a substrate candidate model/selector for neighboring and near-duplicate conversations;
    • keep the output explanatory, not dedupe/merge authoritative;
    • expose the flow through archive operations plus CLI/MCP coverage;
    • cover same-title-different-body and nearby-similar-content cases in tests;
    • run focused query/storage/surface checks and final devtools verify before PR.

    Scratch log: .agent/scratch/220-neighbor-candidates.md.

  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Implementation log for this slice:

    • Added a shared neighbor-discovery substrate in polylogue/lib/neighbor_candidates.py with typed requests, ranked candidates, and evidence reasons.
    • Candidate reasons are explicit and non-authoritative: same_title, nearby_time, shared_attachment_identity, content_search, query_match, and content_similarity.
    • Kept content similarity body-based so same-title candidates do not get semantic credit from title text alone.
    • Added a conservative source-content FTS seed for known conversations, then still validates candidates with a separate token-overlap reason.
    • Wired the flow through archive operations, the root CLI command polylogue neighbors, the MCP tool neighbor_candidates, shared CLI/MCP payloads, generated help, and proof catalog surfaces.
    • Added tests for same-title-different-body, nearby similar content, distant content-similar candidates, query-seeded candidates, CLI JSON, MCP reason payloads, command registration, and help snapshots.

    Verification run locally:

    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 finished with verify: all checks passed.

  3. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    PR #364 follow-up after remote verification:

    • Remote showcase-verify failed on the first push because adding the root neighbors command changed the committed tier-0 help baseline and introduced a new help-neighbors showcase exercise output.
    • Refreshed the committed showcase baselines with devtools lab-scenario verify-baselines --update.
    • Added commit 3ac3237d (test: add neighbor command showcase baseline) with only tests/baselines/showcase/help-main.txt and tests/baselines/showcase/help-neighbors.txt.
    • Local verification after the fix:
      • devtools verify-showcase -> all baselines match.
      • pytest -q --ignore=tests/integration -> 5108 passed in 173.83s.
      • pre-push devtools verify --quick -> verify: all checks passed.

    Remaining action: wait for the refreshed PR checks to settle enough to confirm there are no real failures, then squash-merge #364.

  4. added a commit that references this issue on Apr 22, 2026
    d837ab1
  5. added a commit that references this issue on May 7, 2026
    2274fca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions