Skip to Content
axiomOSmainDecisions (ADRs)ADR-0002: Kernel Error Policy

ADR-0002: Kernel Error Policy

Relevant source files

Status: Accepted. Date: 2026-07-14.

Decision

Kernel failures are classified by boundary and handled consistently:

ClassRepresentationRequired behavior
Invalid userspace requestErrno, or a typed error mapped once to ErrnoReturn to the caller; never panic or log synchronously on a hot path
Malformed untrusted inputTyped parser/validation errorReject without partial publication or leaked ownership
Resource exhaustionTyped allocation/quota errorRoll back and return an error, or terminate only the affected task when no caller exists
Would blockTyped readiness resultRegister on a wait channel and retry after wake; preserve nonblocking semantics
Recoverable device/filesystem errorTyped subsystem errorPropagate with context through adapters; never collapse to ()
Boot prerequisite failureBootErrorEmit one bounded fatal record and enter the architecture halt path
Kernel invariant violationDedicated assertion/fatal pathPanic in debug/test; fail closed with a bounded diagnostic in release

Further rules:

  • Public subsystem traits must not use Result with a () or &'static str error type. Errors own stable machine-readable variants; human-readable formatting is not ABI.
  • Operations that acquire resources publish only after all fallible preparation succeeds, or carry a rollback guard that restores the old state on every error path (see mapping transactions).
  • Interrupt handlers cannot format errors: they bump bounded counters, store a compact trace record, move hardware to its safe state, and defer recovery to task context.

In the code

  • Boot uses a BootError enum with stable codes printed once as BOOT_FATAL code=... before halting; kernel::init returns a thiserror-derived KernelInitError (Boot Flow).
  • Syscall dispatch functions return Result with Errno; user-copy failures stay UserMemError until the adapter maps them to EFAULT.

Enforcement

  • Clippy plus a repository check reject unit/string errors at designated public kernel boundaries.
  • cargo xtask check error-policy rejects panic/unwrap/todo and unit-error regressions in supported boot, filesystem-initialization and driver paths; rejects unit/string errors at low-level address, fork/exec and AArch64 paging/DTB boundaries; and enforces the bounded release fatal path and transactional block-device publication order.
  • Failure-injection tests cover every transactional allocation/mapping API.
  • Syscall adapters hold the only subsystem-error-to-Errno mapping tables.
Last updated on