feat(#2102): skip startup rebuild for stopped/unchanged containers

This commit is contained in:
damocles 2026-07-04 18:16:49 +02:00 committed by mara
commit 672e77c849
4 changed files with 125 additions and 34 deletions

View file

@ -803,6 +803,25 @@ async fn handle_start(coord: &Arc<Coordinator>, agent: &str, name: &str) -> Agen
return err;
}
tracing::info!(%agent, %name, "start container");
// If the hyperhive rev is stale, route through the rebuild queue so the
// container runs current nix derivations before it starts. Same logic as
// `run_start`; this covers the MCP `start` tool path.
let current_rev = crate::auto_update::current_flake_rev(&coord.hyperhive_flake);
if let Some(ref rev) = current_rev {
let stored = std::fs::read_to_string(crate::auto_update::rev_marker_path(name)).ok();
if stored.as_deref() != Some(rev.as_str()) {
tracing::info!(%agent, %name, "start: rev stale — enqueuing rebuild");
coord.rebuild_queue.enqueue(
crate::rebuild_queue::QueueKind::Rebuild,
name.to_owned(),
crate::rebuild_queue::QueueSource::Manual,
format!("start {name}: rev stale — rebuilding first"),
None,
);
coord.emit_rebuild_queue_snapshot();
return AgentResponse::Ok;
}
}
match crate::lifecycle::start(name).await {
Ok(()) => {
coord.kick_agent(name, "container started");