Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: archive a destroyed agent's config repo, unarchive it when the name is created again

This commit is contained in:
damocles 2026-11-14 12:48:54 +01:00 • committed by mara
commit 7beb1193f4

View file

@ -0,0 +1,36 @@
//! A destroyed agent's config repo (`agent-configs/<agent>`): archived when the
//! agent is declared `Destroyed`, so it stays readable but takes no more
//! pushes or PRs, and unarchived when an agent of the same name is created
//! again (`forge::Client::create_repo`).
use crate::routes::AppState;
/// Archive `agent`'s config repo. A failure is logged and does not stop the
/// destroy, as in `agent_archetype::clear_on_destroy`: an agent that cannot be
/// torn down is the larger harm, and declaring it destroyed again re-runs
/// this.
pub(crate) async fn archive_on_destroy(state: &AppState, hive: &str, agent: &str) {
let Some(forge) = state.forge.get() else {
tracing::warn!(
hive,
agent,
"no forge access here, so the destroyed agent's config repo was left as it is"
);
return;
};
match forge.set_config_repo_archived(agent, true).await {
Ok(true) => tracing::info!(hive, agent, "destroyed agent's config repo archived"),
Ok(false) => tracing::debug!(
hive,
agent,
"destroyed agent's config repo was already archived, or does not exist"
),
Err(e) => tracing::error!(
hive,
agent,
error = %format!("{e:#}"),
"archiving this agent's config repo FAILED; it was destroyed anyway, so the repo \
still takes pushes. Declaring the agent destroyed again re-runs this."
),
}
}