Skip to content

fix(mcp): adapt cross-surface parity tests to the six-tool cutover - #3121

Merged
Sinity merged 1 commit into
masterfrom
feature/mcp/fix-tool-name-test-debt
Jul 18, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/mcp/fix-tool-name-test-debt

Conversation

@Sinity

@Sinity Sinity commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes ~20 tests left broken by the six-tool MCP cutover (#3095) that still
call individually-named MCP tools which no longer exist, and fixes a real
production bug (NameError) found while doing so in maintenance()'s
preview/execute path.

Stacked on #3118 (dead-code cleanup) — base branch is
feature/mcp/retire-legacy-registrars, not master. Merge #3118 first.

Problem

devtools verify --all (the first full run since #3095 merged) found
tests/unit/storage/{test_surface_parity_adapters,test_query_parity}.py and
tests/unit/maintenance/{test_scope_filter_envelope_contract, test_envelope_contracts,test_scope_filter}.py still calling
server._tool_manager._tools["list_sessions"|"search"|"maintenance_preview"]
— tools retired by the cutover. Deterministic KeyError on every run,
confirmed via isolated reruns (not a fixture-cache artifact). Never caught by
devtools test tests/unit/mcp/ because these files live outside that
directory, and per-PR CI skips the heavy test suite entirely.

Solution

  • Extended query()'s signature and _query_sessions with
    min_messages/max_messages/min_words, mirroring the existing
    origin/tag/repo/since/until/sort filters — closes a real
    (narrow) parameter gap in query(projection="sessions", ...) rather than
    weakening the parity test, since the old list_sessions tool supported
    these. Also threaded through _dispatch_run's saved-query replay for
    symmetry.
  • Rewired both storage parity files' _MCPSurface from
    _tools["search"]/_tools["list_sessions"] to
    _tools["query"].fn(expression=..., projection="sessions", ...) — same
    underlying payload-building machinery, response shape unchanged.
  • Rewired the three maintenance test files' _tools["maintenance_preview"]
    call sites to _tools["maintenance"].fn(operation="preview", ...), and
    fixed two registration-presence assertions that were checking for names
    (maintenance_preview/maintenance_execute) that never existed
    post-cutover — vacuously true, testing nothing.
  • Found and fixed a real production bug: server_cutover.py's
    _build_mcp_scope_filter only had MaintenanceScopeFilter imported under
    TYPE_CHECKING, but constructs one at runtime — every
    maintenance(operation="preview"/"execute") call was raising NameError.
    Added the runtime import to the function's existing lazy-import block.
  • Marked test_mcp_cost_outlook_tool_uses_shared_envelope xfail
    (strict=True, raises=KeyError): cost_outlook has no six-tool-surface
    replacement yet — cost/usage rollup MCP wiring needs a design decision
    explicitly deferred this session, tracked in polylogue-hg97.

Filed polylogue-p6rz for the remaining ~40-file pre-existing failure list
from the same --all run that are not MCP-related (no_color_requested()
signature drift, a stale migration-count assertion, query_units
telemetry-key naming) — confirmed unrelated by isolated reruns, left
untouched here.

Verification

  • devtools test tests/unit/mcp/ tests/unit/maintenance/ tests/unit/storage/test_surface_parity_adapters.py tests/unit/storage/test_query_parity.py tests/unit/cost/test_contract_suite.py tests/unit/verification/test_code_refs_resolve.py — 576 passed, 1 xfailed.
  • mypy --strict / ruff clean.
  • devtools render all --check clean.

Ref polylogue-t46.8

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 63525874-33bb-481f-af7d-7b7b35ac0d1b

📥 Commits

Reviewing files that changed from the base of the PR and between 87efae8 and 74f94f0.

📒 Files selected for processing (7)
  • polylogue/mcp/server_cutover.py
  • tests/unit/cost/test_contract_suite.py
  • tests/unit/maintenance/test_envelope_contracts.py
  • tests/unit/maintenance/test_scope_filter.py
  • tests/unit/maintenance/test_scope_filter_envelope_contract.py
  • tests/unit/storage/test_query_parity.py
  • tests/unit/storage/test_surface_parity_adapters.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/mcp/fix-tool-name-test-debt

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.

@Sinity
Sinity force-pushed the feature/mcp/retire-legacy-registrars branch from 6fbcfec to 5d28a6e Compare July 18, 2026 17:26
@Sinity
Sinity force-pushed the feature/mcp/fix-tool-name-test-debt branch from 31c083f to 6a266bf Compare July 18, 2026 17:28
Base automatically changed from feature/mcp/retire-legacy-registrars to master July 18, 2026 17:29
Ref polylogue-t46.8

Problem: devtools verify --all found ~20 tests across
tests/unit/storage/{test_surface_parity_adapters,test_query_parity}.py
and tests/unit/maintenance/{test_scope_filter_envelope_contract,
test_envelope_contracts,test_scope_filter}.py still calling the
individually-named MCP tools (list_sessions, search,
maintenance_preview) retired by the six-tool cutover (#3095),
deterministically failing with KeyError on every run since -- test
debt this session's earlier work left behind, never caught by
`devtools test tests/unit/mcp/` because these files live outside that
directory.

What changed:
- Extended query()'s tool signature and _query_sessions with
  min_messages/max_messages/min_words, mirroring the existing
  origin/tag/repo/since/until/sort filters -- test_surface_parity_adapters.py
  needed these on the session-listing path and the old list_sessions
  tool supported them, so this closes a real (if narrow) parameter gap
  in query(projection="sessions", ...) rather than watering down the
  parity test. Also threaded the same three fields through
  _dispatch_run's saved-query replay for symmetry.
- Rewired _MCPSurface in both storage parity test files from
  _tools["search"]/_tools["list_sessions"] to
  _tools["query"].fn(expression=..., projection="sessions", ...) --
  same underlying archive_search_payload/archive_session_list_payload
  machinery, so response shape is unchanged.
- Rewired the three maintenance test files'
  _tools["maintenance_preview"] call sites to
  _tools["maintenance"].fn(operation="preview", ...), and fixed two
  stale registration-presence assertions
  (test_maintenance_tools_registered_on_admin_server /
  test_maintenance_tools_absent_from_read_server) that were checking
  for "maintenance_preview"/"maintenance_execute" -- names that never
  existed post-cutover, so the assertions were vacuously true rather
  than testing anything.
- Found and fixed a real production bug while doing this:
  server_cutover.py's _build_mcp_scope_filter only had
  MaintenanceScopeFilter imported under TYPE_CHECKING, but its body
  constructs one at runtime -- every maintenance(operation="preview"
  or "execute") call was raising NameError. Added the runtime import
  to the function's existing lazy-import block.
- Marked test_mcp_cost_outlook_tool_uses_shared_envelope xfail
  (strict=True, raises=KeyError): the cost_outlook tool has no
  six-tool-surface replacement yet -- cost/usage rollup MCP wiring
  needs a design decision explicitly deferred this session, tracked in
  polylogue-hg97. This turns silent breakage into an honest, tracked
  gap that auto-un-xfails once the design lands.

Filed polylogue-p6rz for the remaining ~40-file pre-existing failure
list from the same devtools verify --all run that are NOT MCP-related
(no_color_requested() signature drift, a stale migration-count
assertion, query_units telemetry-key naming) -- confirmed unrelated by
isolated reruns, left untouched here.

Verification: devtools test tests/unit/mcp/ tests/unit/maintenance/
tests/unit/storage/test_surface_parity_adapters.py
tests/unit/storage/test_query_parity.py tests/unit/cost/test_contract_suite.py
tests/unit/verification/test_code_refs_resolve.py (576 passed, 1
xfailed); mypy --strict and ruff clean; devtools render all --check
clean.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/mcp/fix-tool-name-test-debt branch from 6a266bf to 74f94f0 Compare July 18, 2026 17:31
@Sinity
Sinity merged commit 07b1d28 into master Jul 18, 2026
3 checks passed
@Sinity
Sinity deleted the feature/mcp/fix-tool-name-test-debt branch July 18, 2026 17:33
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