Expand description
Migration runner — invoked by agentmux-srv migrate (a CLI subcommand;
the launcher runs migrate --prepare through srv_spawner::run_prepare
when srv’s boot gate asks for it) and, separately, in-process at boot via
run_pending_migrations, only when no supervisor prepares data (headless
srv, task dev:standalone).
--prepare and the in-process path report per-migration progress as
agentmux_common::srv_stderr’s AGENTMUXSRV-MIGRATION-BEGIN/-END lines
on stderr (STDERR_PROGRESS), which the launcher’s splash shows as
sub-rows. Plain migrate (no flags) prints newline-delimited JSON on
stdout instead, for scripts and operators running it by hand.
Failures are written to <home>/logs/migration-error.log; the
process exits non-zero so the launcher can surface the error rather than
booting with a half-migrated data dir.
Structs§
- Applied
Ids - Which migration ids each tracking store records as applied, read through
a FALLIBLE path.
Errmeans the store exists but its tracking state could not be read (not a database, malformed table, locked): every migration of that scope then reportsVerifyOutcome::Errorinstead of being silently skipped as “unapplied” and letting the pass exit 0 — codex P1 on #3058, whichStore::migration_is_applied’sunwrap_or(false)would have caused. A store file that does not exist, or one predating thedb_migrationstable, has nothing recorded and isOk(empty). - Doctor
Report - The complete migration doctor report for one data dir.
- Doctor
Row - One registry migration, in registry order.
- Doctor
Summary - Verify
Record - One line of the verify report.
Enums§
- Pending
Count Error - Why a pending count could not be determined. Distinguished from “zero pending” on purpose: a caller deciding whether the schema is current must be able to tell “nothing to do” from “I could not tell”, because the safe reaction to each is opposite.
Constants§
- VERIFY_
FAILED_ EXIT_ CODE - Exit code of
migrate --verifywhen at least one applied migration’s post-condition is a mismatch or its check errored. Distinct from 1 (a migration RUN failed) so a caller can tell “your data is inconsistent” from “the migrate command itself broke”, and from 2, which clap uses for a CLI usage error (a typoed flag must not read as a data finding — reagent P2 on #3058). See docs/exe-return-codes.md.
Functions§
- count_
pending_ migrations - Return the number of REGISTRY migrations that have not yet been applied, reporting 0 on any error so startup is never blocked.
- doctor_
report - The doctor report for
data_dir, against an explicit registry (tests pass fakes; production passesREGISTRY). Read-only. - doctor_
report_ for_ instance doctor_reportfor the running instance’s own registry and resolved shared store / home — whatGET /api/v1/muxspect/migrationsserves.Errwhen the shared root can’t be resolved at all (noAGENTMUX_SHARED_DIR, CI), the same condition under whichrun_migrate_commandtreats migrations as a no-op.- run_
migrate_ command - Called from
main.rswhen themigratesubcommand is active. Returns the exit code (0 = success, 1 = failure, 3 =--verifyfound a mismatch — seeVERIFY_FAILED_EXIT_CODE). - run_
pending_ migrations - Apply all pending migrations in-process before srv opens its stores.
- try_
count_ pending_ migrations - Number of REGISTRY migrations not yet applied, or why that could not be determined.
- verify_
applied - Run
verify()for every migration inregswhose tracking store records it as applied. Generic over the registry slice so the harness can be tested with fakes; production passesREGISTRY. - verify_
exit_ code - Exit code for a verify report: 0 unless any record is a mismatch or an
error.
NotVerifiableis not a failure — it is the honest default.