Skip to content

feat: handle self-recursion in task planning#197

Merged
branchseer merged 9 commits intomainfrom
claude/plan-workspace-root-g14Nn
Mar 5, 2026
Merged

feat: handle self-recursion in task planning#197
branchseer merged 9 commits intomainfrom
claude/plan-workspace-root-g14Nn

Conversation

@branchseer
Copy link
Member

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

Test plan

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

🤖 Generated with Claude Code

Copy link
Member Author

branchseer commented Mar 5, 2026

@branchseer branchseer changed the title feat: handle workspace root self-recursion in task planning feat: handle self-recursion in task planning Mar 5, 2026
@branchseer branchseer force-pushed the claude/plan-workspace-root-g14Nn branch 2 times, most recently from 6dd3ac7 to b465100 Compare March 5, 2026 02:49
@branchseer branchseer force-pushed the claude/refactor-cache-config-WadB1 branch from 31fd15f to 2537b34 Compare March 5, 2026 02:49
@branchseer branchseer requested a review from fengmk2 March 5, 2026 03:02
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:13 AM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 5, 6:14 AM UTC: @branchseer merged this pull request with Graphite.

@branchseer branchseer changed the base branch from claude/refactor-cache-config-WadB1 to graphite-base/197 March 5, 2026 06:12
@branchseer branchseer changed the base branch from graphite-base/197 to main March 5, 2026 06:12
claude and others added 9 commits March 5, 2026 06:13
--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
When a workspace root task's command contains a `vp run` invocation that
expands back to include itself, the planner now handles this gracefully
instead of treating it as a fatal recursion error.

Two rules are implemented:
- Rule 1 (Skip): When a nested `vp run` query matches the parent query
  exactly, the subcommand is skipped (e.g., root's "build": "vp run -r build"
  when invoked via `vp run -r build`).
- Rule 2 (Prune): When the expanding task appears in a different query's
  expansion result, it is pruned from the graph and edges are reconnected
  through it (e.g., root's "build": "vp run -r build" when invoked via
  `vp run build` from root directory).

Mutual recursion (A→B→A) remains a fatal error via check_recursion.

To enable TaskQuery comparison for Rule 1, a GlobPattern wrapper type is
introduced that implements PartialEq by comparing source strings, and
PartialEq is derived through the entire type chain from PackageFilter
up to TaskQuery.

https://claude.ai/code/session_01QdDRLrGeycdzQ4g1FWX4pZ
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… rules

- Extra args don't affect skip/prune (they're in PlanOptions, not TaskQuery)
- `cd` before `vp run` changes the cwd, producing a different
  ContainingPackage query, so the skip rule correctly does not fire

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `deny_unknown_fields` to `UserRunConfig` so typos and removed
fields (like `cacheScripts`) produce a clear error at load time.
Task-level unknown fields were already rejected via the flatten chain
to `UserCacheConfig`.

Also fix 5 test fixtures still using the old `cacheScripts` field.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@branchseer branchseer force-pushed the claude/plan-workspace-root-g14Nn branch from ebb616f to 5f663f0 Compare March 5, 2026 06:13
@branchseer branchseer merged commit af0900f into main Mar 5, 2026
6 checks passed
@branchseer branchseer deleted the claude/plan-workspace-root-g14Nn branch March 5, 2026 06:14
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