TDD: DecisionService.record_decision allows multiple prompt_definition decisions per plan — violates spec "Single root" structural invariant #1826

Closed
opened 2026-04-02 23:55:55 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: tdd/m3-decision-service-single-root-invariant
  • Commit Message: test(decisions): add tdd issue-capture test for single-root invariant violation in DecisionService
  • Milestone: v3.2.0
  • Parent Epic: #357

Background and Context

This is the TDD issue-capture companion to bug issue #1815. Per the project's mandatory Bug Fix Workflow, every Type/Bug issue must be preceded by a Type/Testing issue that introduces a failing BDD scenario proving the bug exists. The test is tagged @tdd_issue, @tdd_issue_1815, and @tdd_expected_fail so that CI passes while the bug remains unfixed.

The bug: DecisionService.record_decision() does not enforce the "Single root" structural invariant — it allows multiple prompt_definition decisions (with parent_decision_id IS NULL) to be recorded for the same plan, violating the spec.

Deliverable

A single BDD scenario (Behave/Gherkin) that:

  1. Creates a plan and records a first prompt_definition decision (succeeds).
  2. Attempts to record a second prompt_definition decision for the same plan.
  3. Asserts that a BusinessRuleViolation (or equivalent) is raised.

The scenario must carry all three tags: @tdd_issue, @tdd_issue_1815, @tdd_expected_fail.

Acceptance Criteria

  • A Behave scenario exists that reproduces the bug (second prompt_definition call does NOT raise — test currently fails).
  • The scenario is tagged @tdd_issue, @tdd_issue_1815, and @tdd_expected_fail.
  • CI passes because @tdd_expected_fail marks the scenario as an expected failure.
  • The scenario is placed in the appropriate feature file alongside related decision service scenarios.
  • No production code is modified in this TDD issue — only test code.

Subtasks

  • Identify or create the appropriate Behave feature file for DecisionService invariant scenarios
  • Write the failing BDD scenario with tags @tdd_issue @tdd_issue_1815 @tdd_expected_fail
  • Implement any missing step definitions required by the new scenario
  • Verify the scenario fails (as expected) without the fix in place
  • Verify CI passes due to @tdd_expected_fail tagging via nox
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (test(decisions): add tdd issue-capture test for single-root invariant violation in DecisionService), followed by a blank line, then additional lines providing relevant details.
  • The commit is pushed to the remote on the branch tdd/m3-decision-service-single-root-invariant.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • The bug fix issue (#1815) depends on this TDD issue (this issue blocks #1815).
  • All nox stages pass.
  • Coverage >= 97%.

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `tdd/m3-decision-service-single-root-invariant` - **Commit Message**: `test(decisions): add tdd issue-capture test for single-root invariant violation in DecisionService` - **Milestone**: v3.2.0 - **Parent Epic**: #357 ## Background and Context This is the TDD issue-capture companion to bug issue #1815. Per the project's mandatory Bug Fix Workflow, every `Type/Bug` issue must be preceded by a `Type/Testing` issue that introduces a failing BDD scenario proving the bug exists. The test is tagged `@tdd_issue`, `@tdd_issue_1815`, and `@tdd_expected_fail` so that CI passes while the bug remains unfixed. The bug: `DecisionService.record_decision()` does not enforce the "Single root" structural invariant — it allows multiple `prompt_definition` decisions (with `parent_decision_id IS NULL`) to be recorded for the same plan, violating the spec. ## Deliverable A single BDD scenario (Behave/Gherkin) that: 1. Creates a plan and records a first `prompt_definition` decision (succeeds). 2. Attempts to record a second `prompt_definition` decision for the same plan. 3. Asserts that a `BusinessRuleViolation` (or equivalent) is raised. The scenario must carry all three tags: `@tdd_issue`, `@tdd_issue_1815`, `@tdd_expected_fail`. ## Acceptance Criteria - [ ] A Behave scenario exists that reproduces the bug (second `prompt_definition` call does NOT raise — test currently fails). - [ ] The scenario is tagged `@tdd_issue`, `@tdd_issue_1815`, and `@tdd_expected_fail`. - [ ] CI passes because `@tdd_expected_fail` marks the scenario as an expected failure. - [ ] The scenario is placed in the appropriate feature file alongside related decision service scenarios. - [ ] No production code is modified in this TDD issue — only test code. ## Subtasks - [ ] Identify or create the appropriate Behave feature file for `DecisionService` invariant scenarios - [ ] Write the failing BDD scenario with tags `@tdd_issue @tdd_issue_1815 @tdd_expected_fail` - [ ] Implement any missing step definitions required by the new scenario - [ ] Verify the scenario fails (as expected) without the fix in place - [ ] Verify CI passes due to `@tdd_expected_fail` tagging via `nox` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`test(decisions): add tdd issue-capture test for single-root invariant violation in DecisionService`), followed by a blank line, then additional lines providing relevant details. - The commit is pushed to the remote on the branch `tdd/m3-decision-service-single-root-invariant`. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - The bug fix issue (#1815) **depends on** this TDD issue (this issue blocks #1815). - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.2.0 milestone 2026-04-02 23:56:51 +00:00
Author
Owner

Closing as duplicate of #1815 (same DecisionService.record_decision issue).


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Closing as duplicate of #1815 (same DecisionService.record_decision issue). --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo 2026-04-02 23:57:35 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1826
No description provided.