# `SmolBox.Store.Codec`
[🔗](https://github.com/hfiguera/smolbox/blob/v0.1.3/lib/smolbox/store/codec.ex#L1)

Versioned data-only record encoding for trusted host store adapters.

This is an internal persistence format, never an endpoint for guest or public
input. Records are validated before encoding and after safe decoding. Compressed
terms, trailing bytes, unknown schemas, unexpected structs/keys, PIDs, refs,
ports, and closures are rejected. Payloads have a fixed 16 MiB cap.

Encoding does not encrypt secrets. Durable adapters must authenticate and encrypt
these bytes or use an explicitly approved equivalent secure storage policy.
Schema v2 adds network policy. Exact v1 records are upgraded to offline defaults
on read; offline fingerprints are unchanged. Old readers cannot read v2 writes.
Every write uses v2, including offline executions. Follow
[Upgrading to 0.1.3](recovery.html#upgrading-to-0-1-3) across all controllers.
Silently treating undecodable records as absent
would permit replay and is forbidden.

# `decode`

```elixir
@spec decode(binary()) :: {:ok, SmolBox.Execution.t()} | {:error, SmolBox.Error.t()}
```

# `encode`

```elixir
@spec encode(SmolBox.Execution.t()) :: {:ok, binary()} | {:error, SmolBox.Error.t()}
```

---

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