Memory.Presentation (fnord v0.8.92)
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_days(DateTime.t(), DateTime.t()) :: non_neg_integer()
Returns the age in whole days since dt relative to now.
If dt is in the future, returns 0.
@spec age_line(Memory.t(), 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.
@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(Memory.t(), 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.