Priority: High
RequestHandler (~780 lines) concentrates too many responsibilities: device-state management, payload decoding, EMA time updates, edge inference, offloading, background I/O scheduling, CSV/JSONL/debug output, and profiling. All shared state lives in mutable class-level variables (device_profiles, model_registry, variance_detector, csv_writer, inference_counter, …), which makes the class hard to test and extend.
Tasks
Files
src/server/communication/request_handler.py
From the Feature 042 codebase review (recommendations #2, #9, #14).
Priority: High
RequestHandler(~780 lines) concentrates too many responsibilities: device-state management, payload decoding, EMA time updates, edge inference, offloading, background I/O scheduling, CSV/JSONL/debug output, and profiling. All shared state lives in mutable class-level variables (device_profiles,model_registry,variance_detector,csv_writer,inference_counter, …), which makes the class hard to test and extend.Tasks
DeviceStateManager(profiles, EMA updates, variance tracking)InferenceCycleRecorder(CSV, JSONL, debug file output)OffloadingService(wrapper aroundOffloadingAlgo+ decision logging)handle_device_inference_result(EMA update, offloading decision, background I/O scheduling) — currently the most critical component has no dedicated testsdevice_profiles,inference_counter, and the variance sets are mutated from the ASGI thread and the background I/O thread without locksFiles
src/server/communication/request_handler.pyFrom the Feature 042 codebase review (recommendations #2, #9, #14).