Skip to main content

Module migrations

Module migrations 

Source
Expand description

SQL schema setup for Store, FileStore, and the saga log.

objects.db uses a flat schema: run_object_schema defines the final table set directly in one idempotent CREATE TABLE IF NOT EXISTS batch. It replaced an 11-step incremental migration chain (run_forge_v1 … run_forge_v11) — see docs/specs/SPEC_SCHEMA_FLATTENING_2026_05_19.md. The chain was pure historical accretion: per-version data dirs mean every new version is born with a fresh objects.db and ran the whole chain top-to-bottom anyway, so the intermediate states were never reachable in production.

filestore.db and sagas.db were already single-DDL stores; they keep their existing schema functions and gain only the user_version tripwire (check_schema_compat + stamp_version).

Modules§

object_schema
The steps of run_object_schema, one function each, in the order they ran: the generic object tables, typed input history, the flat table batch, the additive column migrations, the blank Bundle seed and the channel migration table. Moved out of run_object_schema without a change in behaviour. The doc comment above notes inside the SQL point at OBJECT_SCHEMA_VERSION in migrations.rs.
store_schema
The tables, seed and additive columns of the shared store (store.db) and the identity store, one function each, for run_shared_store_schema and run_identity_store_schema. Moved out of them without a change in behaviour. The version notes (v4, v6 and so on) that the SQL comments below refer to are in the docs of SHARED_STORE_SCHEMA_VERSION and IDENTITY_STORE_SCHEMA_VERSION in migrations.rs.

Constants§

FILESTORE_SCHEMA_VERSION
user_version value stamped into filestore.db.
IDENTITY_STORE_SCHEMA_VERSION
user_version stamped into the permanently-global ~/.agentmux/shared/identity-store.db (a different file from store.db; see run_identity_store_schema). Independent counter from SHARED_STORE_SCHEMA_VERSION. What each version (v1 to v11) added: docs/architecture/STORAGE_SCHEMA_VERSION_HISTORY.md, “Identity store”.
OBJECT_SCHEMA_VERSION
user_version stamped into objects.db after run_object_schema. The flat schema reset the counter to 1 (the pre-flatten chain never set user_version, so legacy files read 0). Bumped per additive migration; check_schema_compat makes an older binary refuse a file stamped newer than it. What each version (v1 to v45) added: docs/architecture/STORAGE_SCHEMA_VERSION_HISTORY.md, “Objects store”.
SAGA_LOG_SCHEMA_VERSION
user_version value stamped into sagas.db.
SHARED_STORE_SCHEMA_VERSION
user_version stamped into ~/.agentmux/shared/store.db after run_shared_store_schema. Versioned independently from objects.db. What each version (v1 to v12) added: docs/architecture/STORAGE_SCHEMA_VERSION_HISTORY.md, “Shared store”.

Functions§

check_schema_compat
PRAGMA user_version tripwire (AUDIT_SQLITE_SYSTEMS §8.5): compare the file’s user_version to current and refuse to open a database written by a NEWER binary. This is the forward-compat safety lock of the channels design (SPEC_DATA_CHANNELS_2026_05_24.md §3.3): within a channel several released AgentMux versions share one data dir, and the lock keeps an older binary from writing into a schema a newer one laid down (as Chrome’s profile-too-new check and Postgres’s catalog version mismatch do).
run_filestore_migrations
Initialize the FileStore schema. Creates the wave_file and file_data tables. Already a flat single-DDL store — unaffected by the objects.db flattening.
run_identity_store_schema
Initialize (or re-validate) the ~/.agentmux/shared/identity-store.db schema: the permanently-global store from docs/specs/SPEC_IDENTITY_STORE_SPLIT_2026_08_17.md, which fixes conversation continuity across a version switch (docs/specs/REPORT_HISTORY_CONTINUITY_ACROSS_VERSION_UPGRADE_2026_08_17.md).
run_object_schema
Initialize (or re-validate) the full objects.db schema.
run_saga_log_migrations
Initialize the saga durability schema (saga + saga_step tables and their indexes). See docs/specs/SPEC_SAGA_DURABILITY_2026-05-01.md §2.2. Already a flat single-DDL store.
run_shared_store_schema
Initialize (or re-validate) the ~/.agentmux/shared/store.db schema.
stamp_version
Stamp the database’s user_version PRAGMA to current. Called AFTER run_*_schema succeeds, paired with a prior check_schema_compat that gated the migrations on the caller-binary speaking a compatible (or newer) schema version.