Services.MemoryIndexer (fnord v0.9.29)

View Source

Background service that promotes session-scoped memories to long-term (project/global) storage. Independently scans conversations for unprocessed session memories, processes one conversation at a time via the Memory.Indexer agent, and applies the resulting actions.

The service is self-driven: on startup it begins scanning for work. After processing a conversation, it scans again. When no unprocessed memories remain, it goes idle. External callers can nudge it via scan/0 if they know new work is available (e.g. after saving a conversation).

Public API:

  • start_link/1
  • scan/0 -- nudge the service to look for work
  • process_sync/1 -- test-only synchronous processing
  • status/0

Summary

Functions

Returns a specification to start this module under a supervisor.

Cleans up abandoned stale per-memory lock directories whose target memory files no longer exist.

Callback implementation for GenServer.init/1.

Process a conversation synchronously; returns :ok | {:error, term()}

Nudge the service to scan for unprocessed conversations

Get status: whether a task is currently running

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

cleanup_orphan_memory_locks()

@spec cleanup_orphan_memory_locks() :: :ok

Cleans up abandoned stale per-memory lock directories whose target memory files no longer exist.

FileLock creates a *.json.lock directory before the target *.json file may exist, and release_lock/1 may temporarily rename that directory to *.json.lock.released.* before removing it. This maintenance path intentionally mirrors that lifecycle: it only inspects those lock-directory forms under the project and global memory storage roots, leaves allocation locks and unrelated store locks alone, and only removes a lock when the target file is missing, the lock age is strictly greater than the stale threshold, and no live local owner pid can be found.

handle_continue(atom, state)

Callback implementation for GenServer.handle_continue/2.

init(opts)

Callback implementation for GenServer.init/1.

process_sync(convo)

Process a conversation synchronously; returns :ok | {:error, term()}

scan()

Nudge the service to scan for unprocessed conversations

start_link(opts \\ [])

status()

Get status: whether a task is currently running

summarize_conversation(messages)