repo-layout: lay the repo out by machine (2/2) #6

Merged
thodkatz merged 14 commits from impl/repo-layout-2-restructure into main 2026-11-05 10:26:55 +00:00
Owner

Slice 2/2 of the repo-layout track (spec docs/superpowers/specs/2026-11-05-repo-layout-design.md, plan
docs/superpowers/plans/2026-11-05-repo-layout/slice-2-restructure.md).

What moved and why

The tree now shows what runs where (spec D1): vps/ and nixos/ each hold one directory per stack that machine
runs, plus the machine's caddy (vps/caddy/, nixos/caddy/, which was caddy-nixed/). The stale setup.sh and
sync.sh are now under backup/, with a README saying they are stale.

  • Tasks 2.1, moves: every move is a git mv, so git log --follow keeps each file's history.
  • Task 2.2, keep containers and state across the move:
    • every compose file sets name: to its current project name, so the move keeps the same containers, volumes
      and networks; nixos/caddy keeps caddy-nixed;
    • the five absolute /srv/selfhosted/<stack> mounts are now relative, so they follow the stack;
    • .gitignore is rewritten for the new paths, so live state stays ignored.
  • Task 2.3, upstream checker: the check command in AGENTS.md Setup now also fails when a reverse_proxy
    upstream isn't a stack on the same machine, unless <machine>/caddy/external-upstreams lists it (today
    mysite). This catches a Caddy block left in the wrong machine's Caddyfile after a move.
  • Task 2.4, Plane on one machine: nixos/plane/ loses the microVM/host switch and microvm.env. The
    microVM's Plane is retired (RETIRED.md).
  • Task 2.5, docs: AGENTS.md, the network guide, BACKLOG.md, the ente spec (clarification 1, folded), the
    repo-layout spec (D10 check; clarification 1) and the docs index now use the new paths. There is also a
    one-time move guide, docs/guides/moving-to-the-machine-layout.md.
  • Finishing: the track's Current work line is removed, the ente line now waits on the move, and
    BACKLOG.md Next has the move as a step waiting on the user.

After the merge (the user)

Nothing is deployed. On the VPS and on the NixOS host, follow docs/guides/moving-to-the-machine-layout.md.
It covers stopping each stack, git pull, moving the untracked state, starting the stacks again and the URLs to
check. When both machines are done, tell an agent: it deletes the guide, and the ente plan starts. The nixed
repo's comments that name the old paths are a BACKLOG.md item.

Early output: the branch's tree

find vps nixos -mindepth 1 -maxdepth 2 -type d | sort, the same directories as tree -L 2 -d vps nixos.
Compare it with the spec's Target tree:

nixos/caddy
nixos/caddy/config
nixos/ente
nixos/ente/config
nixos/plane
nixos/spliit
vps/actual
vps/authentik
vps/caddy
vps/caddy/config
vps/firefly
vps/forgejo
vps/freshrss
vps/grafana
vps/grafana/config
vps/headscale
vps/headscale/config
vps/hedgedoc
vps/overleaf-toolkit
vps/overleaf-toolkit/config
vps/portainer
vps/rclone
vps/stirling-pdf
vps/uptime-kuma
vps/wallos
vps/wud

Instructions changed

Every rule this PR removes or rewrites, and where it now lives:

  • AGENTS.md Never commit secrets: the ignored list drops backup/ (now tracked scripts) and adds
    nixos/plane/backup/; same bullet.
  • AGENTS.md Setup: the check command also checks each reverse_proxy upstream against its own machine's stacks
    or <machine>/caddy/external-upstreams (new rule, same section, with a note on the one form it reads); After a
    merge
    now says "a change under vps/ or nixos/" (rewritten, same place).
  • AGENTS.md Project in brief: new rules: the tree is the source of truth for what runs where; a moved stack
    moves with git mv in the same commit as its Caddy block and DNS record; a stopped one is deleted with a
    RETIRED.md row.
  • Network guide: "Both machines run Plane from the same shared plane/ directory": dropped on purpose (spec D8);
    "caddy-nixed/ is the deployment config … new services go there by default": rewritten as "nixos/ is the
    default for new stacks" (AGENTS.md Project in brief table and the guide); the microVM as a migration target
    for extra_records: dropped (it hosts no stacks, RETIRED.md); new: each <machine>/caddy proxies only to its
    own machine's stacks.
  • nixos/plane/README.md: the microVM/host switch (PLANE_MACHINE): dropped (D8); replaced by a guard: off the
    host, lib.sh refuses unless the caller sets PLANE_DATA (and APP_DOMAIN) for a test run.

