Skip to content

feat(wasm): enforce bounded per-session fuel and execution permits #42

Closed

Description

@zackees

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 × budget child 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 = []/full remain 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, and wasi_thread_start all 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

Activity

  1. added
    enhancement
    on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions