The short version
Safety code is the part you least want to break by accident. Rust is a programming language that checks, before the program ever runs, a whole class of mistakes that other languages let through: reading memory that is no longer yours, or two parts of a program changing the same thing at once. It is like a workshop where the saw will not start if the guard is off.
We write nearly everything in Rust. The same language runs on the Raspberry Pi, on the RP2350 chips and in the tests, so a rule is written once and checked in all three places.
The language mix
Computed on 26 November 2026 from the files tracked in the repository on main, using tokei 15, excluding lock files and fuzz corpus seeds. "Code" counts lines that are not blank and not comments. Markdown is documentation and is listed separately.
| Language | Files | Lines of code | Share of code |
|---|---|---|---|
| Rust | 147 | 38,904 | 90.5% |
| TOML | 28 | 2,188 | 5.1% |
| Python | 9 | 907 | 2.1% |
| YAML | 14 | 730 | 1.7% |
| JSON | 2 | 145 | 0.3% |
| Shell | 4 | 101 | 0.2% |
| WIT | 1 | 17 | under 0.1% |
| Total code | 205 | 42,992 | 100% |
Alongside that sit 51 Markdown documents with about 14,700 lines of design notes, the threat model, the decision log and the roadmap. The Rust count includes tests, which are a large share of it. The Python is CI tooling such as the regression guard and the benchmark runner. The repository is early, so these numbers will move.
Why Rust
- Memory safety without a garbage collector. Firmware has no room for a runtime that pauses.
- One language from firmware to host. The interlock, the module protocol, the bus guard and the approval format are
no_stdcrates that compile into both the supervisor and the firmware, so they cannot drift apart. CI builds them for the RP2350 target (thumbv8m.main-none-eabihf) on every change: seeci/no_std_crates.txt. - Types as guard rails. A reading's trust tier cannot be set by a plugin because the field is private, and a compile-fail test proves it. An authorized bus write can only be built by one function.
Where we forbid unsafe code
The workspace sets unsafe_code = "forbid" in Cargo.toml, and every crate under crates/ inherits it, so those crates contain no unsafe block. There are two exceptions, both outside the workspace lint. The RP2350 firmware image, firmware/trust-root, needs unsafe for raw register writes, and its manifest says so. The sample WebAssembly plugin uses unsafe for a static arena because a plugin with no imports cannot allocate otherwise; it runs in the plugin sandbox.
The pieces
sawbones-interlock: the state machine. See Interlock.sawbones-trust-rootandfirmware/trust-root: the RP2350 loop,no_std.sawbones-plugin-host: wasmtime, a zero-import component model sandbox and seccomp.sawbones-supervisor,-policy,-reading,-approvals,-busguard,-module-protocol,-regmap,-isolation,-sim-modules,-redteam,-benchand-solar-assistant(a read-only tap on a solar monitor's MQTT output).
The checks every change faces
Workflows live in .github/workflows.
- Tests, formatting and Clippy with warnings denied, including an arm64 run and a firmware build.
- Fuzzing of the four decoders that read outside bytes, weekly.
- Mutation testing with cargo-mutants on the safety crates, weekly.
- CodeQL for Rust and GitHub Actions, plus OpenSSF Scorecard and a workflow linter (zizmor).
- cargo-deny for advisories, licences, bans and sources, a build-script and proc-macro allow-list, and a typosquat check on new dependencies.
- Pinned actions. Every GitHub Action is pinned to a full commit SHA.
- Regression guard. A pull request that closes a bug must add a test named for the issue and a row in
docs/REGRESSIONS.md, and the guard judges the PR with the base branch's copy of itself. - Protected paths. Changes to CI, dependency policy, the red-team catalog and the contribution rules need a label and a clean-room review. The rule is described in
CONTRIBUTING.md. - Instruction-count benchmarks that fail on more than a 10% slowdown. See Benchmarks.
Everything is provisional
Crate documentation carries a "provisional" banner: the design is under review and types may change. Nothing here has run on real hardware yet.
Browse or contribute: github.com/rafe-walker/sawbones-labs.