Skip to content

fix(doctor): resolve contract/versions repo-first via a shared resolver - #736

Merged
mlorentedev merged 2 commits into
mainfrom
fix/doctor-env-shared-resolver
Jul 10, 2026
Merged

fix(doctor): resolve contract/versions repo-first via a shared resolver#736
mlorentedev merged 2 commits into
mainfrom
fix/doctor-env-shared-resolver

Conversation

@mlorentedev

Copy link
Copy Markdown
Owner

Problem

dotf doctor located env-contract.json/versions.conf deployed-copy-first (config.go) while dotf env generate resolved 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) and ok: 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

  • Shared resolver. env.ResolveRepoFirst(name, repoDir, dotfilesDir, startDir): checkout copy (fresher SSOT) wins over the deployed copy, then a walk-up. env.ResolveContractPath is refactored onto it (behavior unchanged); doctor.loadConfig uses it for both the contract and versions.conf. Precedence now lives in one shared function.
  • Consistent repo discovery in doctor. loadConfig resolves the checkout the way env does (DOTFILES_REPO_DIR when 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 .git walk-up), and drops the dead deployed-first helpers.
  • Provenance. dotf doctor prints always-visible [INFO] contract: <path> and [INFO] versions.conf: <path> so a stale-copy read is self-diagnosing.

Testing

  • env unit tests: ResolveRepoFirst precedence (repo → deployed → walk-up → "").
  • Anti-drift guard (doctor): with BOTH copies present, loadConfig resolves the repo copy and reads the repo pin (not the stale deployed one), and env.ResolveContractPath is cross-checked to agree.
  • go build/vet/test ./... clean; golangci-lint clean.
  • End-to-end: dotf doctor on 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.

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.
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mlorentedev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d2da957-f6ef-4461-bdef-4df50f179a8c

📥 Commits

Reviewing files that changed from the base of the PR and between 374d816 and f633eb8.

📒 Files selected for processing (9)
  • cli/internal/doctor/checks_tools.go
  • cli/internal/doctor/config.go
  • cli/internal/doctor/config_test.go
  • cli/internal/doctor/doctor.go
  • cli/internal/env/env.go
  • cli/internal/env/env_test.go
  • specs/BUG-030-doctor-env-shared-resolver/proposal.md
  • specs/BUG-030-doctor-env-shared-resolver/tasks.md
  • specs/BUG-030-doctor-env-shared-resolver/verification.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/doctor-env-shared-resolver

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mlorentedev
mlorentedev merged commit 54fe5ca into main Jul 10, 2026
13 checks passed
@mlorentedev
mlorentedev deleted the fix/doctor-env-shared-resolver branch July 10, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: doctor resolves contract/versions deployed-first while env generate is repo-first — contradictory verdicts

1 participant