Skip to main content

Module supervisor

Module supervisor 

Source
Expand description

OTP-shaped supervisor trees, encoded as a typed :kind Supervisor caixa with a strategy + restart-policy children list.

See theory/INSPIRATIONS.md §II.2 + §III.2 for the prior-art frame (Erlang OTP supervisor + Lunatic supervisor strategies as Rust types).

(defcaixa
  :nome           "my-app-root"
  :versao         "0.1.0"
  :kind           Supervisor
  :estrategia     OneForOne
  :max-restarts   5
  :restart-window "60s"
  :children       ((:caixa "worker"       :versao "^0.1" :restart Permanent)
                   (:caixa "cache-server" :versao "^0.1" :restart Transient)
                   (:caixa "scratch-job"  :versao "^0.1" :restart Temporary)))

wasm-operator (M3) walks the tree, materializes one ComputeUnit per child, and applies the strategy on child failure. The Rust types here are the typed contract; the runtime owns lifecycle.

Modules§

duration_codec
Shared duration string codec for the typed slots that take a duration (restart_window, MeshPolicy::timeout, CircuitBreaker::window, …). Public so crate::aplicacao can reuse it without duplicating the parser.
duration_codec_required
Required-Duration variant for fields that aren’t Option.

Structs§

ChildSpec
One child entry in the supervisor’s :children list.
RestartPolicyParseError
Auto-generated parse error for the matching FromStrKind impl.
RestartStrategyParseError
Auto-generated parse error for the matching FromStrKind impl.
SupervisorSpec
Supervisor-typed slots that live alongside the standard Caixa fields when :kind Supervisor. Held flat in crate::Caixa so the manifest stays a single typed form; this struct exists for validation + conversion.

Enums§

RestartPolicy
Per-child restart policy.
RestartStrategy
One of the four canonical Erlang/OTP restart strategies.
SupervisorError

Constants§

SUPERVISOR_CHILD_RESTART_DEFAULT
Substrate-canonical Erlang/OTP-shaped per-child restart-decision-policy default for the :children :restart axis — the OTP permanent worker-child default ({ChildId, StartFunc, permanent, …} in a supervisor’s init/1 child-spec tuple), extracted as a typed pub const so every substrate-side consumer that resolves “what ChildSpec::restart variant does an author-omitted :children :restart slot degrade onto?” reaches for exactly one substrate- primitive RestartPolicy.
SUPERVISOR_ESTRATEGIA_DEFAULT
Substrate-canonical Erlang/OTP-shaped sibling-restart-strategy default for the :supervisor :estrategia axis — the canonical one_for_one half of Learn You Some Erlang’s {one_for_one, intensity, 5, 60} worker-supervisor default, extracted as a typed pub const so every substrate-side consumer that resolves “what SupervisorSpec::estrategia variant does an author-omitted :estrategia slot degrade onto?” reaches for exactly one substrate- primitive RestartStrategy.
SUPERVISOR_MAX_RESTARTS_DEFAULT
Substrate-canonical Erlang/OTP-shaped MaxIntensity restart-budget- count default for the :supervisor :max-restarts axis — the canonical {intensity, 5, 60} MaxIntensity half of Learn You Some Erlang’s worker-supervisor default, extracted as a typed pub const so every substrate-side consumer that resolves “what SupervisorSpec::max_restarts value does an author-omitted :max-restarts slot degrade onto?” reaches for exactly one substrate-primitive u32.
SUPERVISOR_MAX_RESTARTS_MAX
Upper-bound ceiling on the :supervisor :max-restarts axis — every validated SupervisorSpec::max_restarts past SupervisorSpec::validate lies in 1..=SUPERVISOR_MAX_RESTARTS_MAX.
SUPERVISOR_RESTART_WINDOW_DEFAULT
Substrate-canonical Erlang/OTP-shaped Period sliding-window-duration default for the :supervisor :restart-window axis — the canonical {intensity, 5, 60} Period half of Learn You Some Erlang’s worker-supervisor default, extracted as a typed pub const so every substrate-side consumer that resolves “what SupervisorSpec::restart_window value does an author-omitted :restart-window slot degrade onto?” reaches for exactly one substrate-primitive Duration.
SUPERVISOR_RESTART_WINDOW_MAX
Upper-bound ceiling on the :supervisor :restart-window axis — every validated Some(SupervisorSpec::restart_window) past SupervisorSpec::validate lies in 1ms..=SUPERVISOR_RESTART_WINDOW_MAX (inclusive on both ends, integer-millisecond magnitudes by the canonical-form gate immediately preceding).

Functions§

validate_no_self_supervision
Cross-slot coherence gate on the supervision tree: no :children :caixa entry may name the supervisor’s own :nome.