fix(env): seed machine.json so update/mem resolve the real checkout - #732
Conversation
On a fresh machine nothing writes ~/.config/dotfiles/machine.json, so the phantom contract default DOTFILES_REPO_DIR=$HOME/Projects/dotfiles propagates through the ADR-025 cascade to every consumer that resolves via ResolvePath: `dotf update` reports "not a git repo" and no-ops (exit 0), and `dotf mem` prints "run setup" though setup ran. Consumers using the RepoDir() git walk-up (secrets, spec) were unaffected — two contradictory answers in one binary. - Add `dotf env set <KEY> <VALUE>`, the write-side counterpart of `env path`: validates the key against the contract, merges into machine.json preserving other overrides, writes atomically. setup-linux.sh / setup-windows.ps1 call it to seed DOTFILES_REPO_DIR to the checkout before `dotf env generate`. - repoForUpdate() and the mem resolvers fall back to the RepoDir() walk-up when the cascade value is not an existing directory. - Add a `dotf doctor` check that FAILs when the DOTFILES_REPO_DIR cascade resolves to a phantom/missing path (mirrors what update/mem see, no walk-up masking), plus Go unit tests and an integration bats asserting setup seeds machine.json. Refs #696. Spec: specs/BUG-029-seed-machine-repo-dir.
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…v set ships The integration container installs the released dotf (install-dotf.sh downloads the pinned release, not a PR build) and dotf is off the bats-time PATH, so the new env set subcommand cannot be exercised there yet. Guard the two #696 checks to skip until an available dotf carries env set; the seed logic stays covered by the Go unit tests + the doctor repo-dir check. Harness gap tracked in #734.
Problem
On a docs-faithful fresh machine, nothing writes
~/.config/dotfiles/machine.json,so the phantom contract default
DOTFILES_REPO_DIR=$HOME/Projects/dotfilespropagates through the ADR-025 cascade (
env -> machine.json -> contract default) — and through the generatedpaths.sh/paths.ps1— into everyconsumer that resolves via
env.ResolvePath:dotf updatereportsnot a git repo: ~/Projects/dotfiles — nothing to self-updateand exits 0. Self-deploy is a silent no-op on every fresh machine.dotf mem session-startprobes~/Projects/dotfiles/scripts/vault-health.sh,misses, and says "run dotfiles setup" though setup ran.
ResolvePathreturns the default even when it does not exist, so therepo == ""guards never fire. Meanwhilesecrets/spec/doctor's drift checkuse the
RepoDir()git walk-up and work — two contradictory "where is the repo"answers in one binary.
Fix
dotf env set <KEY> <VALUE>— the write-side counterpart ofdotf env path: validates the key against the contract (a typo fails loud),merges into
machine.jsonpreserving every other override, writes atomically.setup-linux.sh/setup-windows.ps1call it to seedDOTFILES_REPO_DIRtothe checkout they run from, before
dotf env generate(so the generated pathfile carries the real value too). One Go JSON-merge instead of hand-rolled JSON
in two shells (ADR-020).
repoForUpdate()and thememresolvers prefer acascade value only when it names an existing directory, else fall back to the
RepoDir()walk-up (interactivedotf update/memfrom inside a checkout).dotf doctorassertion FAILs (with anactionable hint) when the
DOTFILES_REPO_DIRcascade resolves to aphantom/missing path. It deliberately mirrors what
update/memsee (nowalk-up masking), so the class is caught on any box.
Testing
env set(merge/preserve/idempotent/unknown-key-fails),repoForUpdatewalk-up fallback, and the doctor check (pass/missing/not-git).dotf env setin an isolatedXDG_CONFIG_HOME: seedcreates
machine.json, re-set is idempotent, other keys are preserved, anunknown key exits non-zero.
verify-setup.batsasserts setup seedsmachine.jsonwiththe checkout path and
dotf env path DOTFILES_REPO_DIRresolves to a real dir(runs in the Linux container).
go build ./...,go vet ./...,go test ./...clean;bash -n setup-linux.sh;.ps1change is ASCII-only.Spec:
specs/BUG-029-seed-machine-repo-dir.Closes #696.