docs: rename plan — avoid reserved keyword 'new' (use new_name)
Author:
Chris Tusa <chris.tusa@leafscale.com>
Date:
Jul 15, 2026 14:24
Changeset:
1cca34dfff9a67dcb0cc884f5286418286b662fa
Branch:
default
Changed files:
Diff
diff -r 4d16e936690e -r 1cca34dfff9a docs/superpowers/plans/2026-07-15-repoman-rename.md --- a/docs/superpowers/plans/2026-07-15-repoman-rename.md Wed Jul 15 14:16:21 2026 -0500 +++ b/docs/superpowers/plans/2026-07-15-repoman-rename.md Wed Jul 15 14:24:07 2026 -0500 @@ -38,7 +38,7 @@ **Interfaces:** - Consumes: `config.Registry`, `config.Project`, `config.Defaults`, `config.Host`, `config.with_projects` (existing). -- Produces: `fn rename_project(reg: Registry, old: string, new: string): rg.Result[Registry, string]` — renames the project named `old` to `new`; sets `repo = new` **iff** the old `repo == old` (coupled dirname), else leaves `repo` unchanged; `Err` if `old` absent or `new` already used by a different project. +- Produces: `fn rename_project(reg: Registry, old: string, new_name: string): rg.Result[Registry, string]` — renames the project named `old` to `new_name`; sets `repo = new_name` **iff** the old `repo == old` (coupled dirname), else leaves `repo` unchanged; `Err` if `old` absent or `new_name` already used by a different project. NOTE: `new` is a reserved keyword in Reef (array allocation), so the parameter is `new_name`. - [ ] **Step 1: Write the failing test** @@ -116,7 +116,7 @@ In `src/config.reef`, inside the `export` block, add after the `remove_project` line (~line 44): ```reef - fn rename_project(reg: Registry, old: string, new: string): rg.Result[Registry, string] + fn rename_project(reg: Registry, old: string, new_name: string): rg.Result[Registry, string] ``` - [ ] **Step 4: Implement `rename_project`** @@ -128,7 +128,7 @@ // only when it was coupled to the old name (repo == old); a deliberately // decoupled dirname (e.g. a nested monorepo path) is preserved. Errors if `old` // is absent or `new` is already used by a different project. -fn rename_project(reg: Registry, old: string, new: string): rg.Result[Registry, string] +fn rename_project(reg: Registry, old: string, new_name: string): rg.Result[Registry, string] let n: int = reg.projects.length() mut found: int = -1 mut i: int = 0 @@ -145,8 +145,8 @@ mut j: int = 0 while j < n - if j != found and reg.projects[j].name == new - return @Result[Registry, string].Err("project already exists: " + new) + if j != found and reg.projects[j].name == new_name + return @Result[Registry, string].Err("project already exists: " + new_name) end if j = j + 1 end while @@ -158,10 +158,10 @@ let old_p: Project = reg.projects[k] mut new_repo: string = old_p.repo if old_p.repo == old - new_repo = new + new_repo = new_name end if new_projects[k] = Project { - name: new, repo: new_repo, image: old_p.image, + name: new_name, repo: new_repo, image: old_p.image, profiles: old_p.profiles, created: old_p.created, last_sync: old_p.last_sync, backup: old_p.backup } @@ -200,7 +200,7 @@ - Produces: - `fn stop(project: string, name: string): rg.Result[bool, string]` - `fn start(project: string, name: string): rg.Result[bool, string]` - - `fn rename_container(project: string, old: string, new: string): rg.Result[bool, string]` + - `fn rename_container(project: string, old: string, new_name: string): rg.Result[bool, string]` - `fn device_set(project: string, name: string, dev: string, keyvals: [string]): rg.Result[bool, string]` - [ ] **Step 1: Add the export declarations** @@ -210,7 +210,7 @@ ```reef fn stop(project: string, name: string): rg.Result[bool, string] fn start(project: string, name: string): rg.Result[bool, string] - fn rename_container(project: string, old: string, new: string): rg.Result[bool, string] + fn rename_container(project: string, old: string, new_name: string): rg.Result[bool, string] fn device_set(project: string, name: string, dev: string, keyvals: [string]): rg.Result[bool, string] ``` @@ -227,8 +227,8 @@ return run_incus(["start", "--project", project, name]) end start -fn rename_container(project: string, old: string, new: string): rg.Result[bool, string] - return run_incus(["rename", "--project", project, old, new]) +fn rename_container(project: string, old: string, new_name: string): rg.Result[bool, string] + return run_incus(["rename", "--project", project, old, new_name]) end rename_container // incus config device set <container> <device> <key>=<val> ... @@ -313,15 +313,15 @@ return 2 end if let old: string = positionals[0] - let new: string = positionals[1] + let new_name: string = positionals[1] let do_history: bool = flag.get_bool(parser, "migrate-claude-history") - if old == new + if old == new_name console.printErr("repoman: error: <old> and <new> are the same: " + old) return 2 end if - if not incus.validate_name(new) - console.printErr("repoman: error: invalid new name: " + new) + if not incus.validate_name(new_name) + console.printErr("repoman: error: invalid new name: " + new_name) console.printErr("hint: lowercase alphanumeric + hyphens, <=63 chars, no leading hyphen") return 1 end if @@ -350,7 +350,7 @@ if reg.projects[i].name == old old_idx = i end if - if reg.projects[i].name == new + if reg.projects[i].name == new_name new_idx = i end if i = i + 1 @@ -360,7 +360,7 @@ return 1 end if if old_idx >= 0 and new_idx >= 0 - console.printErr("repoman: error: both '" + old + "' and '" + new + "' exist in the registry; refusing to merge") + console.printErr("repoman: error: both '" + old + "' and '" + new_name + "' exist in the registry; refusing to merge") return 1 end if mut base_idx: int = old_idx @@ -370,21 +370,21 @@ let proj: config.Project = reg.projects[base_idx] // The directory tier applies only when the repo dirname was coupled to the - // name (repo == old, or == new on a resumed run). A decoupled dirname is - // left alone. - let coupled: bool = proj.repo == old or proj.repo == new + // name (repo == old, or == new_name on a resumed run). A decoupled dirname + // is left alone. + let coupled: bool = proj.repo == old or proj.repo == new_name let repos_root: string = paths.expand_home(reg.defaults.repos_root) let old_dir: string = paths.join(repos_root, old) - let new_dir: string = paths.join(repos_root, new) + let new_dir: string = paths.join(repos_root, new_name) let inc_project: string = reg.defaults.incus_project // Confirmation (case-aware). let auto_confirmed: bool = flag.get_bool(parser, "yes") if not auto_confirmed - println("repoman rename " + old + " " + new) + println("repoman rename " + old + " " + new_name) println(" will move:") - println(" - incus container " + old + " -> " + new) - println(" - registry entry " + old + " -> " + new) + println(" - incus container " + old + " -> " + new_name) + println(" - registry entry " + old + " -> " + new_name) if coupled println(" - repo directory " + old_dir + " -> " + new_dir) if do_history @@ -402,7 +402,7 @@ end if end if - let _ol: bool = log.open_log(reg.defaults.logdir, new, "rename") + let _ol: bool = log.open_log(reg.defaults.logdir, new_name, "rename") // Inspect container run-state for both names. mut state_old: string = "MISSING" @@ -411,12 +411,12 @@ state_old = rg.unwrap_ok(so_r) end if mut state_new: string = "MISSING" - let sn_r = incus.container_state(inc_project, new) + let sn_r = incus.container_state(inc_project, new_name) if rg.is_ok(sn_r) state_new = rg.unwrap_ok(sn_r) end if if state_old != "MISSING" and state_new != "MISSING" - log.write("repoman: error: containers '" + old + "' and '" + new + "' both exist; refusing to merge") + log.write("repoman: error: containers '" + old + "' and '" + new_name + "' both exist; refusing to merge") return 1 end if let was_running: bool = state_old == "RUNNING" or state_new == "RUNNING" @@ -430,8 +430,8 @@ return 1 end if elif state_new == "RUNNING" - log.write("==> incus stop " + new) - let r = incus.stop(inc_project, new) + log.write("==> incus stop " + new_name) + let r = incus.stop(inc_project, new_name) if rg.is_err(r) log.write("repoman: error: " + rg.unwrap_err(r)) return 1 @@ -445,7 +445,7 @@ let mv_r = iofile.rename(old_dir, new_dir) if rg.is_err(mv_r) log.write("repoman: error: cannot move repo dir: " + error.error_message(rg.unwrap_err(mv_r))) - log.write("hint: move it manually then re-run 'repoman rename " + old + " " + new + "'") + log.write("hint: move it manually then re-run 'repoman rename " + old + " " + new_name + "'") return 1 end if elif paths.is_dir(new_dir) @@ -458,22 +458,22 @@ // Step: rename the container. if state_old != "MISSING" - log.write("==> incus rename " + old + " -> " + new) - let rn_r = incus.rename_container(inc_project, old, new) + log.write("==> incus rename " + old + " -> " + new_name) + let rn_r = incus.rename_container(inc_project, old, new_name) if rg.is_err(rn_r) log.write("repoman: error: " + rg.unwrap_err(rn_r)) return 1 end if elif state_new != "MISSING" - log.write("==> container already named " + new + " (skipping rename)") + log.write("==> container already named " + new_name + " (skipping rename)") else log.write("==> no incus container for '" + old + "' (skipping rename)") end if // Step: repoint the repo device (coupled only), on the now-new container. if coupled and (state_old != "MISSING" or state_new != "MISSING") - log.write("==> incus config device set " + new + " repo source/path -> " + new_dir) - let ds_r = incus.device_set(inc_project, new, "repo", ["source=" + new_dir, "path=" + new_dir]) + log.write("==> incus config device set " + new_name + " repo source/path -> " + new_dir) + let ds_r = incus.device_set(inc_project, new_name, "repo", ["source=" + new_dir, "path=" + new_dir]) if rg.is_err(ds_r) log.write("repoman: error: " + rg.unwrap_err(ds_r)) return 1 @@ -482,7 +482,7 @@ // Step: registry (skip if already renamed on a resumed run). if old_idx >= 0 - let reg2_r = config.rename_project(reg, old, new) + let reg2_r = config.rename_project(reg, old, new_name) if rg.is_err(reg2_r) log.write("repoman: error: " + rg.unwrap_err(reg2_r)) return 1 @@ -513,15 +513,15 @@ // Step: restart if it was running before. if was_running - log.write("==> incus start " + new) - let st_r = incus.start(inc_project, new) + log.write("==> incus start " + new_name) + let st_r = incus.start(inc_project, new_name) if rg.is_err(st_r) log.write("repoman: error: " + rg.unwrap_err(st_r)) return 1 end if end if - log.write("==> renamed '" + old + "' -> '" + new + "'") + log.write("==> renamed '" + old + "' -> '" + new_name + "'") return 0 end cmd_rename ```