Skip to main content

build_run_store

Function build_run_store 

pub fn build_run_store(
    cfg: &SopConfig,
    data_dir: &Path,
) -> Result<Arc<dyn SopRunStore>, StoreError>
Expand description

Build the configured run store.

  • persist_runs = true (default), backend "sqlite" (default) -> SqliteRunStore at <run_state_dir | data_dir/sop>/runs.db (dir created mode-0700), so in-flight runs - including runs parked at a HITL approval - survive a restart.
  • persist_runs = false -> ephemeral InMemoryRunStore (opt back into non-durable state).
  • persist_runs = true, backend "memory" -> ephemeral InMemoryRunStore (degraded/tests).

The backend is the closed SopRunStoreBackend enum, so an out-of-set value is rejected at config-deserialize time rather than here (no runtime unknown arm).

Called by build_sop_engine, which injects the result via with_store and then calls restore_runs() to rehydrate in-flight runs at startup. A backend-open failure is non-fatal there: the daemon logs and falls back to the in-memory store rather than failing to boot.