Repository navigation
Description
Parent: #16. Depends on #36's versioned generated core-ABI contract and consumes #15's private threaded-root execution substrate.
Scope
Implement the generated Wasmtime async-operation lifecycle for the v1 ABI using exactly one caller-provided kernal_api::async_engine::RuntimeHandle. Replace any ambient Tokio use and fp-bindgen's former AsyncValue callback model: generated imports submit/poll/yield/cancel through the explicit kernal-api runtime handle and private dispatcher only. Add only one synthetic semantic operation: clock/yield completion. It proves request creation, guest suspension, native completion, generated poll/resume, cancellation, and one terminal result without granting clock, filesystem, network, process, or platform authority.
The guest facade exposes an idiomatic semantic future/result surface. It may yield or be polled; it does not expose packet pointers, Wasmtime futures, Tokio tasks, callbacks, or runtime handles. The host dispatch maps generated operation IDs to private native work and resumes only the Store/Instance that owns the request. It must not construct a runtime or re-enter a Store concurrently.
Define one terminal-winner state machine for completion, cancellation, timeout, trap, close, thread exit, and sketch teardown. Late native completions are ignored/reclaimed deterministically.
Safety and identity invariants
- Every operation ID is generation-tagged and scoped to one logical sketch plus its authorized capability context. A stale/raw/forged ID cannot address a reused operation slot.
- No Store, Instance,
Caller, guest pointer/reference, resource-table borrow, mutex guard, orDashMapguard may survive an await, yield, native completion handoff, cancellation callback, or guest re-entry. - Native completion never moves a Store/Instance across a native thread and never executes guest code while that Store is active.
- Bounded pending-operation quota is enforced before scheduling.
- The exact generated ABI is the only operation path; no direct test-only host call, ambient Tokio callback, old
AsyncValue, or handwritten guest import. - Public result/error types are semantic and bounded; private dispatcher/backend errors never leak.
Non-goals
No resource handles, blobs, streams, raw clocks, real timers, Tauri, filesystem, output capability, broad WASI, worker containment, or blocking std adapters.
RED → GREEN
- RED: a generated guest fixture has no operation capable of suspending/resuming through the host and no typed terminal-race behavior.
- RED: fixtures characterize forbidden direct/re-entrant Store execution, retained pointer/guard across yield, stale operation ID, and duplicate terminal completion.
- GREEN: a generated root guest invokes synthetic yield/clock, returns
Pending, resumes from native completion, and completes through the generated facade and explicitRuntimeHandle. - GREEN: cancellation wins against completion in both orderings; exactly one typed terminal result is observed and late completion cannot re-enter guest code.
- GREEN: timeout/trap/thread-exit/sketch teardown cancel outstanding operations and return pending-operation counters to zero.
- GREEN: quota exhaustion rejects before scheduling with a facade-owned error.
- GREEN: instrumentation records operation ID, logical sketch scope, generation, suspend/resume count, terminal reason, and pending count without backend leaks.
- GREEN: root-only execution proves no illegal Store re-entry, deadlock, ambient callback/runtime, or second kernel runtime. Do not substitute a native/mock child-thread test: a separate-guest-thread proof is deferred until feat(wasm): bootstrap owned threaded guest instances #35 is complete.
- GREEN: default-feature isolation remains intact.
Platform and deliverables
Compile Linux/macOS/Windows x86-64/ARM64; run native focused root proof where supported. Deliver private dispatcher/state machine, generated synthetic-operation facade, race fixtures, teardown/instrumentation tests, and Soldr-only commands.
Dependencies and closure
- Parent: feat(wasm): add generated async kernel ABI and generation-safe resources #16; depends on feat(wasm-abi): define and generate the versioned core-Wasm ABI contract #36, feat(wasm): prove a streamed kernal-api Rust sketch runtime with zccache and extension2 cores #13, and feat(wasm): establish threaded sketch build, import validation, and lifecycle substrate #15.
- Followed by the scoped generation-safe resource child. feat(wasm): add bounded opaque blobs and exact-output file capability #17 depends on that child, not directly on this issue.
- Close only when the resource child can reuse this same request lifecycle for create/use/close operations without adding a second scheduler or ABI path.
Activity
zackees commentedon Sep 12, 2026
Closed as completed. Main now has the single RuntimeHandle-backed generated submit/poll/yield/cancel lifecycle with generation-scoped ownership, quotas, terminal cleanup, and real threaded guest coverage. PR #151 fixed the scheduler-first deferred-close race and its cancellation winner rule; focused hub and real artifact proofs pass.