retirer: retire a stack in one command #10

Merged
thodkatz merged 4 commits from change/retire-tool into main 2026-11-05 12:25:58 +00:00
Owner

Closes #9.

Status: review round done, every finding addressed (comment below); merging. Handoff:
docs/handoffs/2026-11-05T1223Z-retirer-done.md. Nothing to deploy: the tool runs in a checkout.

Plan

The user, 2026-11-05: "check the raised issue as well we can do it like that a simple tool". Retiring a stack used to
take four manual steps: stop it, git rm it, find a commit that still has it, and write the RETIRED.md row. One
command now does them and asks only what it can't infer. The user also asked, through the move-scripts session, for
the name retirer, a command run as retirer <stack> with no .sh.

./retirer <stack> (or <machine>/<stack> when both machines have one) sits at the repo root. The repo-layout
spec's D1 allows only backup/ docs/ nixos/ vps/ as directories, so it is a root file.

  • What it infers: the machine, the path, and a commit on main that still has the stack: the merge-base with
    origin/main, because a branch's own commits are gone after the squash merge.
  • What it asks: what it was for and why it was dropped. An agent has no terminal, so it passes them as
    --for / --why.
  • What it changes: it git rm -rs the directory and puts the row first in RETIRED.md's table, both staged. It
    doesn't commit, so the Caddy block, the DNS record and the doc mentions it lists (with git grep) go in the same
    commit.
  • Refusals: it won't run on a dirty stack or a dirty RETIRED.md, a machine's caddy, a stack not on
    origin/main, a path that already has a row, or a stack name both machines use.
  • State on disk: it never deletes untracked state (.env, data/, …) or a volume. It lists what stays.
  • Stopping the stack: only with --down, which runs compose down without -v: podman under nixos/,
    docker under vps/, or the stack's own compose.sh or bin/docker-compose when it has one. --down is
    refused in the agent microVM (agentvm-*), because agents don't deploy.
  • What it prints for the user, on the machine:
    1. Stop the stack before pulling, since the pull deletes the compose file.
    2. Pull, then hot-reload that machine's caddy.
    3. Redeploy headscale if a DNS record went.
    4. Clear the leftovers by hand.

Rules this PR rewrites (instructions): in AGENTS.md, Project in brief, "a stack that stops running is deleted and
gets a row in RETIRED.md" now adds "both by ./retirer <stack>". The rule stays where it is and nothing is
removed. RETIRED.md's intro gains the same pointer.

Check (run): a throwaway clone covers each of these:

  • ./retirer --for … --why … wallos stages the deletion, and RETIRED.md's first row is wallos with
    origin/main's commit and vps/wallos/; git cat-file -e <commit>:vps/wallos exits 0.
  • Its Caddy and DNS lines are listed, and so are the untracked .env and data/.
  • nixos/spliit prints the podman commands.
  • overleaf-toolkit works and prints the project caveat.
  • x\ny and a | b stay in their cells.
  • These are refused: --down on agentvm-repos, a dirty stack, a dirty RETIRED.md, a bad path, caddy, a row
    that already exists, a branch-only stack, a name both machines use, and running outside a repo.
  • shellcheck is clean apart from style warning SC2001.
  • The AGENTS.md Setup check exits 0.

🤖 Generated with Claude Code

Closes #9. **Status:** review round done, every finding addressed (comment below); merging. Handoff: `docs/handoffs/2026-11-05T1223Z-retirer-done.md`. Nothing to deploy: the tool runs in a checkout. ## Plan The user, 2026-11-05: "check the raised issue as well we can do it like that a simple tool". Retiring a stack used to take four manual steps: stop it, `git rm` it, find a commit that still has it, and write the `RETIRED.md` row. One command now does them and asks only what it can't infer. The user also asked, through the move-scripts session, for the name `retirer`, a command run as `retirer <stack>` with no `.sh`. **`./retirer <stack>`** (or `<machine>/<stack>` when both machines have one) sits at the repo root. The repo-layout spec's D1 allows only `backup/ docs/ nixos/ vps/` as directories, so it is a root file. - **What it infers:** the machine, the path, and a commit on `main` that still has the stack: the merge-base with `origin/main`, because a branch's own commits are gone after the squash merge. - **What it asks:** *what it was for* and *why it was dropped*. An agent has no terminal, so it passes them as `--for` / `--why`. - **What it changes:** it `git rm -r`s the directory and puts the row first in `RETIRED.md`'s table, both staged. It doesn't commit, so the Caddy block, the DNS record and the doc mentions it lists (with `git grep`) go in the same commit. - **Refusals:** it won't run on a dirty stack or a dirty `RETIRED.md`, a machine's caddy, a stack not on `origin/main`, a path that already has a row, or a stack name both machines use. - **State on disk:** it never deletes untracked state (`.env`, `data/`, …) or a volume. It lists what stays. - **Stopping the stack:** only with `--down`, which runs `compose down` without `-v`: `podman` under `nixos/`, `docker` under `vps/`, or the stack's own `compose.sh` or `bin/docker-compose` when it has one. `--down` is refused in the agent microVM (`agentvm-*`), because agents don't deploy. - **What it prints for the user, on the machine:** 1. Stop the stack *before* pulling, since the pull deletes the compose file. 2. Pull, then hot-reload that machine's caddy. 3. Redeploy headscale if a DNS record went. 4. Clear the leftovers by hand. **Rules this PR rewrites (instructions):** in `AGENTS.md`, *Project in brief*, "a stack that stops running is deleted and gets a row in `RETIRED.md`" now adds "both by `./retirer <stack>`". The rule stays where it is and nothing is removed. `RETIRED.md`'s intro gains the same pointer. **Check (run):** a throwaway clone covers each of these: - `./retirer --for … --why … wallos` stages the deletion, and `RETIRED.md`'s first row is `wallos` with `origin/main`'s commit and `vps/wallos/`; `git cat-file -e <commit>:vps/wallos` exits 0. - Its Caddy and DNS lines are listed, and so are the untracked `.env` and `data/`. - `nixos/spliit` prints the `podman` commands. - `overleaf-toolkit` works and prints the project caveat. - `x\ny` and `a | b` stay in their cells. - These are refused: `--down` on `agentvm-repos`, a dirty stack, a dirty `RETIRED.md`, a bad path, `caddy`, a row that already exists, a branch-only stack, a name both machines use, and running outside a repo. - `shellcheck` is clean apart from style warning SC2001. - The `AGENTS.md` *Setup* check exits 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: theo <thodkatz@pm.me>
Retiring a stack was four manual steps (stop it, git rm it, look up the last
commit that has it, write the RETIRED.md row), and the row's fields were easy
to get inconsistent. retire.sh infers the name, path and commit, asks only what
it was for and why it was dropped (or takes --for/--why, for agents), and
leaves the result staged so the Caddy block and DNS record it lists go in the
same commit.

It never deletes untracked state or volumes, and stops the stack only with
--down, which it refuses in the agent microVM: agents don't deploy, so by
default it prints what the user runs on the machine, stopping before the pull
since the pull deletes the compose file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
thodkatz changed title from WIP: retire.sh: retire a stack in one command to retire.sh: retire a stack in one command 2026-11-05 12:19:32 +00:00
thodkatz force-pushed change/retire-tool from 1606baf826 to 167ecdd441 2026-11-05 12:23:33 +00:00 Compare
thodkatz changed title from retire.sh: retire a stack in one command to retirer: retire a stack in one command 2026-11-05 12:23:57 +00:00
Author
Owner

Local review round (correctness and methodology reviewers). Each finding and its fix, in 1989280 unless noted:

