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

Portable proposal with no authority or execution capability.

A candidate contains every field that may materially affect classification,
mandate matching, consent or admission.  `identity_key` provides idempotency:
the same key and material digest is the same proposal; the same key with a
different digest is a conflict for the kernel to reject.

`consent` is one closed, portable declaration of the exact material a person
must evaluate. Consent uses a separate pre-consent binding covering that
declaration and every other field knowable before presentation. Only verified
approval Evidence for that Presentation may be excluded to break the causal
cycle; all other Evidence remains bound. The final candidate digest still
covers the Presentation and every Evidence ref.

# `t`

```elixir
@type t() :: %Spectre.GAM.Candidate{
  accountable_ref: String.t(),
  class: String.t(),
  consent: Spectre.GAM.Consent.t() | nil,
  consequence: term(),
  disclosure: Spectre.GAM.Disclosure.t() | nil,
  evidence_refs: [String.t()],
  executor_contract_ref: String.t(),
  executor_ref: String.t(),
  identity_key: String.t(),
  material_digest: String.t(),
  meter_requests: %{optional(String.t()) =&gt; non_neg_integer()},
  observation_window_ms: non_neg_integer(),
  presentation_ref: String.t() | nil,
  proposer_ref: String.t(),
  purpose_params: map(),
  purpose_ref: String.t(),
  ref: String.t(),
  requested_mandate_ref: String.t() | nil,
  row: Spectre.GAM.Row.t(),
  schema_version: 1,
  scope_ref: String.t(),
  subject_refs: [String.t()],
  target_refs: [String.t()]
}
```

# `canonical`

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

Returns the plain, string-keyed ledger representation.

# `content_ref`

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

Returns the content-derived reference, independent of an assigned `ref`.

# `digest`

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

Returns the stable digest of the complete candidate.

# `from_canonical`

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

Restores a candidate from its canonical map and verifies its digest.

# `material`

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

Returns exactly the fields bound by `material_digest`.

# `new`

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

Builds and validates a candidate, computing its material digest and ref.

# `presentation_binding`

```elixir
@spec presentation_binding(t(), [String.t()]) :: map()
```

Returns the exact, acyclic candidate material bound by a Presentation.

# `presentation_binding_ref`

```elixir
@spec presentation_binding_ref(t(), [String.t()]) :: String.t()
```

Returns the content address of `presentation_binding/2`.

# `request_fields`

```elixir
@spec request_fields() :: [atom()]
```

Fields a proposer may supply before the Turn binds proposer and Scope.

---

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