feat(epic-execute): reconcile TDD test specs with design plan

Design phase improvement #7:

- Add build_planned_test_files_context, which extracts the test_files the
  design phase already planned (resume-safe: in-memory then persisted file)
- Inject it into the test-spec phase prompt so TDD reuses the planned test
  files and paths instead of independently deciding the test surface, and
  flags any deviation

Returns empty (no-op) when there is no plan, no test_files, or jq is absent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Caleb 2026-06-03 06:05:33 -05:00
parent 33d55f902c
commit 4f0a4f4a03
2 changed files with 50 additions and 1 deletions

View File

@ -507,6 +507,48 @@ get_last_design() {
echo "$LAST_DESIGN" echo "$LAST_DESIGN"
} }
# Build a focused "planned test files" context block from the design plan (#7).
# Lets the TDD test-spec phase reuse the test files the design already proposed,
# rather than independently deciding the test surface. Reads the in-memory plan
# first, then the persisted file (resume-safe). Requires a JSON plan + jq.
# Arguments:
# $1 - story_id
build_planned_test_files_context() {
local story_id="$1"
local design="$LAST_DESIGN"
if [ -z "$design" ] && [ -n "${DESIGN_DIR:-}" ]; then
local design_file="$DESIGN_DIR/${story_id}-design.md"
[ -f "$design_file" ] && design=$(cat "$design_file")
fi
if [ -z "$design" ] || ! command -v jq >/dev/null 2>&1; then
echo ""
return
fi
local files
files=$(echo "$design" | jq -r '.test_files[]? | "- \(.path): \(.covers)"' 2>/dev/null || echo "")
if [ -z "$files" ]; then
echo ""
return
fi
cat << EOF
## Planned Test Files (from design phase)
The design phase already identified the intended test files below. Align your
specifications with these paths and reuse them; only introduce a new test file
when a scenario genuinely isn't covered here, and call out any deviation.
<planned-test-files>
$files
</planned-test-files>
EOF
}
# Build the design context block for dev phase prompt # Build the design context block for dev phase prompt
# Returns formatted design context for inclusion in prompts # Returns formatted design context for inclusion in prompts
build_design_context_for_dev() { build_design_context_for_dev() {

View File

@ -54,6 +54,13 @@ execute_test_spec_phase() {
design_context=$(get_last_design) design_context=$(get_last_design)
fi fi
# Get the test files the design phase already planned, so the test-spec
# phase reuses them instead of deciding the test surface independently (#7).
local planned_tests=""
if type build_planned_test_files_context >/dev/null 2>&1; then
planned_tests=$(build_planned_test_files_context "$story_id")
fi
local spec_prompt="You are a Test Architect (TEA) generating test specifications from acceptance criteria. local spec_prompt="You are a Test Architect (TEA) generating test specifications from acceptance criteria.
## Your Task ## Your Task
@ -89,7 +96,7 @@ $arch_contents
<design> <design>
$design_context $design_context
</design> </design>
$planned_tests
## Exploration Commands ## Exploration Commands
First, explore existing test patterns in the codebase: First, explore existing test patterns in the codebase: