Repository navigation
Description
Child of #27. Depends on #41, the private execution-limit/shared-memory-ledger child. Builds on #35 and contributes to #13/#14; #28 remains the containment boundary for non-cooperative blocking.
Scope
Enable Wasmtime 45 fuel instrumentation once when the private SketchCompiler engine is constructed: Config::consume_fuel(true). Record the Cargo-resolved Wasmtime version and selected Cranelift engine policy. Fuel is engine instrumentation, not a per-sketch engine toggle.
For each logical execution session, enforce a bounded total fuel credit. Before every root and child Store instantiates or calls Wasm, reserve a fixed fuel slice from session credit and call Store::set_fuel(slice). Root and child slices together may never exceed session credit. A child without a reservable slice is rejected before native spawn/Store/Instance construction; no TID, JoinHandle, Store, or permit leaks.
Map fuel exhaustion into a facade-owned typed terminal reason with logical root/guest-thread identity and bounded accounting. Integrate active-root and native-child execution permits from #41. Keep Store/Engine/Trap details private.
Invariants
consume_fuel(true)is selected once for the one engine before module compilation; each root and child Store starts with explicitly assigned fuel.- Fuel is the deterministic v1 compute boundary. It is not a throughput/rate limiter and is never silently replenished.
- Session aggregate reservation, not “full budget per Store,” prevents
N × budgetchild overspend. - No epoch interruption, async yield/call, timer, cancellation, extra Tokio runtime, Store crossing, or pooling allocator in this slice.
- Terminal diagnostics/snapshots are facade-owned and bounded; no Wasmtime
Trap,Store, or raw fuel backend values leak. default = []/fullremain isolated from engine/parser/scheduling dependencies.
Non-goals
No wall-clock deadline, Config::epoch_interruption, epoch ticker, async-yield/resume, cancellation, atomic-wait claim, worker process, generated async operations/resources/streams/blobs, or Tauri.
RED → GREEN
- RED: tight root and child loop fixtures have no configured deterministic aggregate compute ceiling.
- RED: characterize that assigning the full budget to each child would permit aggregate overspend.
- GREEN: fixed artifact/input/fuel deterministically terminates root and child loops with the typed fuel-exhausted result; normal small work completes.
- GREEN: exact root+child slice reservation never exceeds the session credit; exhausted child credit rejects before native spawn/Store/Instance and leaves zero leaked permit/TID/JoinHandle.
- GREEN: module start, root
_start, andwasi_thread_startall receive finite fuel before execution; fuel exhaustion during any stage is typed and teardown releases ledger/permits. - GREEN: concurrent sketches cannot consume one another’s ledger credit; outcome snapshots identify configured/reserved/remaining session fuel without backend leakage.
- GREEN: focused Wasmtime 45/Cranelift compatibility, Linux/macOS/Windows x86-64/ARM64 compile evidence, and no-default dependency-isolation checks are recorded.
Deliverables
- One-time private engine fuel configuration with resolved-version evidence.
- Per-session fuel-credit/permit controller and root/child Store initialization.
- Typed facade terminal reason/snapshot counters and deterministic loop fixtures.
- Focused Soldr commands and compatibility note.
Dependencies and closure
- Parent feat(wasm): add scheduling limits and teardown instrumentation #27; depends on feat(wasm): add private execution-limit policy and shared-memory ledger #41 and feat(wasm): bootstrap owned threaded guest instances #35; parent chain feat(wasm): add engine policy and strict module admission validation #25/feat(wasm): add threaded Rust guest and owned thread bootstrap #26/feat(wasm): establish threaded sketch build, import validation, and lifecycle substrate #15; contributes to feat(wasm): prove a streamed kernal-api Rust sketch runtime with zccache and extension2 cores #13/feat(wasm): drive a Tauri screenshot task through the async kernal API #14.
- Epoch/deadline/cancellation work depends on this issue.
- feat(wasm): add killable threaded-sketch worker containment #28 remains required for non-cooperative atomic waits/blocked host calls; this issue must not claim to interrupt them.
- Close only when total per-session fuel is enforced across every root/child Store and all fuel terminal paths drain accounting/permits.
Activity