Problem
sensing-server/src/main.rs is 3,765 lines with cyclomatic complexity ~65. It contains 12 structs, 60+ functions, and a 37-field AppStateInner god object. This was identified as Finding #2 in the quality engineering analysis (#170) and is tracked as Sprint 2 in ADR-050.
Plan
Decompose into 14 focused modules across 6 phases. See ADR-051 for the full extraction plan.
Module Breakdown
| Module |
Contents |
~Lines |
cli.rs |
Args struct, CLI parsing |
100 |
state.rs |
AppStateInner + all DTOs |
220 |
signal.rs |
Feature extraction, classification |
350 |
smoothing.rs |
EMA smoothing, vital sign filtering |
180 |
routes_health.rs |
Health/readiness/info endpoints |
350 |
routes_model.rs |
Model management endpoints |
180 |
routes_recording.rs |
Recording endpoints |
210 |
routes_training.rs |
Training + adaptive endpoints |
120 |
routes_sensing.rs |
Vitals, WASM, SONA endpoints |
150 |
routes_pose.rs |
Pose estimation + endpoints |
280 |
websocket.rs |
WS upgrade + client handlers |
170 |
udp_receiver.rs |
UDP CSI frame receiver |
170 |
data_sources.rs |
Windows WiFi + simulated data |
400 |
router.rs |
Route assembly |
80 |
Result: main.rs drops to ~250 lines (startup only).
Extraction Phases
- cli.rs + state.rs (types only, zero behavioral change)
- signal.rs + smoothing.rs (pure functions)
- routes_health.rs + routes_model.rs + routes_recording.rs
- routes_training.rs + routes_sensing.rs + routes_pose.rs
- websocket.rs + udp_receiver.rs + data_sources.rs
- router.rs + final cleanup
Acceptance Criteria
References
Problem
sensing-server/src/main.rsis 3,765 lines with cyclomatic complexity ~65. It contains 12 structs, 60+ functions, and a 37-fieldAppStateInnergod object. This was identified as Finding #2 in the quality engineering analysis (#170) and is tracked as Sprint 2 in ADR-050.Plan
Decompose into 14 focused modules across 6 phases. See ADR-051 for the full extraction plan.
Module Breakdown
cli.rsstate.rssignal.rssmoothing.rsroutes_health.rsroutes_model.rsroutes_recording.rsroutes_training.rsroutes_sensing.rsroutes_pose.rswebsocket.rsudp_receiver.rsdata_sources.rsrouter.rsResult: main.rs drops to ~250 lines (startup only).
Extraction Phases
Acceptance Criteria
References