# `Threadline.Evidence.Proof`
[🔗](https://github.com/szTheory/threadline/blob/v1.2.0/lib/threadline/evidence/proof.ex#L1)

A proof document summarizes evidence snapshots and the claims they support.

Use `proof_document/2` to work with the JSON-ready map,
`to_json_iodata/2` to encode it, and `render_json/1` or `render_human/1` to
print it from a command-line task.

# `claim_kind`

```elixir
@type claim_kind() :: String.t()
```

A proof category string: `direct_fact`, `posture_snapshot`, or `unsupported_claim`.

# `claim_status`

```elixir
@type claim_status() :: String.t()
```

A proof status string: `proven`, `inferred_posture`, or `unsupported`.

# `evidence_record_input`

```elixir
@type evidence_record_input() ::
  Threadline.Governance.EvidenceRecord.t() | Threadline.json_map()
```

An evidence row supplied to a proof projection.

# `presented_record`

```elixir
@type presented_record() :: %{
  subject: Threadline.json_value(),
  subject_ref: Threadline.json_value(),
  summary_status: Threadline.json_value(),
  recorded_at: String.t() | nil,
  verdict_status: claim_status(),
  verdict_kind: claim_kind(),
  verdict_reason: Threadline.json_value()
}
```

A row formatted for the evidence viewer.

# `proof_document`

```elixir
@type proof_document() :: Threadline.json_map()
```

A JSON-ready proof document with guaranteed keys `format_version`, `generated_at`, `proof_type`, `subject`, `mode`, `filters`, `summary`, `claim_assessment`, and `records`; new JSON keys may be added.

# `proof_filter`

```elixir
@type proof_filter() ::
  {:from, DateTime.t()} | {:to, DateTime.t()} | {:limit, pos_integer()}
```

A filter accepted by a proof read.

# `proof_mode`

```elixir
@type proof_mode() :: :latest | :history
```

A supported proof read mode.

# `proof_opt`

```elixir
@type proof_opt() :: Threadline.repo_opt() | {:generated_at, DateTime.t()}
```

An option accepted by proof document reads.

# `proof_request`

```elixir
@type proof_request() :: [proof_request_opt()]
```

A keyword list selecting the evidence included in a proof document.

# `proof_request_opt`

```elixir
@type proof_request_opt() ::
  {:subject, Threadline.Evidence.Subject.subject_descriptor() | nil}
  | {:subject_ref, Threadline.Evidence.subject_ref() | nil}
  | {:mode, :latest | :history}
  | {:from, DateTime.t()}
  | {:to, DateTime.t()}
  | {:limit, pos_integer()}
```

A key accepted in a proof request. Unrecognized keys are ignored.

# `proof_document`

```elixir
@spec proof_document(proof_request(), [proof_opt()]) :: proof_document()
```

Builds a JSON-ready proof document from matching evidence snapshots and their claim assessment.

Use `to_json_iodata/2` when the encoded JSON is the desired output. The
request selects an overview or one subject, a latest or history read, and
optional date bounds and limit. Unrecognized request keys are ignored.

## Request

- `:subject` — supported subject name or descriptor. Optional; omission selects the overview.
- `:subject_ref` — subject reference map. Optional.
- `:mode` — `:latest` or `:history`. Optional; defaults to `:latest`.
- `:from` — `DateTime`. Optional; inclusive lower bound on the record time.
- `:to` — `DateTime`. Optional; inclusive upper bound on the record time.
- `:limit` — positive integer. Optional; caps the matching records.

## Options

- `:repo` — Ecto repository module. Required.
- `:generated_at` — `DateTime`. Optional; defaults to the current UTC time.

## Returns

Returns a string-keyed JSON map containing the format version, generation
time, selected subject and mode, filters, record counts, claim assessment,
and matching records. Raises `KeyError` when `:repo` is omitted and
`ArgumentError` for an unsupported subject, invalid subject reference, or
invalid Evidence filter.

# `render_human`

```elixir
@spec render_human(proof_document()) :: :ok
```

Prints a JSON-ready proof document in human-readable form through the Mix shell and returns `:ok`.

# `render_json`

```elixir
@spec render_json(proof_document()) :: :ok
```

Prints a JSON-ready proof document to standard output and returns `:ok`.

# `to_json_iodata`

```elixir
@spec to_json_iodata(proof_request(), [proof_opt()]) :: {:ok, iodata()}
```

Encodes matching evidence snapshots and their claim assessment as `{:ok, iodata}`.

Use `proof_document/2` when the JSON-ready map is needed instead of encoded
output. The request and options have the same meaning as that function;
unrecognized request keys are ignored.

## Request

- `:subject` — supported subject name or descriptor. Optional; omission selects the overview.
- `:subject_ref` — subject reference map. Optional.
- `:mode` — `:latest` or `:history`. Optional; defaults to `:latest`.
- `:from` — `DateTime`. Optional; inclusive lower bound on the record time.
- `:to` — `DateTime`. Optional; inclusive upper bound on the record time.
- `:limit` — positive integer. Optional; caps the matching records.

## Options

- `:repo` — Ecto repository module. Required.
- `:generated_at` — `DateTime`. Optional; defaults to the current UTC time.

## Returns

Returns `{:ok, iodata()}` containing the encoded proof document. Raises
`KeyError` when `:repo` is omitted and `ArgumentError` for an unsupported
subject, invalid subject reference, or invalid Evidence filter.

---

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