Helpers for masking secrets and gating payload capture.
Provides utilities to safely mask sensitive information in data structures and to conditionally enable/disable payload capture to prevent secret leaks.
Summary
Functions
Gate payload capture. Returns {request_payload, response_payload}.
Splits a "provider:model_id" model string into {provider, model_id}.
If there is no : separator, returns {nil, model}.
Truncates a binary to at most max bytes, UTF-8-safely: if the byte cut lands
mid-character, the trailing incomplete sequence is dropped so the result is
always valid UTF-8 (and still ≤ max bytes). Non-binaries pass through.
Functions
Gate payload capture. Returns {request_payload, response_payload}.
When enabled? is false (the default), returns {nil, nil} — message content
is never persisted, so no secrets can leak through the payload columns. When
true, returns the payloads as maps (the gated path); scalar metadata is always
safe and is captured regardless.
Splits a "provider:model_id" model string into {provider, model_id}.
If there is no : separator, returns {nil, model}.
iex> Mimir.Redact.split_provider("bedrock:nvidia.nemotron-super-3-120b")
{"bedrock", "nvidia.nemotron-super-3-120b"}
iex> Mimir.Redact.split_provider("claude-3")
{nil, "claude-3"}
@spec truncate(binary(), non_neg_integer()) :: binary()
Truncates a binary to at most max bytes, UTF-8-safely: if the byte cut lands
mid-character, the trailing incomplete sequence is dropped so the result is
always valid UTF-8 (and still ≤ max bytes). Non-binaries pass through.