Skip to content

refactor: decompose main.rs into 15 focused modules#9

Merged
rahulrajaram merged 1 commit into
masterfrom
refactor/module-decomposition
Mar 27, 2026
Merged

refactor: decompose main.rs into 15 focused modules#9
rahulrajaram merged 1 commit into
masterfrom
refactor/module-decomposition

Conversation

@rahulrajaram
Copy link
Copy Markdown
Owner

Summary

  • Decompose monolithic src/main.rs (13,241 lines) into 15 focused modules
  • main.rs reduced from 13,241 to 495 lines (module wiring + dispatch)
  • Pure structural refactoring — zero behavior changes

Module Breakdown

Module Lines Responsibility
main.rs 495 Module wiring, CLI dispatch
cli.rs 1,173 Clap CLI struct definitions
types.rs 978 Shared type definitions
config.rs 107 Config loading and resolution
search.rs 317 BM25, SimHash, MinHash primitives
util.rs 579 Shared utilities and index loaders
index.rs 639 Index building (yore build)
assemble.rs 1,570 Assembly engine and cross-refs
mcp.rs 767 MCP protocol handlers
commands_query.rs 1,243 query, similar, dupes, diff
commands_text.rs 840 stats, repl, vocabulary, eval
commands_links.rs 1,377 check-links, policy, fix-links
commands_graph.rs 877 mv, paths, export-graph, stale, health
commands_audit.rs 498 orphans, canonicality, suggest
tests_main.rs 1,939 Unit tests (extracted via #[path])

Test plan

  • All 125 tests pass (74 unit + 51 integration)
  • cargo clippy -- -D warnings clean
  • cargo fmt --check clean
  • No behavior changes — purely moves code between files
  • Each extraction step verified independently

Break a monolithic 13,241-line main.rs into cohesive modules:

- cli.rs: Clap CLI struct definitions (1173 lines)
- types.rs: all shared type definitions (978 lines)
- config.rs: config loading and resolution (107 lines)
- search.rs: BM25, SimHash, MinHash primitives (317 lines)
- util.rs: shared utilities and index loaders (579 lines)
- index.rs: index building (639 lines)
- assemble.rs: assembly engine and cross-refs (1570 lines)
- mcp.rs: MCP protocol handlers (767 lines)
- commands_query.rs: query, similar, dupes, diff (1243 lines)
- commands_text.rs: stats, repl, vocabulary, eval (840 lines)
- commands_links.rs: check-links, policy, fix-links (1377 lines)
- commands_graph.rs: mv, paths, graph, stale, health (877 lines)
- commands_audit.rs: orphans, canonicality, suggest (498 lines)
- tests_main.rs: unit tests via #[path] (1939 lines)

main.rs is now 495 lines (module wiring + dispatch).
All 125 tests pass, zero clippy warnings.
@github-actions
Copy link
Copy Markdown

Commit squash-scope review

Range: origin/master..37159ca54ab7fb02553689194d343560cbf4753d
Commits reviewed: 2

Heuristic candidates

No clear squash candidates found from overlap or message-prefix heuristics.

SQUASH_SCOPE_NEEDS_REWRITE=0

@rahulrajaram rahulrajaram merged commit 486b090 into master Mar 27, 2026
6 checks passed
@rahulrajaram rahulrajaram deleted the refactor/module-decomposition branch March 27, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant