Skip to content

feat: add --cache/--no-cache CLI flags to vp run#196

Merged
branchseer merged 8 commits intomainfrom
claude/refactor-cache-config-WadB1
Mar 5, 2026
Merged

feat: add --cache/--no-cache CLI flags to vp run#196
branchseer merged 8 commits intomainfrom
claude/refactor-cache-config-WadB1

Conversation

@branchseer
Copy link
Member

Summary

Adds --cache and --no-cache CLI flags to vp run that override the global cache configuration:

  • --cache forces caching on for all tasks and scripts (per-task cache: false is still respected)
  • --no-cache forces all caching off
  • The two flags are mutually exclusive
  • Flags work in nested vp run commands within task scripts — a nested vp run --no-cache inner will disable caching for the inner execution regardless of the parent's config

Examples

# Force caching off for this run
vp run build --no-cache

# Force caching on even if globally disabled
vp run test --cache

Architectural change

Global cache resolution has been moved from task graph load time to the plan stage. The task graph now stores per-task cache config without applying the global kill switch, and the final cache decision is made at plan time where CLI overrides are available. This enables proper support for nested vp run --cache/--no-cache.

Test plan

  • All existing plan snapshot tests pass with updated snapshots
  • All existing e2e snapshot tests pass
  • cargo test -p vite_task_graph --lib unit tests pass
  • cargo clippy clean on all modified crates

Copy link
Member Author

branchseer commented Mar 5, 2026

claude added 8 commits March 5, 2026 10:47
…lan stage

Move global cache config resolution from task graph load time to plan
time, enabling CLI overrides and proper nested vp run support.

Key changes:
- Add TaskSource enum to distinguish TaskConfig vs PackageJsonScript
- Store ResolvedGlobalCacheConfig on IndexedTaskGraph without applying
  the global kill switch at graph load time
- Add CacheOverride enum (None/ForceEnabled/ForceDisabled) to PlanOptions
- Add --cache and --no-cache flags to RunFlags with conflicts_with
- Compute final ResolvedGlobalCacheConfig in PlanContext by combining
  graph config with CLI override
- Apply effective_cache_config per task at plan time using TaskSource
- Nested vp run --cache/--no-cache overrides parent's resolved config

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
… scope

Add two new plan snapshot test fixtures:

- cache-cli-override: Tests CLI flag overriding rules
  - --cache enables task/script caching when globally disabled
  - --cache does not override per-task cache: false
  - --no-cache disables caching even with per-task cache: true
  - --cache and --no-cache conflict produces an error

- nested-cache-override: Tests scope of nested vp run cache flags
  - nested --no-cache disables inner task caching
  - nested --cache enables inner task caching
  - nested run without flags inherits parent resolved cache
  - outer --no-cache does not propagate into nested --cache
  - outer --no-cache propagates to nested run without flags

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
The task graph now stores per-task cache config without applying the global
kill switch. Add plan test cases to verify cache is correctly resolved to
null at plan time when the global config disables caching.

Updated fixtures (commands changed from echo to print-file to produce
Spawn nodes with visible cache_metadata in plan snapshots):

- cache-tasks-disabled: verify tasks/scripts not cached with cache.tasks: false
- cache-scripts-default: verify scripts not cached by default
- cache-scripts-task-override: verify tasks cached, scripts not cached by default
- cache-true-no-force-enable: verify per-task cache: false respected with cache: true

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
Change nested-cache-override fixture from `"cache": true` to default
config (scripts: false, tasks: true). This makes the tests more
meaningful since scripts aren't cached by default.

Add "outer --cache propagates to nested run without flags" test case
to verify that `vp run --cache outer` where outer runs `vp run inner`
correctly caches the inner script despite scripts being off globally.

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
Update CacheOverride::None doc to explain inheritance from parent context.
Add comments on the if-guard in plan_query_request explaining why skipping
the update enables propagation, and why overrides are relative to the
workspace config rather than the parent's resolved state.

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
--cache acts as cache: true, overriding both cache.tasks and
cache.scripts (not just scripts). Restructure the decision tree
to reflect that --cache/--no-cache are resolved first as global
overrides, then per-task cache: false is checked, then the
task-vs-script distinction determines which global switch applies.

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
Per-task cache: false only applies to tasks (scripts can't have it),
so it belongs under the task branch, not before the task/script split.

https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
@branchseer branchseer force-pushed the claude/refactor-cache-config-WadB1 branch from 31fd15f to 2537b34 Compare March 5, 2026 02:49
Copy link
Member Author

branchseer commented Mar 5, 2026

Merge activity

  • Mar 5, 6:12 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 5, 6:12 AM UTC: @branchseer merged this pull request with Graphite.

@branchseer branchseer merged commit db49c4f into main Mar 5, 2026
7 checks passed
@branchseer branchseer deleted the claude/refactor-cache-config-WadB1 branch March 5, 2026 06:12
branchseer added a commit that referenced this pull request Mar 5, 2026
## Summary
- Add skip rule and prune rule to prevent infinite recursion when workspace root tasks reference themselves (e.g., `"build": "vp run -r build"`)
- Reject unknown fields in `vite-task.json` with `deny_unknown_fields`
- Test coverage for extra_arg interaction and `cd` changing the cwd

## Stack
- #196

## Test plan
- [x] Plan snapshot tests for self-reference, multi-command, mutual recursion, depends-on passthrough, cd-no-skip fixtures
- [x] Unit tests for unknown field rejection at top-level and task-level
- [x] All plan snapshot tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

3 participants