# `ExGAM.Payload.Retention`
[🔗](https://github.com/elchemista/ex_gam/blob/0.1.0/lib/ex_gam/payload/retention.ex#L1)

Host-controlled retention planning for external payloads, not ledger entries.

`request/4` turns a retention threshold into request attributes accepted by
`ExGAM.request_erasure/4`. It does not delete bytes, append events, grant
authority or claim that a payload has become irrelevant to governance.
The normal erasure path derives the current causal impact, checks authority
and records the Attempt/Outcome and any loss of verifiability.

The application owns scheduling, indexed enumeration and usage metadata.
Supply the last use of the *payload*, including all its consumers, not the
observation time of an arbitrary Evidence referencing it. A shared payload
must not age independently for each reference. A retention hold wins over
both thresholds; do not use this planner as a substitute for host policy.

Options are `:after_ms`, `:after_events` and `:reason`. At least one threshold
is required. When both are supplied, both must elapse. Events count ledger
revision distance, not the number of Evidence. Future usage is retained.

    case ExGAM.Payload.Retention.request(ref, last_use, head,
           after_ms: 30 * 86_400_000, after_events: 10_000) do
      {:ok, request} -> ExGAM.request_erasure(scope, request, executor_attrs)
      :retain -> :ok
      {:error, reason} -> {:error, reason}
    end

`last_use` is `%{recorded_at: integer, revision: integer}` with optional
`hold?: boolean`; `head` supplies the current trusted recording time and
revision. These are planning inputs, not authority claims accepted by GAM.

# `position`

```elixir
@type position() :: %{recorded_at: non_neg_integer(), revision: non_neg_integer()}
```

# `usage`

```elixir
@type usage() :: %{
  :recorded_at =&gt; non_neg_integer(),
  :revision =&gt; non_neg_integer(),
  optional(:hold?) =&gt; boolean()
}
```

# `request`

```elixir
@spec request(String.t(), usage(), position(), keyword()) ::
  :retain | {:ok, map()} | {:error, term()}
```

Plans erasure request attributes only after all chosen retention thresholds; holds always retain.

---

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