Skip to content

feat(task): include dependency artifacts in cache keys - #11340

Merged
jdx merged 2 commits into
mainfrom
agent/task-cache-dependency-keys
Jul 26, 2026
Merged

jdx merged 2 commits into
mainfrom
agent/task-cache-dependency-keys

Conversation

@jdx

@jdx jdx commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • include direct dependency artifact keys in a task's cache key
  • let dependents restore cached outputs after cacheable dependencies execute, skip, or restore
  • preserve conservative execution when a dependency did work without producing a stable artifact key
  • carry dependency cache state through nested task graphs
  • document the behavior and update the temporary parity tracker

This is the next experimental task-cache follow-up to #11328. It makes downstream artifact identities transitively reflect the dependency graph, closing the key prerequisite for changed-workspace execution parity.

User impact

Cacheable task graphs can now reuse downstream artifacts when their dependencies resolve to the same artifact identities. Changing an upstream task's inputs changes its artifact key and therefore invalidates the matching downstream cache key. Uncached or failed-to-store upstream work remains conservative and forces downstream execution.

Validation

  • mise run lint-fix
  • cargo fmt --all -- --check
  • cargo check --all-features
  • mise run test:e2e test_task_artifact_cache test_task_dep_invalidates_sources test_task_delegation_dedup

Note

Medium Risk
Changes core task scheduling, cache key hashing, and nested graph state propagation; incorrect key or dependency logic could cause stale restores or missed invalidation, though conservative unkeyed-dependency handling and new e2e tests mitigate this.

Overview
Experimental task artifact caching now folds direct dependency artifact keys into each task’s cache key, so downstream artifacts stay aligned with upstream inputs across execute, skip, and restore paths.

The scheduler tracks TaskCompletionState (completed tasks, whether they did work, and published cache keys) and TaskDependencyState per task. Dependents can restore from cache when dependencies expose stable keys; if a dependency ran without a key (e.g. cache disabled), dependents still execute conservatively. depends_post parents contribute keys the same way as regular dependencies. Nested run = [{ task = ... }] graphs merge completion state so delegated tasks do not rerun shared work.

Docs and the parity tracker describe the new key material and behavior; new e2e coverage exercises lib→app restores, invalidation on upstream change, uncached deps, and post-deps.

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved task artifact caching so downstream tasks restore or reuse cached outputs based on stable dependency cache identities.
    • Added safer invalidation: downstream artifacts are refreshed when dependency inputs change, while uncached dependencies trigger conservative re-execution.
  • New Features

    • Cache keys now incorporate dependency key material to strengthen cache correctness across task graphs.
  • Documentation

    • Updated cache-key and dependency interaction documentation, including cache failure (“miss”) semantics.
  • Tests

    • Expanded end-to-end coverage for dependency cache restoration/invalidation (including post-dependency behavior) and added a delegation deduplication scenario.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Task dependency tracking now carries stable artifact identities and structured completion outcomes. Artifact cache keys include dependency keys, enabling dependent restoration and conservative execution when identities are unavailable. Scheduling, documentation, and end-to-end coverage are updated.

Changes

Task cache dependency parity

Layer / File(s) Summary
Dependency completion and identity state
src/task/deps.rs, src/task/mod.rs
Dependency tracking records completed tasks, whether work occurred, and stable cache keys, with new public state types and APIs.
Cache-key and executor outcomes
src/task/task_cache.rs, src/task/task_executor.rs
Artifact cache keys include dependency identities, and task execution returns structured work and cache-key outcomes across skip, restore, and write paths.
Scheduler state propagation
src/cli/run.rs
The scheduler passes structured dependency state into execution and records work and cache identities after tasks finish.
Dependency cache scenarios and documentation
e2e/tasks/test_task_artifact_cache_dependencies, e2e/tasks/test_task_delegation_dedup, docs/tasks/task-configuration.md, TASK_CACHE_PARITY.md
Tests cover restoration, invalidation, identity reuse, conservative execution, post-dependency caching, and delegation deduplication; documentation and parity tracking describe the updated behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TaskScheduler
  participant Deps
  participant TaskExecutor
  participant TaskArtifactCache
  TaskScheduler->>Deps: Compute dependency state
  TaskScheduler->>TaskExecutor: Run task with completion state
  TaskExecutor->>TaskArtifactCache: Build key with dependency identities
  TaskArtifactCache-->>TaskExecutor: Return cache result and identity
  TaskExecutor-->>TaskScheduler: Return work and cache-key outcome
