# `ExGAM.Ledger.Store.Compression`
[🔗](https://github.com/elchemista/ex_gam/blob/0.1.0/lib/ex_gam/ledger/store/compression.ex#L1)

Optional physical compression of canonical storage bytes.

Compression is below the ledger format: decompression returns the exact
original bytes, so Entry digests, exports and idempotency do not change.
Small/incompressible values stay unwrapped. Readers accept both forms,
allowing a host to change its write policy without rewriting old records.

The envelope declares the decoded size and its SHA-256 checksum. Neither is
trusted: inflation proceeds in small chunks under the caller's byte limit,
and the actual size/checksum are checked before canonical decoding. This
checksum detects damage; it is not an authenticity signature.

# `pack`

```elixir
@spec pack(binary(), boolean()) :: binary()
```

Compresses storage bytes only when enabled and smaller, without changing canonical identity.

# `unpack`

```elixir
@spec unpack(binary(), pos_integer()) :: {:ok, binary()} | {:error, term()}
```

Returns exact original bytes within the caller's limit, rejecting corrupt or oversized envelopes.

---

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