Skip to main content

Module def_migrate

Module def_migrate 

Source
Expand description

Global migration: backfill user-agent DEFINITIONS (with their content + skills) from every channel’s per-version objects.db — and every dev/ branch DB — into the GLOBAL definition store, so EXISTING agents become cross-channel without waiting for the next edit. Read-only on every scanned SQLite.

Version-gated, re-runnable marker (not strictly one-shot): the .migrated_definitions marker in the store root records the [MIGRATION_VERSION] that last ran. A marker older than the current version — including the legacy migrated text, which parses as version 0 — re-runs the scan ONCE, so users whose earlier pass was incomplete recover automatically on the next launch. Bump [MIGRATION_VERSION] whenever the scan logic changes to trigger a one-time re-run for everyone.

On a re-run, an agent already in the global store is refreshed only when the scanned copy is strictly fresher than the global record (so a broken earlier pass’s stale/content-less copy is corrected) — never downgraded below what the live write-mirror has since advanced, and never resurrected if tombstoned. (codex P1 / reagent P2 #1391.)

Cross-channel agent persistence, P0.2d (docs/specs/SPEC_CROSS_CHANNEL_AGENT_PERSISTENCE_2026-06-13.md).

Resilience mirrors scripts/import-agents.sh: a single unreadable / locked / old-schema objects.db is skipped with a warning, never aborting the pass. The marker is written after a pass even if some DBs were skipped — a transiently-skipped DB’s agents still go global on their next edit via the live write-mirror (P0.2b), and a future [MIGRATION_VERSION] bump re-scans everything — so nothing is permanently lost and the migration never loops forever on a permanent old-schema failure.

Structs§

DefMigrateStats
Outcome stats — surfaced in the srv log.

Functions§

migrate_definitions_global_once
Scan every channel AND dev-branch objects.db under home for user agents and backfill them into the global definition store. Re-runs once per [MIGRATION_VERSION] bump (marker in store.root()); read-only on every scanned SQLite, and tolerant of older schemas (missing columns).