Expand description
SQLite-backed job queue + Phase 1 / Phase 2 workers for the
autonomous memory pipeline (memory_summary.rs).
This module is split out so the memory artifact surface
(prompts, paths, redaction) stays in memory_summary.rs while
the runtime machinery (SQLite schema, lease/heartbeat,
LLM-backed extraction + consolidation) lives here.
Status: skeletons only. The runtime spawn hook
(services::start_memory_pipeline) will instantiate and drive
these in the follow-up PR. Each worker is a pure function over
the SQLite connection so it’s unit-testable in isolation.
Re-exports§
pub use super::memory_summary::STAGE_ONE_SYSTEM_PROMPT as STAGE1_SYSTEM_PROMPT;pub use super::memory_summary::CONSOLIDATION_SYSTEM_PROMPT as CONSOLIDATION_SYSTEM_PROMPT_EXPORT;
Structs§
- Stage1
Row - One row from
memory_stage1_outputs. - Thread
Info - A single session (thread) that is eligible for Phase 1 processing.
Statics§
- PIPELINE_
DB_ PATH - A lazily-evaluated path for the pipeline’s working DB.
Functions§
- claim_
stage1_ job - Atomically claim one Stage 1 job. Returns the (thread_id, cwd) pair plus the ownership token if a job was claimed.
- collect_
threads - Collect eligible threads from
sessions_dirfor the given cwd.nowis the current Unix timestamp in seconds. - finish_
phase2 - Release the Phase 2 lease (success).
- heartbeat_
phase2 - Refresh the heart-beat on a held Phase 2 lease.
- init_
schema - Initialize the SQLite schema (idempotent). Safe to call on every open. Adds three tables:
- list_
stage1_ outputs - Load all Stage 1 outputs for
cwd, newest first, capped atlimit. - open_db
- Owned
MemoryDbconnection helper. Used byservicesto spawn the worker without exposing the rawConnection. - pipeline_
db_ path - Resolve where the pipeline DB should live. Mirrors
MemoryBackendplacement:<home>/memory/pipeline.db. - render_
stage1_ user - Build the user-turn text for Stage 1 by templating
STAGE_ONE_USER_TEMPLATEwith the session metadata + persistable items JSON. - render_
stage2_ user - Build the user-turn text for Stage 2 from accumulated Stage 1 rows.
- run_
stage1_ iteration - Run one Stage 1 iteration: claim a job, call the LLM, persist the
output. Returns
Ok(true)if a job was processed;Ok(false)when there is nothing to do. - run_
stage2_ iteration - try_
claim_ phase2 - Try to claim the global Phase 2 job for
cwd. ReturnsSome((token, lease))when claimed;Nonewhen another oxi process already owns it. - upsert_
thread - Insert / update the row for a single thread observation.
- write_
stage1_ output - Insert the Stage 1 output for a thread and mark it extracted.