# `Spectre.Experience.Evidence`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/experience/evidence.ex#L1)

Immutable, redacted and non-canonical operational evidence.

Evidence is tied to an exact Definition and activation generation. It may
inform reflection and future proposals, but it never authorizes execution,
replaces Instance state, or becomes a Journal record.

# `retention`

```elixir
@type retention() :: :ephemeral | :bounded | :retained
```

# `t`

```elixir
@type t() :: %Spectre.Experience.Evidence{
  activation_generation: non_neg_integer(),
  definition_ref: Spectre.Definition.Ref.t(),
  expires_at: non_neg_integer() | nil,
  facts: map(),
  kind: String.t(),
  observed_at: non_neg_integer(),
  provenance: map(),
  redactions: [[String.t() | non_neg_integer()]],
  retention: retention(),
  schema_version: pos_integer(),
  source_ref: String.t()
}
```

# `decode`

```elixir
@spec decode(binary()) :: {:ok, t()} | {:error, term()}
```

Decodes and revalidates canonical evidence bytes.

# `digest`

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

Returns the stable full-content evidence digest.

# `encode`

```elixir
@spec encode(t()) :: {:ok, binary()} | {:error, term()}
```

Encodes evidence with the production canonical codec.

# `expired?`

```elixir
@spec expired?(t(), non_neg_integer()) :: boolean()
```

Returns whether evidence is expired at the supplied millisecond timestamp.

# `from_data`

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

Restores and verifies evidence from portable data.

# `new`

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

Builds and verifies already-redacted Experience evidence.

# `new!`

```elixir
@spec new!(map() | keyword()) :: t()
```

Builds evidence or raises with the stable validation reason.

# `ref`

```elixir
@spec ref(t()) :: Spectre.Experience.Evidence.Ref.t()
```

Returns the content-addressed evidence Ref.

# `schema_version`

```elixir
@spec schema_version() :: pos_integer()
```

Returns the Experience evidence schema version.

# `to_data`

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

Returns canonical portable evidence data.

# `verify`

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

Revalidates evidence and its canonical transport representation.

---

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