adk_context_guard (erlang_adk v0.7.0)
View SourceSecret-removing, JSON-safe boundary for session and model context data.
Unlike diagnostic redaction, context safety removes secret-bearing fields entirely. A model must not be told that a credential exists, and a cache key must not depend on its value. Sensitive maps are pruned before JSON normalization so even a non-JSON credential value can never escape through a validation error.
Summary
Functions
Convert an event record or persisted event map to its canonical, secret-free JSON representation.
Normalize an ordinary value to JSON after removing all sensitive map entries. Binary keys are emitted even if the input used atoms or strings.
Whether a key denotes authentication material. Matching is case-insensitive and separator-insensitive. Generic keys such as key are deliberately retained, while API/private/signing keys are removed.
Types
-type error_reason() :: {invalid_event, term()} | adk_json:error_reason().
Functions
-spec sanitize_event(adk_event:event() | map()) -> {ok, map()} | {error, error_reason()}.
Convert an event record or persisted event map to its canonical, secret-free JSON representation.
-spec sanitize_value(term()) -> {ok, term()} | {error, adk_json:error_reason()}.
Normalize an ordinary value to JSON after removing all sensitive map entries. Binary keys are emitted even if the input used atoms or strings.
Whether a key denotes authentication material. Matching is case-insensitive and separator-insensitive. Generic keys such as key are deliberately retained, while API/private/signing keys are removed.