Skip to content

Convergence ABI: async Thenable-handle + thenableThen continuation protocol (AffineScript + Ephapax) #31

@hyperpolymath

Description

@hyperpolymath

Tracks the async section of the typed-wasm convergence ABI, surfaced by AffineScript issue #225 / ADR-013 and needing Ephapax co-stakeholder review (typed-wasm ADR-004: typed-wasm is the shared aggregate/convergence layer for AffineScript and Ephapax).

What is being fixed as a shared convention

The async-over-wasm boundary protocol both languages must agree on:

  • An async host import returns a Thenable handle (i32) synchronously; the host registers the Promise in the handle table.
  • The guest registers a continuation closure via thenableThen(handle, closurePtr) using the closure ABI ([fnId@0, envPtr@4] dispatched through __indirect_function_table).
  • The host re-enters the guest after settlement; thenableResultJson(handle) (or a typed reader) yields the settled value.
  • An async guest function itself returns a Thenable handle, so the protocol composes up the call chain — this is what lets a backend present a transparent value-returning surface (AffineScript ADR-013's CPS transform) without JSPI.

Why it is convergence-layer, not AffineScript-internal

AffineScript ADR-013 (transparent CPS transform of Async functions on WasmGC) is the consumer; the protocol/handle conventions above are the shared contract. Ephapax compiles to the same typed WasmGC and must interoperate on identical conventions. This issue does not couple AffineScript to typed-wasm nor constrain Ephapax — it fixes the shared async convention where both already converge.

Asks

  • Ephapax co-stakeholder review of the protocol (closure ABI shape, settlement re-entry, handle lifetime/once-settle guarantee, error/reject shape { __error })
  • Record the agreed protocol as a typed-wasm convergence-ABI spec section
  • Confirm no divergence vs Ephapax's existing async lowering (or note required reconciliation)

Refs: affinescript#225, affinescript#160, affinescript ADR-013 (docs/specs/async-on-wasm-cps.adoc), affinescript #199 (closure ABI), affinescript #205 (Thenable resolution), typed-wasm ADR-004.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions