# `Spectre.Payload.Store`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/payload/store.ex#L1)

Application-owned storage for content kept outside durable Spectre records.

Configure `{MyApp.Payloads, options}` at the consuming runtime boundary.
`put/3` returns an opaque, portable reference; `fetch/3` resolves it. Spectre
does not prescribe a database, object store, encryption scheme, digest or
reference format. The adapter owns those choices and the guarantees offered
by its references, including retention and any integrity checks.

Callbacks run in the caller's worker. This facade does not start detached
tasks, retain payloads, retry writes or fall back to inline persistence.
Runtime integrations must invoke it outside their ordering process and own
the worker's timeout, cancellation and result handling.

The small context map describes why content is being stored or fetched.
Adapters can use its operation identity for idempotency and access control;
it is application context, never an authorization capability.

A successful `put/3` must mean the reference can be resolved according to the
adapter's contract. If an external write succeeds but the subsequent Spectre
commit fails, cleanup of unused content belongs to the application.

# `config`

```elixir
@type config() :: {module(), keyword()}
```

# `context`

```elixir
@type context() :: map()
```

# `payload_ref`

```elixir
@type payload_ref() :: term()
```

# `fetch`

```elixir
@callback fetch(payload_ref(), context(), keyword()) :: {:ok, term()} | {:error, term()}
```

# `put`

```elixir
@callback put(term(), context(), keyword()) :: {:ok, payload_ref()} | {:error, term()}
```

# `fetch`

```elixir
@spec fetch(config(), payload_ref(), context()) :: {:ok, term()} | {:error, term()}
```

Resolves content through the configured adapter without imposing a payload schema.

# `normalize`

```elixir
@spec normalize(term()) :: {:ok, config() | nil} | {:error, :invalid_payload_store}
```

Validates adapter wiring; nil leaves external payload storage unconfigured.

# `put`

```elixir
@spec put(config(), term(), context()) :: {:ok, payload_ref()} | {:error, term()}
```

Stores content and validates only that its opaque reference is portable.

---

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