Skip to content

feat(api): formalize Polylogue as canonical surface, rewire CLI+MCP adapters (#723, #578) - #764

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/api-formalization
May 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/api-formalization

Conversation

@Sinity

@Sinity Sinity commented May 3, 2026 •

Copy link
Copy Markdown
Owner

13 new API methods. CLI verbs (export/neighbors/tags) switched from ops to API. MCP tools rewired from ArchiveOperations to Polylogue. Type fixes. Drift cleanup.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added conversation discovery features including neighbor/near-duplicate candidate discovery and session tree retrieval.
    • Added tag management and conversation metadata operations.
    • Added conversation statistics and summary retrieval.
  • Bug Fixes

    • Improved error handling for missing conversations with explicit error reporting.
  • API Changes

    • Message retrieval now returns structured message objects instead of dictionary representations.

Copilot AI review requested due to automatic review settings May 3, 2026 15:58
@Sinity
Sinity merged commit f0c5e1d into master May 3, 2026
@Sinity
Sinity deleted the feature/feat/api-formalization branch May 3, 2026 15:58
@coderabbitai

coderabbitai Bot commented May 3, 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: 023e9c97-98a4-4d98-8c12-1c41e38c9e5e

📥 Commits

Reviewing files that changed from the base of the PR and between 47590af and f7427d1.

📒 Files selected for processing (16)
  • polylogue/api/archive.py
  • polylogue/cli/commands/export.py
  • polylogue/cli/commands/neighbors.py
  • polylogue/cli/commands/tags.py
  • polylogue/cli/messages.py
  • polylogue/cli/shared/types.py
  • polylogue/daemon/http.py
  • polylogue/mcp/server.py
  • polylogue/mcp/server_insight_tools.py
  • polylogue/mcp/server_maintenance_tools.py
  • polylogue/mcp/server_mutation_tools.py
  • polylogue/mcp/server_support.py
  • polylogue/mcp/server_tools.py
  • tests/infra/mcp.py
  • tests/unit/mcp/test_server_surfaces.py
  • tests/unit/mcp/test_tool_contracts.py

📝 Walkthrough

Walkthrough

This PR introduces a higher-level Polylogue facade API by extending PolylogueArchiveMixin with new methods for conversation stats, neighbor discovery, session trees, and tag/metadata management. The PR wires CLI commands, HTTP daemon, and MCP tools to use the new facade instead of directly accessing lower-level stores and operations.

Changes

Facade API Extension and Integration

Layer / File(s) Summary
Error Type & API Signatures
polylogue/api/archive.py
New ConversationNotFoundError exception. get_messages_paginated return type changes from list[dict] to list[Message], and now raises the error when conversation is missing instead of returning empty results. Ten new methods added to PolylogueArchiveMixin for conversation summary, stats, neighbor candidates, session tree, tags, and metadata management.
CLI/Shared Configuration
polylogue/cli/shared/types.py
AppEnv.polylogue property added to lazily instantiate and return a Polylogue facade configured with archive_root and db_path.
CLI Command Wiring
polylogue/cli/commands/export.py, polylogue/cli/commands/neighbors.py, polylogue/cli/commands/tags.py
Each command switches its data-retrieval call target from low-level stores (env.operations, env.repository) to the new facade (env.polylogue).
Message Handling Updates
polylogue/cli/messages.py, polylogue/daemon/http.py
Message serialization and retrieval updated to handle typed Message objects instead of dictionary representations. run_messages now catches ConversationNotFoundError instead of checking for None results. HTTP handler constructs explicit JSON shape with id, role, text, message_type.
MCP Server Integration
polylogue/mcp/server.py, polylogue/mcp/server_support.py
New _get_polylogue() helper added and exported; build_server() wires get_polylogue callback into MCP ServerCallbacks.
MCP Tool Refactoring
polylogue/mcp/server_insight_tools.py, polylogue/mcp/server_maintenance_tools.py, polylogue/mcp/server_mutation_tools.py, polylogue/mcp/server_tools.py
All MCP tools switched from using hooks.get_archive_ops() / direct store access to hooks.get_polylogue(). Mutation tools add ConversationNotFoundError handling. Metadata set_metadata now stringifies parsed JSON values before passing to facade.
Test Infrastructure & Coverage
tests/infra/mcp.py, tests/unit/mcp/test_server_surfaces.py, tests/unit/mcp/test_tool_contracts.py
New make_polylogue_mock() helper provides a Polylogue facade mock with async tool methods. Unit tests updated to patch _get_polylogue instead of _get_archive_ops and to validate calls against the polylogue facade mock. Assertions adjusted for update_metadata stringified values and new exception handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

type:refactor, area:mcp, area:storage

Poem

🐰 The lowly stores once ruled the land,
But now a Polylogue takes command!
With facade bright, the CLI sings,
MCP tools dance on façade wings.
Refactored paths lead clearer now! ✨

✨ 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/api-formalization

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.

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

ℹ️ 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/api/archive.py Resolved
Comment thread polylogue/mcp/server_mutation_tools.py Resolved
@Sinity
Sinity removed the request for review from Copilot May 3, 2026 16:20
Sinity added a commit that referenced this pull request May 3, 2026
…_poly ref

J's API formalization (#764) converted MCP tools to use Polylogue mock
but missed the import and one residual mock_ops reference.
Sinity added a commit that referenced this pull request May 7, 2026
…dapters (#723, #578) (#764)

13 new API methods. CLI verbs (export/neighbors/tags) switched from ops
to API. MCP tools rewired from ArchiveOperations to Polylogue. Type
fixes. Drift cleanup.

Co-authored-by: Claude Opus 4.7 <[email protected]>
Sinity added a commit that referenced this pull request May 7, 2026
…_poly ref

J's API formalization (#764) converted MCP tools to use Polylogue mock
but missed the import and one residual mock_ops reference.
@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.

  • 56.F095 / P1: fixed-already at the checked revision: The replacement HTTP message route returns None when a session cannot be resolved: polylogue/operations/http_session_reads.py:272-274 handles the archive resolver's KeyError, and the facade route checks a missing summary at polylogue/daemon/http.py:4876. polylogue/daemon/route_families/read_detail.py:93-95 maps that result to HTTP 404 rather than an internal error.

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