Repository navigation
refactor: contract CLI and MCP read surfaces - #248
Conversation
|
Warning Rate limit exceeded
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 16 minutes and 19 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (25)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b156a12181
ℹ️ 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".
| """Stream conversation messages to stdout without buffering.""" | ||
| conv_record = await repo.queries.get_conversation(conversation_id) | ||
| if not conv_record: | ||
| projection = await repo.get_render_projection(conversation_id) |
There was a problem hiding this comment.
Avoid eager render projection in streaming path
stream_conversation now fetches get_render_projection(...) before streaming, but the default repository implementation of that projection loads all messages and attachments eagerly. In --stream mode this duplicates work because messages are then read again via iter_messages(...), which can significantly increase latency and memory usage (and potentially fail) for large conversations or small message_limit values.
Useful? React with 👍 / 👎.
## Summary - contract CLI, MCP, and TUI read paths around explicit repository and archive-operation surfaces - remove direct `.queries` and backend reach-through from the affected surfaces - align CLI and MCP tests with the narrowed injection seams ## Problem The renewed substrate was still leaking implementation details into higher-level surfaces. CLI helpers, MCP resources/tools, and the TUI were reaching through `repo.queries` and backend connections instead of depending on explicit read-side contracts. That kept surface code coupled to repository internals and made the MCP seam brittle in tests. Ref #245 ## Solution - flatten the relevant protocols in `polylogue/protocols.py` so surface code depends on direct read/query methods instead of nested `.queries` - add repository and `ArchiveOperations` delegates for the surfaced read/stat methods - rewire CLI query helpers, MCP resources/prompts/tools, and the TUI base app to use those narrower contracts - keep a stable `_get_repo()` seam in `polylogue.mcp.server` while exposing narrower callbacks for query, tag, backend, and archive-operation access - update CLI embed/query tests and MCP server-surface/tool-contract tests to match the new seams ## Verification - `pytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_run.py -k 'query or embed'` - `pytest -q tests/unit/mcp tests/unit/ui -k 'tool or resource or prompt or mutation or maintenance or browser or dashboard or search or app'` - `pytest -q tests/unit/cli/test_embed.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_tool_contracts.py` - `devtools verify`
The renewed substrate was leaking implementation details into higher-level surfaces. CLI helpers, MCP resources/tools, and the TUI were reaching through `repo.queries` and backend connections instead of depending on explicit read-side contracts. That kept surface code coupled to repository internals and made the MCP seam brittle in tests. Flattens the relevant protocols in `protocols.py` so surface code depends on direct read/query methods instead of nested `.queries`. Adds repository and `ArchiveOperations` delegates for the surfaced read/stat methods. Rewires CLI query helpers, MCP resources / prompts / tools, and the TUI base app to use those narrower contracts. Keeps a stable `_get_repo()` seam in `mcp.server` while exposing narrower callbacks for query, tag, backend, and archive- operation access. Updates CLI embed/query tests and MCP server- surface/tool-contract tests to match the new seams. Verification: focused pytest over cli query/embed, mcp, ui, and surface/tool-contract suites; devtools verify green. Ref #245
The renewed substrate was leaking implementation details into higher-level surfaces. CLI helpers, MCP resources/tools, and the TUI were reaching through `repo.queries` and backend connections instead of depending on explicit read-side contracts. That kept surface code coupled to repository internals and made the MCP seam brittle in tests. Flattens the relevant protocols in `protocols.py` so surface code depends on direct read/query methods instead of nested `.queries`. Adds repository and `ArchiveOperations` delegates for the surfaced read/stat methods. Rewires CLI query helpers, MCP resources / prompts / tools, and the TUI base app to use those narrower contracts. Keeps a stable `_get_repo()` seam in `mcp.server` while exposing narrower callbacks for query, tag, backend, and archive- operation access. Updates CLI embed/query tests and MCP server- surface/tool-contract tests to match the new seams. Verification: focused pytest over cli query/embed, mcp, ui, and surface/tool-contract suites; devtools verify green. Ref #245
The renewed substrate was leaking implementation details into higher-level surfaces. CLI helpers, MCP resources/tools, and the TUI were reaching through `repo.queries` and backend connections instead of depending on explicit read-side contracts. That kept surface code coupled to repository internals and made the MCP seam brittle in tests. Flattens the relevant protocols in `protocols.py` so surface code depends on direct read/query methods instead of nested `.queries`. Adds repository and `ArchiveOperations` delegates for the surfaced read/stat methods. Rewires CLI query helpers, MCP resources / prompts / tools, and the TUI base app to use those narrower contracts. Keeps a stable `_get_repo()` seam in `mcp.server` while exposing narrower callbacks for query, tag, backend, and archive- operation access. Updates CLI embed/query tests and MCP server- surface/tool-contract tests to match the new seams. Verification: focused pytest over cli query/embed, mcp, ui, and surface/tool-contract suites; devtools verify green. Ref #245
|
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. |
Summary
.queriesand backend reach-through from the affected surfacesProblem
The renewed substrate was still leaking implementation details into higher-level surfaces. CLI helpers, MCP resources/tools, and the TUI were reaching through
repo.queriesand backend connections instead of depending on explicit read-side contracts. That kept surface code coupled to repository internals and made the MCP seam brittle in tests.Ref #245
Solution
polylogue/protocols.pyso surface code depends on direct read/query methods instead of nested.queriesArchiveOperationsdelegates for the surfaced read/stat methods_get_repo()seam inpolylogue.mcp.serverwhile exposing narrower callbacks for query, tag, backend, and archive-operation accessVerification
pytest -q tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/cli/test_query_fmt.py tests/unit/cli/test_run.py -k 'query or embed'pytest -q tests/unit/mcp tests/unit/ui -k 'tool or resource or prompt or mutation or maintenance or browser or dashboard or search or app'pytest -q tests/unit/cli/test_embed.py tests/unit/cli/test_query_exec.py tests/unit/cli/test_query_exec_laws.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_tool_contracts.pydevtools verify