Skip to content

feat(wasm): add private execution-limit policy and shared-memory ledger #41

Closed

Description

@zackees

Child of #27. Depends on #35; contributes to #13 and #14, and establishes the in-process accounting boundary that #28 will contain when execution is non-cooperative.

Scope

Add facade-owned semantic execution limits and a private per-logical-sketch execution session/ledger over the #35 threaded root:

  • aggregate logical shared-memory reservation;
  • active root-execution permit;
  • guest-thread hard cap;
  • bounded execution/fuel budget fields reserved for the following child;
  • bounded deadline/cancellation-registration fields reserved for the following epoch child.

The ledger owns exactly one shared-memory reservation lease for a prepared execution session. For the exact Rust 1.95 threaded contract, reserve the admitted maximum before SharedMemory::new: 16,384 × 65,536 = 1,073,741,824 bytes (1 GiB). Current committed pages are telemetry only; they must never permit aggregate oversubscription. The lease releases exactly once when session preparation, execution, or teardown terminates.

Add private counters/snapshots for logical sketch id, configured/reserved/current shared pages, active root permits, live Store/Instance/native-thread registrations, and terminal state. Public errors/configuration use only facade-owned semantic values; do not expose Engine, Store, Instance, SharedMemory, limiter, pointer, or backend diagnostics.

Invariants

  • Reserve before SharedMemory::new, and reject a quota failure before engine-owned allocation or Wasm effect.
  • Shared-memory accounting is owned by kernal-api, independent of Store::limiter, pooling, or committed-page observation.
  • Release is idempotent: normal completion, root/child trap, failed preparation, and explicit session close cannot underflow or leak the lease/permits.
  • Existing feat(wasm): bootstrap owned threaded guest instances #35 shared module/prelink semantics remain private; no additional runtime, allocator, pool, or backend fallback.
  • default = [] and full do not resolve Wasmtime/parser/scheduling support; heavyweight behavior remains behind wasm-sketch-host.

Non-goals

No fuel/epoch configuration, timer, cancellation, async guest resources, stream/blob limits, worker-process containment, pool allocator, or Tauri. Pending async-operation quotas are deferred to the generated operation lifecycle work; this issue budgets only executable roots and native guest registrations.

RED → GREEN

  • RED: characterize that two admitted threaded roots can prepare their 1 GiB-compatible shared memory without a kernel-owned aggregate reservation/release observation.
  • RED: characterize that a failed preparation/trap has no facade-owned resource snapshot.
  • GREEN: a configured aggregate 1 GiB ceiling admits one exact threaded session and deterministically rejects a second reservation before SharedMemory::new/Wasm; a larger configured ceiling has exact arithmetic and no overflow.
  • GREEN: normal completion, child/root trap, failed SharedMemory::new, and explicit close release exactly one lease and leave zero active root permits/live registrations/accounted bytes.
  • GREEN: snapshots distinguish reserved maximum from current observed pages and identify shared-session versus per-thread state without backend leakage.
  • GREEN: regression fixtures prove no Store::limiter or pooling allocator is required for the shared-memory boundary.
  • GREEN: focused Soldr tests pass on Linux/macOS/Windows x86-64/ARM64 compilation matrix; actual native runs are recorded separately. --no-default-features remains free of Wasmtime/parser.

Deliverables

  • Facade semantic limit/config/error/snapshot types.
  • Private execution-session, permit, and shared-memory lease/ledger implementation.
  • Pre-allocation rejection and exact-once teardown tests.
  • Resolved Wasmtime-45 compatibility/accounting note and focused Soldr commands.

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