fix(doctor): resolve contract/versions repo-first via a shared resolver - #736
Conversation
dotf doctor located env-contract.json/versions.conf deployed-copy-first while dotf env generate resolved repo-first, so on a machine whose deploy dir lags the repo the same binary reported both "paths stale — run env generate" (doctor) and "up to date" (env generate). The stale deployed read also produced nonsensical version-drift directions and could re-render paths without #663's age keys (#518 class). - Add env.ResolveRepoFirst(name, repoDir, dotfilesDir, startDir) — checkout copy wins over the deployed copy, then a walk-up — and route both env.ResolveContractPath and doctor.loadConfig (contract + versions.conf) through it, so the precedence lives in one shared function and cannot drift again. - doctor.loadConfig resolves the checkout like env does (DOTFILES_REPO_DIR when a real dir, else the .git walk-up) and drops the dead deployed-first helpers. - dotf doctor prints always-visible `contract:` / `versions.conf:` provenance lines so a stale-copy read is self-diagnosing. - Anti-drift guard: with both copies present doctor picks the repo copy and reads the repo pin, and env.ResolveContractPath is cross-checked to agree. Refs #697. Spec: specs/BUG-030-doctor-env-shared-resolver.
|
Warning Review limit reached
Next review available in: 47 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 (9)
✨ 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 |
Problem
dotf doctorlocatedenv-contract.json/versions.confdeployed-copy-first (config.go) whiledotf env generateresolved repo-first (env.ResolveContractPath). On a machine whose deploy dir lags the repo, the same binary in the same shell reported both[FAIL] paths.* stale — run dotf env generate(doctor, stale deployed contract) andok: up to date(env generate, fresh repo contract). The stale deployed read also produced nonsensical version-drift directions (off a stale pin) and could re-render paths without #663's age keys (the #518 class).Two independent resolvers with opposite precedence — the drift itself was the bug.
Fix
env.ResolveRepoFirst(name, repoDir, dotfilesDir, startDir): checkout copy (fresher SSOT) wins over the deployed copy, then a walk-up.env.ResolveContractPathis refactored onto it (behavior unchanged);doctor.loadConfiguses it for both the contract andversions.conf. Precedence now lives in one shared function.loadConfigresolves the checkout the way env does (DOTFILES_REPO_DIRwhen a real dir — now reliably seeded by BUG: no journey creates machine.json — phantom DOTFILES_REPO_DIR default breaks update/mem/doctor --fix #696 — else the.gitwalk-up), and drops the dead deployed-first helpers.dotf doctorprints always-visible[INFO] contract: <path>and[INFO] versions.conf: <path>so a stale-copy read is self-diagnosing.Testing
envunit tests:ResolveRepoFirstprecedence (repo → deployed → walk-up → "").loadConfigresolves the repo copy and reads the repo pin (not the stale deployed one), andenv.ResolveContractPathis cross-checked to agree.go build/vet/test ./...clean; golangci-lint clean.dotf doctoron this machine prints the provenance lines resolving the repo copy, not~/.dotfiles.Spec:
specs/BUG-030-doctor-env-shared-resolver. Sibling of #696/BUG-029.Closes #697.