Imp.Observability.Inspection (Imp v0.5.0)

Copy Markdown View Source

A deterministic, redacted debugging snapshot, as returned by Imp.Observability.inspect_artifact/2.

Inspection entries use a common shape across provider calls, tools, RLM actions, optimizer reports, predictions, and telemetry. Large payloads are replaced by bounded fingerprints so interactive debugging cannot accidentally copy an unbounded model response into the shell or logs.

Summary

Functions

Returns value as a term Jason can encode, deterministically.

Types

entry()

@type entry() :: %{source: atom(), sequence: pos_integer(), payload: term()}

t()

@type t() :: %Imp.Observability.Inspection{
  entries: [entry()],
  kind: atom(),
  status: atom(),
  summary: map()
}

Functions

json_safe(inspection)

@spec json_safe(term()) :: term()

Returns value as a term Jason can encode, deterministically.

Structs and maps with atom or string keys become maps with string keys; a map with other keys becomes %{"__imp_type__" => "map", "entries" => [[key, value], ...]} in a stable order. Tuples become lists, an improper list becomes %{"__imp_type__" => "improper_list", "head" => ..., "tail" => ...}, atoms other than nil, true and false become strings, and anything else that is not a number or a binary becomes its inspect/1 text. Nothing is redacted here; pass a value through Imp.Redaction.redact/1 first when it may carry secrets.

iex> Imp.Observability.Inspection.json_safe(%{kind: :tool, args: {1, :a}})
%{"args" => [1, "a"], "kind" => "tool"}