Mimir.DecisionRecord (Mimir v0.1.0)

Copy Markdown View Source

Pure builder for a routing-decision audit record. Returns a binary-keyed map suitable for appending as a turn event. No Repo, no clock beyond accepting the snapshot's snapshot_at.

Key conventions

  • All map keys are strings (binary), never atoms.
  • Grant id is the caller-supplied grant key's UUID string. The plaintext bearer token is NEVER included.
  • Snapshot summary: only snapshot_at + a list of degraded lanes — the full pricing table is NOT copied in (it can be large and is not decision-relevant at audit time; the embedder has the full table if needed).
  • decision_id: "rd_" prefix + 26-char lowercase base32 of 16 random bytes.

Summary

Functions

Build a binary-keyed routing decision map.

Functions

build(descriptor, verdict, grant_or_nil, ids, snapshot)

@spec build(
  Mimir.Descriptor.t(),
  {:placement, Mimir.Oracle.Placement.t()} | {:no_candidate, [term()], [map()]},
  String.t() | nil,
  %{workflow_id: String.t() | nil, step_id: String.t() | nil},
  Mimir.Snapshot.t()
) :: map()

Build a binary-keyed routing decision map.

Arguments:

  • descriptor — the %Descriptor{} the oracle was called with.
  • verdict{:placement, %Placement{}} or {:no_candidate, reasons, candidates}.
  • grant_id — the minted grant key's UUID string (never the plaintext bearer token), or nil.
  • ids%{workflow_id: string, step_id: string} (the correlation ids).
  • snapshot — the %Snapshot{} used for the decision.

Returns a binary-keyed map ready to append as a routing_decision turn event.