cli: rename — abort on container-state probe failure; warn on both-slug-dirs
Author:
Chris Tusa <chris.tusa@leafscale.com>
Date:
Jul 15, 2026 16:14
Changeset:
ddc5aec03c4cba9f960924f5908c0d908934c972
Branch:
default
Changed files:
Diff
diff -r bea3fb9b867f -r ddc5aec03c4c src/cli.reef --- a/src/cli.reef Wed Jul 15 16:07:25 2026 -0500 +++ b/src/cli.reef Wed Jul 15 16:14:46 2026 -0500 @@ -1084,17 +1084,23 @@ let _ol: bool = log.open_log(reg.defaults.logdir, new_name, "rename") - // Inspect container run-state for both names. - mut state_old: string = "MISSING" + // Inspect container run-state for both names. A probe FAILURE (incus + // unreachable) must abort before any mutation — otherwise we'd move the + // repo dir + registry while skipping the container rename, silently + // creating exactly the drift this command exists to fix. A confirmed-empty + // result (Ok "MISSING") is genuine absence and is handled normally. let so_r = incus.container_state(inc_project, old) - if rg.is_ok(so_r) - state_old = rg.unwrap_ok(so_r) + if rg.is_err(so_r) + log.write("repoman: error: cannot query container state for '" + old + "': " + rg.unwrap_err(so_r)) + return 1 end if - mut state_new: string = "MISSING" + let state_old: string = rg.unwrap_ok(so_r) let sn_r = incus.container_state(inc_project, new_name) - if rg.is_ok(sn_r) - state_new = rg.unwrap_ok(sn_r) + if rg.is_err(sn_r) + log.write("repoman: error: cannot query container state for '" + new_name + "': " + rg.unwrap_err(sn_r)) + return 1 end if + let state_new: string = rg.unwrap_ok(sn_r) if state_old != "MISSING" and state_new != "MISSING" log.write("repoman: error: containers '" + old + "' and '" + new_name + "' both exist; refusing to merge") return 1 @@ -1181,7 +1187,9 @@ if coupled and do_history let old_slug: string = claude_slug_dir(home, old_dir) let new_slug: string = claude_slug_dir(home, new_dir) - if paths.is_dir(old_slug) and not paths.is_dir(new_slug) + if paths.is_dir(old_slug) and paths.is_dir(new_slug) + log.write("repoman: warning: both claude history dirs exist; leaving " + old_slug + " in place") + elif paths.is_dir(old_slug) log.write("==> mv claude history " + old_slug + " -> " + new_slug) let hs_r = iofile.rename(old_slug, new_slug) if rg.is_err(hs_r)