refactor: REST/MCP service layer + delete dead routers (slice 10)#129
Conversation
Remove api/routes_control.py and api/routes_config.py. Both defined create_control_router()/create_config_router() factories that were never imported or mounted — register_routes() wires the live inline copies in routes.py instead. The dead routes_control.py cleanup branch deleted the entire state dir (including the state.json it had just saved), a latent data-loss bug now gone. Verified: api package imports + create_app() build cleanly (11 routes), ruff/mypy pass, 239 api tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Add transport-neutral core/services/: ServiceResult/ServiceOutcome taxonomy, TaskService (status/plan/logs/progress/context/list/init/ clean/pause/stop/resume/update-config), RepoService (path-confined, anyio.to_thread offload). - REST routes.py + MCP tools.py delegate to the services; outcome-> status-code (REST) / result-dict (MCP) mapping lives in one place. Drops routes.py substring-matching on exception text. - routes_repo.py + mcp/server.py share one RepoService instance. - Add tests/core/services/: 57 tests incl. full TaskService coverage. Co-Authored-By: Claude <noreply@anthropic.com>
- Add validate_model() to agent_models: the single path REST, MCP, and plan_repo share. Accepts every ModelType (fixes fable/sonnet_1m), rejects unknown with one message. - REST request models validate via field_validator (drop the opus|sonnet|haiku regex that missed fable/sonnet_1m); remove the dead inline ModelType check + unused import in routes. - MCP initialize_task/plan_repo validate the model instead of persisting any string / silently coercing unknowns to Opus. - Generate the MCP task+mailbox tools from a declarative ForwardingSpec table so each tool's params derive from the underlying fn — kills the enable_verification (and update_config) drift; rename repo_dir→work_dir. - Control routes already surface NoActiveTaskError/ControlOperationNot- AllowedError via TaskService (no more message substring matching). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
29 tests in tests/contract/ verify that both transports agree on success/failure for every shared operation routed through TaskService: - get_status, get_plan, get_logs, get_progress, get_context - stop, resume, update_config, delete_coding_style, clean - cross-transport state visibility (MCP pause → REST sees paused) Documents the one intentional divergence: clean's NOT_FOUND maps to REST 404 (client error) but MCP success=True (benign no-op). Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 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.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (27)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
core/services/withTaskServiceandServiceResult— single validation path shared by REST and MCPControlOperationNotAllowedError/NoActiveTaskErrortyped exceptionstests/contract/verifying REST and MCP produce identical validation outcomes for every shared operationTransport contract
Both REST and MCP delegate to
TaskService; contract tests assert:NOT_FOUND→ REST 404 +success:False/ MCPsuccess:FalseINVALID→ REST 400/422 / MCPsuccess:FalseOK→ REST 200 / MCPsuccess:TruecleanNOT_FOUND → REST 404 vs MCP success=True (benign no-op)pause_task→ REST/statussees"paused"→ REST/control/resumesucceedsTest plan
uv run pytest tests/contract/→ 29 passeduv run pytest tests/→ 5873 passed, 0 failuresruff check . && ruff format --check .→ cleanmypy .→ no new errors🤖 Generated with Claude Code