refactor(hive-c0re): drop the request_init_config tool and InitConfig approval
swarm-controller's `InitAgentConfigRepo` node already covers config-repo creation, so this deletes a duplicate rather than a capability; old `init_config` rows are skipped by `collect_lenient` with no migration, by operator decision. Refs #4398
This commit is contained in:
parent
3f086bc659
commit
a3b672d1d5
31 changed files with 134 additions and 601 deletions
|
|
@ -97,20 +97,6 @@ pub struct CompactArgs {
|
|||
// Privileged tool arg types (lifecycle, approvals, scheduling, diagnostics)
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
|
||||
pub struct RequestInitConfigArgs {
|
||||
/// New sub-agent name (≤9 chars). Queues an `InitConfig` approval; on
|
||||
/// approval hive-c0re creates the child's config repo and seeds it with a
|
||||
/// default `agent.nix`. Approving the follow-up `Spawn` creates the
|
||||
/// container. Config changes — including the child's first — are PRs on
|
||||
/// that repo, made from a clone, reviewed + approved by the operator;
|
||||
/// `/agents/<name>/config` is a read-only copy, not an editing surface.
|
||||
pub name: String,
|
||||
/// Optional description shown on the dashboard approval card.
|
||||
#[serde(default)]
|
||||
pub description: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
|
||||
pub struct KillArgs {
|
||||
/// Sub-agent name (without the `h-` container prefix).
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@ mod render;
|
|||
pub use args::{
|
||||
AckUntilArgs, AgentGetLooseEndsArgs, CancelLooseEndArgs, CancelScheduleArgs, CompactArgs,
|
||||
CreateRepoArgs, EditScheduleArgs, FireScheduleNowArgs, GetAgentMetaArgs, GetHostJournalArgs,
|
||||
GetLogsArgs, KillArgs, MarkTodosDoneArgs, RecvArgs, RemindArgs, RequestInitConfigArgs,
|
||||
RequestSchedulePromptArgs, RestartArgs, SendArgs, SetStatusArgs, StartArgs, UpdateArgs,
|
||||
UpdateMetaInputsArgs,
|
||||
GetLogsArgs, KillArgs, MarkTodosDoneArgs, RecvArgs, RemindArgs, RequestSchedulePromptArgs,
|
||||
RestartArgs, SendArgs, SetStatusArgs, StartArgs, UpdateArgs, UpdateMetaInputsArgs,
|
||||
};
|
||||
pub use render::{annotate_retries, format_ack, format_agent_meta, format_recv};
|
||||
|
||||
|
|
@ -710,47 +709,6 @@ impl AgentServer {
|
|||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `approvals` tool group
|
||||
// is configured for the agent (`HIVE_TOOL_GROUPS` contains `approvals`).
|
||||
// hive-c0re performs a topology check server-side: an unused `name` is
|
||||
// accepted from any caller (the requester becomes its parent); an existing
|
||||
// agent is accepted only from inside the caller's subtree.
|
||||
#[tool(description = "Create a new agent's config repo and queue an \
|
||||
`InitConfig` approval for the operator to review. Requires the `approvals` tool \
|
||||
group. `name` must be either unused — in which case you become its parent — or an \
|
||||
agent already in your subtree, whose config you are re-seeding. Fails if a \
|
||||
config repo for that agent already exists. This tool **creates the repo** and \
|
||||
nothing else: on approval hive-c0re seeds it with a default `agent.nix`, and \
|
||||
approving the follow-up `Spawn` creates the container. \
|
||||
Every config change — the child's first one included — goes through a PR on its \
|
||||
config repo, made from a clone you take yourself, reviewed + approved by the \
|
||||
operator. `/agents/<name>/config` is a **read-only copy** for reading a config, \
|
||||
never an editing surface.")]
|
||||
async fn request_init_config(
|
||||
&self,
|
||||
Parameters(args): Parameters<RequestInitConfigArgs>,
|
||||
) -> String {
|
||||
let log = format!("{args:?}");
|
||||
let name = args.name.clone();
|
||||
run_tool_envelope("request_init_config", log, async move {
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_core_agent_sock::Request::RequestInitConfig {
|
||||
name: args.name,
|
||||
description: args.description,
|
||||
})
|
||||
.await;
|
||||
annotate_retries(
|
||||
format_ack(
|
||||
resp,
|
||||
"request_init_config",
|
||||
format!("init_config approval queued for {name}"),
|
||||
),
|
||||
retries,
|
||||
)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `lifecycle` tool group
|
||||
// is granted to this agent. hive-c0re enforces the topology check
|
||||
// server-side: the call is rejected unless `name` is in the caller's
|
||||
|
|
|
|||
|
|
@ -643,12 +643,12 @@ mod tests {
|
|||
Ok(hive_core_agent_sock::Response::OkWarn {
|
||||
warnings: vec!["name is reserved".to_owned(), "second thing".to_owned()],
|
||||
}),
|
||||
"request_init_config",
|
||||
"init_config approval queued for forge".to_owned(),
|
||||
"request_update_meta_inputs",
|
||||
"update_meta_inputs approval queued".to_owned(),
|
||||
);
|
||||
// The operation HAPPENED — dropping the success line would read as a
|
||||
// failure and invite a retry that queues a second approval.
|
||||
assert!(out.starts_with("init_config approval queued for forge"));
|
||||
assert!(out.starts_with("update_meta_inputs approval queued"));
|
||||
assert!(out.contains("⚠️ name is reserved"));
|
||||
assert!(out.contains("⚠️ second thing"));
|
||||
}
|
||||
|
|
@ -659,7 +659,7 @@ mod tests {
|
|||
// warning marker would pass the test above.
|
||||
let out = format_ack(
|
||||
Ok(hive_core_agent_sock::Response::Ok),
|
||||
"request_init_config",
|
||||
"request_update_meta_inputs",
|
||||
"queued".to_owned(),
|
||||
);
|
||||
assert_eq!(out, "queued");
|
||||
|
|
|
|||
Loading…
Reference in a new issue