Skip to content

feat: clarify query paths and add read surfaces - #570

Merged
Sinity merged 4 commits into
masterfrom
feature/feat/interface-cleanup
May 1, 2026
Merged

Sinity merged 4 commits into
masterfrom
feature/feat/interface-cleanup

Conversation

@Sinity

@Sinity Sinity commented May 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Clarifies the query/read interface by splitting referenced-file filters from working-directory filters, adds dedicated paginated read surfaces, and folds in the completed post-close bot-review fixes.

Problem

The archive surfaces overloaded path terminology across referenced files and working-directory prefixes, recall workflows had to hydrate whole conversations to read messages, and the closed-issue bot-review audit had accumulated actionable correctness findings across CLI, MCP, storage, pipeline, schema, and devtools contracts.

Solution

  • Rename query-facing file-reference filters to referenced_path / --referenced-path / .referenced_path() while retaining cwd_prefix for working-directory filtering, and remove the old query path/path_terms surfaces.
  • Add consistent offset support and dedicated message/raw read surfaces across CLI and MCP, with get_conversation and conversation resources becoming header-only.
  • Add shared message-type classification and preserve summary/tool/thinking message types as queryable stored message facets.
  • Normalize MCP resources, MCP product tool schemas, generated references, docs, witnesses, and CLI baselines to match the new surfaces.
  • Address Post-hoc bot review audit: all closed issues and merged PRs #544/fix: resolve recent post-close bot review gaps #569 review findings around product filters, MCP signatures, payload Decimal handling, cost exactness, readiness checks, pipeline contracts, topology/proof/devtools checks, schema/operator handling, and query/test robustness.

Verification

pytest -q tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/devtools/test_coverage_gate.py tests/unit/devtools/test_verify_cross_cuts.py tests/unit/core/test_operator_annotations.py tests/unit/core/test_pricing.py tests/unit/sources/test_dispatch_payloads.py tests/unit/cli/test_products_command_runtime.py
# 135 passed in 13.98s

devtools verify --quick
# verify: all checks passed

devtools verify
# verify: all checks passed; pytest ok (194.7s)

git diff --check
# passed

pre-push hook
# devtools verify --quick passed

Closes #544
Closes #569

Summary by CodeRabbit

  • New Features

    • Message-type support across storage, APIs, CLI and payloads; content projection for message-level filtering; new diagnostics/messages/raw CLI verbs and pagination offset support
    • Blob-store JSON report included in check output
  • Changed

    • Renamed path filters to referenced-path across CLI and APIs; conversation reads split into summaries + paginated messages; DB schema version bumped; query and search readiness checks relaxed/tightened as appropriate
  • Documentation

    • CLI reference, help text, and API docs updated to reflect new flags and names

Problem: Query and read surfaces overloaded path semantics, forced whole-conversation hydration for recall workflows, and left post-close bot review findings unresolved across CLI, MCP, storage, schema, pipeline, and devtools surfaces.

What changed: Rename query-facing path filters to referenced_path while keeping cwd_prefix for working-directory scopes; add paginated message/raw read surfaces; normalize MCP resources and product tool schemas; preserve summary message types; tighten pagination, query, readiness, schema, pipeline, and topology contracts; and fold in the actionable Codex/Copilot audit findings tracked in #544 and #569.

Verification: devtools verify --quick passed. devtools verify passed, including pytest ok (194.7s). git diff --check passed.

Closes #544

Closes #569
Copilot AI review requested due to automatic review settings May 1, 2026 02:56
@coderabbitai

coderabbitai Bot commented May 1, 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 22 minutes and 30 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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: 933b4ee7-5165-41f5-9fe5-bb6d617e4d60

📥 Commits

Reviewing files that changed from the base of the PR and between fc981ce and 6e45aad.

📒 Files selected for processing (26)
  • devtools/verify_cross_cuts.py
  • polylogue/api/archive.py
  • polylogue/cli/query_progress.py
  • polylogue/lib/query/fields.py
  • polylogue/lib/query/runtime_filters.py
  • polylogue/lib/query/runtime_matching.py
  • polylogue/mcp/product_tool_contracts.py
  • polylogue/mcp/query_contracts.py
  • polylogue/mcp/server_maintenance_tools.py
  • polylogue/mcp/server_resources.py
  • polylogue/mcp/server_tools.py
  • polylogue/pipeline/materialization_runtime.py
  • polylogue/schemas/operator/annotations.py
  • polylogue/storage/backends/queries/conversations_search.py
  • polylogue/storage/backends/queries/filter_builder.py
  • polylogue/storage/backends/queries/message_query_reads.py
  • polylogue/storage/search/runtime.py
  • polylogue/surfaces/payloads.py
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/integration/test_cli_query_mode.py
  • tests/unit/cli/test_diagnostics.py
  • tests/unit/cli/test_query_progress_runtime.py
  • tests/unit/core/test_facade_api.py
  • tests/unit/devtools/test_topology_projection_witness.py
  • tests/unit/sources/test_dispatch_payloads.py
  • tests/unit/storage/test_message_query_reads.py
