Skip to main content

agentmux_srv/migrations/
m0010_session_ids.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::registry;
5use super::{Migration, MigrationContext, MigrationError, MigrationScope};
6
7pub struct M0010SessionIds;
8
9impl Migration for M0010SessionIds {
10    fn id(&self) -> &'static str { "0010_session_ids" }
11    fn scope(&self) -> MigrationScope { MigrationScope::Global }
12    fn description(&self) -> &'static str { "Backfill session_id on registry records for cross-channel resume" }
13
14    fn up(&self, ctx: &MigrationContext) -> Result<(), MigrationError> {
15        let registry_root = ctx.home.join("shared").join("agents").join("registry");
16        if !registry_root.exists() {
17            return Ok(());
18        }
19        let reg = registry::Registry::open(registry_root)
20            .map_err(|e| MigrationError(format!("session_ids: open registry: {}", e)))?;
21        let shared_dir = ctx.home.join("shared");
22        crate::backend::session_backfill::backfill_session_ids(&reg, &shared_dir);
23        Ok(())
24    }
25}