Skip to content

refactor: REST/MCP service layer + delete dead routers (slice 10)#129

Merged
sebyx07 merged 4 commits into
mainfrom
refactor/slice-10-rest-mcp-services
Jul 19, 2026
Merged

refactor: REST/MCP service layer + delete dead routers (slice 10)#129
sebyx07 merged 4 commits into
mainfrom
refactor/slice-10-rest-mcp-services

Conversation

@sebyx07

@sebyx07 sebyx07 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Delete dead divergent router variants that pre-dated the service layer
  • Extract core/services/ with TaskService and ServiceResult — single validation path shared by REST and MCP
  • Replace stringly-typed exception handling with ControlOperationNotAllowedError / NoActiveTaskError typed exceptions
  • Add 29 contract tests in tests/contract/ verifying REST and MCP produce identical validation outcomes for every shared operation

Transport contract

Both REST and MCP delegate to TaskService; contract tests assert:

  • NOT_FOUND → REST 404 + success:False / MCP success:False
  • INVALID → REST 400/422 / MCP success:False
  • OK → REST 200 / MCP success:True
  • Documents intentional divergence: clean NOT_FOUND → REST 404 vs MCP success=True (benign no-op)
  • Cross-transport state: MCP pause_task → REST /status sees "paused" → REST /control/resume succeeds

Test plan

  • uv run pytest tests/contract/ → 29 passed
  • uv run pytest tests/ → 5873 passed, 0 failures
  • ruff check . && ruff format --check . → clean
  • mypy . → no new errors

🤖 Generated with Claude Code

sebyx07 and others added 4 commits July 19, 2026 08:40
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>
@sebyx07 sebyx07 added the claudetm PRs created by Claude Task Master label Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 44 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.yml

Review profile: CHILL

Plan: Pro

Run ID: 4ebffa04-f11f-4648-ad11-b745a7712521

📥 Commits

Reviewing files that changed from the base of the PR and between f671779 and ff9f692.

📒 Files selected for processing (27)
  • src/claude_task_master/api/models.py
  • src/claude_task_master/api/routes.py
  • src/claude_task_master/api/routes_config.py
  • src/claude_task_master/api/routes_control.py
  • src/claude_task_master/api/routes_repo.py
  • src/claude_task_master/core/agent_models.py
  • src/claude_task_master/core/services/__init__.py
  • src/claude_task_master/core/services/repo_service.py
  • src/claude_task_master/core/services/results.py
  • src/claude_task_master/core/services/task_service.py
  • src/claude_task_master/mcp/server.py
  • src/claude_task_master/mcp/tool_forwarding.py
  • src/claude_task_master/mcp/tools.py
  • tests/api/test_repo_security.py
  • tests/api/test_routes_repo.py
  • tests/api/test_routes_task.py
  • tests/contract/__init__.py
  • tests/contract/conftest.py
  • tests/contract/test_rest_mcp_parity.py
  • tests/core/services/__init__.py
  • tests/core/services/test_repo_service.py
  • tests/core/services/test_results.py
  • tests/core/services/test_task_service.py
  • tests/core/test_agent_models.py
  • tests/mcp/test_tool_forwarding.py
  • tests/mcp/test_tools_repo_setup.py
  • tests/mcp/test_tools_task_management.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/slice-10-rest-mcp-services

Comment @coderabbitai help to get the list of available commands.

@sebyx07
sebyx07 merged commit 889e9e6 into main Jul 19, 2026
11 checks passed
@sebyx07
sebyx07 deleted the refactor/slice-10-rest-mcp-services branch July 19, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudetm PRs created by Claude Task Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant