Repository navigation
feat(task): add command inputs to cache - #11381
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTask artifact caching adds ChangesRuntime cache inputs
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TaskExecutor
participant CmdLineRunner
participant TaskArtifactCache
TaskExecutor->>TaskArtifactCache: prepare cache
TaskExecutor->>CmdLineRunner: execute cache.command_inputs
CmdLineRunner-->>TaskExecutor: return stdout/stderr hashes
TaskExecutor->>TaskArtifactCache: finish with command inputs
TaskArtifactCache-->>TaskExecutor: restore or populate artifact cache
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Greptile SummaryAdds command-derived task-cache inputs and the bounded execution infrastructure needed to hash their output safely.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (8): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/task/task_executor.rs (1)
540-559: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winBypass cache construction before evaluating runtime inputs.
TaskArtifactCache::newevaluatescache.runtimebefore this branch discards caching for raw/interactive execution. A raw task can therefore run a hidden probe such astouch markereven though artifact caching is bypassed. Gate this beforenew(or pass a bypass flag), and add a regression test.🤖 Prompt for 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. In `@src/task/task_executor.rs` around lines 540 - 559, Update the artifact-cache setup in the task execution flow to detect raw or interactive execution before calling TaskArtifactCache::new, bypassing cache construction and runtime-input evaluation entirely in that case. Preserve the existing warning and None result, while retaining normal cache construction for eligible tasks, and add a regression test covering a runtime probe that must not execute for raw or interactive tasks.
🤖 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 `@schema/mise.json`:
- Around line 2972-2977: Add the existing `runtime` array property definition to
`$defs.task_config.properties.cache`, alongside `enabled` and `env`, so
scoped-cache configurations accept and document runtime commands while
preserving `unevaluatedProperties: false`.
In `@src/task/task_cache.rs`:
- Around line 368-391: Update the runtime probe execution in the task-cache flow
around the process command construction so cache.runtime uses TaskExecutor’s
sandboxed, platform-normalized runner instead of invoking
tokio::process::Command directly. Preserve the existing command, environment,
working-directory, and output behavior while ensuring deny_env,
filesystem/network restrictions, CLI sandbox overrides, and Windows
POSIX-shell/PATH normalization are applied; add coverage for these policy paths.
---
Outside diff comments:
In `@src/task/task_executor.rs`:
- Around line 540-559: Update the artifact-cache setup in the task execution
flow to detect raw or interactive execution before calling
TaskArtifactCache::new, bypassing cache construction and runtime-input
evaluation entirely in that case. Preserve the existing warning and None result,
while retaining normal cache construction for eligible tasks, and add a
regression test covering a runtime probe that must not execute for raw or
interactive tasks.
🪄 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: 84f3fcfb-6bed-446a-bc47-5419ddac0425
📒 Files selected for processing (9)
TASK_CACHE_PARITY.mddocs/tasks/task-configuration.mde2e/tasks/test_task_artifact_cache_runtime_inputsschema/mise-task.jsonschema/mise.jsonsrc/task/mod.rssrc/task/task_cache.rssrc/task/task_executor.rssrc/task/task_template.rs
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
e2e/tasks/test_task_artifact_cache_command_inputs (1)
44-52: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMake the working-directory probe path-sensitive.
pwdsucceeds from any directory, and this test never validates its output, so it passes if command inputs run from the caller’s directory. Usetest -f nested-only-input.txtwith a sentinel created only undernested/to make the assertion meaningful.🤖 Prompt for 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. In `@e2e/tasks/test_task_artifact_cache_command_inputs` around lines 44 - 52, Update the command-inputs test around the [tasks.check] configuration to use a path-sensitive probe: create the sentinel file only inside nested/, replace the pwd command input with test -f nested-only-input.txt, and retain the existing assertion that the task runs once. Ensure the probe can succeed only when command inputs execute from the nested working directory.src/task/task_cache.rs (1)
383-392: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftStream command input outputs into BLAKE3 hashes.
resolve_command_inputs()uses.output()after piping stdout/stderr, accumulating the entire command output before hashing it. Since only digest values are needed, write the child’s stdout and stderr directly into hash writers and add a timeout/break when the hash writes too much.🤖 Prompt for 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. In `@src/task/task_cache.rs` around lines 383 - 392, Update the command execution flow in resolve_command_inputs() to stream the child process’s stdout and stderr into BLAKE3 hash writers instead of collecting them with output(). Preserve the digest-only behavior, and enforce a timeout or size limit that aborts processing when hash writes exceed the allowed threshold.
🤖 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.
Outside diff comments:
In `@e2e/tasks/test_task_artifact_cache_command_inputs`:
- Around line 44-52: Update the command-inputs test around the [tasks.check]
configuration to use a path-sensitive probe: create the sentinel file only
inside nested/, replace the pwd command input with test -f
nested-only-input.txt, and retain the existing assertion that the task runs
once. Ensure the probe can succeed only when command inputs execute from the
nested working directory.
In `@src/task/task_cache.rs`:
- Around line 383-392: Update the command execution flow in
resolve_command_inputs() to stream the child process’s stdout and stderr into
BLAKE3 hash writers instead of collecting them with output(). Preserve the
digest-only behavior, and enforce a timeout or size limit that aborts processing
when hash writes exceed the allowed threshold.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 3be3136c-f616-4fc5-bc6e-8863862dd52b
📒 Files selected for processing (8)
TASK_CACHE_PARITY.mddocs/tasks/task-configuration.mde2e/tasks/test_task_artifact_cache_command_inputsschema/mise-task.jsonschema/mise.jsonsrc/task/mod.rssrc/task/task_cache.rssrc/task/task_template.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- src/task/task_template.rs
- src/task/mod.rs
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit be62db9. Configure here.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
e2e/tasks/test_task_artifact_cache_command_inputs (1)
114-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
shell-overridetest doesn't verify anything shell-specific.
command_inputs = ["true"]succeeds identically regardless of which shell runs it, so this test would pass even if the--shell "sh -c"CLI override were silently ignored for command-input resolution. Every other test added in this file ends with a concreteassert/assert_fail_contains; this one only has a trailing comment.Consider a command that only succeeds/produces distinguishable output under the overridden shell (e.g. writing shell-specific syntax to a marker file and asserting its contents), so the test actually exercises the described "command inputs honor the CLI shell override" behavior rather than just "the invocation didn't crash."
🤖 Prompt for 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. In `@e2e/tasks/test_task_artifact_cache_command_inputs` around lines 114 - 127, Strengthen the shell-override test around the shell-override task so command_inputs uses syntax or behavior specific to the CLI-provided “sh -c” shell, then add a concrete assertion validating the resulting marker/output. Replace the current universally successful command_inputs entry and trailing comment while preserving the existing mise run invocation.
🤖 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 `@src/cmd.rs`:
- Around line 1082-1170: Make TimeoutGuard self-cancelling by implementing Drop
for the TimeoutGuard type and invoking its existing idempotent cancel method
during destruction. Preserve the explicit cancellation in execute_hashes_async
and other existing call sites, ensuring all early returns from consume errors,
wait failures, and drain failures also stop the timeout worker.
In `@src/task/task_executor.rs`:
- Around line 1258-1264: Update the timeout parsing in
resolve_cache_command_inputs around the timeout expression to match
exec_program’s non-fatal behavior: warn when task.timeout cannot be parsed, then
fall back to running without an enforced timeout rather than propagating the
error with wrap_err_with and ?. Preserve COMMAND_INPUT_TIMEOUT for absent or
otherwise valid timeout values as appropriate.
---
Nitpick comments:
In `@e2e/tasks/test_task_artifact_cache_command_inputs`:
- Around line 114-127: Strengthen the shell-override test around the
shell-override task so command_inputs uses syntax or behavior specific to the
CLI-provided “sh -c” shell, then add a concrete assertion validating the
resulting marker/output. Replace the current universally successful
command_inputs entry and trailing comment while preserving the existing mise run
invocation.
🪄 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: 70bb6475-35ad-4e8a-b8aa-133d052f4ac4
📒 Files selected for processing (6)
docs/tasks/task-configuration.mde2e/tasks/test_task_artifact_cache_command_inputsschema/mise.jsonsrc/cmd.rssrc/task/task_cache.rssrc/task/task_executor.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/tasks/task-configuration.md
Hyperfine Performance
|
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.14 x -- echo |
18.2 ± 2.7 | 15.5 | 32.5 | 1.00 |
mise x -- echo |
19.8 ± 1.2 | 17.1 | 24.5 | 1.08 ± 0.17 |
mise env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.14 env |
17.6 ± 0.9 | 15.8 | 22.0 | 1.00 |
mise env |
19.1 ± 1.2 | 16.2 | 23.9 | 1.09 ± 0.09 |
mise hook-env
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.14 hook-env |
18.4 ± 1.0 | 16.3 | 22.3 | 1.00 |
mise hook-env |
20.0 ± 1.1 | 17.4 | 25.1 | 1.09 ± 0.08 |
mise ls
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
mise-2026.7.14 ls |
16.5 ± 1.1 | 14.2 | 21.6 | 1.00 |
mise ls |
19.1 ± 1.4 | 16.3 | 23.9 | 1.16 ± 0.12 |
ls measured 16% slower, but the relative uncertainty overlaps the 10% threshold. |
xtasks/test/perf
| Command | mise-2026.7.14 | mise | Variance |
|---|---|---|---|
| install (cached) | 163ms | 177ms | -7% |
| ls (cached) | 64ms | 69ms | -7% |
| bin-paths (cached) | 66ms | 72ms | -8% |
| task-ls (cached) | 90ms | 97ms | -7% |
Cache command inputs are non-interactive probes with piped output, so detach stdin and always setpgid instead of skipping the process group when stdin is a terminal. Timeout, output-limit, and stuck-pipe cleanup now reaches descendants rather than only the direct child. Also fixes the clippy argument-count error on TaskArtifactCacheBuilder::finish and the tasks info JSON fixture, which did not include the new cache.command_inputs field. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Instruction counts
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.
|

Summary
cache.command_inputscommands whose command text and raw stdout/stderr hashes participate in task artifact cache keysUser impact
Cacheable tasks can now invalidate on command-derived state that is not naturally represented by source files, such as compiler versions or generated configuration fingerprints. The setting also works through scoped
[task_config.cache]defaults.Validation
cargo test --bin mise task::task_cache::testsmise run test:e2e e2e/tasks/test_task_artifact_cache_command_inputsmise run render:schemamise run lint-fixSummary by CodeRabbit
cache.command_inputsto run specified commands before cache lookup and include their stdout/stderr (and the command text) in task cache keys.Note
Medium Risk
Runs user-defined shell commands on every cache key computation with task env/sandbox; mistakes could cause stale hits or unexpected side effects, though output is capped and the feature remains experimental.
Overview
Adds experimental
cache.command_inputsso cacheable tasks can fold runtime-derived state (e.g.node --version) into artifact cache keys, not only declared sources andcache.env.Before lookup, each listed command runs in the task directory with the same inline shell (including
--shell), resolved tools/env, sandbox policy, and timeout as the task (30s default). Command text plus blake3 hashes of stdout/stderr are serialized into cache key material; output is not printed or stored. Empty commands and non-zero exits fail configuration/lookup; dry runs, raw tasks, and invalid overlap checks skip running them.TaskArtifactCache::newis split intoprepare(sources/outputs validation) andfinish(after command inputs resolve).CmdLineRunner::execute_hashes_asyncstreams piped output into hashes with a 16 MiB cap, uses process groups for cleanup on timeout/limit breaches, and refactors Unix/Windows tree kill helpers used by timeout handling.Reviewed by Cursor Bugbot for commit c5814eb. Bugbot is set up for automated code reviews on this repo. Configure here.