Loading

Possibly related PRs

  • jdx/mise#11328: Introduces the related task artifact caching behavior extended here for dependency identities and restoration.

Poem

I’m a rabbit with caches tucked under the moon,
Dependency keys make restores happen soon.
Stable identities tell tasks when to run,
While artifacts hop back, one by one.
Tests guard the burrow, docs shine bright—
The cache keeps thumping through the night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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 clearly matches the main change: dependency artifact keys are now included in task cache keys.

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 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR incorporates dependency artifact identities into task cache keys and propagates completion state through nested task graphs.

  • Tracks completed tasks, work status, and stable cache keys across scheduling boundaries.
  • Allows downstream cache restoration when dependencies publish stable artifact identities while retaining conservative execution for unkeyed work.
  • Merges nested graph completion state between sequential delegated task entries.
  • Adds dependency-cache and delegation-deduplication regression coverage.
  • Updates task-cache documentation and the parity tracker.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported stale nested completion-state issue is resolved: every successful injected graph returns its completed task state, that state is merged before the next sequential entry, and the subsequent graph prunes tasks using the same task identity.

Important Files Changed

Filename Overview
src/task/deps.rs Adds dependency artifact and completion-state bookkeeping, including propagation into pruned nested graphs.
src/task/task_executor.rs Uses dependency identities in cache decisions and merges each completed injected graph before processing the next sequential task entry.
src/cli/run.rs Carries structured dependency and completion outcomes between the scheduler, executor, and dependency graph.
src/task/task_cache.rs Extends task artifact keys with deterministic dependency artifact identities.
e2e/tasks/test_task_delegation_dedup Covers the previously reported repeated-delegation case and verifies that the delegated task and its dependency each execute once.
e2e/tasks/test_task_artifact_cache_dependencies Exercises downstream restoration, upstream invalidation, unkeyed dependency work, and post-dependency artifact identities.

Reviews (2): Last reviewed commit: "fix(task): propagate dependency cache st..." | Re-trigger Greptile

Comment thread src/task/task_executor.rs Resolved

@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: 2

🧹 Nitpick comments (1)
src/task/deps.rs (1)

344-363: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding unit tests for dependency_state/new_pruned cache-identity propagation.

This is the core of the new caching contract (three interacting signals: cache_keys, any_did_work, any_unkeyed_did_work), but the existing test module only covers cycle-detection. A few focused unit tests (e.g. a chain A→B→C verifying any_unkeyed_did_work when B has no key, and cache-key propagation surviving new_pruned) would guard against regressions in this fairly intricate logic.

🤖 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/deps.rs` around lines 344 - 363, Add focused unit tests covering
dependency_state’s three signals: cache_keys, any_did_work, and
any_unkeyed_did_work. Include an A→B→C dependency-chain case where B performed
work without a cache key, and a new_pruned case verifying cache-key propagation
remains intact; place them alongside the existing cycle-detection tests and use
the established test helpers.
🤖 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/task/deps.rs`:
- Around line 344-363: Update dependency_state() to include depends_post
relationships from post_dep_parents, folding cache keys and execution flags from
each post-dependency parent into TaskDependencyState alongside dep_edges. Ensure
artifact restoration or execution gating also requires those post-depend parents
to have executed or restored successfully when the post-task consumes their
outputs.

In `@TASK_CACHE_PARITY.md`:
- Line 81: Update the checklist item “Allow dependents to restore after
dependencies execute or restore” in TASK_CACHE_PARITY.md to qualify restoration
on dependencies publishing stable artifact keys; explicitly preserve that
unkeyed dependency work forces dependents to execute.

