Sign in to edit tickets from this page.

← all tickets · home

Extract `mod tests` from `src/mcp.rs` into `src/mcp/tests.rs`

resolved 0683e140-4e17-4322-b51a-f0be949053bc

created_at
2026-04-24
updated_at
2026-04-24
code_context
src/mcp.rs:3934-7386
priority
P4
ticket_type
chore
labels
mcp, refactor, tests
resolved_at
2026-04-24
resolution
accepted

Body

src/mcp.rs is 7,416 lines, of which lines 3934–7386 (≈3,450 lines, ~47% of the file) are the inline #[cfg(test)] mod tests { ... } block. Moving that block to a sibling file is a pure code-move that roughly halves the working size of mcp.rs without touching any production code, any public API, any handler organization, or any test content.

This ticket is deliberately the smallest possible first step. Follow-up work — splitting handlers by domain (worlds / tickets / code / git), restructuring tool_manifest(), introducing a ToolSpec registry — is explicitly out of scope here and should be filed as separate tickets after this lands.

In scope

  1. Create src/mcp/tests.rs containing the full body of the existing mod tests from src/mcp.rs (everything between { and the matching } on lines ~3934–7386, exclusive of the wrapper line itself).
  2. In src/mcp.rs, replace the inline #[cfg(test)] mod tests { ... } block with a single declaration: #[cfg(test)] mod tests;. Rust 2018+ resolves this to src/mcp/tests.rs automatically; no #[path] attribute needed.
  3. Fix any use super::* / visibility details that break as a result of the move. Private items in mcp.rs remain accessible because tests is still a child module — nothing should need to become pub.
  4. Verify cargo test passes with the same test count and the same set of test names as before.
  5. Verify cargo clippy and cargo fmt --check are clean.

Out of scope — do not do these in this ticket

Acceptance criteria

Commit hygiene

Land as a single commit titled something like refactor(mcp): extract tests module to src/mcp/tests.rs. A straight copy-paste-and-delete is fine — git log --follow src/mcp/tests.rs will track history through the move.

Proposed resolution

Pure code-move, nothing else.

What moved

Lines 3964-7414 of the pre-change src/mcp.rs (the entire inline #[cfg(test)] mod tests { ... } block body, excluding the wrapper) verbatim into src/mcp/tests.rs, dedented 4 spaces so top-level items sit at column 0. First line use super::*; unchanged from original. No renames, no reorders, no content edits.

What remains in src/mcp.rs at the same spot

#[cfg(test)]
mod tests;

Rust 2018+ resolves this to src/mcp/tests.rs because the parent module mcp has no mod.rs directory form. No #[path] attribute needed. Private items in mcp.rs remain accessible to the tests module because tests is still a child of mcp — nothing needed to become pub.

Line counts

FileBeforeAfterDelta
src/mcp.rs74153963−3452
src/mcp/tests.rs03451+3451

The 1-line discrepancy is the new mod tests; declaration.

Verification

Production smoke

Scope discipline held

Merged alongside

The sibling ticket d3c5fe99 (Slug newtype) was merged into main in the same push, just before this one. Its src/mcp.rs edits are in handle_create_world (~line 1623), well above the extracted test block. Git's 3-way merge reconciled both branches automatically with no conflicts.

Per standing guidance I am not confirming — only proposing.

History (4 events)

Sign in as a human to drive this ticket from the page, or use the MCP tools.