Skip to content

Commit d38453f

Browse files
committed
config: add canonical execution-model.md and update references
1 parent 170a278 commit d38453f

8 files changed

Lines changed: 151 additions & 38 deletions

File tree

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"status": "open",
3-
"dependencies": [],
4-
"blocks": []
5-
}
2+
"status" : "in-progress",
3+
"dependencies" : [ ],
4+
"blocks" : [ ],
5+
"target_branch" : "v2.1"
6+
}

plugin/concepts/execution-model.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!--
2+
Copyright (c) 2026 Gili Tzabari. All rights reserved.
3+
Licensed under the CAT Commercial License.
4+
See LICENSE.md in the project root for license terms.
5+
-->
6+
# CAT Execution Model
7+
8+
This document is the canonical reference for CAT's execution hierarchy and wave-based parallelism model.
9+
10+
## Hierarchy
11+
12+
CAT organizes work in a five-level hierarchy:
13+
14+
```
15+
version
16+
└── issue
17+
└── sub-issue (decomposed from a parent issue when context is too large)
18+
└── wave (a batch of work items executed by one subagent)
19+
└── subagent (executes one wave in an isolated worktree)
20+
```
21+
22+
| Level | Description |
23+
|-------|-------------|
24+
| **version** | A major or minor release (e.g., `v2.1`). See `plugin/concepts/hierarchy.md`. |
25+
| **issue** | An atomic unit of work within a version. |
26+
| **sub-issue** | A child issue created by decomposing a parent issue that exceeds the context-size threshold. |
27+
| **wave** | A batch of work items assigned to one subagent. Items within a wave run in parallel; waves run sequentially only when a dependency exists between them. |
28+
| **subagent** | An isolated Claude instance that executes one wave inside a dedicated git worktree. |
29+
30+
## Waves
31+
32+
A **wave** is defined by a `### Wave N` subsection under `## Execution Waves` (or `## Sub-Agent Waves`) in plan.md.
33+
Each wave contains one or more top-level bullet items (`- `) listing the work to be done. Sub-items
34+
(indented bullets with ` - `) are informational and do not spawn additional subagents.
35+
36+
```markdown
37+
## Execution Waves
38+
39+
### Wave 1
40+
- Implement parser module
41+
- Add parser tests
42+
43+
### Wave 2
44+
- Implement formatter module
45+
- Add formatter tests
46+
- Run full test suite
47+
```
48+
49+
### Wave Parallelism
50+
51+
**All waves spawn simultaneously in a single API response.** There is no sequential waiting between
52+
waves unless an explicit dependency between them is declared. Within each wave, all items also run in
53+
parallel (each item is handled by the same subagent).
54+
55+
Ordering is sequential **only when a dependency exists** between waves (e.g., Wave 2 requires output
56+
produced by Wave 1). When no dependency exists, treat all waves as launching at the same time.
57+
58+
### When to Use Multiple Waves
59+
60+
Use multiple waves **only** when:
61+
62+
- Work items are genuinely independent (no data or file dependencies between waves)
63+
- Items in different waves modify **different files** (overlapping files cause merge conflicts)
64+
- The parallelism benefit justifies the added complexity
65+
66+
**Do NOT use multiple waves when:**
67+
68+
- Items must run in sequence (later items consume output from earlier ones)
69+
- Items modify the same files
70+
- The issue is small enough that parallelism adds no benefit
71+
72+
Plans with only 1 wave (or no waves at all) use single-subagent mode, spawning one implementation
73+
subagent with all items. Only plans with 2 or more distinct waves spawn parallel subagents.
74+
75+
## Sub-Issue Decomposition
76+
77+
A **sub-issue** is created when an issue's context size exceeds the safe threshold (approximately 80 K tokens
78+
or when compaction events occur). Decomposition splits the parent issue into smaller, focused child issues
79+
that each fit within a single subagent's context window.
80+
81+
Triggers for decomposition:
82+
- Token report shows issue approaching 40% threshold (80 K tokens)
83+
- Subagent has experienced compaction events
84+
- Pre-emptive analysis reveals the issue is too large before execution begins
85+
86+
After decomposition, the sub-issues are organized into waves following the same dependency analysis rules
87+
described above. See `plugin/skills/decompose-issue-agent/first-use.md` for the full decomposition workflow.
88+
89+
## Worktree Sharing and Push Coordination
90+
91+
All wave subagents share the same worktree (`WORKTREE_PATH`). They commit and push to the same issue branch.
92+
Each subagent must `git pull --rebase` before pushing to incorporate commits from other waves that completed
93+
first.
94+
95+
When pushing encounters a non-fast-forward rejection, the subagent retries up to 3 times, rebasing before
96+
each retry. See `plugin/concepts/parallel-execution.md` for the full push coordination protocol.
97+
98+
## index.json Ownership
99+
100+
`index.json` must be updated exactly once per issue run. The last wave alphabetically owns the index.json
101+
update:
102+
103+
- All waves except the last: do NOT update `index.json`
104+
- Last wave: updates `index.json` to `"status": "closed"` in its final commit
105+
106+
## Architecture Summary
107+
108+
```
109+
work-with-issue (main agent)
110+
|
111+
+---> Read plan.md directly
112+
| Detect ## Execution Waves / ### Wave N sections
113+
| Count top-level bullet items per wave
114+
|
115+
+---> [if 2+ waves] Spawn all wave subagents simultaneously
116+
| Wave 1: subagent handles all items in Wave 1 (parallel)
117+
| Wave 2: subagent handles all items in Wave 2 (parallel)
118+
| Worktree: shared
119+
| index.json: NO (all waves except last) / YES (last wave)
120+
|
121+
+---> Collect commits from all waves
122+
|
123+
+---> stakeholder-review (single review of combined work)
124+
|
125+
+---> work-merge (squashes all commits, single merge)
126+
```

