Skip to content

F0057 host-3

Rule: Unknown enum values from the host are refused, not mapped to a default.

Code F0057 (stable, never reused)
Id host-3
Category host
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded warn bedrock warning: Unknown enum value from a newer host mapped to a default (_ => ..) instead of refused
ui off
egui off
units-strict off
units-paranoid off

Why

A host built against a newer wire protocol can send an enum variant this firmware doesn't know about. Matching it with a catch-all arm (_ => some_default) makes the firmware silently do something else than what the host asked for, instead of telling the host its request wasn't understood.

Example

This is a general wire-compatibility trap anywhere a request carries an enum the firmware dispatches on — usb_io_fw's diag API (API-5) is exactly the shape of surface (many small enum-tagged requests, built and evolved independently of any one host) where a newer host's added variant would otherwise land on whatever arm a _ => catch-all happens to pick.

How to fix

Refuse an enum value the firmware doesn't recognize with a typed "unknown/unsupported" error instead of mapping it to any existing variant; WireWeaver's evolution rules exist so a protocol can grow a variant without old firmware needing to guess at it.

How it is checked

Src mid — needs the dispatch model (which match arms exist, which is the catch-all, whether the catch-all returns an error or a default) rather than a single pattern.

Source

Ported from embedded_bedrock's firmware check catalogue, HOST-3 (book/checks.md, detail in book/checks/host.md). Found on: usb_io_fw API-5.

Configure

[lints.host-3]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(host-3) <reason> (waivers); the code works there too, as in [lints.F0057].