# `Spectre.GAM.Attempt`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/gam/attempt.ex#L1)

Durable proof that an exact-bound grant was consumed before capability release.

Only a digest of the grant nonce is persisted.  The bearer grant, raw nonce,
credentials and handles are deliberately absent from this portable record.
`generation` is the host generation which minted and consumed that Grant. It
can differ from the admission generation frozen in the Act when an admitted,
still-unattempted Act is safely resumed after a host restart.

# `t`

```elixir
@type t() :: %Spectre.GAM.Attempt{
  act_ref: String.t(),
  executor_ref: String.t(),
  generation: non_neg_integer(),
  grant_nonce_digest: String.t(),
  material_digest: String.t(),
  ref: String.t(),
  schema_version: 1,
  started_at: integer()
}
```

# `canonical`

```elixir
@spec canonical(t()) :: map()
```

Returns the plain, string-keyed ledger representation.

# `digest`

```elixir
@spec digest(t()) :: String.t()
```

Returns the stable digest of the complete attempt.

# `from_canonical`

```elixir
@spec from_canonical(map()) :: {:ok, t()} | {:error, term()}
```

Restores an attempt from its canonical map.

# `new`

```elixir
@spec new(map() | keyword() | t()) :: {:ok, t()} | {:error, term()}
```

Builds and validates an attempt record.

---

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