Skip to content

Safety profiles

Safety-critical domains have coding standards that restrict what language features are allowed. Milo can check your code against these standards at compile time.

bash
milo safety flight_controller.milo --safety=do178c-a

Available profiles

bash
milo safety --list
DomainStandardProfilesGoverns
AvionicsDO-178Cdo178c-a, do178c-b, do178c-cAirborne software (DAL A–C)
AutomotiveISO 26262iso26262-a through iso26262-dVehicle ECUs, ADAS (ASIL A–D)
SpacecraftNASA-STD-8739.8nasa-a, nasa-bFlight software (Class A–B)
IndustrialIEC 61508iec61508-3, iec61508-4Nuclear, rail signaling (SIL 3–4)
MedicalIEC 62304iec62304-a, iec62304-b, iec62304-cDevice software (Class A–C)

What gets checked

Each profile is a combination of constraints, tuned to the standard's requirements:

ConstraintDescriptionStrictest at
No recursionDirect self-calls bannedDO-178C A, IEC 61508 SIL 4
Bounded loopswhile loops must have invariant clausesDO-178C A, NASA A
No dynamic allocationNo Vec, String, HashMap constructionIEC 61508 SIL 4
Require contractsAll functions need requires/ensuresDO-178C A, NASA A
No floating pointInteger-only arithmetic (no f32/f64 in signatures, locals, casts, or literals)IEC 61508 SIL 4
No recursive typesSelf-referential types banned even through Heap<T>: recursive data has unbounded traversal depthDO-178C A, IEC 61508 SIL 4
Max call depthLongest static call chain bounded (call graph is a DAG since recursion is banned)IEC 61508 SIL 4 (max 20)
Complexity limitCyclomatic complexity cap per functionIEC 61508 SIL 4 (max 15)
No unsafe blocksunsafe { } banned entirelyAll profiles
Full match coverageAll match arms required (enforced by the type checker's exhaustiveness pass)Most profiles
Used resultsA discarded Option, Result or @mustUse result (the unused-result warning) is an errorDO-178C A–C, NASA A–B

The command exits nonzero and names the profile on every violation:

safety check failed: do178c-a, 4 violation(s)

  error: [do178c-a] function 'processInput' must have requires/ensures contracts
  error: [do178c-a] while loop in 'processInput' must have an invariant clause for bounded execution (line 3:5)
  error: [do178c-a] recursion detected: processInput -> processInput (banned at this safety level)
  error: [do178c-a] static call depth (unbounded) starting at 'processInput' exceeds max 30

Integrating with CI

Add safety checking to your build pipeline:

bash
milo safety src/controller.milo --safety=do178c-a || exit 1

The command exits with code 1 if any errors are found, making it suitable for CI gates.