Skip to main content

agentmux_srv/migrations/
m0014_agent_direct_bindings_rerun.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Re-run the direct agent↔account link backfill to catch instances
5//! launched in the gap between `m0013`'s original run and the launch flow
6//! write-through landing (PR B1, #1950) — historical.
7//!
8//! `m0013` backfills `db_agent_identity_links` from bundle bindings, but
9//! every migration runs AT MOST ONCE per install (guarded by
10//! `db_migrations`, see `migrations/mod.rs`). Any agent launched after
11//! `m0013` ran on a given install, but before PR B1 shipped, would have a
12//! bundle-based `identity_id` and NO direct link — `m0013` never sees it
13//! because it already ran. This migration only ever looked at the SINGLE
14//! latest instance per definition — the one whose bundle pick (or
15//! "blank") was the actual current intent — and only ADDED/UPDATED links
16//! implied by it (never unlinked, since `identity.account.upsert` also
17//! writes `db_agent_identity_links` independent of any bundle or launch).
18//!
19//! **Retired.** `db_identity_bundles`/`db_identity_bindings` (the source
20//! this read from) were dropped in Phase 4c of
21//! SPEC_PRESET_TO_BUNDLE_REFACTOR_2026_07_02.md, once this migration had
22//! already run on every real install. The migration id stays registered
23//! (already-applied installs must never re-run a Global migration) but its
24//! body is now a documented no-op.
25
26use super::{Migration, MigrationContext, MigrationError, MigrationScope};
27
28pub struct M0014AgentDirectBindingsRerun;
29
30impl Migration for M0014AgentDirectBindingsRerun {
31    fn id(&self) -> &'static str { "0014_agent_direct_bindings_rerun" }
32    fn scope(&self) -> MigrationScope { MigrationScope::Global }
33    fn description(&self) -> &'static str {
34        "Retired no-op — historically re-ran the direct agent<->account link \
35         backfill (latest instance per definition only) for instances launched \
36         after m0013's one-time run but before the launch-flow write-through"
37    }
38
39    fn up(&self, _ctx: &MigrationContext) -> Result<(), MigrationError> {
40        Ok(())
41    }
42}