Memory.Presentation (fnord v0.9.29)
View SourceHelpers for presenting %Memory{} metadata to humans.
This module is intentionally small and pure (no I/O) so it can be reused by:
AI.Tools.Memory(tool output)Cmd.Memory(CLI output)AI.Agent.Coordinator(auto-injected recall section)
Timestamps are stored on %Memory{} as ISO8601 strings (DateTime.to_iso8601/1).
Summary
Types
@type iso8601() :: binary()
Functions
@spec age_line(:error | Memory.t() | term(), DateTime.t()) :: binary()
Returns an "Age" line for a memory.
Examples:
"Age: unknown (missing timestamps)""Age: 312 days (updated 12 days ago)"
Notes:
- Uses
updated_atif present; otherwise usesinserted_at. - Uses
nowfor deterministic testing. - If the first argument is
:erroror any non-struct value (e.g. a parse error), this will return"Age: unknown (missing timestamps)".
@spec parse_ts(nil | iso8601()) :: {:ok, DateTime.t()} | :error
Parse an ISO8601 timestamp string into a DateTime.
Returns {:ok, dt} or :error.
@spec warning_line(:error | Memory.t() | term(), DateTime.t(), keyword()) :: binary() | nil
Returns an optional warning line based on how long ago the memory was updated.
- If
updated_atis missing/unparseable, returnsnil. - If
updated_days >= strong_days, returns a strong warning. - Else if
updated_days >= mild_days, returns a mild warning. - Else returns
nil.
This is intended as a gentle prompt to check for cobwebs.
If the first argument is :error or any non-struct value, this function will
return nil (no warning).