📝 Walkthrough

Walkthrough

This PR renames path-related filters to referenced_path, introduces a message_type concept across models/DB/queries, delegates message pagination/filtering to storage, tightens devtools/FTS/verification behaviors, and updates many CLI/docs/tests to align with these API and schema changes.

Changes

Cohort / File(s) Summary
Pre-commit & CI
\.githooks/pre-commit, .github/dependabot.yml, .github/workflows/ci.yml
Pre-commit hook: safer staged-path handling (null-delimited git diff -z, mapfile, pass quoted array, include R rename); Dependabot package-ecosystem changed to uv; CI step command adjusted.
Docs & Baselines
CHANGELOG.md, docs/*, tests/baselines/*, tests/unit/cli/__snapshots__/*
Update examples, API docs, CLI help baselines, topology/status markdown and generated verification catalog to reflect renamed filters, new options, and updated LOC/targets.
Query filter rename
polylogue/lib/query/..., polylogue/cli/..., polylogue/protocols.py, polylogue/storage/..., polylogue/lib/filter/builder.py
Systematic rename path_terms → referenced_path across spec/plan/runtime/matching/protocols/storage and associated exports; helper/function renames (e.g., matches_referenced_path).
MessageType core
polylogue/lib/message/types.py, polylogue/lib/message/models.py, polylogue/sources/parsers/base_models.py, polylogue/storage/runtime/archive/records.py, polylogue/surfaces/payloads.py
Add MessageType enum with normalization; add message_type field to Message/ParsedMessage/MessageRecord/payloads with validators and defaults.
MessageType propagation & reads
polylogue/operations/archive.py, polylogue/api/archive.py, polylogue/mcp/server_tools.py, polylogue/cli/messages.py
Move paginated message retrieval into operations layer (get_messages_paginated), include message_type in API payloads, and delegate filtering/pagination to storage.
Storage schema & queries
polylogue/storage/backends/schema_ddl.py, polylogue/storage/backends/schema_ddl_archive.py, polylogue/storage/backends/queries/*, polylogue/storage/fts/fts_lifecycle.py, polylogue/storage/backends/queries/message_query_reads.py, polylogue/storage/backends/queries/message_query_writes.py
Bump schema version; add message_type column and composite index; extend INSERT/UPSERT and read SQL to handle message_type; simplify FTS readiness signatures (exact_counts → verify_total_rows) and tighten readiness checks.
Pipeline & ingest
polylogue/pipeline/materialization_runtime.py, polylogue/pipeline/prepare_transform.py, polylogue/pipeline/services/ingest_batch.py, polylogue/pipeline/services/ingest_worker.py, polylogue/pipeline/semantic_capture.py
Materialization and ingest now populate message_type; tuple/record formats extended; semantic capture recognizes notebook_path; stronger upsert update gating.
Content projection
polylogue/lib/semantic/content_projection.py, polylogue/operations/archive.py
Add project_message_content to project per-message visibility and thread content-projection through operations paging.
MCP surfaces & tools
polylogue/mcp/server_resources.py, polylogue/mcp/server_product_tools.py, polylogue/mcp/server_prompts.py, polylogue/mcp/server_maintenance_tools.py
Resources return summary/list payloads; get_messages/tools use paginated ops; tool wrapper signatures improved; prompt summarization uses lazy islice; maintenance export supports offset.
CLI & product contracts
polylogue/cli/commands/products.py, polylogue/cli/shared/*, polylogue/cli/click_app.py
Normalize product query kwargs (provider, since, until) with validation and error type; message CLI includes message_type in outputs; error handling extended for new input error.
Devtools & verification fixes
devtools/render_topology_status.py, devtools/verify_cross_cuts.py, devtools/coverage_gate.py, devtools/verify.py, devtools/verify_migrations.py, devtools/affected_obligations.py
Refactor dashboard content generation; compute global target conflicts; tighten at-target/pending logic; add convention tag checks; reject boolean fail_under in coverage; argv fallback fix; route strict migration errors to stderr.
Schemas & utilities
polylogue/schemas/*, polylogue/sources/dispatch.py
Broaden JSON scalar handling, incremental session batching, distinguish empty JSON from missing, Decimal → numeric normalization for dispatch payloads, and resilient schema resolution fallbacks.
Tests added/updated
tests/unit/**, tests/integration/**, tests/data/witnesses/mcp-tool-schemas.json
Extensive test updates and additions exercising referenced_path rename, message types, content projection, pagination/offset, FTS readiness, topology checks, MCP tool schemas, CLI verbs (messages, raw), and numerous new baselines.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Client/CLI
    participant Spec as QuerySpec
    participant Plan as QueryPlan
    participant Runtime as RuntimeFilters
    participant Storage as Storage/DB
    participant Ops as Operations
    participant API as API/MCP

    CLI->>Spec: build_query_spec(referenced_path, message_type)
    Spec->>Plan: to_plan()
    Plan->>Runtime: apply_full_filters(plan)
    Runtime->>Storage: list_conversations(referenced_path, message_type)
    Storage->>Storage: SQL filter by referenced_path & message_type
    Storage-->>Runtime: conversations
    Runtime-->>CLI: filtered results

    CLI->>API: request get_messages_paginated(conversation_id, message_role, message_type, limit, offset, projection)
    API->>Ops: forward to operations
    Ops->>Storage: get_messages_paginated(..., content_projection)
    Storage->>Storage: SQL filters + LIMIT/OFFSET
    Storage-->>Ops: (messages, total)
    Ops->>Ops: project_message_content(messages)
    Ops-->>API: payload (messages, total)
    API-->>CLI: MCPMessagesListPayload
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~90 minutes

Possibly related PRs

Suggested labels

area:cli, area:mcp, area:storage, area:schema, area:qa, area:parser, tool:claude

Poem

🐰
Paths now whisper "referenced" in the glen,
Five message-types hop through code again,
Paginate at source, no post-filter stray,
Tests and docs aligned — we munch and play,
Carrots for CI, a tiny joyful spin.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/interface-cleanup

@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: b1c2a771a7

ℹ️ 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: CI still invoked the removed devtools verify-showcase command, so PR showcase verification failed even though the replacement lab-scenario surface is the supported baseline verifier.

What changed: Update the workflow to devtools lab-scenario verify-baselines and refresh the committed tier-0 showcase help baselines for the current CLI surface.

Verification: POLYLOGUE_FORCE_PLAIN=1 devtools lab-scenario verify-baselines --update; POLYLOGUE_FORCE_PLAIN=1 devtools lab-scenario verify-baselines.

@coderabbitai coderabbitai 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.

Actionable comments posted: 12

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
polylogue/storage/backends/queries/message_query_reads.py (1)

104-133: 🧹 Nitpick | 🔵 Trivial

Remove the unused _post_filter_by_message_type function.

This function is dead code—it's not called anywhere in the codebase, not exported in __all__, and the filtering it performed has been moved to SQL-level operations in get_messages_paginated.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/storage/backends/queries/message_query_reads.py` around lines 104 -
133, Delete the dead helper function _post_filter_by_message_type from the
module (remove its entire async def block) since it is unused and filtering is
now implemented in SQL; also clean up any now-unused imports or type references
in the same file (e.g., aiosqlite, MessageRecord) that were only used by that
function to avoid linter errors.
polylogue/storage/backends/queries/filter_builder.py (1)

112-120: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Normalize stored separators and escape wildcards in referenced_path SQL.

term is normalized to /, but path.value is only lowercased. That makes Windows paths stored as C:\repo\file.py miss this filter entirely. Also, _ and % in real file names are treated as LIKE wildcards here, so the new path surface can return false positives.

Suggested fix
     if referenced_path:
         for term in referenced_path:
-            normalized = str(term).replace("\\", "/").lower()
+            normalized = (
+                str(term)
+                .replace("\\", "/")
+                .lower()
+                .replace("%", "\\%")
+                .replace("_", "\\_")
+            )
             where_clauses.append(
                 f"EXISTS (SELECT 1 FROM action_events ae "
                 f"JOIN json_each(COALESCE(ae.affected_paths_json, '[]')) path "
-                f"WHERE ae.conversation_id = {conv_id_col} AND LOWER(path.value) LIKE ?)"
+                f"WHERE ae.conversation_id = {conv_id_col} "
+                f"AND REPLACE(LOWER(path.value), '\\\\', '/') LIKE ? ESCAPE '\\')"
             )
             params.append(f"%{normalized}%")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/storage/backends/queries/filter_builder.py` around lines 112 - 120,
Normalize separators in the SQL comparison and escape LIKE wildcards: update the
WHERE clause built in the referenced_path loop (where_clauses, params,
conv_id_col) to compare REPLACE(LOWER(path.value), '\\', '/') against the
parameter and add an ESCAPE clause, and when building params escape any '%' or
'_' in normalized (str(term).replace("\\", "/").lower()) before wrapping with %
for the LIKE pattern; keep the json_each join on action_events (ae) and ensure
the same escape character is used in both the SQL ESCAPE and the param escaping.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@devtools/verify_cross_cuts.py`:
- Around line 71-72: The guard currently uses
path.startswith("polylogue/ui/facade") which also matches names like
polylogue/ui/facade_helpers.py; update the conditional that sets
expected.setdefault("api", "async") to only match the actual facade
module/directory by checking for exact module or directory boundaries (e.g.
replace the startswith check with path == "polylogue/ui/facade" or path ==
"polylogue/ui/facade.py" or path.startswith("polylogue/ui/facade/")). Keep the
other branch (path.startswith("polylogue/api/")) unchanged and apply this change
to the conditional involving the variables path and expected in
verify_cross_cuts.py.

In `@polylogue/cli/query_progress.py`:
- Around line 161-165: In the except asyncio.CancelledError block inside
observe_slow_query, after cancelling task and notice_task you must await them to
drain their cleanup and capture any exceptions; replace the current immediate
raise with awaiting both cancelled tasks using asyncio.gather(task, notice_task,
return_exceptions=True) (only include notice_task if not None) and then re-raise
the CancelledError, mirroring the normal-path behavior that awaits cancelled
tasks to avoid unobserved exceptions.
- Around line 147-160: The code currently calls notice_task.result() directly in
observe_slow_query which will propagate exceptions from notice_factory and abort
the command; change this so failures from notice_factory are treated as
non-fatal: wrap the await/inspection of notice_task (the asyncio.Task returned
by notice_factory) in a try/except Exception block (or use contextlib.suppress)
and on exception log the error (use the module logger or click.echo on err) and
continue to await/return the main operation_task/task result; ensure you still
cancel notice_task if operation_task completes early. Also add a regression test
that makes notice_factory raise after the threshold and asserts
observe_slow_query returns the operation result despite the notice failure.

In `@polylogue/lib/query/fields.py`:
- Around line 625-638: The message_type field configuration is wired to durable
storage (record_attr and sql_param) but is still forcing post-hydration
filtering via requires_post_filter=True and requires_content_loading=True;
remove or set both requires_post_filter and requires_content_loading to False on
the message_type Field declaration so queries can be applied in SQL instead of
the post-filter/hydration path (leave record_attr/sql_param/storage_value
as-is); update any tests or callers that assumed post-filter behavior if
necessary.

In `@polylogue/lib/query/runtime_matching.py`:
- Around line 20-28: In matches_referenced_path, affected_paths are only
lowercased so Windows-style backslashes won't match plan.referenced_path; update
the construction of affected_paths (in the loop over
_action_events_for(conversation) for path in action.affected_paths) to normalize
separators like the CLI matcher (e.g., call path.lower().replace("\\", "/") or
equivalent) before using them in the final membership checks so comparisons use
unified "/"-separated, lowercased paths.

In `@polylogue/mcp/server_resources.py`:
- Around line 65-78: The payload currently echoes the caller's conv_id instead
of the resolved canonical id from get_conversation_summary; change the
MCPMessagesListPayload conversation_id to use the canonical id from the resolved
summary (e.g. summary.id or summary.conversation_id) instead of conv_id, keeping
the rest of the logic (calls to get_conversation_summary,
get_messages_paginated, and MCPMessagePayload.from_message) unchanged so the
returned payload contains the canonical conversation id.

In `@polylogue/pipeline/materialization_runtime.py`:
- Around line 265-271: The code currently treats messages with msg.role ==
"tool" as MessageType.TOOL_USE; change the branching so messages with msg.role
== "tool" are classified as MessageType.TOOL_RESULT instead. Specifically, in
the block that sets message_type (where MessageType.MESSAGE is handled and
block_types is inspected), ensure the check for "tool_result" or msg.role ==
"tool" sets message_type = MessageType.TOOL_RESULT, and keep "tool_use" only
tied to the presence of "tool_use" in block_types (so the clause referencing
"tool_use" no longer includes msg.role == "tool"). Update the conditions around
MessageType.TOOL_RESULT and MessageType.TOOL_USE to reflect this distinction.

In `@polylogue/schemas/operator/annotations.py`:
- Around line 58-61: The helper _string_list currently drops object/array enum
members by filtering only None, str, int, float, bool; update it so it preserves
structured JSON values (dicts, lists, etc.) when building enum coverage.
Specifically, keep the early guard (return [] if value is not a Sequence or is a
str/bytes/bytearray) but change the comprehension in _string_list to include any
item except bytes/bytearray (and still allow None), then stringify each item
with str(item) so objects/arrays contribute to total_enum_values and
values_count; reference function name _string_list and the existing
Sequence/isinstance checks when making this change.

In `@polylogue/surfaces/payloads.py`:
- Line 136: The nested getattr expression that computes message_type
(getattr(getattr(message, "message_type", "message"), "value", "message")) fails
when message.message_type is already a string; update the logic where
message_type is derived (the code using message.message_type in payload
construction) to first read raw_type = getattr(message, "message_type", None),
then set message_type = "message" if raw_type is None, elif hasattr(raw_type,
"value") use raw_type.value, else use str(raw_type); replace the single nested
getattr with this branching so both Enum and plain-string message_type values
are handled correctly.

In `@tests/data/witnesses/mcp-tool-schemas.json`:
- Around line 47-55: The published JSON schema allows negative pagination values
because the source argument models for the paginated endpoints expose "limit"
and "offset" as unconstrained integers; update those source models (the fields
named "limit" and "offset" used to generate these schemas) to add lower-bound
validation so the generated schema includes "minimum": set offset >= 0 and limit
>= 1; ensure the models' validators/field constraints (e.g., pydantic Field(...)
/ OpenAPI annotations) are updated wherever the paginated argument model is
defined so all generated schema occurrences (including the instances that
produced the JSON in tests/data/witnesses/mcp-tool-schemas.json and the other
listed ranges) emit the minimum constraints.

In `@tests/unit/devtools/test_topology_projection_witness.py`:
- Line 77: The set comprehension building file_owners treats missing keys and
empty strings the same; change it so missing owner keys default to "stable" but
empty-string owners remain "" (so they will be flagged as malformed later).
Update the comprehension that defines file_owners (currently using
item.get("owner") or "stable") to explicitly distinguish missing keys (e.g., use
item.get("owner", None") or check "owner" in item) and only substitute "stable"
when the key is absent, leaving empty strings untouched.

In `@tests/unit/sources/test_dispatch_payloads.py`:
- Line 13: The test asserts only value equality for _payload_sequence(payload)
which allows Decimal vs numeric regressions to slip; update the test to assert
the converted numeric types explicitly by checking that elements inside the
returned sequence have the expected numeric types (e.g., Decimal for precise
fields) and values — locate the helper/_payload_sequence function used in tests
and the test variable payload in tests/unit/sources/test_dispatch_payloads.py
and add assertions that the "whole" and "fraction" fields are instances of the
expected numeric class (and still equal the expected numeric values) rather than
relying on loose equality alone.

---

Outside diff comments:
In `@polylogue/storage/backends/queries/filter_builder.py`:
- Around line 112-120: Normalize separators in the SQL comparison and escape
LIKE wildcards: update the WHERE clause built in the referenced_path loop
(where_clauses, params, conv_id_col) to compare REPLACE(LOWER(path.value), '\\',
'/') against the parameter and add an ESCAPE clause, and when building params
escape any '%' or '_' in normalized (str(term).replace("\\", "/").lower())
before wrapping with % for the LIKE pattern; keep the json_each join on
action_events (ae) and ensure the same escape character is used in both the SQL
ESCAPE and the param escaping.

In `@polylogue/storage/backends/queries/message_query_reads.py`:
- Around line 104-133: Delete the dead helper function
_post_filter_by_message_type from the module (remove its entire async def block)
since it is unused and filtering is now implemented in SQL; also clean up any
now-unused imports or type references in the same file (e.g., aiosqlite,
MessageRecord) that were only used by that function to avoid linter errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5b400a28-b86d-4c57-ab15-f8a3e32e7f0d

📥 Commits

Reviewing files that changed from the base of the PR and between 1282bb6 and b1c2a77.

📒 Files selected for processing (113)
  • .githooks/pre-commit
  • .github/dependabot.yml
  • CHANGELOG.md
  • devtools/coverage_gate.py
  • devtools/render_topology_status.py
  • devtools/verify.py
  • devtools/verify_cross_cuts.py
  • devtools/verify_migrations.py
  • docs/cli-reference.md
  • docs/library-api.md
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/api/archive.py
  • polylogue/cli/click_app.py
  • polylogue/cli/commands/products.py
  • polylogue/cli/messages.py
  • polylogue/cli/query_progress.py
  • polylogue/cli/query_semantic.py
  • polylogue/cli/query_verbs.py
  • polylogue/cli/shared/check_models.py
  • polylogue/cli/shared/check_rendering_json.py
  • polylogue/cli/shared/check_workflow.py
  • polylogue/cli/shared/product_command_contracts.py
  • polylogue/lib/filter/builder.py
  • polylogue/lib/message/models.py
  • polylogue/lib/message/types.py
  • polylogue/lib/pricing.py
  • polylogue/lib/query/fields.py
  • polylogue/lib/query/plan.py
  • polylogue/lib/query/retrieval_candidates.py
  • polylogue/lib/query/runtime.py
  • polylogue/lib/query/runtime_filters.py
  • polylogue/lib/query/runtime_matching.py
  • polylogue/lib/query/spec.py
  • polylogue/lib/semantic/content_projection.py
  • polylogue/mcp/server_maintenance_tools.py
  • polylogue/mcp/server_product_tools.py
  • polylogue/mcp/server_prompts.py
  • polylogue/mcp/server_resources.py
  • polylogue/mcp/server_tools.py
  • polylogue/operations/archive.py
  • polylogue/pipeline/materialization_runtime.py
  • polylogue/pipeline/prepare_transform.py
  • polylogue/pipeline/run_execution.py
  • polylogue/pipeline/semantic_capture.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/pipeline/services/ingest_worker.py
  • polylogue/protocols.py
  • polylogue/schemas/operator/annotations.py
  • polylogue/schemas/runtime_registry.py
  • polylogue/schemas/sampling_sessions.py
  • polylogue/schemas/synthetic/build_wire_formats.py
  • polylogue/schemas/synthetic/relation_solver_runtime.py
  • polylogue/schemas/tooling_registry.py
  • polylogue/schemas/validator_resolution.py
  • polylogue/sources/dispatch.py
  • polylogue/sources/parsers/base_models.py
  • polylogue/sources/parsers/claude/code_parser.py
  • polylogue/storage/backends/queries/conversations_reads.py
  • polylogue/storage/backends/queries/conversations_search.py
  • polylogue/storage/backends/queries/filter_builder.py
  • polylogue/storage/backends/queries/mappers_archive.py
  • polylogue/storage/backends/queries/message_query_reads.py
  • polylogue/storage/backends/queries/message_query_writes.py
  • polylogue/storage/backends/queries/session_product_profile_reads.py
  • polylogue/storage/backends/schema_ddl.py
  • polylogue/storage/backends/schema_ddl_archive.py
  • polylogue/storage/fts/fts_lifecycle.py
  • polylogue/storage/hydrators.py
  • polylogue/storage/products/session/aggregates.py
  • polylogue/storage/products/session/records.py
  • polylogue/storage/query_models.py
  • polylogue/storage/repository/archive/queries.py
  • polylogue/storage/runtime/archive/records.py
  • polylogue/storage/search/runtime.py
  • polylogue/surfaces/payloads.py
  • tests/baselines/showcase/help-bulk-export.txt
  • tests/baselines/showcase/help-main.txt
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/infra/semantic_facts.py
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_check_support_runtime.py
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_products_command_runtime.py
  • tests/unit/cli/test_query_exec.py
  • tests/unit/cli/test_query_exec_laws.py
  • tests/unit/cli/test_query_progress_runtime.py
  • tests/unit/cli/test_query_support_runtime.py
  • tests/unit/core/test_operator_annotations.py
  • tests/unit/core/test_pricing.py
  • tests/unit/core/test_query_fields.py
  • tests/unit/core/test_schema_validation.py
  • tests/unit/devtools/test_coverage_gate.py
  • tests/unit/devtools/test_render_topology_status.py
  • tests/unit/devtools/test_topology_projection_witness.py
  • tests/unit/devtools/test_verify_cross_cuts.py
  • tests/unit/devtools/test_verify_migrations.py
  • tests/unit/lib/test_filter_executor.py
  • tests/unit/lib/test_query_runtime_filters.py
  • tests/unit/lib/test_query_runtime_matching.py
  • tests/unit/mcp/test_server_surfaces.py
  • tests/unit/mcp/test_tool_contracts.py
  • tests/unit/pipeline/test_differential_paths.py
  • tests/unit/pipeline/test_ingest_batch.py
  • tests/unit/pipeline/test_run_sources.py
  • tests/unit/proof/test_evidence_runners.py
  • tests/unit/sources/test_compaction.py
  • tests/unit/sources/test_dispatch_payloads.py
  • tests/unit/sources/test_parsers_base.py
  • tests/unit/storage/test_retrieval_readiness_laws.py
  • tests/unit/storage/test_scale.py
  • tests/unit/storage/test_store_ops.py
💤 Files with no reviewable changes (1)
  • polylogue/schemas/synthetic/build_wire_formats.py

Comment thread devtools/verify_cross_cuts.py Resolved
Comment thread polylogue/cli/query_progress.py Resolved
Comment thread polylogue/cli/query_progress.py Resolved
Comment thread polylogue/lib/query/fields.py Resolved
Comment thread polylogue/lib/query/runtime_matching.py Resolved
Comment thread polylogue/surfaces/payloads.py Resolved

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Problem: PR #570 exposed stale local and CI assumptions after the interface cleanup. Integration tests still exercised the retired configured inbox source, affected-obligations path mode still inspected the default master ref in shallow CI checkouts, and the new read helpers had gaps around partial-id resolution and filter ordering.

What changed: Route integration ingestion tests through explicit run --input paths, bypass ref inspection when affected-obligations receives explicit --path values, resolve conversation tokens before message/raw reads, and apply since-session filtering before message-type filtering. Added focused unit and integration coverage for the new messages/raw surfaces, diagnostics helpers, query normalizers, message types, run-state payloads, archive helpers, and message-query reads.

Verification: POLYLOGUE_FORCE_PLAIN=1 uv run pytest tests/unit/storage/test_run_state_models.py tests/unit/operations/test_archive_helpers.py tests/unit/core/test_message_types.py tests/unit/storage/test_message_query_reads.py tests/unit/cli/test_diagnostics.py tests/unit/cli/test_messages.py tests/unit/core/test_facade_api.py::TestPolylogueReadSurfaces -q; POLYLOGUE_FORCE_PLAIN=1 HYPOTHESIS_PROFILE=ci uv run devtools coverage-gate; POLYLOGUE_FORCE_PLAIN=1 uv run devtools verify --quick.

@coderabbitai coderabbitai 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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@polylogue/api/archive.py`:
- Around line 269-271: The method currently returns None when summary is
missing; instead return an empty paginated result to keep the shape consistent.
Replace the early return after calling await
self.operations.get_conversation_summary(conversation_id) so that when summary
is None the method returns an empty page (e.g., ([], 0)) — matching how
polylogue/operations/archive.py and get_raw_records_for_conversation normalize
unresolved conversation ids — so callers of this method don't need to
special-case None.

In `@polylogue/lib/query/runtime_filters.py`:
- Around line 148-149: The since_session_id filter is being applied to the
already-filtered results, so if earlier predicates removed the anchor
conversation the constraint is lost; change the logic to compute the
since-session set by calling _apply_since_session on the full conversations
collection (not results) when plan.since_session_id is present, then intersect
that returned set with the current results (e.g., replace results =
_apply_since_session(results, plan.since_session_id) with computing since_scope
= _apply_since_session(conversations, plan.since_session_id) and then set
results = results ∩ since_scope) so the since_session_id constraint survives
other filters.

In `@tests/integration/test_cli_query_mode.py`:
- Around line 113-123: The test currently only asserts payload["total"] == 1 but
not the returned array lengths, which can mask pagination regressions; update
the assertions around messages_payload and raw_payload (the block that uses
messages_payload, raw_result/run_cli, and raw_payload) to also assert
len(messages_payload["messages"]) == 1 and len(raw_payload["records"]) == 1,
keeping the existing checks for roles/text and raw_id so the test verifies both
reported totals and actual returned page sizes.

In `@tests/unit/cli/test_diagnostics.py`:
- Around line 116-119: The assertion is too broad because assert "2" in rendered
matches "1.2s"; update the test in tests/unit/cli/test_diagnostics.py to target
the turns cell specifically: after building rendered from
_console_print(env).call_args_list, locate the final data row (e.g.,
splitlines() and pick the last non-empty line) or parse the table columns and
assert the turns column equals "2" (or use a regex with word boundaries like
r"\b2\b") instead of a loose substring check; reference the rendered variable
and the _console_print(env) call to find where to change the assertion.

In `@tests/unit/storage/test_message_query_reads.py`:
- Around line 89-97: Add a test case that verifies pagination with a non-zero
offset when filtering by message_type: create at least two messages with
message_type="summary" in the "conv-message-reads" conversation, then call
get_messages_paginated(conn, "conv-message-reads", message_type="summary",
limit=1, offset=1) and assert that total equals the full count of "summary"
messages and that the single returned message is the second message's
message_id; this ensures get_messages_paginated applies the message_type filter
before LIMIT/OFFSET.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 925463fe-f559-4551-b66c-f7f7c8dd5bd7

📥 Commits

Reviewing files that changed from the base of the PR and between b1c2a77 and fc981ce.

📒 Files selected for processing (29)
  • .github/workflows/ci.yml
  • devtools/affected_obligations.py
  • polylogue/api/archive.py
  • polylogue/lib/query/runtime_filters.py
  • tests/baselines/showcase/help-bulk-export.txt
  • tests/baselines/showcase/help-diagnostics-pace.txt
  • tests/baselines/showcase/help-diagnostics-tools.txt
  • tests/baselines/showcase/help-diagnostics-turns.txt
  • tests/baselines/showcase/help-diagnostics.txt
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-messages.txt
  • tests/baselines/showcase/help-raw.txt
  • tests/baselines/showcase/help-run-publish.txt
  • tests/baselines/showcase/help-run.txt
  • tests/integration/test_chronology_extremes.py
  • tests/integration/test_cli_query_mode.py
  • tests/integration/test_ingestion_chaos.py
  • tests/integration/test_ingestion_interrupts.py
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_diagnostics.py
  • tests/unit/cli/test_messages.py
  • tests/unit/core/test_content_projection.py
  • tests/unit/core/test_facade_api.py
  • tests/unit/core/test_message_types.py
  • tests/unit/core/test_query_fields.py
  • tests/unit/lib/test_query_runtime_filters.py
  • tests/unit/operations/test_archive_helpers.py
  • tests/unit/storage/test_message_query_reads.py
  • tests/unit/storage/test_run_state_models.py

Comment thread polylogue/api/archive.py Resolved
Comment thread polylogue/lib/query/runtime_filters.py Resolved
Comment thread tests/unit/cli/test_diagnostics.py Resolved
Problem: CodeRabbit and Codex surfaced final correctness gaps on PR #570 after the CI fix push, including message-type SQL routing, since-session composition, canonical MCP ids, stricter MCP pagination schemas, FTS readiness, and slow-query cancellation/notice handling.

What changed: Keep message_type on the SQL-backed query path, compute since-session scope from the full candidate set, canonicalize MCP message/raw resource ids, add lower-bound MCP pagination schemas, restore full FTS readiness checks before search, harden path matching and LIKE escaping, classify tool-role messages as tool results, and remove the dead content-block post-filter helper. Added or tightened regression coverage for these review findings.

Verification: POLYLOGUE_FORCE_PLAIN=1 uv run pytest tests/unit/cli/test_query_progress_runtime.py tests/unit/devtools/test_verify_cross_cuts.py tests/unit/lib/test_query_runtime_matching.py tests/unit/lib/test_query_runtime_filters.py tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_tool_contracts.py tests/unit/pipeline/test_ingest_batch.py tests/unit/core/test_operator_annotations.py tests/unit/sources/test_dispatch_payloads.py tests/unit/storage/test_message_query_reads.py tests/integration/test_cli_query_mode.py::test_cli_messages_and_raw_routes_read_conversation_records tests/unit/cli/test_diagnostics.py tests/unit/core/test_facade_api.py::TestPolylogueReadSurfaces -q; POLYLOGUE_FORCE_PLAIN=1 HYPOTHESIS_PROFILE=ci uv run devtools coverage-gate; POLYLOGUE_FORCE_PLAIN=1 uv run devtools verify --quick; git diff --check.
@Sinity
Sinity merged commit a47ac85 into master May 1, 2026
14 checks passed
@Sinity
Sinity deleted the feature/feat/interface-cleanup branch May 1, 2026 05:05
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Clarifies the query/read interface by splitting referenced-file filters from working-directory filters, adds dedicated paginated read surfaces, and folds in the completed post-close bot-review fixes.

## Problem

The archive surfaces overloaded `path` terminology across referenced files and working-directory prefixes, recall workflows had to hydrate whole conversations to read messages, and the closed-issue bot-review audit had accumulated actionable correctness findings across CLI, MCP, storage, pipeline, schema, and devtools contracts.

## Solution

- Rename query-facing file-reference filters to `referenced_path` / `--referenced-path` / `.referenced_path()` while retaining `cwd_prefix` for working-directory filtering, and remove the old query `path`/`path_terms` surfaces.
- Add consistent `offset` support and dedicated message/raw read surfaces across CLI and MCP, with `get_conversation` and conversation resources becoming header-only.
- Add shared message-type classification and preserve summary/tool/thinking message types as queryable stored message facets.
- Normalize MCP resources, MCP product tool schemas, generated references, docs, witnesses, and CLI baselines to match the new surfaces.
- Address #544/#569 review findings around product filters, MCP signatures, payload Decimal handling, cost exactness, readiness checks, pipeline contracts, topology/proof/devtools checks, schema/operator handling, and query/test robustness.

## Verification

```text
pytest -q tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/devtools/test_coverage_gate.py tests/unit/devtools/test_verify_cross_cuts.py tests/unit/core/test_operator_annotations.py tests/unit/core/test_pricing.py tests/unit/sources/test_dispatch_payloads.py tests/unit/cli/test_products_command_runtime.py
# 135 passed in 13.98s

devtools verify --quick
# verify: all checks passed

devtools verify
# verify: all checks passed; pytest ok (194.7s)

git diff --check
# passed

pre-push hook
# devtools verify --quick passed
```

Closes #544
Closes #569


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Message-type support across storage, APIs, CLI and payloads; content projection for message-level filtering; new diagnostics/messages/raw CLI verbs and pagination offset support
  * Blob-store JSON report included in check output

* **Changed**
  * Renamed path filters to referenced-path across CLI and APIs; conversation reads split into summaries + paginated messages; DB schema version bumped; query and search readiness checks relaxed/tightened as appropriate

* **Documentation**
  * CLI reference, help text, and API docs updated to reflect new flags and names
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

## Final Verification

- `POLYLOGUE_FORCE_PLAIN=1 uv run pytest tests/unit/cli/test_query_progress_runtime.py tests/unit/devtools/test_verify_cross_cuts.py tests/unit/lib/test_query_runtime_matching.py tests/unit/lib/test_query_runtime_filters.py tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_tool_contracts.py tests/unit/pipeline/test_ingest_batch.py tests/unit/core/test_operator_annotations.py tests/unit/sources/test_dispatch_payloads.py tests/unit/storage/test_message_query_reads.py tests/integration/test_cli_query_mode.py::test_cli_messages_and_raw_routes_read_conversation_records tests/unit/cli/test_diagnostics.py tests/unit/core/test_facade_api.py::TestPolylogueReadSurfaces -q` — `158 passed`
- `POLYLOGUE_FORCE_PLAIN=1 HYPOTHESIS_PROFILE=ci uv run devtools coverage-gate` — `5937 passed, 2 xfailed`, coverage `90.05%`
- `POLYLOGUE_FORCE_PLAIN=1 uv run devtools verify --quick` — `verify: all checks passed`
- GitHub PR checks passed: lint, typecheck, showcase-verify, tests on Python 3.11/3.12/3.13, actionlint, Nix, CodeQL, GitGuardian, CodeRabbit, PR metadata.
@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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: resolve recent post-close bot review gaps Post-hoc bot review audit: all closed issues and merged PRs

2 participants