pub fn repair_def_gaps(conn: &mut Connection) -> Result<usize, StoreError>Expand description
Delta repair: backfill any db_agent_definitions rows that are
missing from db_agents.
This closes a gap the one-shot consolidation migration cannot cover:
agents defined after the marker file was written (and before Phase 3b
dual-write landed) live only in db_agent_definitions. Phase 3b
readers look exclusively at db_agents, so those agents are invisible
— no icon, no reattach, “clicking does nothing”.
Unlike run_consolidate_migration, this is not marker-gated. It
runs on every startup (cheap — one indexed LEFT JOIN + a handful of
inserts at most) and is idempotent via INSERT OR IGNORE.
Returns the number of definitions inserted.