Skip to content

fix(task): fix source freshness for workspace-rooted patterns in subproject tasks#11202

Merged
jdx merged 1 commit into
jdx:mainfrom
rabadin:fix/task-source-freshness-monorepo-subproject
Jul 23, 2026
Merged

fix(task): fix source freshness for workspace-rooted patterns in subproject tasks#11202
jdx merged 1 commit into
jdx:mainfrom
rabadin:fix/task-source-freshness-monorepo-subproject

Conversation

@rabadin

@rabadin rabadin commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

In a monorepo setup where a subproject has its own mise.toml nested
inside a workspace, tasks that use source patterns rooted at the
workspace root do not correctly track files inside the subproject
directory — edits there do not trigger a rebuild.

Example:

# /workspace/mise.toml
[vars]
workspace_root = "{{ config_root }}"

[settings.task]
source_freshness_hash_contents = true

# /workspace/lib/worker/mise.toml
[tasks.build]
run = "echo built"
sources = ["{{ vars.workspace_root }}/lib/**/*"]
outputs = { auto = true }

Running from lib/worker/, the second mise run build after editing
worker.go (inside lib/worker/) is incorrectly skipped — the task
reports fresh despite the change.

Root cause: build_source_matcher was anchored at the task CWD
(lib/worker/). Source patterns are template-expanded to absolute paths
like /workspace/lib/**/*. The matcher's relativize_pattern tries to
strip the task CWD as a prefix from this path, fails (since lib/**/*
is not under lib/worker/), and leaves the pattern as a raw absolute
string. The Override matcher then can't match files against it, returning
Match::Ignore for everything inside the subproject — silently dropping
them from source tracking.

Fix: replace relativize_pattern with normalize_pattern(match_root, task_cwd, pattern). The matcher is now anchored at the outermost config root that is an ancestor of the task CWD (the workspace root). Absolute patterns are stripped of that prefix as before. Relative patterns are prefixed with the task-CWD-relative-to-workspace path so they remain anchored at the subproject, not the workspace root.

Note: the fix was mostly created by Claude since I'm not that familiar with Rust... and I'm not too sure about the fix... but the e2e test should make it clear what the problem is at least.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed task source freshness checks for tasks in subprojects.
    • Changes to files within a subproject or shared workspace files now correctly trigger task reruns.
    • Improved handling of relative and workspace-rooted source patterns, while preserving skip behavior when no sources have changed.
  • Tests

    • Added end-to-end coverage for initial runs, unchanged-source skips, and rebuilds after modifying local or shared files.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 94936949-0871-409e-a705-fd4d58646596

📥 Commits

Reviewing files that changed from the base of the PR and between 35fd845 and 0f2b9a7.

📒 Files selected for processing (3)
  • e2e/tasks/test_task_source_freshness_subproject
  • src/task/task_script_parser.rs
  • src/task/task_source_checker.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • e2e/tasks/test_task_source_freshness_subproject
  • src/task/task_script_parser.rs
  • src/task/task_source_checker.rs

📝 Walkthrough

Walkthrough

Changes

Subproject source freshness

Layer / File(s) Summary
Normalize source patterns
src/task/task_source_checker.rs
Source matchers distinguish the outer project root from the task directory and normalize absolute, relative, and negated patterns accordingly.
Integrate and validate freshness
src/task/task_source_checker.rs, src/task/task_script_parser.rs, e2e/tasks/test_task_source_freshness_subproject
Freshness checks select the outermost project root, callers use the new matcher signature, and tests verify rebuilds and skips across subproject and shared files.

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

Possibly related PRs

  • jdx/mise#11098: Related task source tracking and freshness-state changes.

Poem

I’m a rabbit who watches the source paths hop,
A workspace change makes the builder stop—
Then files within the burrow make it run,
While quiet repeats are skipped, one by one.
Freshness now follows every trail,
Across the root, without fail!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: source freshness handling for workspace-rooted patterns in subproject tasks.
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.

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 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes source freshness checks for tasks defined in nested workspace projects. The main changes are:

  • Anchors source matching at the outermost applicable config root.
  • Keeps relative source patterns scoped to the task working directory.
  • Updates the task script parser for the new matcher interface.
  • Adds unit and end-to-end tests for nested project sources.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues were found in the updated code.
  • The workspace and subproject source paths are covered by focused tests.

Important Files Changed

Filename Overview
src/task/task_source_checker.rs Separates the matcher root from the task directory and normalizes workspace-rooted and relative source patterns.
src/task/task_script_parser.rs Updates source matcher construction to use the expanded interface while retaining task-directory matching.
e2e/tasks/test_task_source_freshness_subproject Tests freshness updates for files inside and outside a nested task directory under one workspace source glob.

Reviews (2): Last reviewed commit: "fix(task): fix source freshness for work..." | Re-trigger Greptile

Comment thread src/task/task_source_checker.rs
@rabadin

rabadin commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Hey @jlarmstrongiv / @risu729, maybe you would be interested in looking at this since you've changed this part of the code most recently. I would appreciate any help on fixing this.

…roject tasks

In a monorepo, tasks in a subproject with workspace-rooted source
patterns (e.g. `{{ vars.workspace_root }}/lib/**/*`) silently failed to
track files inside the subproject directory, so edits there never
triggered a rebuild.

The matcher was anchored at the task CWD, so template-expanded absolute
patterns couldn't be relativized to it — leaving them as raw absolute
strings the Override matcher couldn't evaluate, returning Match::Ignore
for all files in the subproject.

Fix: anchor the matcher at the workspace root and normalize patterns
relative to it — absolute patterns are stripped of the workspace prefix,
relative patterns are prefixed with the subproject path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rabadin
rabadin force-pushed the fix/task-source-freshness-monorepo-subproject branch from 35fd845 to 0f2b9a7 Compare July 22, 2026 23:02
@jdx
jdx merged commit 7bef55c into jdx:main Jul 23, 2026
33 checks passed
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.

2 participants