Fix AgentClient::connect reporting BadMagic(0) instead of Timeout#62
Merged
Conversation
connect() polls for the mailbox magic word until poll_timeout, but a device that never publishes the magic at all (no probe attached, power issue) used to fall through to BadMagic(0) once the deadline passed, indistinguishable from genuinely wrong firmware being loaded. Split the deadline check into its own branch so a magic that stayed exactly 0 the whole poll reports SdkError::Timeout, while a non-zero non-matching magic still fails fast as BadMagic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #52
Summary
AgentClient::connectpollsOFF_MAGICuntilpoll_timeoutelapses, but previously combined the "wrong magic" and "deadline passed" conditions into a single check, so a device that never boots (magic stays 0 the whole poll) was reported asSdkError::BadMagic(0)— indistinguishable from genuinely wrong firmware being loaded.BadMagic, but a magic that stays exactly 0 past the deadline now reportsSdkError::Timeoutinstead, sinceTimeoutexists in the error enum but was never reachable fromconnect().Test plan
connect_times_out_instead_of_reporting_bad_magic_zero, which removes the magic word from the fake device's RAM (simulating a device that never publishes it) and assertsconnect()returnsSdkError::Timeoutrather thanBadMagic.cargo test -p nucleus-test-sdk --lib— 10 passedcargo clippy -p nucleus-test-sdk --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanGenerated by Claude Code