Skip to content

refactor: contract CLI, MCP, and UI surfaces over renewed substrate - #264

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/cli-mcp-ui-surface-contracts
Apr 20, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/cli-mcp-ui-surface-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 20, 2026 •

Copy link
Copy Markdown
Owner

Ref #245

Summary

Tighten the remaining CLI, MCP, and UI surface contracts so those entrypoints consume the renewed substrate through explicit typed request/result boundaries instead of weak parameter bags and ad hoc prompt or payload glue.

Problem

The first half of this tranche tightened check-command and UI prompt surfaces, but query and MCP paths still carried a lot of broad dict[str, object] plumbing, dynamic registration glue, and prompt-side ad hoc payload shaping. That left the public surfaces technically type-clean in places while still underspecifying meaning and forcing compatibility workarounds deeper in the stack.

Solution

  • introduced typed CLI surface aliases and callback protocols in polylogue/cli/query.py, polylogue/cli/query_output.py, polylogue/cli/query_verbs.py, and polylogue/cli/root_request.py
  • tightened semantic stats and action-read-model readiness compatibility in polylogue/lib/query_retrieval_candidates.py
  • rebuilt MCP dynamic tool registration and prompt payload shaping in polylogue/mcp/server_product_tools.py, polylogue/mcp/server_prompts.py, polylogue/mcp/server_support.py, polylogue/mcp/payloads.py, and polylogue/mcp/__init__.py
  • kept the machine-facing metadata payload raw while avoiding recursive Pydantic root-model traps
  • the earlier branch commit also tightened the check-command/UI prompt surface with explicit result models and typed prompt stubs

Verification

  • ruff check polylogue/cli/query.py polylogue/cli/query_output.py polylogue/cli/query_verbs.py polylogue/cli/root_request.py polylogue/mcp/__init__.py polylogue/mcp/payloads.py polylogue/mcp/server_product_tools.py polylogue/mcp/server_prompts.py polylogue/mcp/server_support.py polylogue/ui/facade_console.py
  • mypy polylogue/cli/query.py polylogue/cli/query_output.py polylogue/cli/query_verbs.py polylogue/cli/root_request.py polylogue/mcp/payloads.py polylogue/mcp/server_support.py polylogue/mcp/server_prompts.py polylogue/mcp/server_product_tools.py polylogue/mcp/__init__.py polylogue/ui/facade_console.py
  • pytest -q tests/unit/ui/test_ui.py tests/unit/cli/test_check.py
  • pytest -q tests/unit/mcp/test_tool_contracts.py::TestMutationTools::test_get_metadata_success tests/unit/mcp/test_server_surfaces.py::TestClampLimit::test_clamp_limit_contract\[10-10_0\] tests/unit/cli/test_click_app.py::TestMcpServerImport::test_serve_stdio_can_be_imported
  • pytest -q tests/unit/cli/test_query_exec_laws.py::test_async_execute_query_semantic_stats_by_falls_back_without_summaries_contract
  • devtools verify

@coderabbitai

coderabbitai Bot commented Apr 20, 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 13 minutes and 55 seconds before requesting another review.

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 13 minutes and 55 seconds.

⌛ 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: 4af7acb2-be27-4889-80aa-c1b0cefe7a0c

📥 Commits

Reviewing files that changed from the base of the PR and between 386e483 and 4f15d64.

📒 Files selected for processing (20)
  • polylogue/cli/check_maintenance.py
  • polylogue/cli/check_models.py
  • polylogue/cli/check_rendering_json.py
  • polylogue/cli/check_rendering_plain.py
  • polylogue/cli/check_support.py
  • polylogue/cli/check_workflow.py
  • polylogue/cli/commands/check.py
  • polylogue/cli/query.py
  • polylogue/cli/query_output.py
  • polylogue/cli/query_verbs.py
  • polylogue/cli/root_request.py
  • polylogue/lib/query_retrieval_candidates.py
  • polylogue/mcp/__init__.py
  • polylogue/mcp/payloads.py
  • polylogue/mcp/server_product_tools.py
  • polylogue/mcp/server_prompts.py
  • polylogue/mcp/server_support.py
  • polylogue/ui/facade.py
  • polylogue/ui/facade_prompts.py
  • tests/unit/ui/test_ui.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/cli-mcp-ui-surface-contracts

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.

@Sinity
Sinity merged commit 01502be into master Apr 20, 2026
13 checks passed
@Sinity
Sinity deleted the feature/refactor/cli-mcp-ui-surface-contracts branch April 20, 2026 09:36
Sinity added a commit that referenced this pull request Apr 22, 2026
…264)

Ref #245

## Summary

Tighten the remaining CLI, MCP, and UI surface contracts so those entrypoints consume the renewed substrate through explicit typed request/result boundaries instead of weak parameter bags and ad hoc prompt or payload glue.

## Problem

The first half of this tranche tightened check-command and UI prompt surfaces, but query and MCP paths still carried a lot of broad `dict[str, object]` plumbing, dynamic registration glue, and prompt-side ad hoc payload shaping. That left the public surfaces technically type-clean in places while still underspecifying meaning and forcing compatibility workarounds deeper in the stack.

## Solution

- introduced typed CLI surface aliases and callback protocols in `polylogue/cli/query.py`, `polylogue/cli/query_output.py`, `polylogue/cli/query_verbs.py`, and `polylogue/cli/root_request.py`
- tightened semantic stats and action-read-model readiness compatibility in `polylogue/lib/query_retrieval_candidates.py`
- rebuilt MCP dynamic tool registration and prompt payload shaping in `polylogue/mcp/server_product_tools.py`, `polylogue/mcp/server_prompts.py`, `polylogue/mcp/server_support.py`, `polylogue/mcp/payloads.py`, and `polylogue/mcp/__init__.py`
- kept the machine-facing metadata payload raw while avoiding recursive Pydantic root-model traps
- the earlier branch commit also tightened the check-command/UI prompt surface with explicit result models and typed prompt stubs

