# `Kettlecorn.VM`
[🔗](https://github.com/mjrusso/kettlecorn/blob/v0.1.0/host/lib/kettlecorn/vm.ex#L1)

One sandboxed BEAM instance running in Wasmtime.

The bundled native launcher embeds Wasmtime and owns the guest.
This GenServer owns the launcher through an Erlang port for input and process
lifecycle. Guest output arrives over a private local socket in records capped
at 64 KiB. Delivery is re-armed after each record is processed, bounding raw
bytes awaiting processing independently of owner event budgets.

The guest protocol uses length-prefixed frames (`PROTOCOL.md` in the repository):

  * guest console output (`IO.puts/1` etc.) arrives as `:stdout`/`:stderr` frames,
  * `:wasm.send/1` in the guest arrives as a `:message` frame (ETF),
  * the host delivers messages to guest processes with `:send` frames.

If the port dies (the guest crashed, ran out of memory, hit the wall-clock
limit, or was killed) every pending request fails with
`{:error, {:vm_down, reason}}` and this process stops. A guest frame longer
than `:max_message_size` (default 64 MiB) also stops the VM, with reason
`{:vm_down, {:frame_too_large, length}}`.

Use the public API in `Kettlecorn`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
