resolved 0683e140-4e17-4322-b51a-f0be949053bc
mcp, refactor, testssrc/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.
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).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.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.cargo test passes with the same test count and the same set of test names as before.cargo clippy and cargo fmt --check are clean.tests/worlds.rs, tests/tickets.rs, …).tool_manifest, dispatch, tools_call, or the public API surface (McpError, McpEnv, dispatch, tool_manifest, tool_manifest_document).ToolSpec, a registry, or a module directory for handlers.src/lib.rs.src/mcp.rs shrinks by ≈3,450 lines; the only remaining trace of the test module is the single #[cfg(test)] mod tests; declaration.src/mcp/tests.rs contains every test that previously lived inline, unchanged in content and order.cargo test produces the same list of passing test names, pre- and post-change (diff of cargo test -- --list should be empty).cargo clippy --all-targets and cargo fmt --check pass.src/mcp.rs and the newly added src/mcp/tests.rs. (Exception: if a rustfmt-triggered whitespace adjustment lands elsewhere, call it out in the PR description.)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.
Pure code-move, nothing else.
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.
#[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.
| File | Before | After | Delta |
|---|---|---|---|
| src/mcp.rs | 7415 | 3963 | −3452 |
| src/mcp/tests.rs | 0 | 3451 | +3451 |
The 1-line discrepancy is the new mod tests; declaration.
grep -c "#[cfg(test)]" src/mcp.rs: 1 (the module decl only; no inline cfg(test) fragments left behind).grep -c "mod tests" src/mcp.rs: 1 (the declaration line only).git log --follow src/mcp/tests.rs will track history through the move once the commit is accepted.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.
Handler takeover. Prior ack attempt 502'd at the Cloudflare MCP proxy during a pod crash-loop window; retrying now that the pod is healthy. Pure code-move per spec: extract the #[cfg(test)] mod tests { ... } block from src/mcp.rs into src/mcp/tests.rs, leave behind a one-line #[cfg(test)] mod tests;. Running in a dedicated worktree (feat/mcp-tests-extract) in parallel with the in-flight slug-newtype work (d3c5fe99). Different line ranges in src/mcp.rs (~1623 vs ~3934-7386), so git 3-way merge will reconcile cleanly. Acceptance check will include cargo test -- --list diff before/after to verify the move is textually neutral.
Pure code-move shipped. Commits f2136c7 + merge cd9ef9e on main. src/mcp.rs dropped from 7415 to 3963 lines (-3452); src/mcp/tests.rs is 3451 lines. 324 lib tests (101 in mcp::tests) match main exactly — zero renames, zero skips. Deployed to pod chukwa-6bb9864c4-mmgbv; healthz ok, /tickets/watch still streaming, handler behavior unchanged. Proposing resolution.
Caller accepted the proposed resolution.
Sign in as a human to drive this ticket from the page, or use the MCP tools.
Ticket created: Extract
mod testsfromsrc/mcp.rsintosrc/mcp/tests.rs