Skip to content
App Wasm interface

App Wasm interface

Server and client Wasm share the principle that Apps receive only explicit Host/Shell interfaces, not ambient authority. Their concrete boundaries differ: server Wasm is a WebAssembly Component called by the Host; client Wasm runs in a dedicated worker and talks to the Shell through a bridge.

WIT component contract

WIT means WebAssembly Interface Type and is used to define the interface between the host and the Wasm app. It is an interface definition language for the WebAssembly Component Model: it declares named interfaces, their data types and function signatures, and the imports and exports a component uses. A WIT world groups the imports a component needs with the exports it provides. (WIT overview, worlds)

For a server App, this gives the Host and Wasm component a typed, language-independent contract. The component’s imports are functions the Host must provide; its exports are functions the Host may call, such as named event handlers. The Host can generate Rust bindings from the same WIT definition and check that a component matches the expected world.

The project has selected WIT for the Component Model boundary, but the actual App worlds, interface names, function signatures, error types, and versions are TBD.

The client Wasm ↔ Shell bridge needs its own message schema, even if it follows the same logical operations and event shapes.

JSON Schema remains a separate format for validating durable Dataset records.

Server Wasm ↔ Host

  • The Host embeds Wasmtime and loads server Apps as WebAssembly Components.
  • The Host wakes named event handlers for different events:
    • install/update (maybe it makes sense to run the app after install to do some configurations without access to any datasets and without a user assigned, so it can’t change user specific data)
    • client events (the app’s client Wasm may trigger events for the backend)
    • schedules (at a specific time, a cron or with a specific interval)
    • capability callbacks (an API endpoint, a webhook, etc.)
    • maybe inter app events?
  • App code receives only the capability surface allowed by its manifest and effective admin/account configuration.
  • The Host enforces Dataset access through Grant/View-scoped handles. Apps do not receive raw storage access or general operating-system/network access.

Client Wasm ↔ Shell

  • The Shell owns the DOM, navigation, consent UI, and design-system component tree. Client Wasm holds UI state and submits validated UI patches; Shell event listeners deliver named events back to the App.
  • Client Wasm runs in a dedicated worker with bridge-only imports. It receives no raw fetch, WebSocket, session cookie, or web storage access. The Shell session cookie is HttpOnly and never visible to App Wasm.
  • The bridge is per install and carries App/Shell messaging. The Shell owns network transport to the Host and demultiplexes Host messages by install id.
  • The Shell↔Host primary transport is one WebSocket per browser tab; HTTP is used for large/binary uploads and as fallback. Apps never receive that socket.
  • UI assets such as icon and title graphics are package assets mediated by the Host/Shell. Arbitrary remote images and App-defined custom components are outside the v1 design.

Event and delivery behavior

  • Host/Dataset events are at-least-once with stable event ids; Apps should be idempotent. The Host retains events for a connected session until acknowledgment or equivalent confirmation.
  • On disconnect, events may queue until reconnect or timeout. After timeout the Shell must resynchronize or create a new session. Closing a tab drops its in-browser queue; a server queue may wait until timeout.
  • Exact timeout values and durable multi-tab queue behavior are not defined yet.

TBD

  • Concrete WIT worlds, imports/exports, function signatures, error model, and interface version negotiation.
  • Exact bridge message schema for client Wasm ↔ Shell, including correlation ids, response/error envelopes, and large payload transfer.
  • UI patch and design-system IDL, validation rules, supported components, and accessibility contract.
  • Which WASI interfaces, if any, are exposed to each module type and how they interact with capability grants.
  • App-to-Host RPCs for Dataset operations, capability configuration, registration, event acknowledgment, and cancellation.
  • Resource-limit behavior, precise event timeout/retry policy, and tab-close/resync edge cases.