fix(workflow): correct grep anchor and add threshold=0 guard (#1979)
Two correctness bugs from @trek-e review: 1. Grep pattern `^<task` only matched unindented task tags, missing indented tasks in PLAN.md templates that use indentation. Fixed to `^\s*<task[[:space:]>]` which matches at any indentation level and avoids false positives on <tasks> or </task>. 2. Threshold=0 was documented to disable inline routing but the condition `TASK_COUNT <= INLINE_THRESHOLD` evaluated 0<=0 as true, routing empty plans inline even when the feature was disabled. Fixed by guarding with `INLINE_THRESHOLD > 0`. Added tests/inline-plan-threshold.test.cjs (8 tests) covering: - config-set accepts the key and threshold=0 - VALID_CONFIG_KEYS and planning-config.md contain the entry - Routing pattern matches indented tasks and rejects <tasks>/</task> - Inline routing is guarded by INLINE_THRESHOLD > 0 Review feedback on #2061 from @trek-e.
This commit is contained in:
@@ -61,16 +61,17 @@ PLAN_START_EPOCH=$(date +%s)
|
||||
|
||||
<step name="parse_segments">
|
||||
```bash
|
||||
TASK_COUNT=$(grep -c "^<task" .planning/phases/XX-name/{phase}-{plan}-PLAN.md 2>/dev/null || echo "0")
|
||||
# Count tasks — match <task tag at any indentation level
|
||||
TASK_COUNT=$(grep -cE '^\s*<task[[:space:]>]' .planning/phases/XX-name/{phase}-{plan}-PLAN.md 2>/dev/null || echo "0")
|
||||
INLINE_THRESHOLD=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" config-get workflow.inline_plan_threshold --default 2 2>/dev/null || echo "2")
|
||||
grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
|
||||
```
|
||||
|
||||
**Primary routing: task count threshold (#1979)**
|
||||
|
||||
If `TASK_COUNT <= INLINE_THRESHOLD`: Use Pattern C (inline) regardless of checkpoint type. Small plans execute faster inline — avoids ~14K token subagent spawn overhead and preserves prompt cache. Configure threshold via `workflow.inline_plan_threshold` (default: 2).
|
||||
If `INLINE_THRESHOLD > 0` AND `TASK_COUNT <= INLINE_THRESHOLD`: Use Pattern C (inline) regardless of checkpoint type. Small plans execute faster inline — avoids ~14K token subagent spawn overhead and preserves prompt cache. Configure threshold via `workflow.inline_plan_threshold` (default: 2, set to `0` to always spawn subagents).
|
||||
|
||||
If `TASK_COUNT > INLINE_THRESHOLD`: Apply checkpoint-based routing below.
|
||||
Otherwise: Apply checkpoint-based routing below.
|
||||
|
||||
**Checkpoint-based routing (plans with > threshold tasks):**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user