Skip to main content

Module migrate

Module migrate 

Source
Expand description

One-shot SQLite → file-registry migration for named instances.

Runs at most once per <registry_root>/.migrated_from_sqlite marker; idempotent and read-only on every SQLite it touches.

P0.3 re-roots the registry to the GLOBAL ~/.agentmux/shared/agents/ registry/, so this scan is generalized from “the current channel’s per-version DBs” to every channel and every dev branch on the machine:

  <home>/channels/<ch>/versions/<v>/data/db/objects.db   (installed/portable)
  <home>/dev/<branch>[/<sub>]/data/db/objects.db         (dev)

Workspace anchoring. Agent workspaces live GLOBALLY at <home>/agents/<name> (verified on disk: real working_directory values are ~/.agentmux/agents/<name>, e.g. …/agents/mazs-0527n), independent of channel/version. [row_to_record] therefore strips each row’s working_directory against the global <home>/agents root FIRST, then falls back to this row’s own source-channel agents dir (channels/<ch>/agents, or <instance_dir>/agents for dev) for any legacy row that genuinely lived in-channel — each source DB still carries that per-source dir. The two subtrees are disjoint, so the fallback never mis-maps a global workspace. The chosen base is stored absolute in the record, so a reader in ANY channel round-trips source_agents_base.join(working_dir) back to the real workspace. See docs/specs/SPEC_CROSS_CHANNEL_AGENT_PERSISTENCE_2026-06-13.md §11.5.

Structs§

MigrateStats
Outcome stats — surfaced in the marker file + the srv log.
SourceBackfillStats
Outcome of backfill_source_bases_once.

Functions§

backfill_source_bases_once
One-shot backfill of source_agents_base onto registry records written before schema v3 — i.e. by P0.3b’s global migration (#1389) or any pre-P0.4 live mirror.
enumerate_objects_dbs
Public variant of enumerate_sources that returns only the objects.db paths, without the per-source agents-root pairing. Used by m0011_shared_store_backfill to seed store.db from all channels rather than just the current instance’s DB.
migrate_from_sqlite_once
Scan every channel + dev objects.db under home and populate the shared registry. Skipped if the marker file exists. Never overwrites an existing registry record (idempotency + respect for newer-written data). The SQLite files are opened read-only — never modified.