Skip to content

feat: diagnose query misses - #358

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/query-miss-diagnostics
Apr 22, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/query-miss-diagnostics

Conversation

@Sinity

@Sinity Sinity commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a shared query-miss diagnostic model for empty query results.
  • Surfaces observed no-result causes in CLI plain/JSON output and MCP search/list responses.
  • Covers empty archive scopes, raw-ingest backlog, message FTS readiness, and action-event read-model readiness.

Closes #217

Problem

Query and MCP no-result paths previously collapsed several distinct operator states into a generic empty result. That made an absent match look the same as an empty archive, an unbuilt/degraded index, an action read-model gap, or raw ingested data that had not reached materialized conversations.

Solution

  • Added polylogue/lib/query_miss_diagnostics.py as the shared diagnostic builder over observable archive stats, raw conversation counts, readiness checks, and action-event artifact state.
  • Threaded diagnostics through CLI no-result emitters and machine-error details without changing the existing successful output shape.
  • Added MCP empty-result payloads with results: [] plus structured diagnostics while preserving the existing root-list payload for successful search/list calls.
  • Exposed ArchiveSearchMixin.diagnose_query_miss() so MCP and other archive operation surfaces can reuse the same semantics.
  • Added focused unit coverage for archive-empty, raw-backlog, degraded message FTS, degraded action readiness, CLI diagnostics, and MCP diagnostics.

Verification

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
devtools verify

Pre-push also ran devtools verify --quick through the repository hook.

@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 58 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 58 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dfd605f8-4875-4d08-8a6b-2e9bace7089c

📥 Commits

Reviewing files that changed from the base of the PR and between 8efbde0 and 1dd2303.

📒 Files selected for processing (11)
  • polylogue/cli/machine_errors.py
  • polylogue/cli/query.py
  • polylogue/cli/query_feedback.py
  • polylogue/cli/query_output.py
  • polylogue/lib/query_miss_diagnostics.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/server_tools.py
  • polylogue/operations/archive.py
  • tests/unit/cli/test_query_exec_laws.py
  • tests/unit/lib/test_query_miss_diagnostics.py
  • tests/unit/mcp/test_tool_contracts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/query-miss-diagnostics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit c18be53 into master Apr 22, 2026
12 checks passed
@Sinity
Sinity deleted the feature/feat/query-miss-diagnostics branch April 22, 2026 11:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1dd2303245

ℹ️ 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".

Comment thread polylogue/mcp/server_tools.py Resolved
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary

- Adds a shared query-miss diagnostic model for empty query results.
- Surfaces observed no-result causes in CLI plain/JSON output and MCP search/list responses.
- Covers empty archive scopes, raw-ingest backlog, message FTS readiness, and action-event read-model readiness.

Closes #217

## Problem

Query and MCP no-result paths previously collapsed several distinct operator states into a generic empty result. That made an absent match look the same as an empty archive, an unbuilt/degraded index, an action read-model gap, or raw ingested data that had not reached materialized conversations.

## Solution

- Added `polylogue/lib/query_miss_diagnostics.py` as the shared diagnostic builder over observable archive stats, raw conversation counts, readiness checks, and action-event artifact state.
- Threaded diagnostics through CLI no-result emitters and machine-error details without changing the existing successful output shape.
- Added MCP empty-result payloads with `results: []` plus structured diagnostics while preserving the existing root-list payload for successful search/list calls.
- Exposed `ArchiveSearchMixin.diagnose_query_miss()` so MCP and other archive operation surfaces can reuse the same semantics.
- Added focused unit coverage for archive-empty, raw-backlog, degraded message FTS, degraded action readiness, CLI diagnostics, and MCP diagnostics.

## Verification

```bash
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
devtools verify
```

Pre-push also ran `devtools verify --quick` through the repository hook.
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary

- Adds a shared query-miss diagnostic model for empty query results.
- Surfaces observed no-result causes in CLI plain/JSON output and MCP search/list responses.
- Covers empty archive scopes, raw-ingest backlog, message FTS readiness, and action-event read-model readiness.

Closes #217

## Problem

Query and MCP no-result paths previously collapsed several distinct operator states into a generic empty result. That made an absent match look the same as an empty archive, an unbuilt/degraded index, an action read-model gap, or raw ingested data that had not reached materialized conversations.

## Solution

