Services.Memories (fnord v0.8.82)
View SourceGenServer maintaining the in-memory graph of all loaded memories.
Tracks current project context and provides client API for CRUD operations. State includes both global and project-scoped memories when a project is selected.
Summary
Functions
Returns a specification to start this module under a supervisor.
Creates a new memory. Validates parent scope matches if parent_id provided. Persists to disk and updates in-memory state.
Deletes a memory. Removes from disk and in-memory state.
Gets all loaded memories (global + project if project selected).
Gets a memory by ID.
Gets a memory by slug.
Gets children of a specific memory by ID.
Gets only root memories (parent_id: nil).
Reloads all memories from disk.
Sets the current project context and reloads memories.
Updates an existing memory. Persists to disk and updates in-memory state.
Types
@type t() :: %Services.Memories{ by_id: %{required(String.t()) => AI.Memory.t()}, by_slug: %{required(String.t()) => AI.Memory.t()}, memories: [AI.Memory.t()], project_name: String.t() | nil, roots: [AI.Memory.t()] }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create(AI.Memory.t()) :: :ok | {:error, term()}
Creates a new memory. Validates parent scope matches if parent_id provided. Persists to disk and updates in-memory state.
Deletes a memory. Removes from disk and in-memory state.
@spec get_all() :: [AI.Memory.t()]
Gets all loaded memories (global + project if project selected).
@spec get_by_id(String.t()) :: AI.Memory.t() | nil
Gets a memory by ID.
@spec get_by_slug(String.t()) :: AI.Memory.t() | nil
Gets a memory by slug.
@spec get_children(String.t()) :: [AI.Memory.t()]
Gets children of a specific memory by ID.
@spec get_roots() :: [AI.Memory.t()]
Gets only root memories (parent_id: nil).
@spec reload() :: :ok
Reloads all memories from disk.
@spec set_project(String.t() | nil) :: :ok
Sets the current project context and reloads memories.
@spec start_link(keyword()) :: GenServer.on_start()
@spec update(AI.Memory.t()) :: :ok | {:error, term()}
Updates an existing memory. Persists to disk and updates in-memory state.