Skip to main content

Module stores

Module stores 

Source
Expand description

Split out of the single-file bootstrap module unchanged (SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.3).

Structs§

Stores
Output of open_stores_and_migrate — every store/log handle the rest of bootstrap and AppState need.

Functions§

carry_forward_or_exit 🔒
carry_forward_or_stop for the start path: a copy that failed while an older version has data is NOT a fresh start. With no launcher to show a dialog (this path is the headless and hosted one), the person would see an empty workspace while the previous version’s folder still holds their data. srv stops, says why, and leaves that folder as it was.
carry_forward_or_stop 🔒
The copy-forward of the previous version’s data before this version’s first start: Ok(true) when it was copied, Ok(false) when there was nothing to copy (a first start, or this version already has data: a fresh start on purpose), and Err with the message to stop with when an older version has data and copying it failed.
load_config
Step 2: Parse CLI args and build config. Dispatches the migrate subcommand (and exits) before touching AUTH_KEY-gated config.
migrate_data_dir 🔒
The data folder migrate works on: the one the daemon opens given the same environment. The daemon turns its data folder into AGENTMUX_DATA_HOME and opens base::get_mux_db_dir(), which resolves through agentmux_root(), where AGENTMUX_HOME_OVERRIDE comes first, except for a data folder inside it (an isolated instance’s version folder, task #3569). Without the same resolution, the launcher’s migrate --prepare under a home override migrated the version’s folder while srv’s boot check read <override>/db, and srv never started (Korp@narko, after #5252).
open_stores_and_migrate
Step 4: Initialize backend (matching Go cmd/server/main-server.go:374-590). Sets up the data directory, runs in-process migrations, opens every SQLite-backed store, attaches the shared/global registries, and performs the various one-time startup seed/repair passes.
open_work_store 🔒
The stores the work queue and scheduled jobs use. Installed and task package builds share the host’s (the identity store and the shared store, as before); a task dev build gets a work-store.db of its own, so it never reads or changes the operator’s real queue or jobs. If that store can’t be opened srv exits, as it does for objects.db: falling back to the host’s files would be the leak this exists to close.
prepare_in_process 🔒
What an unsupervised srv does before opening its stores: copy a previous version’s data forward, snapshot, and run pending migrations (the same work agentmux-srv migrate --prepare does for the launcher).
restore_repaired_history 🔒
After a repair of the shared store (filestore::repair): put back, from the per-channel copies of it, the conversation of each agent whose zone lost rows. Runs inside the repair, before the store is opened for use.