---

Nitpick comments:
In `@src/task/deps.rs`:
- Around line 344-363: Add focused unit tests covering dependency_state’s three
signals: cache_keys, any_did_work, and any_unkeyed_did_work. Include an A→B→C
dependency-chain case where B performed work without a cache key, and a
new_pruned case verifying cache-key propagation remains intact; place them
alongside the existing cycle-detection tests and use the established test
helpers.
🪄 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: 69e4620f-e0e7-4854-8fc8-cea325c0115f

📥 Commits

Reviewing files that changed from the base of the PR and between 35de0e2 and 3e86ceb.

📒 Files selected for processing (8)
  • TASK_CACHE_PARITY.md
  • docs/tasks/task-configuration.md
  • e2e/tasks/test_task_artifact_cache_dependencies
  • src/cli/run.rs
  • src/task/deps.rs
  • src/task/mod.rs
  • src/task/task_cache.rs
  • src/task/task_executor.rs

Comment thread src/task/deps.rs Resolved
Comment thread TASK_CACHE_PARITY.md Resolved

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e/tasks/test_task_artifact_cache_dependencies (1)

81-87: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert every restored artifact, not only the log and run counters.

These checks can pass while one deleted output remains missing: app-dist contains copied lib content, so it does not prove lib-dist was restored, and the post-dependency case never checks either output before the later source change recreates them. Add explicit content assertions immediately after each restore.

Proposed assertions
+assert "cat app-dist/result.txt" $'lib-one\napp'
...
+assert "cat lib-dist/result.txt" "lib-one"
...
+assert "cat parent-dist/result.txt" "parent-one"
+assert "cat after-dist/result.txt" $'parent-one\nafter'

Also applies to: 88-95, 104-112, 129-132

🤖 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_dependencies` around lines 81 - 87, Expand
the restore checks in the task artifact cache dependency test to assert the
expected contents of every restored artifact, not just log and run counters. Add
explicit content assertions immediately after each restore, including both
lib-dist and app-dist in the initial and post-dependency restore cases, and
preserve the existing checks around later source changes.
🤖 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_dependencies`:
- Around line 81-87: Expand the restore checks in the task artifact cache
dependency test to assert the expected contents of every restored artifact, not
just log and run counters. Add explicit content assertions immediately after
each restore, including both lib-dist and app-dist in the initial and
post-dependency restore cases, and preserve the existing checks around later
source changes.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: de6e0b01-e42f-4772-8253-bc9b15be4ad6

📥 Commits

Reviewing files that changed from the base of the PR and between 3e86ceb and 77dc5f9.

📒 Files selected for processing (5)
  • TASK_CACHE_PARITY.md
  • e2e/tasks/test_task_artifact_cache_dependencies
  • e2e/tasks/test_task_delegation_dedup
  • src/task/deps.rs
  • src/task/task_executor.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • TASK_CACHE_PARITY.md
  • src/task/deps.rs
  • src/task/task_executor.rs

@github-actions

Copy link
Copy Markdown
Contributor

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.14 x -- echo 16.9 ± 0.8 15.7 20.6 1.00
mise x -- echo 18.6 ± 1.4 16.7 33.5 1.10 ± 0.09

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.14 env 16.1 ± 0.7 14.7 19.5 1.00
mise env 17.4 ± 0.8 16.0 21.5 1.08 ± 0.07

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.14 hook-env 16.8 ± 0.8 15.6 19.8 1.00
mise hook-env 18.2 ± 1.0 16.8 24.1 1.08 ± 0.07

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.14 ls 14.6 ± 0.7 13.4 17.4 1.00
mise ls 15.9 ± 0.9 14.5 20.5 1.09 ± 0.08

xtasks/test/perf

Command mise-2026.7.14 mise Variance
install (cached) 150ms 165ms -9%
ls (cached) 55ms 59ms -6%
bin-paths (cached) 58ms 61ms -4%
task-ls (cached) 121ms 125ms -3%

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