Jido.Memory.Record (Jido Memory v1.0.0)

View Source

Canonical data model for a memory record.

This is intentionally data-first and backend-agnostic so records can be indexed in ETS now and migrated to richer retrieval systems later.

Summary

Functions

Returns the canonical memory class taxonomy.

Returns a normalized comparison key for open kind values.

Builds and normalizes a memory record.

Builds and normalizes a memory record, raising on error.

Normalizes class filters (atoms or class strings).

Normalizes kind values while keeping the field open for custom shapes.

Normalizes a list of tags to unique strings.

Returns the Zoi schema for records.

Returns a deterministic id for normalized record payloads.

Types

class()

@type class() :: :episodic | :semantic | :procedural | :working

kind()

@type kind() :: atom() | String.t()

t()

@type t() :: %Jido.Memory.Record{
  class: atom(),
  content: any(),
  embedding: nil | any(),
  expires_at: nil | integer(),
  id: binary(),
  kind: any(),
  metadata: map(),
  namespace: binary(),
  observed_at: integer(),
  source: nil | binary(),
  tags: [binary()],
  text: nil | binary(),
  version: integer()
}

Functions

canonical_classes()

@spec canonical_classes() :: [class()]

Returns the canonical memory class taxonomy.

kind_key(kind)

@spec kind_key(term()) :: String.t()

Returns a normalized comparison key for open kind values.

new(attrs, opts \\ [])

@spec new(
  map() | keyword(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Builds and normalizes a memory record.

new!(attrs, opts \\ [])

@spec new!(
  map() | keyword(),
  keyword()
) :: t()

Builds and normalizes a memory record, raising on error.

normalize_class(class)

@spec normalize_class(term()) :: {:ok, class()} | {:error, term()}

Normalizes class filters (atoms or class strings).

normalize_kind(kind)

@spec normalize_kind(term()) :: {:ok, kind()} | {:error, term()}

Normalizes kind values while keeping the field open for custom shapes.

normalize_tags(tags)

@spec normalize_tags(term()) :: {:ok, [String.t()]} | {:error, term()}

Normalizes a list of tags to unique strings.

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for records.

stable_id(normalized_attrs)

@spec stable_id(map()) :: String.t()

Returns a deterministic id for normalized record payloads.