## Verification

- `ruff check polylogue/cli/query.py polylogue/cli/query_output.py polylogue/cli/query_verbs.py polylogue/cli/root_request.py polylogue/mcp/__init__.py polylogue/mcp/payloads.py polylogue/mcp/server_product_tools.py polylogue/mcp/server_prompts.py polylogue/mcp/server_support.py polylogue/ui/facade_console.py`
- `mypy polylogue/cli/query.py polylogue/cli/query_output.py polylogue/cli/query_verbs.py polylogue/cli/root_request.py polylogue/mcp/payloads.py polylogue/mcp/server_support.py polylogue/mcp/server_prompts.py polylogue/mcp/server_product_tools.py polylogue/mcp/__init__.py polylogue/ui/facade_console.py`
- `pytest -q tests/unit/ui/test_ui.py tests/unit/cli/test_check.py`
- `pytest -q tests/unit/mcp/test_tool_contracts.py::TestMutationTools::test_get_metadata_success tests/unit/mcp/test_server_surfaces.py::TestClampLimit::test_clamp_limit_contract\[10-10_0\] tests/unit/cli/test_click_app.py::TestMcpServerImport::test_serve_stdio_can_be_imported`
- `pytest -q tests/unit/cli/test_query_exec_laws.py::test_async_execute_query_semantic_stats_by_falls_back_without_summaries_contract`
- `devtools verify`
Sinity added a commit that referenced this pull request Apr 22, 2026
…264)

The first half of this tranche tightened check-command and UI
prompt surfaces, but query and MCP paths still carried broad
`dict[str, object]` plumbing, dynamic registration glue, and
prompt-side ad hoc payload shaping. The public surfaces were
technically type-clean in places while still underspecifying
meaning and forcing compatibility workarounds deeper in the stack.

Introduces typed CLI surface aliases and callback protocols in
`cli/query.py`, `cli/query_output.py`, `cli/query_verbs.py`, and
`cli/root_request.py`. Tightens semantic stats and action-read-model
readiness compatibility in `lib/query_retrieval_candidates.py`.
Rebuilds MCP dynamic tool registration and prompt payload shaping
in `mcp/server_product_tools.py`, `mcp/server_prompts.py`,
`mcp/server_support.py`, `mcp/payloads.py`, and `mcp/__init__.py`.
Keeps the machine-facing metadata payload raw while avoiding
recursive Pydantic root-model traps.

Verification: ruff + mypy over touched CLI/MCP modules; pytest over
UI, check, and focused MCP/CLI tests; devtools verify green.

Ref #245
Sinity added a commit that referenced this pull request Apr 22, 2026
…264)

The first half of this tranche tightened check-command and UI
prompt surfaces, but query and MCP paths still carried broad
`dict[str, object]` plumbing, dynamic registration glue, and
prompt-side ad hoc payload shaping. The public surfaces were
technically type-clean in places while still underspecifying
meaning and forcing compatibility workarounds deeper in the stack.

Introduces typed CLI surface aliases and callback protocols in
`cli/query.py`, `cli/query_output.py`, `cli/query_verbs.py`, and
`cli/root_request.py`. Tightens semantic stats and action-read-model
readiness compatibility in `lib/query_retrieval_candidates.py`.
Rebuilds MCP dynamic tool registration and prompt payload shaping
in `mcp/server_product_tools.py`, `mcp/server_prompts.py`,
`mcp/server_support.py`, `mcp/payloads.py`, and `mcp/__init__.py`.
Keeps the machine-facing metadata payload raw while avoiding
recursive Pydantic root-model traps.

Verification: ruff + mypy over touched CLI/MCP modules; pytest over
UI, check, and focused MCP/CLI tests; devtools verify green.

Ref #245
Sinity added a commit that referenced this pull request Apr 22, 2026
…264)

The first half of this tranche tightened check-command and UI
prompt surfaces, but query and MCP paths still carried broad
`dict[str, object]` plumbing, dynamic registration glue, and
prompt-side ad hoc payload shaping. The public surfaces were
technically type-clean in places while still underspecifying
meaning and forcing compatibility workarounds deeper in the stack.

Introduces typed CLI surface aliases and callback protocols in
`cli/query.py`, `cli/query_output.py`, `cli/query_verbs.py`, and
`cli/root_request.py`. Tightens semantic stats and action-read-model
readiness compatibility in `lib/query_retrieval_candidates.py`.
Rebuilds MCP dynamic tool registration and prompt payload shaping
in `mcp/server_product_tools.py`, `mcp/server_prompts.py`,
`mcp/server_support.py`, `mcp/payloads.py`, and `mcp/__init__.py`.
Keeps the machine-facing metadata payload raw while avoiding
recursive Pydantic root-model traps.

Verification: ruff + mypy over touched CLI/MCP modules; pytest over
UI, check, and focused MCP/CLI tests; devtools verify green.

Ref #245
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 01502be725

ℹ️ 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/mcp/server_prompts.py Resolved
@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.

  • 69.F031 / P2: fixed-already at the checked revision: polylogue/mcp/server_prompts.py:173 fetches only a bounded message page before constructing PromptSession. The summary helper can copy that page, but it no longer materializes an entire large session merely to display its first ten messages.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant