Skip to content

Commit 34a1fe7

Browse files
fix: eliminate 3-level Skill tool nesting that breaks control flow (335b-c846) (merge worktree-20260325-170522)
2 parents 383f5aa + 4eb5f23 commit 34a1fe7

File tree

5 files changed

+96
-11
lines changed

5 files changed

+96
-11
lines changed

.test-index

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ tests/hooks/test-session-safety.sh: tests/scripts/test-v2-clean-guard.sh
145145
tests/scripts/test-validate-issues.sh: tests/scripts/test-v2-clean-guard.sh
146146
tests/scripts/test-read-config.sh: tests/scripts/test-v2-clean-guard.sh
147147
tests/scripts/test-flat-config-e2e.sh: tests/scripts/test-v2-clean-guard.sh
148+
plugins/dso/skills/implementation-plan/SKILL.md: tests/skills/test-skill-nesting-depth.sh
149+
plugins/dso/skills/design-wireframe/SKILL.md: tests/skills/test-skill-nesting-depth.sh

plugins/dso/skills/design-wireframe/SKILL.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,22 +724,27 @@ Create `designs/<uuid>/manifest.md` combining:
724724

725725
## Phase 5: Design Review (/dso:design-wireframe)
726726

727-
This phase uses `/dso:review-protocol` at Stage 2 (skipping Stage 1 because Phase 4's
727+
This phase uses `REVIEW-PROTOCOL-WORKFLOW.md` at Stage 2 (skipping Stage 1 because Phase 4's
728728
artifact consistency checkpoint already serves as the mental pre-review).
729729

730+
> **NESTING PROHIBITION**: Do NOT invoke `/dso:review-protocol` via the Skill tool here.
731+
> This skill may already be at nesting level 2+ (e.g., `sprint → preplanning → design-wireframe`).
732+
> A Skill tool call to `/dso:review-protocol` would create 3+ levels, which fails to return control.
733+
> Always read and execute the workflow inline.
734+
730735
### Step 16: Submit for committee review (/dso:design-wireframe)
731736

732737
Read [docs/review-criteria.md](docs/review-criteria.md) for reviewer prompt
733738
files and domain-specific review context.
734739

735-
Invoke `/dso:review-protocol` with:
740+
Read and execute `${CLAUDE_PLUGIN_ROOT}/docs/workflows/REVIEW-PROTOCOL-WORKFLOW.md` inline with:
736741

737742
- **subject**: "Design Wireframe: {story title}"
738743
- **artifact**: The design artifacts (manifest, spatial layout JSON, SVG wireframe description, design tokens) plus story context and epic context (if applicable)
739744
- **pass_threshold**: 4
740745
- **start_stage**: 2 (Phase 4 artifact validation serves as Stage 1)
741746
- **max_revision_cycles**: 3
742-
- **perspectives**: Defined by the four reviewer prompt files. For each reviewer, read its prompt file and map to the `/dso:review-protocol` perspective format:
747+
- **perspectives**: Defined by the four reviewer prompt files. For each reviewer, read its prompt file and map to the `REVIEW-PROTOCOL-WORKFLOW.md` perspective format:
743748

744749
**Reviewer 1 — Product Management** (from [docs/reviewers/product-manager.md](docs/reviewers/product-manager.md)):
745750
- Dimensions: `story_alignment`, `user_value`, `scope_appropriateness`, `consistency`, `epic_coherence`
@@ -761,7 +766,7 @@ Invoke `/dso:review-protocol` with:
761766

762767
Because design reviews genuinely benefit from diverse perspectives, **always use
763768
multi-agent dispatch** (one sub-agent per reviewer, launched in parallel via the
764-
Task tool). This bypasses `/dso:review-protocol`'s default single-agent approach.
769+
Task tool). This bypasses `REVIEW-PROTOCOL-WORKFLOW.md`'s default single-agent approach.
765770

