LemonMemory.Ingest (lemon_memory v0.1.0)

View Source

Asynchronous ingest pipeline that writes normalized memory documents to LemonMemory.Store after a run is finalized.

Design

  • Ingest runs in a dedicated GenServer so it never blocks run finalization.
  • Ingest failures are logged and silently dropped — they must never crash or slow down the caller.
  • The session_search feature flag gates whether ingest is active. When the flag is :off (the default), calls to ingest/3 are no-ops.

Usage

# Called by LemonCore.Store when finalizing a run
LemonMemory.Ingest.ingest(run_id, record, summary)

Configuration

Ingest respects LemonMemory.Store configuration and the session_search feature flag in [features] of ~/.lemon/config.toml.

Summary

Functions

Returns a specification to start this module under a supervisor.

LemonCore.Store finalize-run hook: enqueue the finalized run for ingest.

Enqueue a finalized run for asynchronous memory ingest.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

handle_finalize_run(event)

@spec handle_finalize_run(map()) :: :ok

LemonCore.Store finalize-run hook: enqueue the finalized run for ingest.

Wired by the runtime, not by the store:

config :lemon_core, LemonCore.Store,
  finalize_run_hooks: [{LemonMemory.Ingest, :handle_finalize_run}]

handle_finalize_run(server, map)

@spec handle_finalize_run(GenServer.server(), map()) :: :ok

ingest(run_id, record, summary)

@spec ingest(run_id :: term(), record :: map(), summary :: map()) :: :ok

Enqueue a finalized run for asynchronous memory ingest.

This is a fire-and-forget cast. Feature flags are evaluated inside the ingest worker so the config only needs to be loaded once per ingest.

ingest(server, run_id, record, summary)

@spec ingest(GenServer.server(), run_id :: term(), record :: map(), summary :: map()) ::
  :ok

start_link(opts \\ [])