Commit Graph

1 Commits

Author SHA1 Message Date
dave 65a3767a7a refactor: split top-5 largest files into mod.rs + tests.rs
Five files in server/src/ exceeded 1500 lines, with 50–75% of the line
count being inline `#[cfg(test)] mod tests { ... }` blocks. Agents
working on these files have to navigate huge buffers via Read calls,
costing turn budget that could go toward actual work.

Pattern: convert `foo.rs` to `foo/mod.rs` + `foo/tests.rs`.
Rust resolves `mod foo;` to either form, so no parent-module changes
needed.

Before / after (production-code lines, what an agent has to navigate
when editing the module):

  crdt_sync.rs:           3672 → 1003 (mod.rs) + 2667 (tests.rs)
  crdt_state.rs:          2122 → 1263 (mod.rs) + 854  (tests.rs)
  io/fs/scaffold.rs:      2045 →  702 (mod.rs) + 1342 (tests.rs)
  http/mcp/mod.rs:        1882 → 1410 (mod.rs) + 472  (tests.rs)
  http/mcp/story_tools.rs: 1864 →  725 (mod.rs) + 1137 (tests.rs)

Side change: scaffold/mod.rs's include_str! paths got an extra `../`
because the file moved one directory deeper.

Tests: full `cargo test` suite passes (2635 passed, 0 failed).
Formatting: cargo fmt --check clean.

Motivation: today's agent thrashing on 644 / 650 / 652 was partly due to
cumulative-counting (now fixed by 650) but also genuinely due to file
size — sonnet's 50-turn budget barely covers reading these files plus
making the change. Smaller production-code files mean more turn budget
left for the actual work.

Committed straight to master because this is an enabling refactor for
agent autonomy work; running it through the normal pipeline would
require an agent that has to navigate the very files it's about to
split, defeating the purpose.
2026-04-26 20:08:24 +00:00