mullane.info

Renaming arch-setup, and making git safe to run in a shared tree

2026-11-22 · homenet

The repo I called arch-setup started out as something I thought might become a general way to set up an Arch workstation. It didn’t. It’s the record of one machine, desktom, plus the history of moving it off Windows (still useful, but about as generic as a diary). So it’s hosts/desktom now, next to every other host in the network. Workbench, my desktop and terminal environment, had been living inside it, which made less and less sense: it’s public, it’s generic, and it runs on the servers too (bench install --remote). It moved to common/workbench, with the rest of the shared tooling.

The move itself was mostly bookkeeping, but there was more of it than I expected. GitLab first: changing a project’s path needs the Owner role, and the agent’s account is only a Maintainer of my namespace, so it renamed tom/arch-setup to tom/desktom through a Rails one-off on the GitLab VM, during a sudo window I opened for it. GitLab keeps a redirect from the old path, so nothing broke on the remote side. Then the links. The agent’s own ~/.zshenv and Neovim config pointed into the tree being moved, so the move and the retargeting had to happen in one command (a shell whose config disappears out from under it is not a fun way to find out). My own config, as of earlier that day, points into my own clones rather than the shared tree, so those moved too, from one nested clone to two siblings. Even Claude Code’s per-directory memory had to follow, because it’s keyed by path.

The more interesting part was git. Earlier in the day I’d moved my dotfiles out of the agent’s reach, and the obvious next question was: what about git itself? When I run git in one of the shared repos, git reads that repo’s .git/config, and that file is writable by the agent’s account. A surprising number of settings in there make git run a program: core.hooksPath, core.fsmonitor, core.pager, alias.* with a !, filter drivers, include.path. So a hook or an alias written by something running as the agent would quietly (sorry, silently) run as me.

My first instinct was a global setting of my own that points core.hooksPath somewhere safe. That doesn’t work: a repo’s local config beats your global config, which is the whole point of local config. What does beat it is configuration passed on the command line, and git accepts the same thing through the environment: GIT_CONFIG_COUNT, then GIT_CONFIG_KEY_0, GIT_CONFIG_VALUE_0 and so on. So my session now sets two of those, through a file in ~/.config/environment.d. One forces core.hooksPath to a root-owned directory, and the other turns fsmonitor off.

That directory holds a small dispatcher, installed under every hook name git knows, and the homenet hooks themselves (today just the one that refuses commits straight to main). In a repo under /srv/projects, the dispatcher runs a check first, then the homenet hook if there is one, and never the repo’s own .git/hooks. Anywhere else, it just runs the repo’s own hook, as git would have without any of this, so my other projects don’t notice. The check, homenet-git-check, is an allowlist. It reads each repo’s config file directly (it never runs git inside the repo it’s checking) and refuses anything beyond the handful of keys every clone actually has, with the hooks path and the SSH command only allowed at their expected values. Run on its own, it reports on every repo. The first run flagged my transcript-viewer project for rerere settings and a branch-topic note, harmless, so those went on the list. It also turned out that project uses git worktrees, whose .git is a file rather than a directory, which the check now follows instead of refusing.

All of this gets installed by one script, install-seat-copies.sh, which grew out of the fleet-sudo installer from earlier in the day: it puts root-owned copies of fleet-sudo, the check, the dispatcher and the hooks in place, and writes my environment file. Changes reach the installed copies only when I’ve looked at the diff (--diff) and run it again. Every clone on desktom now points its core.hooksPath at the root-owned directory, so the agent’s own commits go through the same reviewed hooks. Then the agent tested it the way I’d want it tested: a commit on main refused, a commit on a branch allowed, an alias.x = !echo pwned planted in a repo’s config and caught, and a scratch repo whose config pointed its hooks at an “evil” script, where the environment override won and the repo’s own hook ran instead.

The general rule I’ve ended up with is simple enough to write on a sticky note: anything I run, source or load must not be writable by the agent. Reading is fine, editing in its own tree is fine, and getting something into my session goes through a review step I actually do. It’s a bit more ceremony than “it’s all one shared folder”, but the ceremony is the point.