Skip to content

feat: add messages and raw query verbs across CLI, API, and MCP surfaces (#555) - #555

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/messages-raw-verbs
Apr 28, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/messages-raw-verbs

Conversation

@Sinity

@Sinity Sinity commented Apr 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Add messages and raw query verbs with full-stack wiring: CLI subcommands, Python API methods, and MCP tools.

Problem

No way to paginate through individual messages of a conversation or inspect raw provider records through any surface. The query chain also lacked message-type filtering and offset-based pagination.

Solution

  • CLI: New messages and raw subcommands with role/type filters, content projection (no-code-blocks, no-tool-calls, prose-only), and format options
  • API: PolylogueArchiveMixin.get_messages_paginated() and get_raw_records_for_conversation()
  • MCP: get_messages and raw_records tools with matching payloads
  • Query chain: --message-type filter, --offset pagination, --since-session for session-recall queries
  • Generated docs: CLI reference, topology, verification catalog updated

Verification

  • Pre-commit hooks pass (format + lint)
  • Full CI suite pending

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

New Features

  • Added --message-type filter to constrain results by message content categories (summary, tool_use, tool_result, thinking)
  • Added --since-session option to scope results based on a prior conversation ID within the same working directory
  • Added --offset parameter for pagination control
  • Added messages subcommand to view conversation messages with filtering, pagination, and output format options
  • Added raw subcommand to retrieve unprocessed provider records for conversations

Add paginated message listing and raw record inspection verbs, wired
through all three surfaces: CLI subcommands (messages, raw), Python API
(PolylogueArchiveMixin), and MCP tools (get_messages, raw_records).

Also adds --message-type filter, --offset pagination, and --since-session
to the conversation query chain.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2f8c8e82-b835-4bdf-ad41-7ab70a675132

📥 Commits

Reviewing files that changed from the base of the PR and between 4ac1571 and dfec8c6.

📒 Files selected for processing (35)
  • docs/cli-reference.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/api/archive.py
  • polylogue/cli/click_app.py
  • polylogue/cli/click_option_groups.py
  • polylogue/cli/messages.py
  • polylogue/cli/query_verbs.py
  • polylogue/lib/filter/builder.py
  • polylogue/lib/query/fields.py
  • polylogue/lib/query/plan.py
  • polylogue/lib/query/runtime_filters.py
  • polylogue/lib/query/spec.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/query_contracts.py
  • polylogue/mcp/server_resources.py
  • polylogue/mcp/server_tools.py
  • polylogue/operations/archive.py
  • polylogue/protocols.py
  • polylogue/storage/backends/async_sqlite_archive.py
  • polylogue/storage/backends/async_sqlite_raw.py
  • polylogue/storage/backends/queries/message_query_reads.py
  • polylogue/storage/backends/queries/messages.py
  • polylogue/storage/backends/queries/raw.py
  • polylogue/storage/backends/queries/raw_reads.py
  • polylogue/storage/backends/query_store_archive.py
  • polylogue/storage/backends/query_store_maintenance.py
  • polylogue/storage/query_models.py
  • polylogue/storage/repository/archive/conversations.py
  • polylogue/storage/repository/raw/repository_raw.py
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py

📝 Walkthrough

Walkthrough

The PR extends the CLI with new query filters (--message-type, --since-session, --offset) and introduces two new top-level commands: messages to display paginated conversation messages, and raw to display unprocessed provider records. Supporting changes thread these capabilities through API, storage query, and MCP integration layers.

Changes

Cohort / File(s) Summary
CLI Command & Options
polylogue/cli/click_app.py, polylogue/cli/click_option_groups.py, polylogue/cli/query_verbs.py, polylogue/cli/messages.py
New top-level commands (messages, raw) with supporting Click options for message/type filtering, session-scoping, and offset-based pagination. run_messages and run_raw entry points handle output formatting (JSON, YAML, plaintext) and message projection controls.
API Facade Layer
polylogue/api/archive.py, polylogue/operations/archive.py, polylogue/protocols.py
New archive mixin methods get_messages_paginated and get_raw_records_for_conversation with role/type filtering and pagination. Protocol definition updated to specify paginated query contracts returning (items, total) tuples.
Query Plan & Filter Infrastructure
polylogue/lib/query/plan.py, polylogue/lib/query/spec.py, polylogue/lib/query/fields.py, polylogue/lib/filter/builder.py, polylogue/lib/query/runtime_filters.py
Extended ConversationQueryPlan and ConversationQuerySpec with new fields (since_session_id, message_type, offset). New runtime filter logic for session-boundary constraints and builder methods for fluent construction.
SQLite Storage Backends
polylogue/storage/backends/async_sqlite_archive.py, polylogue/storage/backends/async_sqlite_raw.py, polylogue/storage/backends/query_store_archive.py, polylogue/storage/backends/query_store_maintenance.py
Async mixin methods wrapping paginated queries, delegating to query layer and hydrating message/raw-record structures with metadata.
Storage Query Layer
polylogue/storage/backends/queries/message_query_reads.py, polylogue/storage/backends/queries/raw_reads.py, polylogue/storage/backends/queries/messages.py, polylogue/storage/backends/queries/raw.py
New paginated SQL read helpers with message-type-to-column mappings, post-filtering for content blocks, and raw-record lookups. Exports updated to surface new query functions.
Storage Models & Repository
polylogue/storage/query_models.py, polylogue/storage/repository/archive/conversations.py, polylogue/storage/repository/raw/repository_raw.py
ConversationRecordQuery extended with new filter fields. Repository mixins introduce get_messages_paginated and get_raw_records_for_conversation to hydrate domain objects from storage queries.
MCP Integration
polylogue/mcp/payloads.py, polylogue/mcp/query_contracts.py, polylogue/mcp/server_resources.py, polylogue/mcp/server_tools.py
New MCP payload models for message/raw-record lists. Query request contract extended with new filter parameters. New MCP tools (get_messages, raw_records) and resources (polylogue://messages/{conv_id}, polylogue://session-tree/{conv_id}, polylogue://provider/{name}/recent) for external tool consumers.
Tests & Documentation
tests/data/witnesses/mcp-tool-schemas.json, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr, tests/unit/cli/test_click_app.py, docs/...
Tool schema witness updated with new tool/parameter definitions. CLI snapshot tests adjusted for new commands/options. Documentation files (topology, verification catalog, test workflows) updated to reflect expanded surface area.

Sequence Diagram

sequenceDiagram
    participant User as CLI/MCP User
    participant CLI as CLI/MCP Handler
    participant API as API Facade<br/>(archive.py)
    participant QueryLayer as Query Layer<br/>(runtime_filters.py)
    participant Storage as Storage Backend<br/>(async_sqlite_*)
    participant DB as SQLite DB

    User->>CLI: messages/raw query<br/>(with filters & pagination)
    CLI->>API: get_messages_paginated<br/>or<br/>get_raw_records_for_conversation
    activate API
    API->>QueryLayer: apply_full_filters<br/>(since_session_id, message_type)
    activate QueryLayer
    QueryLayer->>Storage: Filtered conversation lookup
    Storage->>DB: Query conversations<br/>by timestamp/session boundary
    DB-->>Storage: Matching conversation IDs
    Storage-->>QueryLayer: Filtered result set
    deactivate QueryLayer
    
    API->>Storage: get_messages_paginated<br/>or get_raw_records_for_conversation<br/>(limit, offset)
    activate Storage
    Storage->>DB: Paginated message/raw query<br/>(with role/type filters)
    DB-->>Storage: Page + total count
    Storage-->>API: (items: list, total: int)
    deactivate Storage
    
    API->>API: Hydrate Message/RawRecord<br/>objects + content blocks
    API-->>CLI: Paginated results
    deactivate API
    
    CLI->>CLI: Format output<br/>(JSON/YAML/plaintext)
    CLI-->>User: Displayed results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

area:cli, area:storage, area:query, type:feature, scope:api

Poem

🐰 Hopping through conversations with newfound glee,
Messages paginated, raw records set free!
Session-scoped filters and offset delight,
The CLI hops higher, reaching new height!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/messages-raw-verbs
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch feature/feat/messages-raw-verbs

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@Sinity
Sinity merged commit 9cce9e8 into master Apr 28, 2026
6 of 11 checks passed
@Sinity
Sinity deleted the feature/feat/messages-raw-verbs branch April 28, 2026 08:05

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

ℹ️ 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/lib/query/fields.py Resolved
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:55
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:20
Sinity added a commit that referenced this pull request May 7, 2026
…ces (#555)

## Summary
Add `messages` and `raw` query verbs with full-stack wiring: CLI
subcommands, Python API methods, and MCP tools.

## Problem
No way to paginate through individual messages of a conversation or
inspect raw provider records through any surface. The query chain also
lacked message-type filtering and offset-based pagination.

## Solution
- **CLI**: New `messages` and `raw` subcommands with role/type filters,
content projection (no-code-blocks, no-tool-calls, prose-only), and
format options
- **API**: `PolylogueArchiveMixin.get_messages_paginated()` and
`get_raw_records_for_conversation()`
- **MCP**: `get_messages` and `raw_records` tools with matching payloads
- **Query chain**: `--message-type` filter, `--offset` pagination,
`--since-session` for session-recall queries
- **Generated docs**: CLI reference, topology, verification catalog
updated

## Verification
- Pre-commit hooks pass (format + lint)
- Full CI suite pending

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 <[email protected]>
@Sinity

Sinity commented Sep 30, 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.

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

1 participant