Checks

D1–D11 as the plan words them all pass, as does the check command (exit 0, in bash and zsh, plus D6's three
negative runs) and sync-agents.py --check (exit 0). Each task got a subagent review. Task 2.4's review found
three two-machine comments left in restore.sh and backup.sh; they were fixed in round 1.

🤖 Generated with Claude Code

Slice 2/2 of the repo-layout track (spec `docs/superpowers/specs/2026-11-05-repo-layout-design.md`, plan `docs/superpowers/plans/2026-11-05-repo-layout/slice-2-restructure.md`). ## What moved and why The tree now shows what runs where (spec D1): `vps/` and `nixos/` each hold one directory per stack that machine runs, plus the machine's caddy (`vps/caddy/`, `nixos/caddy/`, which was `caddy-nixed/`). The stale `setup.sh` and `sync.sh` are now under `backup/`, with a README saying they are stale. - **Tasks 2.1, moves:** every move is a `git mv`, so `git log --follow` keeps each file's history. - **Task 2.2, keep containers and state across the move:** - every compose file sets `name:` to its current project name, so the move keeps the same containers, volumes and networks; `nixos/caddy` keeps `caddy-nixed`; - the five absolute `/srv/selfhosted/<stack>` mounts are now relative, so they follow the stack; - `.gitignore` is rewritten for the new paths, so live state stays ignored. - **Task 2.3, upstream checker:** the check command in `AGENTS.md` *Setup* now also fails when a `reverse_proxy` upstream isn't a stack on the same machine, unless `<machine>/caddy/external-upstreams` lists it (today `mysite`). This catches a Caddy block left in the wrong machine's Caddyfile after a move. - **Task 2.4, Plane on one machine:** `nixos/plane/` loses the microVM/host switch and `microvm.env`. The microVM's Plane is retired (`RETIRED.md`). - **Task 2.5, docs:** `AGENTS.md`, the network guide, `BACKLOG.md`, the ente spec (clarification 1, folded), the repo-layout spec (D10 check; clarification 1) and the docs index now use the new paths. There is also a one-time move guide, `docs/guides/moving-to-the-machine-layout.md`. - **Finishing:** the track's *Current work* line is removed, the ente line now waits on the move, and `BACKLOG.md` *Next* has the move as a step waiting on the user. ## After the merge (the user) **Nothing is deployed.** On the VPS and on the NixOS host, follow `docs/guides/moving-to-the-machine-layout.md`. It covers stopping each stack, `git pull`, moving the untracked state, starting the stacks again and the URLs to check. When both machines are done, tell an agent: it deletes the guide, and the ente plan starts. The `nixed` repo's comments that name the old paths are a `BACKLOG.md` item. ## Early output: the branch's tree `find vps nixos -mindepth 1 -maxdepth 2 -type d | sort`, the same directories as `tree -L 2 -d vps nixos`. Compare it with the spec's *Target tree*: ``` nixos/caddy nixos/caddy/config nixos/ente nixos/ente/config nixos/plane nixos/spliit vps/actual vps/authentik vps/caddy vps/caddy/config vps/firefly vps/forgejo vps/freshrss vps/grafana vps/grafana/config vps/headscale vps/headscale/config vps/hedgedoc vps/overleaf-toolkit vps/overleaf-toolkit/config vps/portainer vps/rclone vps/stirling-pdf vps/uptime-kuma vps/wallos vps/wud ``` ## Instructions changed Every rule this PR removes or rewrites, and where it now lives: - `AGENTS.md` *Never commit secrets*: the ignored list drops `backup/` (now tracked scripts) and adds `nixos/plane/backup/`; same bullet. - `AGENTS.md` *Setup*: the check command also checks each `reverse_proxy` upstream against its own machine's stacks or `<machine>/caddy/external-upstreams` (new rule, same section, with a note on the one form it reads); *After a merge* now says "a change under `vps/` or `nixos/`" (rewritten, same place). - `AGENTS.md` *Project in brief*: new rules: the tree is the source of truth for what runs where; a moved stack moves with `git mv` in the same commit as its Caddy block and DNS record; a stopped one is deleted with a `RETIRED.md` row. - Network guide: "Both machines run Plane from the same shared `plane/` directory": dropped on purpose (spec D8); "`caddy-nixed/` is the deployment config … new services go there by default": rewritten as "`nixos/` is the default for new stacks" (`AGENTS.md` *Project in brief* table and the guide); the microVM as a migration target for `extra_records`: dropped (it hosts no stacks, `RETIRED.md`); new: each `<machine>/caddy` proxies only to its own machine's stacks. - `nixos/plane/README.md`: the microVM/host switch (`PLANE_MACHINE`): dropped (D8); replaced by a guard: off the host, `lib.sh` refuses unless the caller sets `PLANE_DATA` (and `APP_DOMAIN`) for a test run. ## Checks D1–D11 as the plan words them all pass, as does the check command (exit 0, in bash and zsh, plus D6's three negative runs) and `sync-agents.py --check` (exit 0). Each task got a subagent review. Task 2.4's review found three two-machine comments left in `restore.sh` and `backup.sh`; they were fixed in round 1. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: theo <thodkatz@pm.me>
The directory tree is now the map of what runs where (spec D1): VPS stacks
under `vps/`, NixOS host stacks under `nixos/`, and backup scripts under
`backup/`. The check command in AGENTS.md that validates the layout is
replaced in a later commit of this PR.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

