Skip to content

baofeng/detect.rs is an orphaned file — never compiled, never tested #238

Description

@forkwright

Finding

The file crates/syntonia/src/baofeng/detect.rs implements auto_detect, try_magic, and a local SerialPort trait, but is not declared as a submodule in crates/syntonia/src/baofeng/mod.rs. It is therefore not a member of the crate and is never compiled under any feature flag or test configuration. The entire auto-detection flow and its five in-file tests are unreachable.

Evidence

crates/syntonia/src/baofeng/mod.rs:3 begins the submodule declaration block, which lists bcd, codec, constants, ident, image, memmap, protocol, tone_codec, and variantdetect is absent. Because no mod detect; line exists, detect.rs is not part of the compilation unit. cargo test -p syntonia produces no auto_detect, try_magic, or SerialPort (detect-variant) symbols in its output, and the five tests (e.g. detect_with_bad_ack_tries_next_magic, unknown_ident_returns_variant_error) never execute.

Why this matters

The radio-identification logic — trying three magic byte sequences to recognize a connected device — is dead code. Variant misidentification corrupts EEPROM writes, so any defect in try_magic or the bad-ACK handling is both unexercised and undetectable. Under a counter-surveillance threat model, a silently-broken or silently-absent detection path means the operator cannot trust that the tool is talking to the radio it claims to be, and a calibration-destroying write could be issued against the wrong device profile.

Desired correction

Make the disposition explicit. Either add pub(crate) mod detect; (or #[cfg(feature = "hardware-serial")] pub(crate) mod detect;) to mod.rs and resolve the resulting compilation errors, or delete the file with a documented rationale that records where the detection flow now lives.

Done when: cargo test -p syntonia (or --features hardware-serial) includes baofeng::detect::tests::* in its output, or detect.rs is removed with a documented rationale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions