LemonCore. RunHistoryStore
(lemon_core v0.1.0)
View Source
Dedicated store for run history, isolated from the main Store GenServer.
Uses its own SQLite database (run_history.sqlite3) so that large
conversation payloads never block secrets lookups, chat-state reads,
or other latency-sensitive operations in the main store.
Includes built-in retention: entries older than the configured TTL are swept periodically.
Configuration
config :lemon_core, LemonCore.RunHistoryStore,
path: "~/.lemon/store", # directory — run_history.sqlite3 created inside
retention_ms: 7 * 24 * 3600_000, # 7 days (default)
max_per_session: 50 # keep at most N entries per session_keyInstances
The store is named (default LemonCore.RunHistoryStore) and every public
function takes an optional leading server argument, so additional instances
can run alongside the default one:
{LemonCore.RunHistoryStore, name: :scratch_history, path: "/tmp/scratch"}start_link/1 opts win over the application env, which is read under the
instance's name (config :lemon_core, LemonCore.RunHistoryStore for the
default).
Summary
Functions
Returns a specification to start this module under a supervisor.
Delete all history for a session.
Fetch the most recent limit history entries for a session.
Fetch history for a session from a specific store instance.
LemonCore.Store finalize-run hook: persist the finalized run's history.
List all entries (for migration/debug). Expensive — avoid in production hot paths.
Store a run history entry.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Delete all history for a session.
Fetch the most recent limit history entries for a session.
Returns [{run_id, data}, ...] sorted by recency (newest first).
Fetch history for a session from a specific store instance.
@spec handle_finalize_run(map()) :: :ok
LemonCore.Store finalize-run hook: persist the finalized run's history.
Wired by the runtime, not by the store:
config :lemon_core, LemonCore.Store,
finalize_run_hooks: [{LemonCore.RunHistoryStore, :handle_finalize_run}]Pass a store instance name as a leading argument to target a non-default
history store: {LemonCore.RunHistoryStore, :handle_finalize_run, [:my_history]}.
List all entries (for migration/debug). Expensive — avoid in production hot paths.
Store a run history entry.