SmolBox.Store.Codec (SmolBox v0.1.0)

Copy Markdown View Source

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 upgrades require a host migration; silently treating undecodable records as absent would permit replay and is forbidden.

Summary

Functions

decode(bytes)

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

encode(record)

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