rename choom flag --continue to --resume to match the claude flag it maps to (mara review)

This commit is contained in:
damocles 2026-07-02 19:48:54 +02:00 committed by mara
commit 2f43077e31
3 changed files with 36 additions and 35 deletions

View file

@ -112,20 +112,20 @@ enum Cmd {
///
/// Runs claude as the agent user from its state dir with the harness's
/// settings / MCP / system prompt. Bare `choom <name>` is a fresh
/// session; `--continue <session-id>` rejoins a prior one. Never
/// session; `--resume <session-id>` rejoins a prior one. Never
/// collides with the harness's live session. Requires root + a running
/// container. See `docs/tools/hivectl.md` (Choom) for details.
Choom {
/// Agent name (e.g. `damocles`, `iris`).
name: String,
/// Resume a prior claude session by its session id, passed
/// through as `claude --resume <value>` (claude's own
/// `--continue` takes no value — it resumes the cwd's latest
/// session, which is the harness's, so choom never uses it).
/// Omit for a fresh blank session. A value is required when
/// the flag is given.
#[arg(long = "continue", value_name = "SESSION")]
continue_session: Option<String>,
/// through as `claude --resume <value>` (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.
#[arg(long = "resume", value_name = "SESSION")]
resume_session: Option<String>,
},
/// Stop containers hive-wide in one operator action. Bare `hivectl
/// stop` stops **everything** — all sub-agents plus the ci, forge,
@ -634,8 +634,8 @@ async fn main() -> Result<()> {
},
Cmd::Choom {
name,
continue_session,
} => choom(&name, continue_session.as_deref()),
resume_session,
} => choom(&name, resume_session.as_deref()),
Cmd::Quota { cmd } => match cmd {
QuotaCmd::Enable => quota_enable().await,
QuotaCmd::Show { name } => quota_show(name.as_deref()).await,
@ -1034,7 +1034,7 @@ fn agent_exists(name: &str) -> Result<bool> {
/// live harness session). See `docs/tools/hivectl.md` (Choom) for the
/// full rationale. Inherits the caller's PTY; requires root + a running
/// container.
fn choom(name: &str, continue_session: Option<&str>) -> Result<()> {
fn choom(name: &str, resume_session: Option<&str>) -> Result<()> {
if !agent_exists(name)? {
bail!("no such agent: '{name}' (no state dir under /var/lib/hyperhive/agents/)");
}
@ -1047,18 +1047,18 @@ fn choom(name: &str, continue_session: Option<&str>) -> Result<()> {
let state_dir = format!("/agents/{name}/state");
// Per-turn config the harness writes; matches `paths::config_dir()`.
let cfg = "/run/hive-config";
// `--continue <value>` maps to `claude --resume <value>` — claude's
// own `--continue` is a bare flag (no argument): passing a value
// after it made claude resume the cwd's latest session and treat the
// value as the first PROMPT, silently poking the harness session.
// `--resume <session-id>` is the actual rejoin-by-id surface. The
// value is single-quoted into the shell script, so reject an
// embedded single quote (the only char that breaks single-quoting)
// to rule out injection — session ids never contain one.
let session_arg = match continue_session {
// `--resume <value>` passes through as `claude --resume <value>` —
// the rejoin-by-id surface. (claude's `--continue` is a bare flag
// that resumes the cwd's latest session — the harness's — and would
// consume a trailing value as the first PROMPT; choom never uses
// it.) The value is single-quoted into the shell script, so reject
// an embedded single quote (the only char that breaks
// single-quoting) to rule out injection — session ids never
// contain one.
let session_arg = match resume_session {
Some(val) => {
if val.contains('\'') {
bail!("invalid --continue value '{val}': must not contain a single quote");
bail!("invalid --resume value '{val}': must not contain a single quote");
}
format!("set -- --resume '{val}';")
}