two-step agent spawn: request_init_config + request_spawn

This commit is contained in:
damocles 2026-05-20 14:32:54 +02:00 committed by Mara
parent 42437f9c6a
commit 80dd5bb69e
7 changed files with 165 additions and 14 deletions

View file

@ -99,6 +99,12 @@ pub enum ApprovalKind {
ApplyCommit,
/// Create + start a new sub-agent container with the given name.
Spawn,
/// Initialise a new agent's proposed config repo so the manager can
/// customise it before submitting a `RequestSpawn`. On approval
/// hive-c0re seeds `proposed/<name>/` with the default `agent.nix`
/// template but does NOT create the container - that requires a
/// subsequent `RequestSpawn` approval.
InitConfig,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
@ -577,6 +583,10 @@ pub enum HelperEvent {
#[serde(default, skip_serializing_if = "Option::is_none")]
tag: Option<String>,
},
/// A new agent's proposed config repo was initialised (post-`InitConfig`
/// approval). The manager can now edit `/agents/<agent>/config/agent.nix`,
/// commit the changes, and submit a `RequestSpawn` to create the container.
ConfigReady { agent: String },
/// A sub-agent's container was stopped (the systemd unit is down;
/// persistent state is unchanged).
Killed { agent: String },
@ -672,9 +682,23 @@ pub enum ManagerRequest {
Recent {
limit: u64,
},
/// Initialise a brand-new agent's proposed config repo and queue an
/// approval for the operator to review. On approval hive-c0re seeds
/// `/agents/<name>/config/` with the default `agent.nix` template,
/// giving the manager RW access so it can customise the config and
/// commit changes before calling `request_spawn`. Fails if a proposed
/// repo for this name already exists (use `request_apply_commit` to
/// update an existing agent's config). Must precede `request_spawn`.
RequestInitConfig {
name: String,
/// Optional description shown on the dashboard approval card.
#[serde(default, skip_serializing_if = "Option::is_none")]
description: Option<String>,
},
/// Submit a spawn request for the user to approve. On approval the host
/// creates and starts the container. Brand-new agent names only — if an
/// agent of the same name already exists, the approval will fail.
/// creates and starts the container. Requires a prior approved
/// `request_init_config` so the manager can customise `agent.nix` first.
/// Fails if the proposed config repo for this name does not exist yet.
RequestSpawn {
name: String,
/// Optional description shown on the dashboard approval card.