766771
Since subagents cannot view images, describe the SVG wireframe's structure and
767772
spatial relationships in text when constructing each prompt.
@@ -780,7 +785,7 @@ The design **passes** if ALL dimension scores across ALL reviewers are 4, 5, or
780785
**Conflict detection**: Scan all findings for direct contradictions — pairs of
781786
suggestions that target the same component/artifact but pull in opposite directions
782787
(add vs remove, more vs less, strict vs flexible, expand vs reduce). Populate the
783-
`conflicts` array. Resolution follows `/dso:review-protocol`:
788+
`conflicts` array. Resolution follows `REVIEW-PROTOCOL-WORKFLOW.md`:
784789
- Critical vs minor: critical finding wins, no escalation
785790
- Both critical/major: escalate to user via AskUserQuestion
786791
- Both minor: caller chooses
@@ -795,7 +800,7 @@ record the aggregate pass/fail result.
795800

796801
### Step 18: Revise and re-submit (max 3 cycles) (/dso:design-wireframe)
797802

798-
Follow `/dso:review-protocol`'s revision protocol:
803+
Follow `REVIEW-PROTOCOL-WORKFLOW.md`'s revision protocol:
799804

800805
1. **Triage by severity**: Address critical findings first, then major, then minor.
801806
2. **Resolve conflicts first**: If `conflicts[]` is non-empty, resolve before revising.

plugins/dso/skills/implementation-plan/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ Copy and track as you work (standalone only):
5858
```
5959
Progress:
6060
- [ ] Step 1: Contextual Discovery (story loaded, context gathered, ambiguities resolved, cross-cutting detection done — layers: _, interfaces: _)
61-
- [ ] Step 2: Architectural Review via /dso:review-protocol (passed / skipped — no new pattern)
61+
- [ ] Step 2: Architectural Review via REVIEW-PROTOCOL-WORKFLOW.md inline (passed / skipped — no new pattern)
6262
- [ ] Step 3: Task Drafting (tasks drafted with E2E + docs coverage)
63-
- [ ] Step 4: Plan Review via /dso:review-protocol (all dimensions: 5, iteration: _/3)
63+
- [ ] Step 4: Plan Review via REVIEW-PROTOCOL-WORKFLOW.md inline (all dimensions: 5, iteration: _/3)
6464
- [ ] Step 5: Task Creation (tasks created, deps added, health validated)
6565
- [ ] Step 6: Gap Analysis (COMPLEX: opus sub-agent dispatched, findings processed; TRIVIAL: skipped)
6666
```

plugins/dso/skills/sprint/prompts/impl-plan-dispatch.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Use the `Read` tool at that path to load the skill. Then execute Steps 1-6 as de
3838
### Steps to Execute
3939

4040
- **Step 1**: Contextual Discovery — load story context, resolve ambiguities, detect cross-cutting changes (or reuse evaluator context if provided above)
41-
- **Step 2**: Architectural Review — invoke `/dso:review-protocol` if a new pattern is needed or cross-cutting thresholds are met; otherwise skip
41+
- **Step 2**: Architectural Review — read and execute `REVIEW-PROTOCOL-WORKFLOW.md` inline if a new pattern is needed or cross-cutting thresholds are met; otherwise skip
4242
- **Step 3**: Atomic Task Drafting — draft tasks with TDD-first, E2E coverage, and docs coverage
43-
- **Step 4**: Plan Review — invoke `/dso:review-protocol` with pass_threshold 5; iterate up to 3 times
43+
- **Step 4**: Plan Review — read and execute `REVIEW-PROTOCOL-WORKFLOW.md` inline with pass_threshold 5; iterate up to 3 times
4444
- **Step 5**: Task Creation — create tasks in tickets, add dependencies, validate ticket health
4545
- **Step 6**: Gap Analysis — dispatch opus sub-agent for COMPLEX stories; skip for TRIVIAL (uses evaluator-context classification)
4646

