Skip to content

test: type mcp and ui surface contracts - #288

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/mcp-test-contracts
Apr 21, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/mcp-test-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add typed MCP surface protocols for test helpers and fixtures.
  • Replace dynamic MCP/security/UI test annotations with concrete fixture, callback, repository, and parameter data types.
  • Route async MCP prompt/tool invocations through the shared surface helper instead of direct untyped calls.

Problem

The mypy cleanup campaign still had dynamic seams in MCP and UI tests. These tests exercised real contracts, but their fixtures and parameter tables were typed as Any, which kept strict checking from proving the surface shapes.

Solution

Typed the MCP server-under-test managers via lightweight protocols in tests/infra/mcp.py, converted the MCP fixture and tests to those contracts, and tightened UI rendering/TUI tests with explicit fixture and parameter aliases. Runtime assertions now narrow mixed parameterized case data where the test matrix intentionally carries multiple shapes.

Ref #281

Verification

  • ruff check tests/infra/mcp.py tests/unit/mcp/conftest.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_mcp_edge_cases.py tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py
  • mypy tests/infra/mcp.py tests/unit/mcp/conftest.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_mcp_edge_cases.py tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py
  • pytest -q tests/unit/mcp tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py
  • PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick

@coderabbitai

coderabbitai Bot commented Apr 21, 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 27 minutes and 6 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 27 minutes and 6 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: 22f642fd-1ab7-4d9d-bd5f-e6187f9eeb38

📥 Commits

Reviewing files that changed from the base of the PR and between 1405711 and c24ecfb.

📒 Files selected for processing (9)
  • tests/infra/mcp.py
  • tests/unit/mcp/conftest.py
  • tests/unit/mcp/test_mcp_edge_cases.py
  • tests/unit/mcp/test_server_surfaces.py
  • tests/unit/mcp/test_tool_contracts.py
  • tests/unit/security/test_mcp_security.py
  • tests/unit/ui/test_tui.py
  • tests/unit/ui/test_ui.py
  • tests/unit/ui/test_ui_visual.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/mcp-test-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 c552101 into master Apr 21, 2026
13 checks passed
@Sinity
Sinity deleted the feature/refactor/mcp-test-contracts branch April 21, 2026 09:47
Sinity added a commit that referenced this pull request Apr 22, 2026
## Summary
- Add typed MCP surface protocols for test helpers and fixtures.
- Replace dynamic MCP/security/UI test annotations with concrete fixture, callback, repository, and parameter data types.
- Route async MCP prompt/tool invocations through the shared surface helper instead of direct untyped calls.

## Problem
The mypy cleanup campaign still had dynamic seams in MCP and UI tests. These tests exercised real contracts, but their fixtures and parameter tables were typed as `Any`, which kept strict checking from proving the surface shapes.

## Solution
Typed the MCP server-under-test managers via lightweight protocols in `tests/infra/mcp.py`, converted the MCP fixture and tests to those contracts, and tightened UI rendering/TUI tests with explicit fixture and parameter aliases. Runtime assertions now narrow mixed parameterized case data where the test matrix intentionally carries multiple shapes.

Ref #281

## Verification
- `ruff check tests/infra/mcp.py tests/unit/mcp/conftest.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_mcp_edge_cases.py tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py`
- `mypy tests/infra/mcp.py tests/unit/mcp/conftest.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_server_surfaces.py tests/unit/mcp/test_mcp_edge_cases.py tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py`
- `pytest -q tests/unit/mcp tests/unit/security/test_mcp_security.py tests/unit/ui/test_ui.py tests/unit/ui/test_tui.py tests/unit/ui/test_ui_visual.py`
- `PATH=/tmp/polylogue-281/.cache/codex-bin:$PATH devtools verify --quick`
Sinity added a commit that referenced this pull request Apr 22, 2026
MCP and UI tests exercised real contracts, but their fixtures and
parameter tables were typed as `Any`, keeping strict checking from
proving the surface shapes.

Adds typed MCP surface protocols in `tests/infra/mcp.py` for test
helpers and fixtures; converts the MCP fixture and tests to those
contracts. Replaces dynamic MCP/security/UI test annotations with
concrete fixture, callback, repository, and parameter data types.
Routes async MCP prompt/tool invocations through the shared surface
helper instead of direct untyped calls. Tightens UI rendering/TUI
tests with explicit fixture and parameter aliases; runtime
assertions now narrow mixed parameterized case data where the test
matrix intentionally carries multiple shapes.

Verification: ruff + mypy + pytest over MCP, security, UI, TUI,
and visual-UI suites; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
MCP and UI tests exercised real contracts, but their fixtures and
parameter tables were typed as `Any`, keeping strict checking from
proving the surface shapes.

Adds typed MCP surface protocols in `tests/infra/mcp.py` for test
helpers and fixtures; converts the MCP fixture and tests to those
contracts. Replaces dynamic MCP/security/UI test annotations with
concrete fixture, callback, repository, and parameter data types.
Routes async MCP prompt/tool invocations through the shared surface
helper instead of direct untyped calls. Tightens UI rendering/TUI
tests with explicit fixture and parameter aliases; runtime
assertions now narrow mixed parameterized case data where the test
matrix intentionally carries multiple shapes.

Verification: ruff + mypy + pytest over MCP, security, UI, TUI,
and visual-UI suites; devtools verify --quick green.

Ref #281
Sinity added a commit that referenced this pull request Apr 22, 2026
MCP and UI tests exercised real contracts, but their fixtures and
parameter tables were typed as `Any`, keeping strict checking from
proving the surface shapes.

Adds typed MCP surface protocols in `tests/infra/mcp.py` for test
helpers and fixtures; converts the MCP fixture and tests to those
contracts. Replaces dynamic MCP/security/UI test annotations with
concrete fixture, callback, repository, and parameter data types.
Routes async MCP prompt/tool invocations through the shared surface
helper instead of direct untyped calls. Tightens UI rendering/TUI
tests with explicit fixture and parameter aliases; runtime
assertions now narrow mixed parameterized case data where the test
matrix intentionally carries multiple shapes.

Verification: ruff + mypy + pytest over MCP, security, UI, TUI,
and visual-UI suites; devtools verify --quick green.

Ref #281
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ 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".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:52
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant