Skip to content

feat(wasm): add scheduling limits and teardown instrumentation #27

Closed

Description

@zackees

Context

Implementation child of #15, following #25 and #26, and required by #13/#14. Make the real threaded guest execution safe and measurable under resource pressure before application capabilities exist.

Depends on

Proposal

Add private scheduling and lifecycle controls for the selected Wasmtime baseline:

  • bounded execution using fuel and epoch interruption where the selected engine supports them;
  • explicit kernel-owned shared-memory accounting independent of Store limiter/pooling allocator;
  • configured per-sketch guest thread, memory, execution, and pending-work limits;
  • cancellation/timeout coordination with the single facade-owned kernel runtime;
  • teardown instrumentation proving cleanup of guest execution, host registrations, permits, and memory-accounting state.

Policy uses facade-owned semantic configuration/errors and keeps engine details private. Fuel/epoch settings must be verified against the resolved Wasmtime version, not assumed from the researched baseline.

Invariants

  • The threaded profile does not rely on a pooling allocator for shared-memory limits.
  • Limits are enforced by kernal-api and are not delegated solely to Wasmtime Store limiting.
  • Timeout/cancellation must not create another Tokio runtime or block the host event loop.
  • Instrumentation identifies logical sketch, guest thread, Store/Instance lifetime, configured/observed memory, interrupts, terminal reason, and live-host-resource count without exposing backend types.
  • default = [] stays independent of all engine/scheduling dependencies.

Non-goals

  • Worker-process implementation (handled by the following containment issue).
  • Async guest capability/resources/streams/blobs/output, Tauri, and screenshots.
  • Claiming atomic-wait interruption is reliable before empirical proof.

Acceptance criteria

  • RED: tests demonstrate no configured execution/memory accounting boundary currently exists for the feat(wasm): add threaded Rust guest and owned thread bootstrap #26 threaded guest.
  • RED: fixtures demonstrate excess thread/memory/execution demand is not yet rejected or observable with facade-owned diagnostics.
  • GREEN: resolved Wasmtime configuration for fuel, epoch interruption, and shared memory is recorded and exercised, or unsupported portions produce an explicit typed unsupported result.
  • GREEN: configured fuel/epoch execution budget interrupts non-cooperative guest compute deterministically where supported.
  • GREEN: shared-memory maximum is accounted/enforced by kernal-api independently of Store limiter and pooling allocator.
  • GREEN: thread, memory, execution, and pending-work limits reject excess demand deterministically with facade-owned errors.
  • GREEN: cancellation/timeout cleanup leaves no live guest scheduling registrations, permits, or accounted memory after normal completion, trap, fuel exhaustion, and epoch-check interruption; blocked atomic waits and host-blocked waits explicitly defer to feat(wasm): add killable threaded-sketch worker containment #28 containment.
  • GREEN: instrumentation proves one kernel runtime and reports shared versus per-thread execution state.
  • GREEN: focused test coverage compiles on Linux, macOS, and Windows x86-64/ARM64; runtime reports identify native coverage.
  • GREEN: no-default-feature checks remain isolated from engine/scheduling dependencies.

Deliverables

  • Private limit/scheduling configuration and facade-owned diagnostics.
  • Fuel/epoch/shared-memory accounting implementation and regression suite.
  • Structured teardown/resource instrumentation and focused Soldr documentation.
  • Compatibility record tied to actual Cargo-resolved engine version.

Decisions

Related issues

Activity

  1. added
    enhancement
    on Aug 27, 2026
  2. zackees commented on Aug 27, 2026

    @zackees
    CollaboratorAuthor

    Acceptance-criteria clarification, following merged #43 (PR #47) and scoped characterization work in #44: deterministic epoch interruption means deterministic semantic terminal-winner selection and facade classification, not an exact deterministic wall-clock deadline. For plain running compute, epoch observation is finite under the configured tick/deadline but its precise timing is scheduler-dependent. Cancellation wins a same-tick deadline; a real fuel trap remains OutOfFuel.

    Blocked atomic.wait and host-blocked calls remain explicitly containment-required and belong to #28; #44 characterizes that boundary with a killable subprocess rather than treating an in-process epoch interrupt as cleanup. Platform evidence must distinguish native-run from compile-only/not-run results. See #44, #43, and #28.

  3. zackees commented on Aug 27, 2026

    @zackees
    CollaboratorAuthor

    Closure evidence:

    All children are closed. The merged set preserves default-feature isolation and keeps backend details private. atomic.wait and host blocking remain explicitly deferred to #28 worker-process containment rather than claimed as in-process interruptibility.

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