@@ -81,7 +81,7 @@ STATUS:blocked QUESTIONS:[{"text":"What is the expected response format for the
8181
### Rules
8282
- Do NOT: git commit, git push, .claude/scripts/dso ticket transition
8383
- You MAY use: .claude/scripts/dso ticket create (with --acceptance, -d flags), .claude/scripts/dso ticket link (required for Step 5 dependency wiring), direct `.tickets/<id>.md` editing for post-creation updates
84-
- Do NOT use the Task tool to dispatch nested sub-agents. Skill tool invocations (e.g., /dso:review-protocol) ARE permitted.
84+
- Do NOT use the Task tool to dispatch nested sub-agents. Do NOT invoke `/dso:review-protocol` via the Skill tool — use `REVIEW-PROTOCOL-WORKFLOW.md` inline instead (Skill nesting creates 3+ levels which fail to return control).
8585
- Do NOT invoke `/dso:commit`, `/dso:review`, or any slash-command other than Skill tool invocations required by the implementation-plan steps
8686
- Do NOT modify files outside the scope of task creation (no source code changes — this is planning only)
8787
- Only modify files under $(git rev-parse --show-toplevel). Do NOT write to any other path.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
# Test: Skill tool nesting depth safety
3+
# Bug: 335b-c846 — 3-level Skill tool nesting fails to return control
4+
#
5+
# Verifies that skills invoked from within sprint (2nd level) do NOT invoke
6+
# other skills via the Skill tool (which would create 3+ levels).
7+
# They must use "read and execute ... inline" for review workflows.
8+
9+
set -uo pipefail
10+
11+
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
12+
PASS=0
13+
FAIL=0
14+
15+
pass() { ((PASS++)); echo " PASS: $1"; }
16+
fail() { ((FAIL++)); echo " FAIL: $1"; }
17+
18+
echo "=== Skill Nesting Depth Tests ==="
19+
20+
# --- implementation-plan tests ---
21+
22+
IMPL_PLAN="$REPO_ROOT/plugins/dso/skills/implementation-plan/SKILL.md"
23+
24+
echo ""
25+
echo "-- implementation-plan checklist labels --"
26+
27+
# Test 1: Checklist must NOT reference "via /dso:review-protocol"
28+
if grep -q 'via /dso:review-protocol' "$IMPL_PLAN"; then
29+
fail "implementation-plan checklist references 'via /dso:review-protocol' (Skill tool invocation risk)"
30+
else
31+
pass "implementation-plan checklist does not reference 'via /dso:review-protocol'"
32+
fi
33+
34+
# Test 2: Checklist should reference the inline workflow pattern
35+
if grep -q 'REVIEW-PROTOCOL-WORKFLOW.md' "$IMPL_PLAN"; then
36+
pass "implementation-plan references REVIEW-PROTOCOL-WORKFLOW.md"
37+
else
38+
fail "implementation-plan does not reference REVIEW-PROTOCOL-WORKFLOW.md"
39+
fi
40+
41+
# Test 3: implementation-plan must NOT contain Skill( invocations
42+
if grep -qE 'Skill\(' "$IMPL_PLAN"; then
43+
fail "implementation-plan contains Skill() invocation — creates 3-level nesting from sprint"
44+
else
45+
pass "implementation-plan contains no Skill() invocations"
46+
fi
47+
48+
# --- design-wireframe tests ---
49+
50+
DESIGN_WF="$REPO_ROOT/plugins/dso/skills/design-wireframe/SKILL.md"
51+
52+
echo ""
53+
echo "-- design-wireframe review-protocol invocation --"
54+
55+
# Test 4: design-wireframe must NOT say "Invoke /dso:review-protocol"
56+
if grep -q 'Invoke.*/dso:review-protocol' "$DESIGN_WF"; then
57+
fail "design-wireframe invokes /dso:review-protocol via Skill tool (creates 3+ level nesting)"
58+
else
59+
pass "design-wireframe does not invoke /dso:review-protocol via Skill tool"
60+
fi
61+
62+
# Test 5: design-wireframe must reference REVIEW-PROTOCOL-WORKFLOW.md for its review
63+
if grep -q 'REVIEW-PROTOCOL-WORKFLOW.md' "$DESIGN_WF"; then
64+
pass "design-wireframe references REVIEW-PROTOCOL-WORKFLOW.md (inline pattern)"
65+
else
66+
fail "design-wireframe does not reference REVIEW-PROTOCOL-WORKFLOW.md"
67+
fi
68+
69+
# Test 6: design-wireframe Phase 5 must use "read and execute ... inline" pattern
70+
if grep -iq 'read and execute.*REVIEW-PROTOCOL-WORKFLOW' "$DESIGN_WF"; then
71+
pass "design-wireframe Phase 5 uses 'read and execute ... inline' pattern"
72+
else
73+
fail "design-wireframe Phase 5 does not use 'read and execute ... inline' pattern"
74+
fi
75+
76+
echo ""
77+
echo "=== Results: $PASS passed, $FAIL failed ==="
78+
[ "$FAIL" -eq 0 ]

0 commit comments

Comments
 (0)