fix(mcp): raise discover_devices timeout floor from 250ms to 1000ms - #475
Conversation
DaqifiAgent.DiscoverAsync clamped the caller's timeout to a 250 ms floor, but the serial identify handshake measures ~830 ms on real hardware (bench Nq1, fw 3.7.2). Every timeout in the lower two-thirds of the advertised 250..30000 range — including the floor itself — returned an empty list before the device could ever answer, silently indistinguishable from "no device attached". Raise the floor to 1000 ms (measured ~830 ms plus ~20% margin) and update the discover_devices tool description to match. Successful discovery still returns as soon as the device responds, not at the full timeout, so this only rejects budgets that could never have succeeded. Extract the clamp into DaqifiAgent.ClampDiscoveryTimeout so it's directly unit-testable; there was no test for the clamp before. Fixes #448
PR Summary by QodoFix device discovery timeout clamp: raise floor to 1000ms and add unit tests
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
The timeoutMs description and ClampDiscoveryTimeout's doc comment said successful discovery returns as soon as a device responds. True for serial probing, but WiFiDeviceFinder's receive loop runs until its CancelAfter(timeout) fires regardless of how quickly a device replies — so a wifi=true call (the default) generally takes close to the full budget either way. Corrected both. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit c0dabe0 |
Summary
DaqifiAgent.DiscoverAsyncclamped the caller'stimeoutMsto a 250 ms floor, but the serial identify handshake takes ~830 ms on real hardware. Every value in the lower two-thirds of the advertised250..30000range — including the floor itself — returned an empty list, silently indistinguishable from "no device is plugged in".Confirmed on bench hardware (Nq1, fw 3.7.2, USB CDC) in #448: 16/16 successful runs returned in 0.80–0.86 s regardless of a 900 ms or 2000 ms budget (the device answers as soon as it's ready, not at the timeout), while every run below ~830 ms failed at exactly its timeout.
Fix
DaqifiAgent.MinDiscoveryTimeoutMsfrom 250 to 1000 (measured ~830 ms + ~20% margin).discover_devicestool description to match and explain why.DaqifiAgent.ClampDiscoveryTimeout— there was no test for the clamp before; this makes it directly unit-testable without spinning up real device finders.The secondary "distinguish timeout from no-device" and "call out the ~1ms claim-skip window" suggestions from the issue are left for a follow-up if it comes up again — this fix addresses the actual bug (a floor that could never succeed).
Testing
ClampDiscoveryTimeout_BelowFloor_ClampsToFloor,ClampDiscoveryTimeout_WithinRange_IsUnchanged,ClampDiscoveryTimeout_AboveCeiling_ClampsTo30SecondsDaqifi.Mcp.Testssuite: 43 passedDaqifi.Core.Testssuite: 2853 passedFixes #448
🤖 Generated with Claude Code