Skip to content

feat: diagnose archive absence and degraded retrieval states #217

Closed

Description

@Sinity

Outcome

When a query returns no hits, Polylogue should help the user understand which of several states they are in instead of flattening them into a single ambiguous miss.

Desired diagnosable outcomes include cases such as:

  • not in archive
  • source or raw artifact known but not parsed or not materialized
  • index or read model not ready
  • degraded fallback path used
  • possible near match exists but did not satisfy the current query

Problem or opportunity

polylogue/cli/query.py currently reports "No conversations matched filters" and a generic broadening hint. That message does not tell the user whether the conversation is truly absent, not yet ingested, or simply not matched by the current search/index formulation.

The repository already has much of the diagnostic substrate:

  • raw parse and validation state in polylogue/storage/raw_ingest_artifacts.py and polylogue/storage/state_views.py
  • index and readiness state in polylogue/health.py
  • action-read-model readiness and fallback behavior in polylogue/lib/query_retrieval_candidates.py and polylogue/lib/query_retrieval_search.py

The missing piece is surfacing that state coherently at the user-facing retrieval boundary.

Expected scope

  • polylogue/cli/query.py
  • polylogue/mcp/server_tools.py
  • polylogue/mcp/payloads.py
  • polylogue/health.py
  • polylogue/lib/query_retrieval_candidates.py
  • polylogue/lib/query_retrieval_search.py
  • raw-ingest and derived-status read helpers as needed
  • tests for no-result and degraded-path reporting

Constraints and invariants

  • Only report states that Polylogue can actually observe. Do not claim global archive absence beyond available evidence.
  • Distinguish archive absence from degraded retrieval or incomplete ingest; do not conflate them.
  • Keep machine-readable diagnostics available for MCP and deterministic surfaces.
  • Avoid overly chatty default output that obscures the main result when a query does succeed.

Acceptance criteria

  • Query/no-result handling can distinguish between at least archive miss, degraded index/read-model state, and observed raw-ingest backlog when the evidence exists.
  • MCP surfaces can return structured no-result diagnostics instead of only an empty list or generic not-found response.
  • CLI exposes clearer guidance about why a query may have missed.
  • Tests cover degraded FTS/action-readiness and raw-ingest-backed diagnostic cases.

Verification plan

  • add unit coverage for no_results/diagnostic rendering
  • add MCP contract tests for structured miss diagnostics
  • add tests that simulate incomplete FTS or action-event readiness
  • run devtools verify

Context and evidence

Relevant files:

  • polylogue/cli/query.py
  • polylogue/health.py
  • polylogue/storage/raw_ingest_artifacts.py
  • polylogue/storage/state_views.py
  • polylogue/lib/query_retrieval_candidates.py
  • polylogue/lib/query_retrieval_search.py

Non-goals or explicitly deferred work

  • General search relevance tuning.
  • Full neighboring-conversation exploration UX.
  • Reworking archive health/readiness naming across the entire repo.

Activity

  1. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #217 on feature/feat/query-miss-diagnostics.

    Tactic for this PR:

    • Map the existing CLI query and MCP retrieval payload paths first.
    • Add one shared no-result diagnostic model/builder consumed by both surfaces.
    • Only report states backed by observable archive evidence: empty/missing archive rows, readiness/degraded retrieval state, and raw-ingest backlog.
    • Keep successful query output quiet; diagnostics should appear primarily on misses.
    • Add focused CLI/MCP/storage tests, then run the full local baseline before PR.
  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Progress update for #217:

    • Added a shared query-miss diagnostic model/builder that observes archive stats, raw conversation counts, message FTS readiness, and action-event read-model readiness.
    • Wired CLI no-result output so plain output includes concise observed causes and JSON output includes diagnostics under the existing machine-error details envelope.
    • Wired MCP search/list empty results to return a structured object with results: [] and diagnostics while preserving the existing root-list payload for successful results.
    • Added focused tests for empty archive scope, raw-ingest backlog, degraded action read model, degraded message FTS readiness, CLI diagnostic output, and MCP empty-result diagnostics.

    Local checks so far:

    ruff check polylogue/lib/query_miss_diagnostics.py polylogue/cli/query.py polylogue/cli/query_feedback.py polylogue/cli/machine_errors.py polylogue/cli/query_output.py polylogue/mcp/payloads.py polylogue/mcp/server_tools.py polylogue/operations/archive.py tests/unit/lib/test_query_miss_diagnostics.py tests/unit/cli/test_query_exec_laws.py tests/unit/mcp/test_tool_contracts.py
    mypy polylogue/lib/query_miss_diagnostics.py polylogue/cli/query.py polylogue/cli/query_feedback.py polylogue/cli/query_output.py polylogue/mcp/payloads.py polylogue/mcp/server_tools.py polylogue/operations/archive.py tests/unit/lib/test_query_miss_diagnostics.py tests/unit/cli/test_query_exec_laws.py tests/unit/mcp/test_tool_contracts.py
    pytest -q tests/unit/lib/test_query_miss_diagnostics.py tests/unit/cli/test_query_exec_laws.py tests/unit/mcp/test_tool_contracts.py

    Next: run the repository verification baseline, then commit/PR if it stays green.

  3. added 5 commits that reference this issue on Apr 22, 2026
    e4a6899
    818ecc4
    91ea52c
    ab1955f
    d1ea50e
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