drop the applied repo: the hive keeps no copy of an agent's config, only the deploy markers. Refs #5913
This commit is contained in:
parent
deeb5ecd86
commit
862495530c
1 changed files with 190 additions and 1634 deletions
|
|
@ -7,19 +7,9 @@ mod setup;
|
|||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(test)]
|
||||
pub use git::git_update_ref;
|
||||
#[cfg(test)]
|
||||
pub use git::run_with_deadline;
|
||||
pub use git::{
|
||||
git, git_authed, git_command, git_command_authed, git_is_ancestor, git_read_tree_reset,
|
||||
git_rev_parse, git_tag, git_update_ref_cas,
|
||||
};
|
||||
pub use git::{git_command, git_command_authed};
|
||||
pub use host_config::write_dropins;
|
||||
pub use setup::{
|
||||
ensure_agent_state_subvolume, ensure_claude_dir, ensure_state_dir, initial_flake_nix,
|
||||
setup_applied,
|
||||
};
|
||||
pub use setup::{ensure_agent_state_subvolume, ensure_claude_dir, ensure_state_dir};
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use tokio::process::Command;
|
||||
|
|
@ -205,8 +195,8 @@ async fn port_collision(self_name: &str) -> Result<Option<String>> {
|
|||
}
|
||||
|
||||
/// First-spawn pre-create provisioning — the job queue's `Provision`
|
||||
/// node. Fail fast on a port collision, set up the applied
|
||||
/// repo + state subvolume + claude/notes dirs, then register the new
|
||||
/// node. Fail fast on a port collision, set up the state
|
||||
/// subvolume + claude/notes dirs, then register the new
|
||||
/// agent in the host-side files that follow the agent set
|
||||
/// ([`crate::agent_set::refresh`]). Does NOT
|
||||
/// create the container — that's `create_only` / the `Create` node.
|
||||
|
|
@ -218,12 +208,9 @@ pub async fn provision_container(name: &str, paths: &AgentPaths) -> Result<()> {
|
|||
agent_web_port(name)
|
||||
);
|
||||
}
|
||||
// Read before anything is seeded: an archetype agent gets no config
|
||||
// repo, and the build takes it from the archetype.
|
||||
// Read before the build: an archetype agent gets no config repo, and
|
||||
// the build takes it from the archetype.
|
||||
crate::archetypes::refresh(name).await?;
|
||||
if crate::archetypes::of(name)?.is_none() {
|
||||
setup_applied(&paths.applied, name).await?;
|
||||
}
|
||||
ensure_agent_state_subvolume(name).await?;
|
||||
ensure_claude_dir(&paths.claude)?;
|
||||
ensure_state_dir(&paths.notes)?;
|
||||
|
|
@ -239,19 +226,7 @@ pub async fn create_only(name: &str, toplevel: &str) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Rebuild-path preamble, run by the job queue's `Prebuild` node: fail fast on
|
||||
/// a port collision, then make sure the applied repo + state dirs exist.
|
||||
/// Container untouched.
|
||||
///
|
||||
/// `applied` is normally already the right shape here (this runs against a
|
||||
/// previously-provisioned agent), but a `destroy --purge` removes it
|
||||
/// (`job_queue::exec::run_purge_state`) — a later revive of the *same*
|
||||
/// agent name is still a rebuild, not a first-spawn, so it lands here, not
|
||||
/// in `provision_container`. Recover from `agent-configs/<name>` on the
|
||||
/// forge when that's the case (forge `main` is the last operator-merged
|
||||
/// config — see `forge::fetch_config_main_into_applied`'s own doc comment)
|
||||
/// rather than bailing outright. Deliberately **no template fallback**: a
|
||||
/// template would silently revive the *wrong* config rather than recovering
|
||||
/// the right one, which is worse than the clear bail this replaces.
|
||||
/// a port collision, then make sure the state dirs exist. Container untouched.
|
||||
pub async fn prepare_rebuild_dirs(name: &str, paths: &AgentPaths) -> Result<()> {
|
||||
validate(name)?;
|
||||
if let Some(other) = port_collision(name).await? {
|
||||
|
|
@ -260,20 +235,6 @@ pub async fn prepare_rebuild_dirs(name: &str, paths: &AgentPaths) -> Result<()>
|
|||
agent_web_port(name)
|
||||
);
|
||||
}
|
||||
// An archetype agent has no applied repo to check or recover.
|
||||
if crate::archetypes::of(name)?.is_none() {
|
||||
if !paths.applied.join(".git").exists()
|
||||
&& !crate::forge::fetch_config_main_into_applied(name).await
|
||||
{
|
||||
bail!(
|
||||
"applied repo at {} is missing its .git directory and could not be reseeded from \
|
||||
the forge (agent-configs/{name} unreachable, has no `main` — never merged or \
|
||||
never seeded — or absent); destroy --purge and re-spawn this agent.",
|
||||
paths.applied.display()
|
||||
);
|
||||
}
|
||||
setup_applied(&paths.applied, name).await?;
|
||||
}
|
||||
ensure_agent_state_subvolume(name).await?;
|
||||
ensure_claude_dir(&paths.claude)?;
|
||||
ensure_state_dir(&paths.notes)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue