fix: keep herdr runtime state out of the dotfiles working tree #3

Merged
hermes merged 8 commits from fm/fm-clone-runtime-dirt-dotfiles into main 2026-10-06 10:25:47 -04:00
Owner

Problem

git -C projects/dotfiles status --short reports two untracked herdr runtime artifacts (home/.config/herdr/herdr.sock.agent, home/.config/herdr/session-snapshots/), and the directory also holds live herdr.sock / herdr-client.sock, herdr-server.log, .plugins.lock and session.json beside the tracked config.toml. The clone reads permanently dirty and keeps falling behind.

Root cause

herdr derives its runtime state from $HOME/.config/herdr (src/config/io.rs config_dir()), and the default session directory is that same config directory (src/session.rs data_dir_for()). Sockets, logs, .plugins.lock, session.json, session-snapshots/ and named sessions/ therefore land beside config.toml. HERDR_CONFIG_PATH relocates only the config file, not the state, and herdr has no state-directory option. home.nix symlinked the whole ~/.config/herdr directory into this repo, so herdr's state directory was the tracked tree.

Fix

  • home.nix links only ~/.config/herdr/config.toml, so ~/.config/herdr stays a real directory in $HOME and herdr's state resolves outside the repo.
  • home.activation.herdrConfigDir runs in the write phase (after writeBoundary, before linkGeneration). It migrates the old whole-directory symlink and removes the known leaked runtime artifacts by name. config.toml and any other repo content are never touched; the removals are run-guarded (dry-run safe) and idempotent, and they do not stop or restart the running herdr server.
  • rebuild.sh follows the target move: ~/.config/herdr/config.toml is rotated as a managed file backup target, and ~/.config/herdr is dropped from the directory-target rotation so a real config.toml cannot later fail checkLinkTargets on config.toml.backup.
  • AGENTS.md records the deliberate decision.

Scope

The same class of problem exists in the Beacon clone (.backpassrc.json) and for ~/.config/beets/state.pickle; both are out of scope here.

Validation

  • no-mistakes pipeline on head 2bcaf5fd: outcome passed (intent, rebase, review, test, document, lint, push; pr and ci skipped because this forge is Gitea). No open findings.
  • The symlink migration was reproduced against home-manager's real generated activate / link scripts: without the migration step home-manager moves the repo's tracked config.toml to config.toml.backup; with it the repo stays clean and herdr's reported session_dir is outside the tree.
  • Effect is on the next rebuild plus the first natural herdr start; the running server is not driven, and already-leaked artifacts are cleared by the activation.
## Problem `git -C projects/dotfiles status --short` reports two untracked herdr runtime artifacts (`home/.config/herdr/herdr.sock.agent`, `home/.config/herdr/session-snapshots/`), and the directory also holds live `herdr.sock` / `herdr-client.sock`, `herdr-server.log`, `.plugins.lock` and `session.json` beside the tracked `config.toml`. The clone reads permanently dirty and keeps falling behind. ## Root cause herdr derives its runtime state from `$HOME/.config/herdr` (`src/config/io.rs` `config_dir()`), and the default session directory is that same config directory (`src/session.rs` `data_dir_for()`). Sockets, logs, `.plugins.lock`, `session.json`, `session-snapshots/` and named `sessions/` therefore land beside `config.toml`. `HERDR_CONFIG_PATH` relocates only the config file, not the state, and herdr has no state-directory option. `home.nix` symlinked the whole `~/.config/herdr` directory into this repo, so herdr's state directory *was* the tracked tree. ## Fix - `home.nix` links only `~/.config/herdr/config.toml`, so `~/.config/herdr` stays a real directory in `$HOME` and herdr's state resolves outside the repo. - `home.activation.herdrConfigDir` runs in the write phase (after `writeBoundary`, before `linkGeneration`). It migrates the old whole-directory symlink and removes the known leaked runtime artifacts by name. `config.toml` and any other repo content are never touched; the removals are `run`-guarded (dry-run safe) and idempotent, and they do not stop or restart the running herdr server. - `rebuild.sh` follows the target move: `~/.config/herdr/config.toml` is rotated as a managed file backup target, and `~/.config/herdr` is dropped from the directory-target rotation so a real `config.toml` cannot later fail `checkLinkTargets` on `config.toml.backup`. - `AGENTS.md` records the deliberate decision. ## Scope The same class of problem exists in the Beacon clone (`.backpassrc.json`) and for `~/.config/beets/state.pickle`; both are out of scope here. ## Validation - no-mistakes pipeline on head `2bcaf5fd`: outcome `passed` (intent, rebase, review, test, document, lint, push; `pr` and `ci` skipped because this forge is Gitea). No open findings. - The symlink migration was reproduced against home-manager's real generated `activate` / `link` scripts: without the migration step home-manager moves the repo's tracked `config.toml` to `config.toml.backup`; with it the repo stays clean and herdr's reported `session_dir` is outside the tree. - Effect is on the next rebuild plus the first natural herdr start; the running server is not driven, and already-leaked artifacts are cleared by the activation.
hermes added 8 commits 2026-10-05 23:20:20 -04:00
herdr resolves its config directory as ~/.config/herdr and writes all of its
runtime state beside config.toml: herdr.sock, herdr-client.sock,
herdr-server.log, .plugins.lock, session.json and session-snapshots/. It offers
no option to relocate that directory, so linking the whole directory into this
repo made ~/.config/herdr resolve into the tracked tree and left every clone
permanently dirty with herdr's live sockets and snapshots.

Link only config.toml and let ~/.config/herdr be a real directory, so herdr's
state lands in $HOME instead of the working tree.

home-manager links a file by resolving the existing directory symlink, which
would move this repo's own tracked config.toml to config.toml.backup and leave
a symlink inside the tree. Add a one-time activation step that drops the stale
symlink before home-manager checks link targets; it is a no-op once
~/.config/herdr is a real directory.
~/.config/herdr moved from a whole-directory home.file target to a file
target, so rebuild.sh must follow. Treat ~/.config/herdr/config.toml as a
managed file backup target and stop listing ~/.config/herdr as a directory
target, otherwise a real config.toml backed up to config.toml.backup would
fail the next switch with "would be clobbered".
hermes merged commit ca3c7fa45a into main 2026-10-06 10:25:47 -04:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: transnet/dotfiles#3