Skip to content

fix(tasks): require field constraints from data-model.md in generated tasks - #4430

Open
chelsealong wants to merge 2 commits into
github:mainfrom
chelsealong:fix/4383-tasks-field-constraints
Open

fix(tasks): require field constraints from data-model.md in generated tasks#4430
chelsealong wants to merge 2 commits into
github:mainfrom
chelsealong:fix/4383-tasks-field-constraints

Conversation

@chelsealong

Copy link
Copy Markdown
Contributor

Fixes #4383

Problem

/speckit.tasks maps data-model.md entities to user stories (templates/commands/tasks.md, "From Data Model" section) but never instructed the agent to carry field-level constraints (max length, nullable/required, enum values, validation rules) into the generated task text. Left to the agent's discretion, a constraint present in data-model.md can be silently dropped from tasks.md, and the implementing agent then invents its own value (e.g. the reporter's data-model.md said SuspendReason nvarchar(200) but the generated code used SuspendReasonMaxLength = 500 because tasks.md never repeated the 200 constraint for that field).

Fix

Added one bullet to the "From Data Model" task-organization rule in templates/commands/tasks.md requiring that field constraints from data-model.md be quoted verbatim in the corresponding task description, so the value isn't left to implementation-time discretion.

This is a prompt-only change — no Python code, no breaking changes.

Testing

Added tests/test_tasks_template_constraints.py, which asserts the "From Data Model" section of templates/commands/tasks.md mentions carrying constraints forward.

Verified the test fails without the fix and passes with it:

$ git checkout HEAD~1 -- templates/commands/tasks.md   # (unfixed content)
$ python -m pytest tests/test_tasks_template_constraints.py -v
FAILED tests/test_tasks_template_constraints.py::test_data_model_section_requires_verbatim_field_constraints
AssertionError: 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.
1 failed in 0.49s

$ git checkout HEAD -- templates/commands/tasks.md      # (fixed content)
$ python -m pytest tests/test_tasks_template_constraints.py -v
tests/test_tasks_template_constraints.py::test_data_model_section_requires_verbatim_field_constraints PASSED
1 passed in 0.17s

Full suite:

$ python -m pytest tests -q --ignore=tests/hooks
10 failed, 7691 passed, 12 skipped, 48 warnings in 473.70s

The 10 failures are pre-existing and unrelated to this change — they are all *_python_parity tests exercising the "composed" preset variant (test_check_prerequisites_python_parity.py, test_create_new_feature_python_parity.py, test_resolve_template_python_parity.py, test_setup_plan_python_parity.py, test_setup_tasks_python_parity.py). I confirmed the identical 10 tests fail on a clean checkout of upstream/main with no changes applied, in this sandbox (likely missing an environment prerequisite for the composed-preset fixtures, e.g. PowerShell). All tests in the affected files pass individually in isolation.

AI Disclosure

I did use AI assistance (Claude, via Claude Code) to investigate the issue, write the template change, and write/verify the regression test.

… 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 github#4383

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression assertion is too broad to reliably detect removal of the required behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates /speckit.tasks to preserve field-level data-model constraints in generated task descriptions.

Changes:

  • Requires constraints to be quoted verbatim.
  • Adds a regression test for the prompt rule.
File summaries
File Description
templates/commands/tasks.md Adds the constraint-preservation instruction.
tests/test_tasks_template_constraints.py Tests the new instruction.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_tasks_template_constraints.py Outdated
…m 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).
@chelsealong

Copy link
Copy Markdown
Contributor Author

Tightened the regression assertion per review: it now checks for the actual verbatim-quoting requirement (quote the constraint verbatim in the task description) instead of just the word "constraint", so it fails again if that requirement is reworded or dropped. Verified it fails against the pre-fix template and passes against the current one; full suite (7701 passed, 12 skipped) still green.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused prompt change addresses the reported gap and includes appropriate regression coverage.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SpecKit implementation differ from spec/data-model/research/PRD

3 participants