Expand description
SQL schema setup for WaveStore, 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 (stamp_and_check_version).
ConstantsΒ§
- DEAD_
TABLE_ πDROPS - Tables retained by the old chain only for a downgrade path the flatten
abandons. Dropped from any legacy DB by the adopt step; never created
by the flat schema.
db_workflow_*data was already copied intodb_drone_*by the old v10 migration, so dropping loses nothing. - FILESTORE_
SCHEMA_ VERSION user_versionvalue stamped intofilestore.db.- LEGACY_
INDEX_ πDROPS - Legacy index names that must be dropped after their table is renamed β
ALTER TABLE β¦ RENAMEkeeps indexes attached but under their old names, which would collide with the flat DDLβsCREATE INDEX. The flat DDL recreates each under the new name. - LEGACY_
TABLE_ πRENAMES - Legacy
objects.dbtable names retired by the de-forge rename, paired with their replacement.adopt_legacy_table_namesrenames any of these it finds β the single surviving piece of the old migration chain (it also subsumes the v11db_identities/db_memoriesrename). - OBJECT_
SCHEMA_ VERSION user_versionvalue stamped intoobjects.dbafterrun_object_schema. The flat schema reset the counter to 1 (the pre-flatten chain never setuser_version, so legacy files read 0). Bumped per additive migration: v1 β flat schema baseline v2 β db_agent_definitions.updated_at v3 β db_agent_definitions.user_hidden (Phase 2 hide templates, SPEC_AGENT_PICKER_TWO_TIER_2026_05_24.md Q2 Decision Y) v4 β db_agents consolidation table (Phase 3a; dual-write only, reads still on db_agent_definitions / db_agent_instances)- SAGA_
LOG_ SCHEMA_ VERSION user_versionvalue stamped intosagas.db.- WSTORE_
OTYPES π - Object type table names matching the
db_<otype>convention.
FunctionsΒ§
- adopt_
legacy_ πtable_ names - Rename any pre-flatten
objects.dbtables to their de-forged names and drop the dead workflow/sentinel tables. Idempotent β on a fresh or already-flat database every check is a no-op. - check_
schema_ compat PRAGMA user_versiontripwire (AUDIT_SQLITE_SYSTEMS Β§8.5).- 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.dbflattening. - run_
object_ schema - Initialize (or re-validate) the full
objects.dbschema. - run_
saga_ log_ migrations - Initialize the saga durability schema (
saga+saga_steptables and their indexes). Seedocs/specs/SPEC_SAGA_DURABILITY_2026-05-01.mdΒ§2.2. Already a flat single-DDL store. - stamp_
version - Stamp the databaseβs
user_versionPRAGMA tocurrent. Called AFTERrun_*_schemasucceeds, paired with a priorcheck_schema_compatthat gated the migrations on the caller-binary speaking a compatible (or newer) schema version.