-
-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Problem
We have significant technical debt from large files that are difficult to navigate and maintain. Files over 1500 lines become code smells, especially when they contain large test modules that could be separated.
Goals
- Split large test modules into separate files (modern Rust
module.rs+module/tests.rspattern) - Extract logical sub-modules from large implementation files
- Improve code navigability without changing functionality
- Establish patterns for future file organization
Statistics (files >1000 lines)
2231 handshake.rs ← In progress (#2015)
2214 priority_select.rs ← In progress (#2012)
1995 connection_handler.rs
1778 client_events/mod.rs
1682 p2p_protoc.rs
1598 tracing/mod.rs
1502 node/mod.rs
1413 operations/connect.rs
1407 operations/put.rs
1337 operations/get.rs
1281 contract/executor/runtime.rs
1235 config/mod.rs
1191 operations/update.rs
1055 topology/mod.rs
Phased Approach
To avoid overwhelming reviewers and minimize merge conflicts, we'll tackle this in phases:
Phase 1: Test Module Extraction (Low Risk) ✅
Simple mechanical splits - extract test modules to separate files.
-
priority_select.rs→priority_select.rs+priority_select/tests.rs(refactor: split priority_select into module with separate test file #2012) -
handshake.rs→handshake.rs+handshake/tests.rs(refactor: split handshake into module with separate test file #2015)
Status: 2 PRs in merge queue
Phase 2: Operations Module Reorganization (Medium Risk) 🔄
Extract message types and state definitions into submodules.
-
operations/put.rs- Extract messages module (already exists inline) -
operations/get.rs- Similar structure -
operations/update.rs- Similar structure -
operations/connect.rs- Similar structure
Approach: Each operations file already has some internal structure. Extract message definitions, state types, and potentially split large impl blocks.
Phase 3: Complex Module Reorganization (Higher Risk) 📋
Requires more design thought and careful review.
-
p2p_protoc.rs- Protocol state machine -
connection_handler.rs- Transport layer with utilities -
node/mod.rs- Core node logic -
client_events/mod.rs- Client event handling -
config/mod.rs- Configuration management
Phase 4: Other Large Files 📋
-
tracing/mod.rs -
contract/executor/runtime.rs -
topology/mod.rs
Principles
- No logic changes - Pure refactoring only
- All tests must pass - Every PR verified with full test suite
- Modern Rust idioms - Use
module_name.rs+module_name/notmod.rs - Reviewable chunks - 2-3 PRs at a time maximum
- Phased execution - Wait for previous phase to merge before starting next
Progress Tracking
Each completed item will be checked off and linked to its PR. Discussion and feedback welcome on the approach!
🤖 Generated with Claude Code
[AI-assisted debugging and comment]
Metadata
Metadata
Assignees
Labels
Type
Projects
Status