plugin/concepts/hierarchy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ See LICENSE.md in the project root for license terms.
66
# CAT Hierarchy: MAJOR > MINOR > ISSUE
77

88
> **See also:** [version-paths.md](version-paths.md) for path construction functions and patterns.
9+
> **See also:** `plugin/concepts/execution-model.md` for the full execution hierarchy including waves and subagents.
910
1011
## Structure
1112

plugin/concepts/parallel-execution.md

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ See LICENSE.md in the project root for license terms.
55
-->
66
# Parallel Subagent Execution
77

8+
> See `plugin/concepts/execution-model.md` for the full execution model, hierarchy, and wave parallelism rules.
9+
810
CAT supports running independent work items in parallel by spawning multiple implementation subagents, each working on
911
its own assigned wave of items. Parallelism is opt-in: it only activates when plan.md contains a `## Execution Waves`
1012
section with multiple `### Wave N` subsections.
@@ -18,10 +20,9 @@ When the work skill starts executing an issue:
1820
3. **Parallel mode requires 2+ waves:** Plans with only 1 wave (or no waves at all) use single-subagent mode, spawning
1921
one implementation subagent with all items (default behavior). Only plans with 2 or more distinct waves spawn
2022
parallel subagents.
21-
4. **Parallel execution (2+ waves):** For each wave (in order), spawn one subagent per wave simultaneously.
22-
5. Wait for all subagents in the wave to complete before proceeding to the next wave.
23-
6. All subagents commit to the same issue branch (`v2.1-issue-name`).
24-
7. After all waves complete, `work-with-issue` merges their commit lists and proceeds to review and merge.
23+
4. **Parallel execution (2+ waves):** All wave subagents spawn simultaneously in a single API response.
24+
5. All subagents commit to the same issue branch (`v2.1-issue-name`).
25+
6. After all waves complete, `work-with-issue` merges their commit lists and proceeds to review and merge.
2526

2627
## Wave Section Syntax
2728

