Repository navigation
refactor(mcp): delete dead legacy MCP registrar code - #3118
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (16)
✨ 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 |
Ref polylogue-t46.8 Problem: the six-tool MCP cutover (#3095) replaced the ~97-tool registration surface with query/read/get/explain/context/status plus the privileged write/judge/run/maintenance transactions, but left the old per-operation registrar modules, their glue, and an inert ~103-row legacy declaration table sitting in the tree unused. What changed: - Deleted server_context_tools.py, server_insight_tools.py, server_maintenance_tools.py, server_mutation_tools.py, server_personal_state_tools.py (2,480 lines) — no role registers them; register_tools() only calls register_cutover_read_tools/ register_cutover_privileged_tools. - Relocated _build_mcp_scope_filter from server_maintenance_tools.py into server_cutover.py's maintenance() dispatch before deleting the source file. - Gutted server_tools.py to its 19-line register_tools() shim. - polylogue/mcp/declarations/registry.py: deleted the dead ~103-row _TOOL_ROWS table and its exclusively-supporting machinery (_WORKFLOW_COVERAGE, _PROMPT_ALTERNATIVES, _RESOURCE_ALTERNATIVES, _DISCOVERY, _CONTINUATION, _TARGET_ROUTE, _OBSERVED_USE, _validate_inventory_tables, _family_id, the never-called _build_declaration) — none of it fed MCP_TOOL_DECLARATIONS, which is built exclusively from the live _CUTOVER_TOOL_ROWS. Kept _ToolRow, _compatibility, and _python_parity, which _cutover_declaration still uses. 3716 -> 528 lines. - Repointed six operations/specs.py code_refs from the deleted server_mutation_tools.py/server_personal_state_tools.py functions to server_cutover._dispatch_write. - Rewrote two test_mcp_call_log.py tests to AST-parse server_cutover.py instead of the deleted per-tool modules, and deleted a third (test_every_session_tool_forwards_telemetry_identity) whose glob-scan premise — many individually-named @mcp.tool() functions, each with its own async_safe_call — no longer holds now that write()/ maintenance() collapse ~20 former per-operation tools into one dispatch with one call site; the two rewritten parametrized tests already cover the same telemetry-forwarding invariant for the collapsed shape. - Renamed test_query_tool_schema_derivation.py -> test_query_request_contracts.py, dropping 8 tests whose premise (deriving schemas from the deleted register_query_tools) no longer applies; kept 5 tests exercising MCPSessionQueryRequest/payload builders directly. - Regenerated docs/plans/topology-target.yaml and docs/topology-status.md (devtools render topology-projection / topology-status) to drop the five deleted files' rows. - Marked architecture-hotspots.md rows 8a/8b resolved. Verification: devtools test tests/unit/mcp/ tests/unit/verification/test_code_refs_resolve.py (368 passed); devtools verify --quick (all static gates green); mypy --strict and ruff clean on every touched file. Note: devtools verify --all surfaced a large body of pre-existing baseline failures unrelated to this diff (MCP tool-name test debt from drift from other recent master commits) — none reproduce from clearing stale fixture caches, none touch any file this diff modifies. Tracked separately, not fixed here to keep this PR's boundary to dead-code deletion. Co-Authored-By: Claude <[email protected]>
The prior commit's git add invocation listed the stale rename source path alongside the new path in one call; git aborted the whole invocation on the missing pathspec, so the previous commit silently kept the file's pre-trim content (still importing the deleted register_query_tools). This lands the actual trimmed content that was already verified passing before the previous commit. Verification: devtools test tests/unit/mcp/test_query_request_contracts.py tests/unit/verification/test_code_refs_resolve.py (207 passed); mypy --strict and ruff clean. Co-Authored-By: Claude <[email protected]>
14 unrelated commits landed on master between this branch's creation and now; topology-target.yaml/topology-status.md track file counts that drifted as a result. Mechanical regen only. Co-Authored-By: Claude <[email protected]>
6fbcfec to
5d28a6e
Compare
…3121) ## 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 Co-authored-by: Claude <[email protected]>
## Summary `status(scope="coordination")` on the six-tool MCP cutover surface silently returned generic `archive.stats()` instead of coordination status. ## Problem `register_cutover_read_tools`'s `status` verb dispatched every scope except `"operation"` to the same `archive.stats()` projection. An agent calling `status(scope="coordination")` got archive stats, not coordination data — discovered while porting polylogue-20d.17's budgeted component-snapshot protocol to coordination status (#3116). ## Solution - `status(scope="coordination")` now dispatches to real coordination logic: compact requests reuse a lazily-constructed `CoordinationEnvelopeCache` (fingerprint-invalidated on git HEAD/logs/`.beads/issues.jsonl`/index db-WAL mtimes, per #3116's substrate), `"detail"` requests bypass the cache and call `build_coordination_envelope` directly — matching the fresh/detail semantics the other status scopes already use. - The cache is constructed lazily inside `register_cutover_read_tools`'s closure so sessions that never call `status(scope="coordination")` don't pay `polylogue.coordination`'s import cost. ## Scope note (polylogue-qink AC-3) qink's AC also asked to "decide and act on `register_read_tools`/`agent_coordination`'s fate" (the old standalone MCP tool, unreachable from the live server). That deletion is Lane C's in-flight six-tool-cutover scope (polylogue-t46.8) and has since landed on master via #3118 (`refactor(mcp): delete dead legacy MCP registrar code`) — no action needed here. ## Verification - `devtools test tests/unit/mcp/test_status_scope_coordination.py` — 2 passed. Drives the live registered `status` tool function end-to-end (not a hand-built registrar): proves the response is coordination-shaped with no `"archive"` key (regression for the silent-fallthrough bug), and that a second compact call hits the warm cache (1 build call across 2 compact + 1 detail invocation) while detail always goes live. - `mypy --strict polylogue/mcp/server_cutover.py` — clean. - `devtools verify --quick` — exit 0 (ran pre-commit and pre-push). Ref polylogue-qink
Summary
Deletes the ~7,000 lines of MCP registrar code and declarations that were
made fully dead weight by the six-tool cutover (#3095) but never removed —
the retired per-operation registrar modules, their glue, and an inert
~103-row legacy declaration table.
Problem
#3095 replaced the ~97-tool MCP surface with
query/read/get/explain/context/statusplus the privilegedwrite/judge/run/maintenancetransactions. The tool registrations were removed (no role registers the
old per-operation tools), but ~2,480 lines of registrar-module code, ~1,000
more dead lines in
server_tools.py, and an inert ~103-row legacydeclaration table in
registry.pywere left sitting in the tree unused.Solution
server_context_tools.py,server_insight_tools.py,server_maintenance_tools.py,server_mutation_tools.py,server_personal_state_tools.py(2,480 lines) — relocated_build_mcp_scope_filterintoserver_cutover.py'smaintenance()dispatch before deleting its source file.
server_tools.pyto its 19-lineregister_tools()shim.polylogue/mcp/declarations/registry.py: deleted the dead_TOOL_ROWStable (distinct from the live
_CUTOVER_TOOL_ROWS) and its exclusively-supporting machinery (
_WORKFLOW_COVERAGE,_PROMPT_ALTERNATIVES,_RESOURCE_ALTERNATIVES,_DISCOVERY,_CONTINUATION,_TARGET_ROUTE,_OBSERVED_USE,_validate_inventory_tables,_family_id, thenever-called
_build_declaration) — confirmed none of it feedsMCP_TOOL_DECLARATIONS, which is built exclusively from_CUTOVER_TOOL_ROWS. Kept_ToolRow/_compatibility/_python_parity,which
_cutover_declarationstill uses. 3,716 → 528 lines.operations/specs.pycode_refsfrom the deletedserver_mutation_tools.py/server_personal_state_tools.pyfunctions toserver_cutover._dispatch_write.test_mcp_call_log.pytests to AST-parseserver_cutover.pyinstead of the deleted per-tool modules, and deleted a third
(
test_every_session_tool_forwards_telemetry_identity) whose glob-scanpremise — many individually-named
@mcp.tool()functions, each with itsown
async_safe_call— no longer holds now thatwrite()/maintenance()collapse ~20 former per-operation tools into one dispatch with one call
site; the two rewritten parametrized tests already cover the same
telemetry-forwarding invariant for the collapsed shape.
test_query_tool_schema_derivation.py→test_query_request_contracts.py, dropping 8 tests whose premise(deriving schemas from the deleted
register_query_tools) no longerapplies; kept 5 tests exercising
MCPSessionQueryRequest/payload buildersdirectly.
docs/plans/topology-target.yaml/docs/topology-status.md; markedarchitecture-hotspots.mdrows 8a/8bresolved.
Verification
devtools test tests/unit/mcp/ tests/unit/verification/test_code_refs_resolve.py— 368 passed (the code-refs drift gate is the main risk surface for this
diff).
devtools verify --quick— all static gates green (also re-ran on pushvia the pre-push hook).
mypy --strict/ruffclean on every touched file.devtools verify --all: surfaced a large body of pre-existingbaseline failures unrelated to this diff — MCP tool-name test debt from
fix(mcp): harden six-tool cutover — session correlation, status(operation), SessionStart preamble #3095 in files outside
tests/unit/mcp/(_tools["list_sessions"],_tools["search"],_tools["cost_outlook"],_tools["maintenance_preview"]still referenced by ~6 test files), plus unrelated CLI/migration drift
from other recent master commits (
no_color_requested()signature drift,a stale migration-count assertion). None reproduce from clearing stale
fixture caches; none touch any file this diff modifies. Tracking the
MCP-tool-name debt as an immediate follow-up PR; filing the unrelated
drift separately rather than expanding this PR's scope.
Ref polylogue-t46.8