//! A destroyed agent's config repo (`agent-configs/`): 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." ), } }