@@ -42,11 +43,8 @@ additional subagents.
4243
- Run full test suite
4344
```
4445

45-
In this example:
46-
- Wave 1 has 2 items (parsed module + tests)
47-
- Wave 2 has 3 items (formatter module + tests + test suite)
48-
- All Wave 1 items run in parallel
49-
- After Wave 1 completes, all Wave 2 items run in parallel
46+
In this example, Wave 1 and Wave 2 spawn simultaneously. If Wave 2 depends on Wave 1's output, declare that dependency
47+
explicitly in plan.md so the orchestrator waits for Wave 1 before delegating Wave 2 items.
5048

5149
## When to Use Execution Waves
5250

@@ -58,7 +56,7 @@ Use execution waves **only** when:
5856

5957
**Do NOT use waves when:**
6058

61-
- Items must run sequentially (later items consume output from earlier ones)
59+
- Items must run in sequence (later items consume output from earlier ones)
6260
- Items modify the same files
6361
- The issue is small enough that parallelism adds no benefit
6462
- There is only one item (or one wave of items)
@@ -74,7 +72,7 @@ The `work-with-issue` skill communicates this ownership in each subagent's deleg
7472

7573
## Worktree Sharing
7674

77-
All wave subagents share the same worktree (`WORKTREE_PATH`). They commit and push sequentially to the same branch.
75+
All wave subagents share the same worktree (`WORKTREE_PATH`). They commit and push to the same branch.
7876
Each subagent must `git pull --rebase` before pushing to incorporate commits from other waves that completed first.
7977

8078
The `work-merge` phase is transparent to parallelism — it squashes all commits from `TARGET_BRANCH..HEAD` regardless of
@@ -95,26 +93,3 @@ wave's commits have already been pushed). The coordination protocol is:
9593

9694
This ensures that even when subagents complete in unpredictable order, each subagent can eventually push its commits
9795
without forcing a merge or overwriting other waves' work.
98-
99-
## Architecture Summary
100-
101-
```
102-
work-with-issue (main agent)
103-
|
104-
+---> Read plan.md directly
105-
| Detect ## Execution Waves / ### Wave N sections
106-
| Count top-level bullet items per wave
107-
|
108-
+---> [if 2+ waves] Spawn one subagent per wave (parallel within wave)
109-
| Wave 1: subagent handles all items in Wave 1 (parallel)
110-
| Wave 2: subagent handles all items in Wave 2 (wait for Wave 1, then parallel)
111-
| Worktree: shared
112-
| index.json: NO (Wave 1) / YES (Wave 2, last)
113-
|
114-
+---> Collect commits from all waves
115-
|
116-
+---> stakeholder-review (single review of combined work)
117-
|
118-
+---> work-merge (squashes all commits, single merge)
119-
```
120-

plugin/concepts/token-warning.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ See LICENSE.md in the project root for license terms.
55
-->
66
# Workflow: Token Warning and Compaction Handling
77

8+
> See `plugin/concepts/execution-model.md` for the full execution hierarchy and sub-issue decomposition context.
9+
810
## When to Load
911

1012
Load this workflow when:

plugin/skills/decompose-issue-agent/first-use.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ See LICENSE.md in the project root for license terms.
66
# Decompose Issue
77

88
See `${CLAUDE_PLUGIN_ROOT}/concepts/version-paths.md` for version path conventions used throughout this skill.
9+
See `${CLAUDE_PLUGIN_ROOT}/concepts/execution-model.md` for the full execution hierarchy, wave definitions, and
10+
sub-issue decomposition context.
911

1012
## Purpose
1113

plugin/skills/plan-builder-agent/first-use.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ subagents to fabricate results.
8888

8989
## Sub-Agent Waves for Parallel Execution
9090

91+
> See `${CLAUDE_PLUGIN_ROOT}/concepts/execution-model.md` for the full wave execution model, hierarchy, and
92+
> parallelism rules.
93+
9194
When the issue has clearly independent work that can run simultaneously, use `## Sub-Agent Waves` with `### Wave N`
9295
sections to enable parallel subagent spawning. Use sparingly — only when items genuinely don't depend on each other
9396
and won't modify the same files.

plugin/skills/work-implement-agent/first-use.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ See LICENSE.md in the project root for license terms.
55
-->
66
# Work Phase: Implement
77

8+
> See `${CLAUDE_PLUGIN_ROOT}/concepts/execution-model.md` for the full execution model, wave definitions, and
9+
> parallelism rules.
10+
811
Implement phase for `/cat:work`. Displays preparing/implementing banners, verifies lock ownership,
912
and orchestrates subagent execution of the implementation plan.
1013

0 commit comments

Comments
 (0)