Skip to content

fix(prune): preserve untrusted version file references - #11501

Merged
jdx merged 3 commits into
mainfrom
agent/fix-tracked-idiomatic-prune
Jul 30, 2026
Merged

jdx merged 3 commits into
mainfrom
agent/fix-tracked-idiomatic-prune

Conversation

@jdx

@jdx jdx commented Jul 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • preserve installed versions referenced by untrusted tracked idiomatic version files and plain .tool-versions
  • classify tracked configs with the same file-type and content rules used by parsing before applying the trust pre-check
  • consult config-root trust only, without carrying forward legacy individual-file trust checks
  • continue skipping executable templated .tool-versions without prompting or rendering them

Root cause

Tracked-config loading applied a blanket trust pre-check before parsing every tracked file. Idiomatic version files do not create trust records, so commands such as mise prune --tools silently discarded their references and could remove versions still used by other projects.

Reported in discussion #11483.

Validation

  • mise run format
  • cargo fmt --all -- --check
  • mise run test:e2e cli/test_prune_tracked_config_trust
  • mise run test:e2e config/test_tool_versions_trust_check config/test_trust_safe_config_tracked

AI-assisted — Tool: Codex; model: unavailable; version: unavailable.


Note

Medium Risk
Changes trust gating for all tracked-config consumers (prune, upgrade, ls), affecting which tool versions stay protected; logic is narrower and covered by new e2e tests.

Overview
Tracked config loading no longer treats every tracked path as trust-gated before parse. Commands like mise prune --tools were dropping references from idiomatic version files and plain .tool-versions because those files never get trust records, so installed versions could be pruned while still in use elsewhere.

Loading now skips ignored tracked configs up front and uses path_requires_trust so only configs that actually need trust (non-exempt mise.toml, templated .tool-versions) are skipped when untrusted. Plain .tool-versions and idiomatic files are still parsed without trust; templated untrusted files are skipped without rendering templates. Trust is checked against the config root only (legacy per-file trust checks removed from this path).

An e2e test covers idiomatic, plain, templated, and ignored tracked configs during mise prune --dry-run.

Reviewed by Cursor Bugbot for commit 9fecefb. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved pruning of tracked configuration files by skipping ignored paths before trust evaluation.
    • Tightened trust enforcement so untrusted configs are skipped only when trust is required (and the config is not global).
    • Untrusted .tool-versions files containing template expressions are no longer processed, preventing template evaluation side effects.
    • Safe/idiomatic configs that don’t require trust continue to be processed normally.
  • Tests
    • Added an end-to-end test validating that ignored/untrusted tracked configs are skipped during prune dry-runs, with no template side effects.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Tracked config discovery now evaluates trust requirements by config type, skips ignored paths before parsing, and gates untrusted tracked files by their trust roots. The prune end-to-end test verifies expected tool output and prevents template execution.

Changes

Tracked config trust handling

Layer / File(s) Summary
Determine per-path trust requirements
src/config/config_file/mod.rs, src/config/config_file/tool_versions.rs
Adds trust evaluation based on safe/paranoid settings, config type, and template syntax in .tool-versions files.
Gate tracked config loading and validate prune behavior
src/config/mod.rs, e2e/cli/test_prune_tracked_config_trust
Skips ignored tracked configs, checks trust roots for files requiring trust, and verifies prune does not render untrusted templates while reporting expected tools and skip messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Config as Config::get_tracked_config_files
  participant IgnoreCheck as config_path_is_ignored
  participant TrustCheck as config_file::path_requires_trust
  participant Prune as mise prune
  Config->>IgnoreCheck: Check tracked config path
  IgnoreCheck-->>Config: Return ignored status
  Config->>TrustCheck: Determine trust requirement
  TrustCheck-->>Config: Return requirement
  Config->>Prune: Skip or load tracked config
  Prune-->>Config: Produce dry-run output
Loading

Possibly related PRs

  • jdx/mise#11151: Changes safe-mode behavior in the same tracked-config trust evaluation paths.
  • jdx/mise#11152: Changes ignore and trusted-path precedence used during tracked-config discovery.

Suggested reviewers: risu729

Poem

I’m a rabbit guarding the config trail,
Untrusted templates shall not prevail.
Ignored paths hop safely by,
No marker wakes beneath the sky.
Prune bounds forward, bright and light! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: preserving version references during prune for untrusted tracked config files.

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.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes tracked-config trust checks file-type aware while preserving version references during pruning.

  • Retains versions referenced by untrusted idiomatic files and plain .tool-versions.
  • Skips ignored configs and untrusted templated .tool-versions before parsing.
  • Adds an end-to-end test covering retention, ignored files, and template side-effect prevention.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/config/config_file/mod.rs Adds centralized file-type and content-aware classification for whether tracked config parsing requires trust.
src/config/config_file/tool_versions.rs Classifies unreadable or templated .tool-versions files as requiring trust.
src/config/mod.rs Applies ignored-path handling and the new trust classification before parsing tracked configs.
e2e/cli/test_prune_tracked_config_trust Verifies referenced versions are retained while ignored and executable templated files remain skipped.

Reviews (3): Last reviewed commit: "fix(prune): respect ignored tracked conf..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/cli/test_prune_tracked_config_trust`:
- Around line 31-34: Update the assertions in the prune tracked-config trust
test to verify that the output includes dummy@3.0.0 as a prune candidate. Keep
the existing assertions for excluding versions 1.0.0 and 2.0.0, reporting the
untrusted tracked config, and confirming the marker is absent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 633ff031-07d0-4dd1-b455-df6bb6d05693

📥 Commits

Reviewing files that changed from the base of the PR and between ee3e917 and c7533c8.

📒 Files selected for processing (4)
  • e2e/cli/test_prune_tracked_config_trust
  • src/config/config_file/mod.rs
  • src/config/config_file/tool_versions.rs
  • src/config/mod.rs

Comment thread e2e/cli/test_prune_tracked_config_trust
@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Instruction counts

benchmark trend instructions Δ wall (min) Δ
env ▃▆▇█▇▇▆▅▇█▂▄▃▁▂▆▂▃▄ 84,667,469 → 84,728,647 +0.07% 22.52 → 23.01ms +2.19%
hook-env ▄▄▅▅▅▅▂▂▄▅▁▁▆▄▇▇▇▇█ 87,392,982 → 87,408,083 +0.02% 25.00 → 24.65ms -1.43%
ls ▆▄▅▅▄▅▃▁▇▇▂▄▆▅▅▇▅▃█ 76,715,378 → 76,821,793 +0.14% 17.47 → 20.37ms +16.59%
registry ▁▃▃▃▃▃▄▄▆▆▂▃▃▃▇▆▆▆█ 50,220,770 → 50,259,511 +0.08% 13.33 → 13.14ms -1.42%
startup ▃▃▃▃▃▃▄▄▆█▁▃▃▂▆█▅▄▆ 16,066,370 → 16,081,622 +0.09% 9.06 → 10.61ms +17.10%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

9fecefb27969 vs ca91ccc0c07d · measured on the runner, not pushed to the history.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7281d71. Configure here.

Comment thread src/config/mod.rs
Comment thread src/config/mod.rs
@jdx
jdx enabled auto-merge (squash) July 30, 2026 16:51
@jdx
jdx merged commit ac9998c into main Jul 30, 2026
36 checks passed
@jdx
jdx deleted the agent/fix-tracked-idiomatic-prune branch July 30, 2026 16:53
This was referenced Jul 30, 2026
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.

1 participant