Skip to content

fix: close remaining gaps — FK doc, MCP cursor (#819/#820) - #906

Merged
Sinity merged 2 commits into
masterfrom
feature/fix/close-genuinely-close
May 7, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/fix/close-genuinely-close

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026 •

Copy link
Copy Markdown
Owner

#819: next_offset cursor. #820: explicit ON DELETE NO ACTION in DDL.

Summary by CodeRabbit

New Features

  • Pagination for query and search results now includes next offset information, enabling efficient sequential navigation through large datasets

Chores

  • Enhanced database schema with explicit deletion constraints to ensure data consistency

Sinity and others added 2 commits May 7, 2026 14:40
- #820: add explicit ON DELETE NO ACTION to parent_message_id FK
- #819: add next_offset cursor to paginated MCP envelopes

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 7, 2026 12:43
@Sinity
Sinity merged commit 92f2335 into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/close-genuinely-close branch May 7, 2026 12:43
@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

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: 4744e0c8-6ce9-4f96-8a45-cba5d2862cbb

📥 Commits

Reviewing files that changed from the base of the PR and between ef669fc and 9f9cc8f.

📒 Files selected for processing (2)
  • polylogue/mcp/payloads.py
  • polylogue/storage/sqlite/schema_ddl_archive.py

📝 Walkthrough

Walkthrough

This PR adds pagination support to MCP response payloads and updates SQLite schema constraints. The first change enriches MCPPaginatedQueryResultPayload and MCPPaginatedSearchResultPayload with an optional next_offset field, computed by factory functions based on page fullness and remaining results. The second change explicitly specifies ON DELETE NO ACTION for the messages table foreign key constraint in the archive schema DDL.

Changes

Pagination Support in MCP Payloads

Layer / File(s) Summary
Payload Data Contracts
polylogue/mcp/payloads.py
MCPPaginatedQueryResultPayload and MCPPaginatedSearchResultPayload add optional next_offset: int | None field defaulting to None.
Offset Computation
polylogue/mcp/payloads.py
conversation_query_result_payload and conversation_search_result_payload compute next_offset when the page is full (len(items/hits) == limit) and more results remain (offset + limit < total), then pass the value to payload constructors.

SQLite Schema Constraint Update

Layer / File(s) Summary
Foreign Key Constraint
polylogue/storage/sqlite/schema_ddl_archive.py
Messages table parent_message_id foreign key constraint now explicitly specifies ON DELETE NO ACTION instead of leaving the delete behavior unspecified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hopping through pages with offset in sight,
Pagination fields shine ever so bright,
Constraints held steady, no deletes run free,
The schema and payloads now dance in harmony!

✨ 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/fix/close-genuinely-close

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.

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.

Pull request overview

Closes remaining gaps from #819 and #820 by (1) making the archive schema’s self-referential messages.parent_message_id FK delete policy explicit, and (2) extending MCP paginated result envelopes with a next_offset cursor for page continuation.

Changes:

  • Add explicit ON DELETE NO ACTION to the messages.parent_message_id foreign key in archive DDL.
  • Add next_offset to MCP paginated list/search payloads and populate it in payload builders.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
polylogue/storage/sqlite/schema_ddl_archive.py Makes the parent_message_id FK delete policy explicit in the archive schema DDL.
polylogue/mcp/payloads.py Adds next_offset to paginated MCP result payloads and computes it for list/search responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread polylogue/mcp/payloads.py
offset: int,
diagnostics: QueryMissDiagnostics | None = None,
) -> MCPPaginatedQueryResultPayload:
next_offset = offset + len(conversations) if len(conversations) == limit and offset + limit < total else None
Comment thread polylogue/mcp/payloads.py
Comment on lines +160 to 161
next_offset: int | None = None
diagnostics: MCPQueryMissDiagnosticsPayload | None = None
Sinity added a commit that referenced this pull request May 7, 2026
- #819 (MCP envelopes): `polylogue/mcp/payloads.py` returns a
  populated `next_offset` cursor on paginated responses so MCP
  clients can iterate without recomputing offsets, completing
  the pagination contract introduced in PR #897.
- #820 (storage integrity): `storage/sqlite/schema_ddl_archive.py`
  switches the message-FK policy from implicit to explicit
  `ON DELETE NO ACTION`, matching the documented invariant in
  the schema docstrings rather than relying on SQLite's default.

Refs #819, #820
Sinity added a commit that referenced this pull request May 7, 2026
- #819 (MCP envelopes): `polylogue/mcp/payloads.py` returns a
  populated `next_offset` cursor on paginated responses so MCP
  clients can iterate without recomputing offsets, completing
  the pagination contract introduced in PR #897.
- #820 (storage integrity): `storage/sqlite/schema_ddl_archive.py`
  switches the message-FK policy from implicit to explicit
  `ON DELETE NO ACTION`, matching the documented invariant in
  the schema docstrings rather than relying on SQLite's default.

Refs #819, #820
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.

2 participants