Skip to content

Fix AgentClient::connect reporting BadMagic(0) instead of Timeout#62

Merged
harshverma27 merged 1 commit into
mainfrom
claude/issue-52-fix
Jun 30, 2026
Merged

Fix AgentClient::connect reporting BadMagic(0) instead of Timeout#62
harshverma27 merged 1 commit into
mainfrom
claude/issue-52-fix

Conversation

@harshverma27

Copy link
Copy Markdown
Owner

Fixes #52

Summary

  • AgentClient::connect polls OFF_MAGIC until poll_timeout elapses, 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 as SdkError::BadMagic(0) — indistinguishable from genuinely wrong firmware being loaded.
  • Split the loop into separate branches: a non-zero, non-matching magic still fails fast as BadMagic, but a magic that stays exactly 0 past the deadline now reports SdkError::Timeout instead, since Timeout exists in the error enum but was never reachable from connect().

Test plan

  • Added 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 asserts connect() returns SdkError::Timeout rather than BadMagic.
  • cargo test -p nucleus-test-sdk --lib — 10 passed
  • cargo clippy -p nucleus-test-sdk --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

Generated by Claude Code

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.
@harshverma27
harshverma27 merged commit 1136bdf into main Jun 30, 2026
5 checks passed
@harshverma27
harshverma27 deleted the claude/issue-52-fix branch June 30, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

connect() returns BadMagic(0) on device timeout instead of SdkError::Timeout

2 participants