Correctness

  1. (high) A stack with no docker-compose.yaml (overleaf-toolkit) exited silently under pipefail. Fixed: the
    name: parse now runs only when the file exists, and a caveat is printed that the project name is a guess.
  2. (high) awk -v read backslashes as escapes. Fixed: the row now goes through ENVIRON["ROW"], and the test
    showed x\ny and a \| b stay in their cells.
  3. (medium) git rm ran before the table check, so a failure could leave the tree half-changed. Fixed: the row is
    built before git rm.
  4. (low) The duplicate check and git grep treated the name as a regex. Fixed: the duplicate check now compares the
    path column literally, so nixos/x and vps/x are distinct, and git grep uses -F.
  5. (low) Unrelated edits to RETIRED.md would be staged too. Fixed: a dirty RETIRED.md is refused.
  6. (minor) Outside a repo, the error was misleading. Fixed: the rev-parse result is checked before the cd.
  7. (minor) The caddy step printed a recreate. Fixed: it now prints the hot reload the caddy compose file documents
    (<engine> exec caddy caddy reload …).

Methodology

  1. (high) The row used HEAD, a branch commit the squash merge drops. Fixed: it now uses the merge-base with
    origin/main, and a stack that is only on the branch is refused.
  2. (medium) The body didn't list the rules this PR rewrites. Fixed: the body now has Rules this PR rewrites.
  3. (low) A root-level file vs D1. No change: D1 constrains only directories and allows "the repo's own files". The
    ruling is recorded in the handoff.
  4. (low) The "other mentions" grep skipped all plans. Fixed: the plans exclusion is dropped.
    5–6. (info) Nothing else is stale; sign-off, sync and size all pass.

Also in 1989280: renamed to retirer, run as retirer <stack>, at the user's request (relayed). The machine is
now inferred too.

Checks: AGENTS.md Setup check command: exit 0

Local review round (correctness and methodology reviewers). Each finding and its fix, in `1989280` unless noted: **Correctness** 1. (high) A stack with no `docker-compose.yaml` (overleaf-toolkit) exited silently under `pipefail`. Fixed: the `name:` parse now runs only when the file exists, and a caveat is printed that the project name is a guess. 2. (high) `awk -v` read backslashes as escapes. Fixed: the row now goes through `ENVIRON["ROW"]`, and the test showed `x\ny` and `a \| b` stay in their cells. 3. (medium) `git rm` ran before the table check, so a failure could leave the tree half-changed. Fixed: the row is built before `git rm`. 4. (low) The duplicate check and `git grep` treated the name as a regex. Fixed: the duplicate check now compares the path column literally, so `nixos/x` and `vps/x` are distinct, and `git grep` uses `-F`. 5. (low) Unrelated edits to `RETIRED.md` would be staged too. Fixed: a dirty `RETIRED.md` is refused. 6. (minor) Outside a repo, the error was misleading. Fixed: the `rev-parse` result is checked before the `cd`. 7. (minor) The caddy step printed a recreate. Fixed: it now prints the hot reload the caddy compose file documents (`<engine> exec caddy caddy reload …`). **Methodology** 1. (high) The row used `HEAD`, a branch commit the squash merge drops. Fixed: it now uses the merge-base with `origin/main`, and a stack that is only on the branch is refused. 2. (medium) The body didn't list the rules this PR rewrites. Fixed: the body now has *Rules this PR rewrites*. 3. (low) A root-level file vs D1. No change: D1 constrains only directories and allows "the repo's own files". The ruling is recorded in the handoff. 4. (low) The "other mentions" grep skipped all plans. Fixed: the plans exclusion is dropped. 5–6. (info) Nothing else is stale; sign-off, sync and size all pass. Also in `1989280`: renamed to `retirer`, run as `retirer <stack>`, at the user's request (relayed). The machine is now inferred too. Checks: AGENTS.md Setup check command: exit 0
thodkatz deleted branch change/retire-tool 2026-11-05 12:25:58 +00:00
thodkatz referenced this pull request from a commit 2026-11-05 12:26:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thodkatz/selfhosted!10
No description provided.