Signed-off-by: theo <thodkatz@pm.me>
Each stack's compose file now pins `name:` to its old project name (its
directory name under vps/ or nixos/, or caddy-nixed for nixos/caddy): compose
derives the project name from the directory by default, and the move changed
every directory name, which would otherwise create new volumes and networks
instead of reusing the ones already deployed.

The five stacks with absolute /srv/selfhosted/<stack> bind mounts
(headscale, authentik, grafana, uptime-kuma, wud) now use relative ./ mounts,
so the mount follows the stack's own directory to wherever it's deployed
instead of hardcoding the VPS's current path.

.gitignore is rewritten for the new vps/<stack>/ and nixos/<stack>/ paths, so
each stack's live state (data/, .env, caddy's state dir, ente's keys, plane's
backup and data-nixed) stays ignored under its new location instead of
silently becoming trackable.

The stacks' own comments and READMEs (Caddyfile headers, ente's and spliit's
"behind ../caddy-nixed", headscale's config.yaml, freshrss's REAMDE.md) are
fixed to the paths and names the move left stale, so they keep pointing at
the right sibling directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Prevents a reverse_proxy block left pointing at a stack that moved to
the other machine during the repo-layout restructure: nixos/caddy/ and
vps/caddy/ now share no containers, so an upstream left over from
before the move would silently proxy to nothing. The check command's
awk now reads each machine's compose files (services and
container_name) plus its caddy/external-upstreams allowlist, and
flags any reverse_proxy upstream in that machine's Caddyfile that
isn't one of them. vps/caddy/external-upstreams lists mysite, the
untracked vps/mywebsite site that vps/caddy/config/Caddyfile proxies
to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The microVM's Plane is retired (RETIRED.md): the hostname switch in
lib.sh had only one live case left (nixed), with the microvm branch
dead code. Drop the per-machine indirection throughout nixos/plane/ -
microvm.env, PLANE_MACHINE, the machines table - and say plainly that
Plane runs on the NixOS host, settings in nixed.env layered over .env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
backup.sh and restore.sh still described a two-machine setup (shared
.env secrets restoring "on either", ownership "right ... on either
machine") after the previous commit moved Plane to the host alone.
Rewrite restore.sh's SECRET_KEY note to the one-machine fact
.env.example already states, and say "either runtime" (docker vs
rootless podman) where that's what the sudo/ownership note is actually
about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The earlier commits of this slice moved every stack under vps/ or nixos/,
but AGENTS.md, the network guide, BACKLOG.md and the ente spec still named
the old top-level directories (caddy/, caddy-nixed/, headscale/, ente/, ...),
so an agent following them would edit or test paths that no longer exist.
They now say the new layout, and AGENTS.md states D1's rule: the tree is the
source of truth for what runs where.

The running stacks on the VPS and the NixOS host still sit in the old
directories with their untracked state (data/, .env, caddy's certificates),
which git pull cannot move. docs/guides/moving-to-the-machine-layout.md gives
the user each machine's one-time steps: stop, pull, move the state with a
merging move_state function, start in dependency order, open the URLs. It is
deleted once both machines moved (BACKLOG.md).

The repo-layout spec's D10 check gains the filter for three strings that
are not repo paths and excludes the move guide, which names the old
directories by design; the ente spec gets a clarification for its rewritten
paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Slice 2 is the track's last: its Current work line goes, the ente plan now waits
on the user moving both machines (BACKLOG Next), and the slice-2 handoff says
what the user runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
thodkatz changed title from WIP: repo-layout: lay the repo out by machine (2/2) to repo-layout: lay the repo out by machine (2/2) 2026-11-05 10:10:22 +00:00
The session reached its context budget with the correctness review still running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Author
Owner

Local review round (two reviewer subagents, whole branch a800f94..df4d167).

  1. Methodology review: 0 Critical, 2 Important, 6 Minor. Important: the PR body lacks an Instructions changed list (AGENTS.md secrets/Setup/Project in brief, network guide, Plane README); the task reviews' deferred minors need fixing in this PR or a BACKLOG.md line. Minor: BACKLOG.md says ~/ente-vps (it is /root/ente-vps); the guide's deletion is two backlog items, and the nixed comments line is due now; the ente line's docs/handoffs/ pointer is right only after the post-merge handoff; the slice-2 handoff names no check; the plan's clarification summary omits the move-guide exclusion; nixos/spliit/README.md still mentions the microVM. Sign-off check clean; sync-agents.py --check: exit 0.
  2. Correctness review: 0 Critical, 3 Important, 8 Minor. Important: the guide's VPS ente steps assume the old ente's compose file is in the working tree (a pull since 226e755 replaced it; its volume is postgres-data, not pgdata); the host clone path ~/repos/selfhosted is hard-coded (guide and the ente spec's Deployment); nixos/plane/lib.sh lost its machine guard, so a test run in the microVM would use the host's live data-nixed. Minor: /root/ente-vps and a re-run guard on the copy; mv mywebsite after a collision; ownership of the VPS clone and a post-pull tree check; a cron/timer warning for setup.sh/sync.sh; move_state's nested || return 1; the checker only reads http:// upstreams; podman-compose and name: (no change); the earlier trailer/newline minors (moot).

All findings are fixed in this PR, except the checker's http://-only form, which gets a note, and the moot ones.

Checks: the AGENTS.md Setup check command: exit 0

Local review round (two reviewer subagents, whole branch a800f94..df4d167). 1. **Methodology review**: 0 Critical, 2 Important, 6 Minor. Important: the PR body lacks an *Instructions changed* list (AGENTS.md secrets/Setup/Project in brief, network guide, Plane README); the task reviews' deferred minors need fixing in this PR or a `BACKLOG.md` line. Minor: `BACKLOG.md` says `~/ente-vps` (it is `/root/ente-vps`); the guide's deletion is two backlog items, and the `nixed` comments line is due now; the ente line's `docs/handoffs/` pointer is right only after the post-merge handoff; the slice-2 handoff names no check; the plan's clarification summary omits the move-guide exclusion; `nixos/spliit/README.md` still mentions the microVM. Sign-off check clean; `sync-agents.py --check`: exit 0. 2. **Correctness review**: 0 Critical, 3 Important, 8 Minor. Important: the guide's VPS ente steps assume the old ente's compose file is in the working tree (a pull since `226e755` replaced it; its volume is `postgres-data`, not `pgdata`); the host clone path `~/repos/selfhosted` is hard-coded (guide and the ente spec's *Deployment*); `nixos/plane/lib.sh` lost its machine guard, so a test run in the microVM would use the host's live `data-nixed`. Minor: `/root/ente-vps` and a re-run guard on the copy; `mv mywebsite` after a collision; ownership of the VPS clone and a post-pull tree check; a cron/timer warning for `setup.sh`/`sync.sh`; `move_state`'s nested `|| return 1`; the checker only reads `http://` upstreams; podman-compose and `name:` (no change); the earlier trailer/newline minors (moot). All findings are fixed in this PR, except the checker's `http://`-only form, which gets a note, and the moot ones. Checks: the AGENTS.md *Setup* check command: exit 0
Dropping the hostname switch made every machine source nixed.env, so an
agent's ./compose.sh in the shared directory would point a second Plane at
the host's live ./data-nixed, and nixed.env, sourced last, left no way to
follow the test recipe's scratch data path. lib.sh now refuses off the host
without PLANE_DATA, keeps a caller's PLANE_DATA/APP_DOMAIN over nixed.env's,
and the scripts accept an absolute data path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The VPS's ente predates 226e755 and runs acbff43's compose file (volume
postgres-data), but any pull since put nixos's file in its ente/, so the
guide's down/copy/up would fail on interpolation or start an empty ente,
and the rm -rf could follow anyway. The guide now checks the mounts, stops
it with the old file, puts that file into /root/ente-vps/ente, and deletes
the clone's ente/ only once museum answers /ping. The host steps no longer
assume ~/repos/selfhosted (this checkout is ~/repos/personal/selfhosted):
the clone comes from caddy's compose working_dir label, and every step cds
there. Also from the review: move_state stops at a nested collision, so the
guide's claim is exact; mywebsite moves only after a clean loop; root-owned
clones, a post-pull tree check, stale cron jobs, a disk-space check, a
guarded copy and a volume-list sanity check. Both specs record the
corrections as folded clarifications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
BACKLOG held the guide's deletion twice and the nixed comment rewrite as
unscheduled though this merge makes it due, and named ~/ente-vps where root's
/root/ente-vps is meant. The slice-2 handoff now names the check that proves
its state and where the deferred minors landed; the plan's clarification
line matches the folded one (it also excludes the move guide); spliit's
README no longer implies the microVM runs it; AGENTS.md says which
reverse_proxy form the upstream checker reads, so a new form is not
silently skipped unnoticed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
The scoped re-review found that re-running the VPS ente step meets an
expected 'No such object' the guide called a stop, that nothing kept the
copy from running while the old ente still ran, that a Plane test run
setting only PLANE_DATA fell back to the real domain, and that -p doesn't
rename plane-proxy. The copy is an if-block, not an exit, because the
user pastes it into a root shell whose exit would hand the rest to their
own shell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Author
Owner

Review round addressed (fixes e19b3f7, a7eb954, 76df1da; the scoped re-review's minors eee95e9):

Methodology

  1. Instructions changed added to the PR body.
  2. Deferred minors: every open one is fixed in the guide (a7eb954); the trailer blank line and the trailing newlines are moot (squash, harmless).
  3. /root/ente-vps in the guide and BACKLOG.md (76df1da).
  4. The duplicate guide-deletion line is dropped; the nixed comments line moved to Next with the new paths (76df1da).
  5. The post-merge docs/handoffs/ handoff names the ente plan's start condition (on main after the merge).
  6. The slice-2 handoff names its check (76df1da).
  7. The plan's clarification summary says D10 also excludes the move guide (76df1da).
  8. nixos/spliit/README.md points to the network guide's test recipe (76df1da).

Correctness

  1. The old VPS ente is checked (docker inspect), stopped with its own acbff43 file, copied with it, and rm -rf waits for /ping; postgres-data replaces pgdata, in the repo-layout spec through a folded clarification (a7eb954, 76df1da).
  2. The host clone is derived from the running caddy and exported as $clone; the ente spec's Deployment says the same through a clarification (a7eb954, 76df1da).
  3. lib.sh refuses off the host unless the caller sets PLANE_DATA and APP_DOMAIN, which win over nixed.env's; data_abs for absolute paths (e19b3f7, eee95e9).
    4–8. Fixed in the guide (a7eb954).
  4. The checker's one form (reverse_proxy http://name:port) is written in Setup (76df1da).
  5. A before/after podman volume ls diff in the host steps (a7eb954).
  6. Moot.

Re-review (scoped, d87ccd0..76df1da): every finding fixed; 4 new Minor (a re-run's expected No such object, a guard before the ente copy, APP_DOMAIN required off the host, plane-proxy's fixed name): fixed in eee95e9.

Checks: the AGENTS.md Setup check command: exit 0

Review round addressed (fixes `e19b3f7`, `a7eb954`, `76df1da`; the scoped re-review's minors `eee95e9`): Methodology 1. *Instructions changed* added to the PR body. 2. Deferred minors: every open one is fixed in the guide (`a7eb954`); the trailer blank line and the trailing newlines are moot (squash, harmless). 3. `/root/ente-vps` in the guide and `BACKLOG.md` (`76df1da`). 4. The duplicate guide-deletion line is dropped; the `nixed` comments line moved to *Next* with the new paths (`76df1da`). 5. The post-merge `docs/handoffs/` handoff names the ente plan's start condition (on `main` after the merge). 6. The slice-2 handoff names its check (`76df1da`). 7. The plan's clarification summary says D10 also excludes the move guide (`76df1da`). 8. `nixos/spliit/README.md` points to the network guide's test recipe (`76df1da`). Correctness 1. The old VPS ente is checked (`docker inspect`), stopped with its own `acbff43` file, copied with it, and `rm -rf` waits for `/ping`; `postgres-data` replaces `pgdata`, in the repo-layout spec through a folded clarification (`a7eb954`, `76df1da`). 2. The host clone is derived from the running caddy and exported as `$clone`; the ente spec's *Deployment* says the same through a clarification (`a7eb954`, `76df1da`). 3. `lib.sh` refuses off the host unless the caller sets `PLANE_DATA` and `APP_DOMAIN`, which win over `nixed.env`'s; `data_abs` for absolute paths (`e19b3f7`, `eee95e9`). 4–8. Fixed in the guide (`a7eb954`). 9. The checker's one form (`reverse_proxy http://name:port`) is written in *Setup* (`76df1da`). 10. A before/after `podman volume ls` diff in the host steps (`a7eb954`). 11. Moot. Re-review (scoped, d87ccd0..76df1da): every finding fixed; 4 new Minor (a re-run's expected `No such object`, a guard before the ente copy, `APP_DOMAIN` required off the host, `plane-proxy`'s fixed name): fixed in `eee95e9`. Checks: the AGENTS.md *Setup* check command: exit 0
thodkatz deleted branch impl/repo-layout-2-restructure 2026-11-05 10:26:55 +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!6
No description provided.