diff --git a/hive-c0re/src/auto_update.rs b/hive-c0re/src/auto_update.rs index 9e13990a..a265ddce 100644 --- a/hive-c0re/src/auto_update.rs +++ b/hive-c0re/src/auto_update.rs @@ -67,21 +67,11 @@ pub fn agent_config_pending(name: &str, deployed_sha: Option<&str>) -> bool { /// the `rebuild_queue` worker (lets the function annotate its phase via /// `coord.set_queue_step`) and `None` when called directly (e.g. the /// root-agent migration nudge in `ensure_root_agent`). -/// -/// `relock` bumps the agent's meta input to `applied//main` before -/// the container rebuild. Pass `false` only for meta-update cascade -/// rebuilds, where re-locking would revert the bump the cascade just -/// committed (see `lifecycle::rebuild`). -/// -/// # Errors -/// -/// Propagates errors from `coord.ensure_runtime` and `lifecycle::rebuild`. pub async fn rebuild_agent( coord: &Arc, name: &str, current_rev: &str, queue_entry_id: Option, - relock: bool, ) -> Result<()> { tracing::info!(%name, rev = %current_rev, "rebuild agent"); let agent_dir = coord @@ -98,7 +88,6 @@ pub async fn rebuild_agent( name, &hive, &paths, - relock, &|step| coord.set_queue_step(queue_entry_id, step), &|log_id| { if let Some(qid) = queue_entry_id @@ -187,9 +176,7 @@ pub async fn ensure_root_agent(coord: &Arc) -> Result<()> { "manager container exists but no applied flake — forcing rebuild to migrate" ); let coord_clone = coord.clone(); - if let Err(e) = - rebuild_agent(&coord_clone, MANAGER_NAME, rev.as_str(), None, true).await - { + if let Err(e) = rebuild_agent(&coord_clone, MANAGER_NAME, rev.as_str(), None).await { tracing::warn!(error = ?e, "manager migration rebuild failed"); } } else { diff --git a/hive-c0re/src/lifecycle.rs b/hive-c0re/src/lifecycle.rs index 12d614b0..1ea2a5f5 100644 --- a/hive-c0re/src/lifecycle.rs +++ b/hive-c0re/src/lifecycle.rs @@ -409,23 +409,10 @@ pub async fn destroy(name: &str) -> Result<()> { Ok(()) } -/// Rebuild `name`'s container: sync the meta flake, optionally re-lock -/// the agent's input, then re-apply + restart via `nixos-container`. -/// -/// When `relock` is `true` the agent's meta input is bumped to whatever -/// `applied//main` points at before the build. Pass `false` for -/// meta-update cascade rebuilds, where re-locking would revert the bump -/// the cascade just committed (see the inline note below). -/// -/// # Errors -/// -/// Propagates errors from meta-flake sync / lock-update and the -/// `nixos-container` apply + restart shellouts. pub async fn rebuild( name: &str, hive: &HiveEnv, paths: &AgentPaths, - relock: bool, on_step: &(dyn Fn(&str) + Send + Sync), on_build_log_id: &(dyn Fn(i64) + Send + Sync), ) -> Result<()> { @@ -439,16 +426,7 @@ pub async fn rebuild( // Then bump just this agent's input — picks up whatever // `applied//main` currently points at (deployed/). // Commits the lock if it changed. - // - // `relock = false` skips this: a meta-update cascade has *just* set - // the meta lock deliberately, and `lock_update_for_rebuild` re-runs - // `nix flake update agent-`, which re-resolves the agent's - // transitive inputs back to the agent's own flake.lock — reverting - // the input the meta-update just bumped. Cascade rebuilds therefore - // build against the freshly-set on-disk lock as-is. - if relock { - crate::meta::lock_update_for_rebuild(name).await?; - } + crate::meta::lock_update_for_rebuild(name).await?; rebuild_no_meta(name, hive, paths, on_step, on_build_log_id).await } diff --git a/hive-c0re/src/rebuild_queue.rs b/hive-c0re/src/rebuild_queue.rs index e40cad20..55bd76f5 100644 --- a/hive-c0re/src/rebuild_queue.rs +++ b/hive-c0re/src/rebuild_queue.rs @@ -886,19 +886,8 @@ async fn dispatch( (QueueKind::Rebuild, None) => { let current_rev = crate::auto_update::current_flake_rev(&coord.hyperhive_flake).unwrap_or_default(); - // A meta-update cascade has just set the meta lock; re-locking - // in the per-agent rebuild would revert it (the agent's own - // flake.lock wins). Every other source wants the relock so it - // advances to applied//main. - let relock = entry.source != QueueSource::MetaUpdate; - crate::auto_update::rebuild_agent( - coord, - &entry.agent, - ¤t_rev, - Some(entry.id), - relock, - ) - .await + crate::auto_update::rebuild_agent(coord, &entry.agent, ¤t_rev, Some(entry.id)) + .await } (QueueKind::MetaUpdate, Some(approval_id)) => { crate::actions::run_approval_update_meta_inputs(coord, Some(entry.id), approval_id) @@ -998,7 +987,7 @@ async fn dispatch( // env var takes effect in the container. let current_rev = crate::auto_update::current_flake_rev(&coord.hyperhive_flake).unwrap_or_default(); - crate::auto_update::rebuild_agent(coord, name, ¤t_rev, Some(entry.id), true).await + crate::auto_update::rebuild_agent(coord, name, ¤t_rev, Some(entry.id)).await } (QueueKind::GracefulStop, _) => run_graceful_stop(coord, entry).await, (QueueKind::Start, _) => run_start(coord, entry).await, diff --git a/hive-c0re/src/server.rs b/hive-c0re/src/server.rs index 13ca9719..0f69098e 100644 --- a/hive-c0re/src/server.rs +++ b/hive-c0re/src/server.rs @@ -425,7 +425,7 @@ async fn handle_rebuild(coord: &Arc, name: &str) -> Result