From 3dbef583a7c28465d6237941ec8adc350ec02ecb Mon Sep 17 00:00:00 2001 From: damocles Date: Tue, 26 May 2026 19:21:57 +0200 Subject: [PATCH] topology: require --parent/--root explicitly + fix stale form doc (#492 nits) --- hive-c0re/src/dashboard.rs | 8 ++++++-- hive-c0re/src/main.rs | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hive-c0re/src/dashboard.rs b/hive-c0re/src/dashboard.rs index 9124f92d..956f9ae9 100644 --- a/hive-c0re/src/dashboard.rs +++ b/hive-c0re/src/dashboard.rs @@ -852,9 +852,13 @@ struct RequestSpawnForm { /// `POST /api/topology/set-parent` body. `child` is required. /// `new_parent` may be: -/// - omitted entirely (form field absent) → no-op error, -/// - empty string → promote to root, +/// - absent or empty / whitespace-only → promote to root, /// - non-empty → new parent's logical name. +/// +/// (The CLI surface gates "no parent specified" behind an explicit +/// `--root` flag for safety; the HTTP surface is permissive +/// because the dashboard form encodes "no value" as the empty +/// string for the optional radio-group input.) #[derive(Deserialize)] struct SetParentForm { child: String, diff --git a/hive-c0re/src/main.rs b/hive-c0re/src/main.rs index 16f26205..9b00cc91 100644 --- a/hive-c0re/src/main.rs +++ b/hive-c0re/src/main.rs @@ -109,7 +109,11 @@ enum Cmd { SetParent { child: String, /// New parent agent name. Mutually exclusive with `--root`. - #[arg(long, conflicts_with = "root")] + /// Exactly one of `--parent` / `--root` is required — clap + /// rejects both-absent calls so a fat-fingered + /// `hive-c0re set-parent alice` doesn't silently promote + /// alice to root (argus flag on PR #492). + #[arg(long, conflicts_with = "root", required_unless_present = "root")] parent: Option, /// Promote `child` to root (no parent). #[arg(long)]