Expand description
Lunatic-style per-process resource limits — the typed slot of
caixa.lisp that wasm-engine consumes at component instantiation.
See theory/INSPIRATIONS.md §III.1 for the prior-art frame: every
caixa Servico runs sandboxed by default; no “trust the author”.
(defcaixa
:nome "my-service"
:versao "0.1.0"
:kind Servico
:limits ((:memory "64MiB") ;; max linear memory per instance
(:fuel 1000000) ;; max wasm-instructions per request
(:wall-clock "30s") ;; max wall-clock per request
(:cpu "500m")) ;; soft cgroup CPU share (millicores)
:servicos ("servicos/my-service.computeunit.yaml"))Authors omit the slot for “no limits” (today’s behavior). When set, wasm-engine M2 wires:
LimitsSpec::memory→wasmtime::StoreLimits::memory_sizeLimitsSpec::fuel→Store::set_fuel+ per-tick refillLimitsSpec::wall_clock→ epoch deadline cancellationLimitsSpec::cpu→ cgroup-v2 hint propagated via the pod spec
Structs§
- Limits
Spec - Per-process limits. All fields optional —
None= unbounded for that axis.
Enums§
Constants§
- LIMITS_
CPU_ MILLICORES_ MAX - Upper-bound ceiling on the
:limits :cpuaxis, in Kubernetes millicores — every validatedLimitsSpec::cpupastLimitsSpec::validatelies in1..=LIMITS_CPU_MILLICORES_MAX(inclusive on both ends). - LIMITS_
FUEL_ MAX - Upper-bound ceiling on the
:limits :fuelaxis, in wasm instructions per outermost call — every validatedLimitsSpec::fuelpastLimitsSpec::validatelies in1..=LIMITS_FUEL_MAX(inclusive on both ends). - LIMITS_
MEMORY_ WASM32_ MAX_ BYTES - Hard upper bound for
:limits :memory, in bytes — thewasm32-wasip2linear-memory ceiling. The canonical caixa Servico compilation target (theory/CAIXA-SDLC.md§V — Substrate / Nix) iswasm32-wasip2, whose linear memory is 32-bit- addressed at a 64 KiB page size; the in-spec maximum is2^16 pages × 2^16 bytes/page = 2^32bytes = 4 GiB exactly. A:limits :memoryvalue above this bound is structurally unreachable under wasm32: wasmtime’sStore::limitercannot grow past the 32-bit address space, so an authored"8GiB"either silently saturates at the engine’s effective cap or surfaces as amemory.growtrap at runtime, far from the source caixa.lisp. - LIMITS_
MEMORY_ WASM32_ PAGE_ BYTES - Structural floor for
:limits :memory, in bytes — thewasm32-wasip2linear-memory page size. The wasm spec defines linear memory in fixed 64 KiB pages (2^16bytes); every typed memory cap is consumed bywasmtime::StoreLimits::memory_sizeas a per-component byte ceiling against which the engine checks everymemory.growrequest. A cap below one page (< 65536bytes) is structurally a “no wasm linear memory allowed” cap — instantiation of any wasm component that declares(memory 1)(i.e. min=1 page, the canonical default for every cdylib-shaped wasm component cargo emits) fails immediately withmemory minimum size of 1 pages exceeds memory limits; a min=0 component traps the firstmemory.grow(1)because the next-page allocation would cross the sub-page cap. Either way the typed value the wasm-engine consumes is operationally indistinguishable fromLimitsError::MemoryZero(no memory at all), but the diagnostic surfaces at engine-load time rather than at caixa-build time, far from the source caixa.lisp. - LIMITS_
WALL_ CLOCK_ MAX - Upper-bound ceiling on the
:limits :wall-clockaxis — every validatedLimitsSpec::wall_clockpastLimitsSpec::validatelies in1ms..=LIMITS_WALL_CLOCK_MAX(inclusive on both ends, integer-millisecond magnitudes by the canonical-form gate immediately preceding).