REFERENCE

Guest ABI overview

The fixed binary contract between WASM guests and the Samoza runtime — module index.

The Guest ABI is the binary interface between WASM guest programs and the Samoza runtime. It defines the host-imported WASM functions and guest-exported entry points that constitute the fixed contract.

This page is the module index. For the developer’s introduction see Develop · Guest ABI.

Architecture

┌──────────────────────────────────┐
│         Guest program            │  ← Your code (TinyGo → WASM)
│    on_init() / on_process()      │
├──────────────────────────────────┤
│         Guest Library            │  ← Convenience wrappers (optional)
├──────────────────────────────────┤
│         Guest ABI                │  ← This specification
├──────────────────────────────────┤
│         Samoza Runtime (zrun)    │  ← Host (Go + wazero)
└──────────────────────────────────┘

Modules

Core — universal

ModulePurpose
Lifecycleon_init, on_process, on_close, memory model
Systemsys.log, sys.sleep, sys.yield, sys.self_emit
Networknet.emit_to, net.recv_next — message passing between spaces
CapabilitiesThe capability model — declaration and enforcement

Extended — software services

ModulePurpose
DataKey/value storage — data.get, data.put, data.list, data.delete
AgentsDF, AF, LLM agent invocation — agent.invoke_df, agent.invoke_af, agent.invoke_llm
EventsComputed events from recognizers — events.register_recognizer, events.subscribe
Intelligence CacheLLM response caching, semantic lookup — ic.lookup, ic.store

Device — physical I/O

ModulePurpose
SensorsGeneric subscribe/read — sensors.subscribe, sensors.read
ActuatorsGeneric lock/command/release — actuators.lock, actuators.command, actuators.release
AudioMicrophone capture and speaker playback streaming

UI spaces are not in the Guest ABI — they run in the browser.

Conventions

Return code (int32): 0 = success, negative = error, positive = bytes/count.

Data: All host-guest data is JSON unless explicitly noted (audio is raw bytes).

Device knowledge: None. Sensor and actuator types are extensible strings; the ABI knows nothing about cameras, motors, or thermometers specifically. Domain knowledge lives in the Guest Library.

Import paths

github.com/anrl/samoza/components/zrun/guest/abi/
├── net          — Network messaging
├── data         — Key/value storage
├── node         — Node primitives
├── sys          — System functions
├── ic           — Intelligence cache
├── agent        — Agent invocation
├── mem          — Memory management
├── z            — Low-level primitives
└── sys/io       — Stream I/O (audio)

Compilation

Guests compile with TinyGo targeting WASI:

tinygo build -target wasi -scheduler=none -opt=z -o core.wasm .

Constraints: no fmt (binary bloat), use encoding/json for serialization, use strconv for number conversion, sys.Log() takes exactly one string argument, main() exists but is empty.

What the ABI doesn’t cover

The Guest ABI specifies only the WASM import/export surface. It does not cover:

  • Construction-time concerns (space creation, path wiring) — see the MEX format.
  • Domain-specific helpers (car control, vision typed structs) — those live in the Guest Library.
  • UI rendering — UI spaces are browser-side and have a separate JavaScript surface.

Per-module specifications for each ABI module are in the source repository at docs/reference/guest-abi/. They will be ported here progressively. The Lifecycle module is the first one available — it covers the entry points every WASM space must implement.