MCPcopy Create free account
hub / github.com/block/buzz / run_boot_migrations

Function run_boot_migrations

desktop/src-tauri/src/migration.rs:130–165  ·  view source on GitHub ↗

Run every data migration that must complete before identity resolution and agent restore. Ordering is load-bearing: `migrate_legacy_app_data_dir` must precede any disk read, and `sync_shared_agent_data` must precede `restore_managed_agents_on_launch` (which reads `managed-agents.json`). Identity-dependent migrations (persona/team event signing) run separately in boot setup after the persisted iden

(app: &tauri::AppHandle)

Source from the content-addressed store, hash-verified

128/// so it runs pre-identity here ahead of all readers — reader-first loses a
129/// launch (stale harness/`mcp_command` until the next boot).
130pub fn run_boot_migrations(app: &tauri::AppHandle) {
131 // Initialize the process-lifetime nest directory before any filesystem
132 // operation that calls nest_dir(). The discriminator matches the existing
133 // pattern used by reconcile_target_dir: dev instances have an app-data-dir
134 // name starting with CANONICAL_DEV_IDENTIFIER.
135 let is_dev = if let Ok(data_dir) = app.path().app_data_dir() {
136 let dev = data_dir
137 .file_name()
138 .and_then(|n| n.to_str())
139 .is_some_and(|n| n.starts_with(CANONICAL_DEV_IDENTIFIER));
140 crate::managed_agents::init_nest_dir(dev);
141 dev
142 } else {
143 false
144 };
145
146 // On dev builds, copy `.repos-dir` from ~/.buzz → ~/.buzz-dev BEFORE
147 // control returns to lib.rs where resolve_repos_at_boot() reads it. This
148 // ensures the dev nest boots with the correct workspace on its first launch,
149 // matching what the prod nest had configured. Skip-if-dest-exists so it is
150 // idempotent and never clobbers a value the dev nest already set explicitly.
151 if is_dev {
152 migrate_dev_repos_dir();
153 }
154
155 migrate_legacy_app_data_dir(app);
156 sync_shared_agent_data(app);
157 migrate_packs_to_teams(app);
158 reconcile_persona_team_dirs(app);
159 migrate_persona_provider_to_runtime(app);
160 reconcile_legacy_command_names(app);
161 if let Err(e) = crate::managed_agents::sync_team_personas(app) {
162 eprintln!("buzz-desktop: sync-team-personas: {e}");
163 }
164 reconcile_provider_mcp_commands(app);
165}
166
167/// Copy one-time app state from the legacy app identifier directory to
168/// the current Buzz identifier directory. The Tauri identifier controls the app

Callers 1

runFunction · 0.85

Calls 11

init_nest_dirFunction · 0.85
migrate_dev_repos_dirFunction · 0.85
sync_shared_agent_dataFunction · 0.85
migrate_packs_to_teamsFunction · 0.85
sync_team_personasFunction · 0.85
pathMethod · 0.45

Tested by

no test coverage detected