Architecture

Runtime Prototype

Kernel decides what runs. Runtime is what actually runs it — a thread, an async executor, a deterministic loop. Keeping them apart is why a tiny tool never pulls in an async runtime.

Status. rustclamp-runtime defines executor-neutral, synchronous task supervision contracts. ManualRuntime drives them deterministically with no external crates; an optional tokio feature adds an adapter. Both are prototype contracts, exercised by example 05.

Why a separate layer#

  • Zero-cost absence. No async code means no async runtime requirement. The default build of the lifecycle example resolves Core, Kernel and Runtime only; Tokio appears when the feature is selected.
  • Many kinds of software. A CLI, a network service, a game loop and a device firmware loop execute differently. The composition model should not change between them.
  • Abstractions over products. Tokio is one provider behind the task contract, not a built-in assumption. Core and the base contract contain no Tokio types and require no async API.

Task supervision#

A task declares its process, whether it is finite or long-lived, whether it is required, and how a failure is recovered. TaskRuntime runs it under one of two drivers:

ModeExternal packagesExecutorPurpose
Default · ManualRuntime0NoneDeterministic coordination and tests
tokio featureTokio + platform cratesOwned multithreaded runtime, or the caller's existing handleSupervised sync and native async tasks, Ctrl-C as a neutral signal

The runtime is chosen per process. In the lifecycle example Worker selects Tokio while Reporter stays on the manual driver, and the default build contains no Tokio at all.

Limits, stated plainly#

  • Cancellation is cooperative. It cannot undo committed side effects, and a task that ignores it may outlive its join timeout.
  • Panics are reported when unwinding is enabled; panic-abort builds cannot recover them.
  • Failure policy belongs to the application, because only it knows which work is critical. RestartOnce is deliberately limited to one retry in this proof.

Responsibilities#

KernelRuntime
Resolves and freezes what a process containsDrives execution of that frozen plan
Orders lifecycle participantsProvides the scheduling those participants run on
CoordinatesExecutes and supervises

Measured cost#

From the Phase 5 evidence, one host, release builds. The Tokio adapter adds 47,696 B to the lifecycle executable and grows the resolved graph from 3 to 17 packages. Over 4,500 tasks, direct work takes 7 ns/task; the manual supervisor 601 ns/task with 5 allocations; the Tokio blocking-task adapter 1.105 ms/task — it schedules through spawn_blocking, so this is not an end-to-end service workload. See Evidence.

Next#

LoopRuntime drives deterministic tick loops under the same task context — see Loops and devices. Pico still needs none of this: Clamp::run calls your closure once on the current thread.