Skip to content

refactor(deps): store deps state under $MISE_STATE_DIR#9301

Merged
jdx merged 3 commits intomainfrom
claude/trusting-babbage-e73fda
Apr 22, 2026
Merged

refactor(deps): store deps state under $MISE_STATE_DIR#9301
jdx merged 3 commits intomainfrom
claude/trusting-babbage-e73fda

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Apr 22, 2026

Summary

  • Move the deps freshness state file from <project>/.mise/deps-state.toml to $MISE_STATE_DIR/deps/<hash>.toml, keyed by a SipHash of the project root — same pattern used for tracked-configs.
  • Stops mise from writing inside the project tree, where the file could easily be committed or conflated with project config.
  • Docs updated in docs/dev-tools/deps.md.

Why

deps is brand new (landed in #9056, 2026.4.18) and the state file currently sits inside the project directory. That's awkward — it's per-machine state, but it lives where users keep versioned config. Moving it under $MISE_STATE_DIR matches how other per-project state (tracked/trusted/ignored configs, env cache, hook-env checks) is stored.

Notes for reviewer

  • No migration needed: the feature is only a few days old, and the state is just a cache of blake3 hashes — on first run after upgrade, providers look stale and rehash. The user experience is one extra run, no breakage.
  • The pre-commit prettier step flagged two unrelated files on main (docs/backend-plugin-development.md, docs/url-replacements.md) where prettier wants to collapse GitHub's > [!WARNING] callout syntax onto a single line — that would actually break the GitHub alert rendering, so I left them alone. I used HK_SKIP_STEPS=prettier for this commit; all other lint steps (cargo-check, cargo-fmt, markdownlint, shellcheck, taplo, shfmt, schema, etc.) passed.

Test plan

  • Run mise deps in a project; confirm $MISE_STATE_DIR/deps/<hash>.toml is created and .mise/deps-state.toml is not.
  • Re-run mise deps; confirm providers report fresh (hashes matched from state dir).
  • Modify a source file; confirm provider reports stale.

This PR was generated by an AI coding assistant.


Note

Medium Risk
Changes where deps freshness state is read/written, which can cause all providers to appear stale once after upgrade or create unexpected state collisions if hashing/scoping is wrong; otherwise it’s cache-only state with limited blast radius.

Overview
Deps freshness state is no longer written to <project>/.mise/deps-state.toml; it is now persisted under $MISE_STATE_DIR/deps/<hash>.toml, where <hash> is derived from the project root path.

DepsState now computes its storage path via dirs::STATE and hash_to_str(project_root), keeping state per-project without touching the repo tree, and the docs are updated to reflect the new location.

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

Store per-project deps freshness state in
`$MISE_STATE_DIR/deps/<hash>.toml` (hashed by project root, mirroring the
`tracked-configs` pattern) instead of `<project>/.mise/deps-state.toml`.

Keeps mise from writing inside the project tree, where the file could
easily end up committed or conflated with project config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR moves the deps freshness state file from <project>/.mise/deps-state.toml to $MISE_STATE_DIR/deps/<siphash>.toml, scoped per-project via a SipHash of the project root path — consistent with how tracked-configs, hook-env, and other per-project state are stored. The remaining changes are unrelated idiomatic Rust cleanups (.iter().flat_map(|(_, t)| ...).values().flat_map(|t| ...), inner-if-to-match-guard refactors) that are all semantically equivalent.

Confidence Score: 5/5

Safe to merge — core change is a correct path relocation with no migration required, and all ancillary refactors are semantically equivalent.

No P0/P1 issues found. The state-path relocation is clean and mirrors existing patterns. All match-guard refactors preserve the original semantics because each affected arm matches a distinct enum variant, so a failed guard cannot accidentally match an unrelated sibling arm.

No files require special attention.

Important Files Changed

Filename Overview
src/deps/state.rs Core change: state_path now uses dirs::STATE.join(deps).join(hash_to_str(&project_root) + .toml) instead of project_root.join(.mise/deps-state.toml). Logic and error handling are unchanged.
crates/mise-interactive-config/src/editor/actions.rs Idiomatic refactor: inner if guards inside match arms converted to match guard syntax. Semantically equivalent because each pattern matches a distinct enum variant, so a failed guard cannot fall through to a sibling arm that would also match.
src/hooks.rs Same if→match-guard refactor for the Hooks::Cd arm; behavior is identical since Cd cannot fall through to Preinstall
src/config/mod.rs Minor idiomatic cleanup: .iter().flat_map(
src/task/task_executor.rs Same .values() cleanup as config/mod.rs; no semantic change.
src/task/task_output_handler.rs if task_needs_permit(task) moved to a match guard on TaskOutput::KeepOrder; semantically equivalent since the failed guard falls through to Replacing (different variant).
docs/dev-tools/deps.md Doc updated to reflect new state file location $MISE_STATE_DIR/deps/.toml; accurate.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["mise deps / task run"] --> B["DepsState::load(project_root)"]
    B --> C["state_path(project_root)"]
    C --> D["hash_to_str(&project_root)\n(SipHash 64-bit)"]
    D --> E["$MISE_STATE_DIR/deps/<hash>.toml"]
    E -->|"file exists"| F["Parse TOML → DepsState"]
    E -->|"file missing"| G["DepsState::default()"]
    F --> H["Check freshness\n(blake3 hashes)"]
    G --> H
    H -->|"stale / first run"| I["Re-hash sources\nDepsState::save(project_root)"]
    H -->|"fresh"| J["Skip provider"]
    I --> E

    style E fill:#d4edda,stroke:#28a745
    style D fill:#fff3cd,stroke:#856404
Loading

Reviews (3): Last reviewed commit: "[autofix.ci] apply automated fixes (atte..." | Re-trigger Greptile

Comment thread src/deps/state.rs
project_root.join(".mise").join("deps-state.toml")
dirs::STATE
.join("deps")
.join(format!("{}.toml", hash_to_str(&project_root)))
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.

P2 Unnecessary double-reference in hash_to_str call

project_root is already &Path, so &project_root produces &&Path. While the Hash blanket impl for &T delegates to T::hash, so the output is identical to passing project_root directly, this is a needless borrow that clippy::needless_borrow would flag. Every other callsite in the codebase (e.g. tracking.rs, hook_env.rs) passes &owned_value, not a double-ref.

Suggested change
.join(format!("{}.toml", hash_to_str(&project_root)))
.join(format!("{}.toml", hash_to_str(project_root)))

Fix in Claude Code

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request moves the dependency freshness state storage from a local .mise/deps-state.toml file to a centralized location in $MISE_STATE_DIR/deps/, using a hash of the project root for the filename. This change ensures that no state files are written inside the project directory. I have no feedback to provide as there were no review comments.

@github-actions
Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.18 x -- echo 22.3 ± 0.6 21.2 24.9 1.00
mise x -- echo 22.5 ± 0.5 21.6 24.4 1.01 ± 0.03

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.18 env 21.8 ± 0.7 20.8 28.1 1.00
mise env 22.8 ± 0.7 21.4 24.8 1.04 ± 0.05

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.18 hook-env 22.6 ± 0.6 21.6 26.3 1.00
mise hook-env 23.1 ± 0.7 21.9 27.1 1.02 ± 0.04

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.4.18 ls 19.8 ± 0.6 18.8 22.5 1.00
mise ls 20.6 ± 0.5 19.2 22.4 1.04 ± 0.04

xtasks/test/perf

Command mise-2026.4.18 mise Variance
install (cached) 144ms ⚠️ 168ms -14%
ls (cached) 76ms 79ms -3%
bin-paths (cached) 80ms 83ms -3%
task-ls (cached) 807ms 809ms +0%

⚠️ Warning: install cached performance variance is -14%

@jdx jdx merged commit d7b7f99 into main Apr 22, 2026
33 of 35 checks passed
@jdx jdx deleted the claude/trusting-babbage-e73fda branch April 22, 2026 16:36
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