- Added `polylogue/lib/query_miss_diagnostics.py` as the shared diagnostic builder over observable archive stats, raw conversation counts, readiness checks, and action-event artifact state.
- Threaded diagnostics through CLI no-result emitters and machine-error details without changing the existing successful output shape.
- Added MCP empty-result payloads with `results: []` plus structured diagnostics while preserving the existing root-list payload for successful search/list calls.
- Exposed `ArchiveSearchMixin.diagnose_query_miss()` so MCP and other archive operation surfaces can reuse the same semantics.
- Added focused unit coverage for archive-empty, raw-backlog, degraded message FTS, degraded action readiness, CLI diagnostics, and MCP diagnostics.

## Verification

```bash
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
devtools verify
```

Pre-push also ran `devtools verify --quick` through the repository hook.
Sinity added a commit that referenced this pull request Apr 22, 2026
Query and MCP no-result paths previously collapsed several distinct
operator states into a generic empty result. An absent match looked
the same as an empty archive, an unbuilt or degraded index, an
action read-model gap, or raw ingested data that hadn't reached
materialized conversations. Users saw "no results" and couldn't
tell which.

Adds a shared query-miss diagnostic model in
`polylogue/lib/query_miss_diagnostics.py` built over observable
archive stats, raw conversation counts, readiness checks, and
action-event artifact state. The diagnostic surfaces the observed
no-result cause: empty archive scope, raw-ingest backlog, message
FTS readiness, or action-event read-model readiness. CLI
plain/JSON output and MCP search/list responses now emit the
diagnostic on empty results; the existing successful-result shape
is unchanged so callers don't see breakage. Exposes
`ArchiveSearchMixin.diagnose_query_miss()` so MCP and other archive
operation surfaces can reuse the semantics.

Unit coverage added for each diagnostic state and both CLI and MCP
surfaces.

Verification: ruff + mypy + pytest over query_miss_diagnostics /
query-exec-laws / mcp-tool-contracts suites; devtools verify green.

Closes #217
Sinity added a commit that referenced this pull request Apr 22, 2026
Query and MCP no-result paths previously collapsed several distinct
operator states into a generic empty result. An absent match looked
the same as an empty archive, an unbuilt or degraded index, an
action read-model gap, or raw ingested data that hadn't reached
materialized conversations. Users saw "no results" and couldn't
tell which.

Adds a shared query-miss diagnostic model in
`polylogue/lib/query_miss_diagnostics.py` built over observable
archive stats, raw conversation counts, readiness checks, and
action-event artifact state. The diagnostic surfaces the observed
no-result cause: empty archive scope, raw-ingest backlog, message
FTS readiness, or action-event read-model readiness. CLI
plain/JSON output and MCP search/list responses now emit the
diagnostic on empty results; the existing successful-result shape
is unchanged so callers don't see breakage. Exposes
`ArchiveSearchMixin.diagnose_query_miss()` so MCP and other archive
operation surfaces can reuse the semantics.

Unit coverage added for each diagnostic state and both CLI and MCP
surfaces.

Verification: ruff + mypy + pytest over query_miss_diagnostics /
query-exec-laws / mcp-tool-contracts suites; devtools verify green.

Closes #217
Sinity added a commit that referenced this pull request Apr 22, 2026
Query and MCP no-result paths previously collapsed several distinct
operator states into a generic empty result. An absent match looked
the same as an empty archive, an unbuilt or degraded index, an
action read-model gap, or raw ingested data that hadn't reached
materialized conversations. Users saw "no results" and couldn't
tell which.

Adds a shared query-miss diagnostic model in
`polylogue/lib/query_miss_diagnostics.py` built over observable
archive stats, raw conversation counts, readiness checks, and
action-event artifact state. The diagnostic surfaces the observed
no-result cause: empty archive scope, raw-ingest backlog, message
FTS readiness, or action-event read-model readiness. CLI
plain/JSON output and MCP search/list responses now emit the
diagnostic on empty results; the existing successful-result shape
is unchanged so callers don't see breakage. Exposes
`ArchiveSearchMixin.diagnose_query_miss()` so MCP and other archive
operation surfaces can reuse the semantics.

Unit coverage added for each diagnostic state and both CLI and MCP
surfaces.

Verification: ruff + mypy + pytest over query_miss_diagnostics /
query-exec-laws / mcp-tool-contracts suites; devtools verify green.

Closes #217
@Sinity
Sinity requested review from Copilot and removed request for Copilot May 1, 2026 00:44
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 68.F020 / P1: fixed-already at the checked revision: polylogue/mcp/archive_support.py:542-543 returns no predicate-probe diagnostics when config is unset instead of dereferencing it. The empty-result payload can therefore be built without triggering the retired ArchiveOperations configuration error.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: diagnose archive absence and degraded retrieval states

1 participant