From 03afbd1316058d234804c41b62f6671db5118649 Mon Sep 17 00:00:00 2001 From: damocles Date: Mon, 27 Jul 2026 19:00:44 +0200 Subject: [PATCH] hivectl: rename hivectl agents to hivectl agent --- docs/agent-hierarchy.md | 2 +- docs/approvals.md | 2 +- docs/persistence.md | 4 +- docs/setup.md | 6 +- docs/tools/hivectl-cli.md | 359 +++++++++++--------------- docs/tools/hivectl.md | 40 +-- docs/turn-loop.md | 2 +- hive-c0re/src/job_queue/submit.rs | 2 +- hive-c0re/src/server.rs | 39 +-- hive-host-sock/src/lib.rs | 51 ++-- hive-priv/src/main.rs | 2 +- hive-sh4re/src/lib.rs | 4 +- hivectl/src/agents.rs | 111 ++++---- hivectl/src/choom.rs | 2 +- hivectl/src/cli.rs | 208 ++++++--------- hivectl/src/main.rs | 30 +-- hivectl/src/quota.rs | 19 +- hivectl/src/subvol.rs | 27 +- nix/agent-modules/claude-settings.nix | 4 +- 19 files changed, 378 insertions(+), 536 deletions(-) diff --git a/docs/agent-hierarchy.md b/docs/agent-hierarchy.md index 426712a2..96f38e0a 100644 --- a/docs/agent-hierarchy.md +++ b/docs/agent-hierarchy.md @@ -26,7 +26,7 @@ above was spawned by `alice`), and the operator can reparent any agent. The bootstrap container (`ruth`) is just another root. Re-parenting is operator-driven: -- CLI: `hivectl agents set-parent --parent ` (or `--root` to +- CLI: `hivectl agent set-parent --parent ` (or `--root` to promote). Exactly one of `--parent` / `--root` is required. - Dashboard: `POST /api/topology/set-parent` (form fields `child`, optional `new_parent` — absent / empty ⇒ promote to root). diff --git a/docs/approvals.md b/docs/approvals.md index 6ae2be1c..527f402b 100644 --- a/docs/approvals.md +++ b/docs/approvals.md @@ -119,7 +119,7 @@ kind-specific payload carrier. - `Spawn` — direct container creation from the agent's config repo. `commit_ref` is empty. Submitted via `HostRequest::RequestSpawn` (operator-gated, the `◆ R3QU3ST SP4WN` dashboard button + - `hivectl agents request-spawn` CLI). The host-level `HostRequest::Spawn` + `hivectl agent request-spawn` CLI). The host-level `HostRequest::Spawn` variant bypasses the approval queue entirely — privileged-context use only (operator on the host shell, test scripts, one-off recoveries). This is the **canonical first-spawn**: a new agent's `InitConfig` diff --git a/docs/persistence.md b/docs/persistence.md index 042fd35a..7c4ff619 100644 --- a/docs/persistence.md +++ b/docs/persistence.md @@ -212,7 +212,7 @@ bind-mount, and that's the whole design: the harness stats it in-container via `hive_sh4re::paths::paused_marker`, while hive-c0re stats it on the host (`Coordinator::is_paused`) to populate the `paused` field on the agent card, and creates/removes it -(`Coordinator::set_paused`) for `hivectl agents pause|resume` and the +(`Coordinator::set_paused`) for `hivectl agent pause|resume` and the dashboard toggle. Because the file itself is the only shared state there's no protocol between them, no round-trip into the container, and pause keeps working when the harness is wedged or the container is @@ -339,7 +339,7 @@ step would re-fire). `R3V1V3` queues a Spawn approval that reuses the kept state on approve (no re-login). - `PURG3` (opt-in via the dashboard button or - `hivectl agents destroy --purge `) — DESTR0Y plus wipes + `hivectl agent destroy --purge`) — DESTR0Y plus wipes `/var/lib/hyperhive/{agents,applied}//`. Config history, claude creds, /state/ notes, and the harness dir are all gone. No undo. diff --git a/docs/setup.md b/docs/setup.md index 349f8a01..a49ebb12 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -79,13 +79,13 @@ See [`approvals.md`](approvals.md) for the full flow. ```bash # Roster: all agents, status, rev, parent, pending reminders -hivectl agents list +hivectl list-agents # Restart a stuck container (no rebuild) -hivectl agents restart +hivectl agent restart # Open a Claude session inside an agent's container -hivectl choom +hivectl agent choom # Open hive web surfaces in a browser (or just print the URLs) hivectl open # operator dashboard diff --git a/docs/tools/hivectl-cli.md b/docs/tools/hivectl-cli.md index 37af3331..7c0d8d31 100644 --- a/docs/tools/hivectl-cli.md +++ b/docs/tools/hivectl-cli.md @@ -20,29 +20,29 @@ This document contains the help content for the `hivectl` command-line program. * [`hivectl gateway create-user`↴](#hivectl-gateway-create-user) * [`hivectl gateway delete-user`↴](#hivectl-gateway-delete-user) * [`hivectl gateway list-users`↴](#hivectl-gateway-list-users) -* [`hivectl agents`↴](#hivectl-agents) -* [`hivectl agents list`↴](#hivectl-agents-list) -* [`hivectl agents restart`↴](#hivectl-agents-restart) -* [`hivectl agents restart-all`↴](#hivectl-agents-restart-all) -* [`hivectl agents pause`↴](#hivectl-agents-pause) -* [`hivectl agents resume`↴](#hivectl-agents-resume) -* [`hivectl agents spawn`↴](#hivectl-agents-spawn) -* [`hivectl agents request-spawn`↴](#hivectl-agents-request-spawn) -* [`hivectl agents kill`↴](#hivectl-agents-kill) -* [`hivectl agents destroy`↴](#hivectl-agents-destroy) -* [`hivectl agents rebuild`↴](#hivectl-agents-rebuild) -* [`hivectl agents set-parent`↴](#hivectl-agents-set-parent) -* [`hivectl agents set-limits`↴](#hivectl-agents-set-limits) -* [`hivectl agents quota`↴](#hivectl-agents-quota) -* [`hivectl agents quota enable`↴](#hivectl-agents-quota-enable) -* [`hivectl agents quota show`↴](#hivectl-agents-quota-show) -* [`hivectl agents quota set`↴](#hivectl-agents-quota-set) -* [`hivectl agents subvol`↴](#hivectl-agents-subvol) -* [`hivectl agents subvol upgrade`↴](#hivectl-agents-subvol-upgrade) -* [`hivectl agents subvol snapshot`↴](#hivectl-agents-subvol-snapshot) -* [`hivectl agents subvol snapshot create`↴](#hivectl-agents-subvol-snapshot-create) -* [`hivectl agents subvol snapshot delete`↴](#hivectl-agents-subvol-snapshot-delete) -* [`hivectl agents subvol snapshot send`↴](#hivectl-agents-subvol-snapshot-send) +* [`hivectl agent`↴](#hivectl-agent) +* [`hivectl agent restart`↴](#hivectl-agent-restart) +* [`hivectl agent pause`↴](#hivectl-agent-pause) +* [`hivectl agent resume`↴](#hivectl-agent-resume) +* [`hivectl agent spawn`↴](#hivectl-agent-spawn) +* [`hivectl agent request-spawn`↴](#hivectl-agent-request-spawn) +* [`hivectl agent kill`↴](#hivectl-agent-kill) +* [`hivectl agent destroy`↴](#hivectl-agent-destroy) +* [`hivectl agent rebuild`↴](#hivectl-agent-rebuild) +* [`hivectl agent set-parent`↴](#hivectl-agent-set-parent) +* [`hivectl agent set-limits`↴](#hivectl-agent-set-limits) +* [`hivectl agent choom`↴](#hivectl-agent-choom) +* [`hivectl agent quota`↴](#hivectl-agent-quota) +* [`hivectl agent quota show`↴](#hivectl-agent-quota-show) +* [`hivectl agent quota set`↴](#hivectl-agent-quota-set) +* [`hivectl agent subvol`↴](#hivectl-agent-subvol) +* [`hivectl agent subvol upgrade`↴](#hivectl-agent-subvol-upgrade) +* [`hivectl agent subvol snapshot`↴](#hivectl-agent-subvol-snapshot) +* [`hivectl agent subvol snapshot create`↴](#hivectl-agent-subvol-snapshot-create) +* [`hivectl agent subvol snapshot delete`↴](#hivectl-agent-subvol-snapshot-delete) +* [`hivectl agent subvol snapshot send`↴](#hivectl-agent-subvol-snapshot-send) +* [`hivectl list-agents`↴](#hivectl-list-agents) +* [`hivectl quota-enable`↴](#hivectl-quota-enable) * [`hivectl approvals`↴](#hivectl-approvals) * [`hivectl approvals pending`↴](#hivectl-approvals-pending) * [`hivectl approvals approve`↴](#hivectl-approvals-approve) @@ -52,7 +52,6 @@ This document contains the help content for the `hivectl` command-line program. * [`hivectl wg peer`↴](#hivectl-wg-peer) * [`hivectl wg status`↴](#hivectl-wg-status) * [`hivectl peer-config`↴](#hivectl-peer-config) -* [`hivectl choom`↴](#hivectl-choom) * [`hivectl stop`↴](#hivectl-stop) * [`hivectl start`↴](#hivectl-start) * [`hivectl restart`↴](#hivectl-restart) @@ -71,11 +70,12 @@ Sibling to the `hive-c0re` daemon binary. Covers host-side admin operations that * `matrix` — matrix-tuwunel user provisioning * `github` — GitHub account provisioning * `gateway` — Gateway htpasswd user management -* `agents` — Agent container management +* `agent` — Lifecycle actions on ONE managed agent container. Needs the hive-c0re daemon running +* `list-agents` — Show all managed agents with their status and technical state +* `quota-enable` — Enable btrfs qgroup accounting on the agent-state filesystem * `approvals` — Operator approval queue: list, approve, or deny pending requests * `wg` — WireGuard inter-hive mesh setup helpers * `peer-config` — Generate the federation peer-config block for THIS hive -* `choom` — Open an interactive Claude session inside an agent container * `stop` — Stop containers hive-wide in one operator action * `start` — Start containers hive-wide — the inverse of `hivectl stop` * `restart` — Restart containers hive-wide — `stop` then `start` over one scope @@ -84,7 +84,7 @@ Sibling to the `hive-c0re` daemon binary. Covers host-side admin operations that ###### **Options:** -* `--socket ` — Path to the hive-c0re host admin socket, used by the daemon-assisted verbs (`agents`, `stop`, `start`). Global: accepted before or after the subcommand. Verbs that don't talk to the daemon ignore it +* `--socket ` — Path to the hive-c0re host admin socket, used by the daemon-assisted verbs (`agent`, `list-agents`, `stop`, `start`). Global: accepted before or after the subcommand. Verbs that don't talk to the daemon ignore it Default value: `/run/hyperhive/host.sock` @@ -327,54 +327,41 @@ List all gateway htpasswd usernames, one per line -## `hivectl agents` +## `hivectl agent` -Agent container management. +Lifecycle actions on ONE managed agent container. Needs the hive-c0re daemon running. -Lifecycle actions on managed agent containers. Needs the hive-c0re daemon running. +Everything here targets a single named agent (`hivectl agent foo restart`, `hivectl agent foo choom`, …) — anything that acts hive-wide lives at the top level instead (`list-agents`, `restart`/`stop`/`start` with a scope, `quota-enable`). -**Usage:** `hivectl agents ` +**Usage:** `hivectl agent ` ###### **Subcommands:** -* `list` — Show all managed agents with their status and technical state -* `restart` — Stop and start a single agent container without rebuilding config -* `restart-all` — Restart all managed agent containers -* `pause` — Park an agent's turn loop, leaving the container running -* `resume` — Resume a paused agent — it drains whatever queued up while parked -* `spawn` — Spawn a new agent container directly, bypassing the approval queue +* `restart` — Stop and start this agent container without rebuilding config +* `pause` — Park this agent's turn loop, leaving the container running +* `resume` — Resume this paused agent — it drains whatever queued up while parked +* `spawn` — Spawn this agent container directly, bypassing the approval queue * `request-spawn` — Queue a spawn request for operator approval -* `kill` — Stop a managed container (graceful) -* `destroy` — Tear down a sub-agent container, keeping its state by default. No undo -* `rebuild` — Apply pending config to a managed container -* `set-parent` — Move an agent in the topology tree — under a new parent, or to root -* `set-limits` — Declare an agent's CPU/memory limits, overriding the hive-wide defaults -* `quota` — Per-agent disk accounting + optional quotas via btrfs qgroups -* `subvol` — btrfs subvolume management for agent state dirs - - - -## `hivectl agents list` - -Show all managed agents with their status and technical state - -**Usage:** `hivectl agents list [OPTIONS]` - -###### **Options:** - -* `--json` — Emit the raw JSON rows instead of the padded table (for scripting). The table is the default human-readable shape - - - -## `hivectl agents restart` - -Stop and start a single agent container without rebuilding config - -**Usage:** `hivectl agents restart [OPTIONS] ` +* `kill` — Stop this managed container (graceful) +* `destroy` — Tear down this sub-agent container, keeping its state by default. No undo +* `rebuild` — Apply pending config to this managed container +* `set-parent` — Move this agent in the topology tree — under a new parent, or to root +* `set-limits` — Declare this agent's CPU/memory limits, overriding the hive-wide defaults +* `choom` — Open an interactive Claude session inside this agent's container +* `quota` — This agent's disk accounting + optional quota via btrfs qgroups +* `subvol` — btrfs subvolume management for this agent's state dir ###### **Arguments:** -* `` — Agent name (e.g. `damocles`, `ruth`) +* `` — Agent name (e.g. `damocles`, `iris`) + + + +## `hivectl agent restart` + +Stop and start this agent container without rebuilding config + +**Usage:** `hivectl agent restart [OPTIONS]` ###### **Options:** @@ -382,91 +369,55 @@ Stop and start a single agent container without rebuilding config -## `hivectl agents restart-all` +## `hivectl agent pause` -Restart all managed agent containers - -**Usage:** `hivectl agents restart-all [OPTIONS]` - -###### **Options:** - -* `--no-wait` — Return immediately after the restart DAGs are queued - - - -## `hivectl agents pause` - -Park an agent's turn loop, leaving the container running. +Park this agent's turn loop, leaving the container running. The harness stops driving turns but keeps serving its web UI and MCP daemons, so the container, its mounts and its warm caches stay up while it burns no tokens. Inbox messages queue unacked and the backlog drains on `resume`. Sticky: it survives a restart, and pausing a stopped agent makes it come up paused. -**Usage:** `hivectl agents pause ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent pause` -## `hivectl agents resume` +## `hivectl agent resume` -Resume a paused agent — it drains whatever queued up while parked +Resume this paused agent — it drains whatever queued up while parked -**Usage:** `hivectl agents resume ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent resume` -## `hivectl agents spawn` +## `hivectl agent spawn` -Spawn a new agent container directly, bypassing the approval queue. +Spawn this agent container directly, bypassing the approval queue. Operator-on-the-host only; use `request-spawn` for an approval-gated spawn. -**Usage:** `hivectl agents spawn ` - -###### **Arguments:** - -* `` — Agent name (e.g. `iris`) +**Usage:** `hivectl agent spawn` -## `hivectl agents request-spawn` +## `hivectl agent request-spawn` Queue a spawn request for operator approval -**Usage:** `hivectl agents request-spawn ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent request-spawn` -## `hivectl agents kill` +## `hivectl agent kill` -Stop a managed container (graceful) +Stop this managed container (graceful) -**Usage:** `hivectl agents kill ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent kill` -## `hivectl agents destroy` +## `hivectl agent destroy` -Tear down a sub-agent container, keeping its state by default. No undo +Tear down this sub-agent container, keeping its state by default. No undo -**Usage:** `hivectl agents destroy [OPTIONS] ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent destroy [OPTIONS]` ###### **Options:** @@ -474,46 +425,34 @@ Tear down a sub-agent container, keeping its state by default. No undo -## `hivectl agents rebuild` +## `hivectl agent rebuild` -Apply pending config to a managed container +Apply pending config to this managed container -**Usage:** `hivectl agents rebuild ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent rebuild` -## `hivectl agents set-parent` +## `hivectl agent set-parent` -Move an agent in the topology tree — under a new parent, or to root +Move this agent in the topology tree — under a new parent, or to root -**Usage:** `hivectl agents set-parent [OPTIONS] ` - -###### **Arguments:** - -* `` — Agent to move +**Usage:** `hivectl agent set-parent [OPTIONS]` ###### **Options:** * `--parent ` — New parent agent name. Mutually exclusive with `--root` -* `--root` — Promote `child` to root (no parent) +* `--root` — Promote this agent to root (no parent) -## `hivectl agents set-limits` +## `hivectl agent set-limits` -Declare an agent's CPU/memory limits, overriding the hive-wide defaults. +Declare this agent's CPU/memory limits, overriding the hive-wide defaults. -Replaces the agent's whole override entry rather than merging into it: any limit you don't pass returns to the hive-wide default. To change one and keep the other, pass both. Disk is a separate resource with its own group — see `agents quota`. +Replaces the agent's whole override entry rather than merging into it: any limit you don't pass returns to the hive-wide default. To change one and keep the other, pass both. Disk is a separate resource with its own group — see `quota`. -**Usage:** `hivectl agents set-limits [OPTIONS] ` - -###### **Arguments:** - -* `` — Agent name +**Usage:** `hivectl agent set-limits [OPTIONS]` ###### **Options:** @@ -523,85 +462,77 @@ Replaces the agent's whole override entry rather than merging into it: any limit -## `hivectl agents quota` +## `hivectl agent choom` -Per-agent disk accounting + optional quotas via btrfs qgroups. +Open an interactive Claude session inside this agent's container. -Opt-in: enable qgroup accounting, then report per-agent usage or cap an agent. No-op on non-btrfs hosts. +A fresh session by default, or resume a prior one. Requires root and a running container. -**Usage:** `hivectl agents quota ` +**Usage:** `hivectl agent choom [OPTIONS]` + +###### **Options:** + +* `--resume ` — Resume a prior claude session by its session id, passed through as `claude --resume ` (claude's `--continue` takes no value — it resumes the cwd's latest session, which is the harness's, so choom never uses it; this flag matches the claude flag it maps to). Omit for a fresh blank session. A value is required when the flag is given + + + +## `hivectl agent quota` + +This agent's disk accounting + optional quota via btrfs qgroups. + +Needs `hivectl quota-enable` run once hive-wide first. No-op on non-btrfs hosts. + +**Usage:** `hivectl agent quota ` ###### **Subcommands:** -* `enable` — Enable btrfs qgroup accounting on the agent-state filesystem -* `show` — Report per-agent disk usage from btrfs qgroups (all agents, or one by name) -* `set` — Set or clear an agent's disk-usage quota +* `show` — Report this agent's disk usage from btrfs qgroups +* `set` — Set or clear this agent's disk-usage quota -## `hivectl agents quota enable` +## `hivectl agent quota show` -Enable btrfs qgroup accounting on the agent-state filesystem. +Report this agent's disk usage from btrfs qgroups -Run once before `show` / `limit`. No-op on non-btrfs hosts. - -**Usage:** `hivectl agents quota enable` +**Usage:** `hivectl agent quota show` -## `hivectl agents quota show` +## `hivectl agent quota set` -Report per-agent disk usage from btrfs qgroups (all agents, or one by name) +Set or clear this agent's disk-usage quota -**Usage:** `hivectl agents quota show [NAME]` +**Usage:** `hivectl agent quota set ` ###### **Arguments:** -* `` — Agent to show (omit for all agents with a state subvolume) - - - -## `hivectl agents quota set` - -Set or clear an agent's disk-usage quota. - -Named `set` rather than `set-quota` because the enclosing `quota` group already carries the noun — `agents quota set iris 5G`. The `set-` spelling stays for the flat verbs (`set-parent`, `set-limits`), which have no group to inherit it from. - -**Usage:** `hivectl agents quota set ` - -###### **Arguments:** - -* `` — Agent whose state subvolume to limit * `` — Size cap (`5G`, `500M`, `1073741824`) or `none` to clear -## `hivectl agents subvol` +## `hivectl agent subvol` -btrfs subvolume management for agent state dirs. +btrfs subvolume management for this agent's state dir. Upgrade an existing plain-dir agent's state into a btrfs subvolume so it gains snapshots and per-subvol usage/quota. -**Usage:** `hivectl agents subvol ` +**Usage:** `hivectl agent subvol ` ###### **Subcommands:** * `upgrade` — Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota -* `snapshot` — Read-only snapshots of an agent's state subvolume +* `snapshot` — Read-only snapshots of this agent's state subvolume -## `hivectl agents subvol upgrade` +## `hivectl agent subvol upgrade` Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota. Bounces the agent to migrate its state, so it requires `--yes`. -**Usage:** `hivectl agents subvol upgrade [OPTIONS] ` - -###### **Arguments:** - -* `` — Agent name (e.g. `damocles`, `iris`) +**Usage:** `hivectl agent subvol upgrade [OPTIONS]` ###### **Options:** @@ -609,11 +540,11 @@ Bounces the agent to migrate its state, so it requires `--yes`. -## `hivectl agents subvol snapshot` +## `hivectl agent subvol snapshot` -Read-only snapshots of an agent's state subvolume +Read-only snapshots of this agent's state subvolume -**Usage:** `hivectl agents subvol snapshot ` +**Usage:** `hivectl agent subvol snapshot ` ###### **Subcommands:** @@ -623,15 +554,11 @@ Read-only snapshots of an agent's state subvolume -## `hivectl agents subvol snapshot create` +## `hivectl agent subvol snapshot create` Create a read-only snapshot (agent must already be a subvolume) -**Usage:** `hivectl agents subvol snapshot create --label