Repository navigation
fix(tasks): honor constitution test-first principles in tasks generation - #5634
TINGyu123644 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Contradictory test-trigger guidance across the command and output templates can still omit required story, contract, or phase test tasks, so the rules must be aligned.
2 open issues
What changed in this PR
This pull request updates task-generation prompts so constitution-mandated test-first development is recognized when producing tasks, and adds regression checks for the updated prompt contracts.
Changes:
- Adds constitution-based test-task requirements and failing-test ordering guidance.
- Updates the task output template’s test guidance and user-story headings.
- Adds prompt-contract regression tests covering both templates.
| File | Description |
|---|---|
| tests/test_tasks_template_constraints.py | Adds regression assertions for constitution-related task-generation prompt requirements. |
| templates/tasks-template.md | Updates test-task notes and user-story test headings to reference constitution-driven requirements. |
| templates/commands/tasks.md | Adds constitution-aware test-generation and failing-test ordering guidance. |
Review effort: Lite (adaptive)
| **CRITICAL**: Tasks MUST be organized by user story to enable independent implementation and testing. | ||
|
|
||
| **Tests are OPTIONAL**: Only generate test tasks if explicitly requested in the feature specification or if user requests TDD approach. | ||
| **Tests are OPTIONAL**: Only generate test tasks if explicitly requested in the feature specification, if the user requests a TDD approach, or if the loaded constitution requires test-first development. When a constitution principle mandates a failing test before implementation (for example, "a failing test MUST exist and be observed failing before implementation"), generate the failing-test task before each implementation task. Tests stay optional only for projects whose constitution does not require them. |
| **Prerequisites**: plan.md (required), spec.md (required for user stories), research.md, data-model.md, contracts/ | ||
|
|
||
| **Tests**: The examples below include test tasks. Tests are OPTIONAL - only include them if explicitly requested in the feature specification. | ||
| **Tests**: The examples below include test tasks. Tests are OPTIONAL - only include them if explicitly requested in the feature specification or required by the project constitution (for example, a test-first principle). |
|
Thanks for addressing this. Could we keep the prompt change concise and avoid prescribing test ordering? The “failing-test task before each implementation task” wording appears specific to the example constitution; each project should follow its own. Could That keeps the generation instructions and output template aligned, while leaving test-first ordering to the project constitution. |

Description
Fixes #5632.
/speckit-tasksloads.specify/memory/constitution.md, but its task-generation rules still said tests are optional unless the feature spec or the user asks for TDD. A constitution principle such as "a failing test MUST exist and be observed failing before implementation" was therefore ignored, and the generatedtasks.mdcould not pass/speckit-analyze's consistency checks.This change makes the constitution an explicit third source of test-task requirements:
templates/commands/tasks.md: when a loaded constitution requires test-first development, generate the failing-test task before each implementation task; tests stay optional only when the constitution does not require them.templates/tasks-template.md: the header note and all three user-story test headings now say tests are included when requested by the spec or required by the constitution.tests/test_tasks_template_constraints.py: two prompt-contract regression tests covering both templates.Testing
python -m pytest --noconftest tests/test_tasks_template_constraints.py -q→ 9 passed (7 existing + 2 new)..venv/bin/specify --help— not run: dependency installation stalled in this sandbox; no CLI behavior changes are included.testssuite — not run for the same dependency-install limitation; only the prompt-contract test file was executed.AI Disclosure
AI disclosure: WorkBuddy (Tencent Hunyuan Hy, agent mode, autonomous with human-supervised submission) was used to inspect the issue and repository templates, draft the template wording and the two regression tests, and run the focused pytest verification. The change is limited to prompt/template documentation text and tests; no CLI runtime code was generated or modified.