From cf586e35863048459bdeae09c0992f0eefb180f4 Mon Sep 17 00:00:00 2001 From: chelsealong Date: Thu, 3 Sep 2026 16:34:33 +0000 Subject: [PATCH 1/2] fix(tasks): require field constraints from data-model.md in generated tasks /speckit.tasks mapped data-model.md entities to user stories but never told the agent to carry field-level constraints (max length, nullable, enum values, validation rules) into the task text. Left to discretion, the implementing agent can silently invent its own value instead of the one recorded in data-model.md. Fixes #4383 --- templates/commands/tasks.md | 1 + tests/test_tasks_template_constraints.py | 28 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/test_tasks_template_constraints.py diff --git a/templates/commands/tasks.md b/templates/commands/tasks.md index 64146a35aa..99e276fa7a 100644 --- a/templates/commands/tasks.md +++ b/templates/commands/tasks.md @@ -197,6 +197,7 @@ Every task MUST strictly follow this format: - Map each entity to the user story(ies) that need it - If entity serves multiple stories: Put in earliest story or Setup phase - Relationships → service layer tasks in appropriate story phase + - For each field with constraints in data-model.md (max length, nullable/required, enum values, validation rules), quote the constraint verbatim in the task description so it is not left to implementation-time discretion 4. **From Setup/Infrastructure**: - Shared infrastructure → Setup phase (Phase 1) diff --git a/tests/test_tasks_template_constraints.py b/tests/test_tasks_template_constraints.py new file mode 100644 index 0000000000..e2f94fa032 --- /dev/null +++ b/tests/test_tasks_template_constraints.py @@ -0,0 +1,28 @@ +"""Regression test for #4383: tasks.md loses data-model field constraints. + +The /speckit.tasks command template maps data-model.md entities to task +descriptions but did not require that field-level constraints (max length, +nullable/required, enum values, validation rules) be carried into the +generated task text verbatim. Without an explicit instruction, the +implementing agent falls back to its own defaults instead of the value +recorded in data-model.md. +""" + +from pathlib import Path + +REPO_ROOT = Path(__file__).parent.parent +TASKS_TEMPLATE = REPO_ROOT / "templates" / "commands" / "tasks.md" + + +def test_data_model_section_requires_verbatim_field_constraints(): + content = TASKS_TEMPLATE.read_text(encoding="utf-8") + + from_data_model_start = content.index("**From Data Model**") + next_section_start = content.index("**From Setup/Infrastructure**") + section = content[from_data_model_start:next_section_start] + + assert "constraint" in section.lower(), ( + "The 'From Data Model' task-organization rules must instruct the " + "agent to carry field constraints (max length, nullable, enum, " + "validation rules) from data-model.md into task descriptions." + ) From c0e6c6abc8a5bacf604db43528379a27872f58c1 Mon Sep 17 00:00:00 2001 From: chelsealong Date: Thu, 3 Sep 2026 18:09:13 +0000 Subject: [PATCH 2/2] test(tasks): tighten constraint regression assertion to match verbatim wording Addresses Copilot review feedback that the prior assertion only checked for the word 'constraint', so it would still pass if the rule's meaning were reversed (e.g. constraints permitted to be omitted). --- tests/test_tasks_template_constraints.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_tasks_template_constraints.py b/tests/test_tasks_template_constraints.py index e2f94fa032..a76cfb050b 100644 --- a/tests/test_tasks_template_constraints.py +++ b/tests/test_tasks_template_constraints.py @@ -21,8 +21,9 @@ def test_data_model_section_requires_verbatim_field_constraints(): next_section_start = content.index("**From Setup/Infrastructure**") section = content[from_data_model_start:next_section_start] - assert "constraint" in section.lower(), ( + assert "quote the constraint verbatim in the task description" in section.lower(), ( "The 'From Data Model' task-organization rules must instruct the " - "agent to carry field constraints (max length, nullable, enum, " - "validation rules) from data-model.md into task descriptions." + "agent to quote field constraints (max length, nullable, enum, " + "validation rules) from data-model.md verbatim in task descriptions, " + "not merely mention that constraints exist." )