Skip to content

feat(wasm): add generated async kernel ABI and generation-safe resources #16

Closed

Description

@zackees

Context

Second dependency-ordered foundation for #13 and #14. It depends on #15 and implements the selected owned private core-Wasm kernal-api ABI generator from #13, before concrete browser, file, or blob capabilities exist.

Depends on

This issue extends that one ABI. Do not add a temporary RPC format, hand-written parallel guest API, fallback engine, or speculative public abstraction trait.

Proposal

Implement a private, versioned generated ABI capable of representing:

  • asynchronous kernel operations and typed semantic errors;
  • opaque generation-safe resource handles;
  • capability-scoped host state;
  • guest suspension/resumption from native completions;
  • cancellation, timeouts, close/drop/trap/thread-exit/sketch-teardown cleanup; and
  • resource/operation instrumentation.

The first concrete operations remain intentionally synthetic: an async kernel clock/yield operation and a create/use/close test resource. They prove the protocol before choosing Tauri, filesystem, or blob API shapes.

Guest calls suspend only their own execution and resume through the selected generated ABI. Native work runs on the existing kernal_api::async_engine; completion must respect Store/Instance ownership and avoid illegal concurrent re-entry.

Handles must be (instance scope, slot, generation) or equivalent opaque identity. A resource belongs to one sketch capability context; copied numeric values do not convey authority. Cancellation can race completion, close, trap, and teardown, but exactly one terminal outcome is observable and cleanup is idempotent.

Backpressure boundary

This issue defines lifecycle and quota rules but does not yet ship arbitrary-byte streaming. It reserves the required policy: explicit resource quotas, bounded pending operations, cancellation, and no ABI operation that implies an unbounded serialized payload. The opaque bounded blob/output implementation follows in #17.

Invariants

  • Guest-facing Rust APIs are versioned, semantic, and facade-owned. WIT, MessagePack, fp-bindgen, Wasmtime, Tokio, and generated support types are not public API.
  • Native host APIs do not publicly re-export engine, binding, Store, task, resource-table, or platform backend types.
  • default = [] must not resolve or compile engine, generator, generated guest support, or parser dependencies.
  • kernal_api::async_engine remains the only host executor. Guest operations cannot construct or bypass another kernel/Tokio runtime.
  • ABI version/capability mismatch fails before sketch entrypoint or effect.

Non-goals

Acceptance criteria

  • RED: checked-in evidence proves the validated threaded sketch has no generated async kernel operation, resource lifecycle protocol, or cross-instance-handle defense.
  • RED: regression fixtures prove stale, raw/forged, double-closed, and cross-instance handles are rejected.
  • GREEN: one selected, generated, versioned guest facade and private native adapter are checked in.
  • GREEN: a guest calls an async kernel clock/yield operation through the generated ABI, suspends/resumes, and returns without blocking the host event loop or creating another runtime.
  • GREEN: a guest creates, uses, and closes a synthetic opaque resource through the real generated ABI.
  • GREEN: handles are generation-safe and instance/capability-scoped; stale, forged, cross-instance, and double-close use returns deterministic facade-owned typed errors.
  • GREEN: configured per-sketch limits bound live resources and pending ABI operations.
  • GREEN: cancelling a pending operation wakes guest and host with a typed result; terminal races do not leak resources or double-complete.
  • GREEN: close, guest-thread exit, trap, timeout, and teardown return live-resource/pending-operation counters to zero.
  • GREEN: two concurrent operations, including separate guest threads, complete without illegal Store re-entry, deadlock, or another kernel runtime.
  • GREEN: ABI/capability mismatch fails before host effects.
  • GREEN: tracing records operation ID, scope, handle generation, suspend/resume, terminal reason, and resource count without exposing backend types.
  • GREEN: default-feature checks remain free of Wasm engine/generator/generated support dependency resolution.

Platform matrix and deliverables

Compile host/generated support on Linux, macOS, and Windows x86-64/ARM64. Run focused lifecycle proof on native supported hosts where available, including a multi-thread guest path, and report target, ABI/engine versions, limits, suspend/resume counts, and teardown counters.

Deliver the generated facade/private adapter, semantic handle/error surface, capability/resource/operation registries, cancellation/race/lifecycle tests, focused Soldr documentation, and an ABI compatibility note reserving opaque-resource/bounded-transfer rules.

Decisions

Related issues

Activity

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

    @zackees
    CollaboratorAuthor

    Closed as completed. The dependency-ordered foundations #36, #37, and #38 now provide one generated private Core-Wasm ABI, caller-owned async lifecycle, and generation-safe resource authority. PR #151 resolved the final real-artifact close/cancellation ordering defect. Local verification includes generator/drift checks, focused real threaded artifact proof, and soldr cargo test --locked --no-default-features (166 unit tests plus integration/doc tests). #17 remains the intentional bounded opaque blob/exact-output follow-on.

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