test: add TDD bug-capture test for #969 — plan correct plan_id handling #1051

Merged
hurui200320 merged 1 commit from tdd/m3-plan-correct-plan-id into master 2026-03-19 07:31:13 +00:00
Member

Summary

Add TDD bug-capture tests for bug #969 (plan correct expects decision_id but M3 acceptance test passes plan_id). These tests prove the bug exists and will serve as regression guards once the fix in #969 is merged.

Changes

  • Behave test (features/tdd_plan_correct_plan_id.feature): Two scenarios tagged @tdd_expected_fail @tdd_bug @tdd_bug_969 — one for --mode revert and one for --mode append — that invoke plan correct <plan_id> (without --plan flag) and assert the command resolves the plan_id to its root decision as target_decision_id. Both modes are tested because the bug affects target_decision_id resolution before mode-specific branching.

  • Step definitions (features/steps/tdd_plan_correct_plan_id_steps.py): Mock setup for DI container (DecisionService), CorrectionService, and _resolve_active_plan_id. Uses tpcpid step prefix per project conventions.

  • Shared fixtures (features/mocks/tdd_plan_correct_plan_id_fixtures.py): Centralised constants, patch targets, mock builders (make_decision_ns, make_mock_container, make_correction_svc, make_default_decisions, make_default_container), and build_cli_args helper. Both the Behave steps and Robot helper import from this shared module, eliminating code duplication and drift risk.

  • Robot test (robot/tdd_plan_correct_plan_id.robot): Two integration-level tests (revert + append) with tdd_expected_fail tdd_bug tdd_bug_969 tags, exercising the same code paths via the helper script.

  • Robot helper (robot/helper_tdd_plan_correct_plan_id.py): Standalone helper that exits 0 with sentinel when the bug is fixed, exits 1 when the bug is present. Imports shared fixtures from features/mocks/.

  • Changelog (CHANGELOG.md): Added entry under Unreleased for #979.

Bug Description

The correct_decision function in cleveragents.cli.commands.plan declares decision_id as its first positional argument. When the M3 acceptance test calls plan correct <plan_id> --mode revert --guidance "...", the plan_id is captured as decision_id and used directly as target_decision_id in svc.request_correction(). Since the plan_id is not a valid decision_id, the correction service cannot find the targeted decision. The same bug path is exercised by --mode append.

How TDD Expected-Fail Works

  • The @tdd_expected_fail tag causes the test framework to invert the result: the test passes CI when the underlying assertion fails (proving the bug exists) and fails CI if the assertion passes (bug was fixed without removing the tag).
  • When bug #969 is fixed, the developer removes the @tdd_expected_fail tag, and the test runs normally as a regression guard.

Quality Gates

All nox sessions pass:

  • nox -s lint
  • nox -s typecheck (0 errors)
  • nox -s unit_tests (387 features, 11121 scenarios, 0 failures)
  • nox -s integration_tests (1561 tests, 0 failures)
  • nox -s e2e_tests (16 tests, 0 failures)
  • nox -s coverage_report (≥97%)

Closes #979

## Summary Add TDD bug-capture tests for bug #969 (`plan correct` expects `decision_id` but M3 acceptance test passes `plan_id`). These tests prove the bug exists and will serve as regression guards once the fix in #969 is merged. ### Changes - **Behave test** (`features/tdd_plan_correct_plan_id.feature`): Two scenarios tagged `@tdd_expected_fail @tdd_bug @tdd_bug_969` — one for `--mode revert` and one for `--mode append` — that invoke `plan correct <plan_id>` (without `--plan` flag) and assert the command resolves the plan_id to its root decision as `target_decision_id`. Both modes are tested because the bug affects `target_decision_id` resolution **before** mode-specific branching. - **Step definitions** (`features/steps/tdd_plan_correct_plan_id_steps.py`): Mock setup for DI container (DecisionService), CorrectionService, and `_resolve_active_plan_id`. Uses `tpcpid` step prefix per project conventions. - **Shared fixtures** (`features/mocks/tdd_plan_correct_plan_id_fixtures.py`): Centralised constants, patch targets, mock builders (`make_decision_ns`, `make_mock_container`, `make_correction_svc`, `make_default_decisions`, `make_default_container`), and `build_cli_args` helper. Both the Behave steps and Robot helper import from this shared module, eliminating code duplication and drift risk. - **Robot test** (`robot/tdd_plan_correct_plan_id.robot`): Two integration-level tests (revert + append) with `tdd_expected_fail tdd_bug tdd_bug_969` tags, exercising the same code paths via the helper script. - **Robot helper** (`robot/helper_tdd_plan_correct_plan_id.py`): Standalone helper that exits 0 with sentinel when the bug is fixed, exits 1 when the bug is present. Imports shared fixtures from `features/mocks/`. - **Changelog** (`CHANGELOG.md`): Added entry under Unreleased for #979. ### Bug Description The `correct_decision` function in `cleveragents.cli.commands.plan` declares `decision_id` as its first positional argument. When the M3 acceptance test calls `plan correct <plan_id> --mode revert --guidance "..."`, the plan_id is captured as `decision_id` and used directly as `target_decision_id` in `svc.request_correction()`. Since the plan_id is not a valid decision_id, the correction service cannot find the targeted decision. The same bug path is exercised by `--mode append`. ### How TDD Expected-Fail Works - The `@tdd_expected_fail` tag causes the test framework to invert the result: the test passes CI when the underlying assertion fails (proving the bug exists) and fails CI if the assertion passes (bug was fixed without removing the tag). - When bug #969 is fixed, the developer removes the `@tdd_expected_fail` tag, and the test runs normally as a regression guard. ### Quality Gates All nox sessions pass: - `nox -s lint` ✅ - `nox -s typecheck` ✅ (0 errors) - `nox -s unit_tests` ✅ (387 features, 11121 scenarios, 0 failures) - `nox -s integration_tests` ✅ (1561 tests, 0 failures) - `nox -s e2e_tests` ✅ (16 tests, 0 failures) - `nox -s coverage_report` ✅ (≥97%) Closes #979
hurui200320 added this to the v3.2.0 milestone 2026-03-18 08:58:19 +00:00
hurui200320 force-pushed tdd/m3-plan-correct-plan-id from 5a08e12ebd
All checks were successful
CI / lint (pull_request) Successful in 16s
CI / typecheck (pull_request) Successful in 44s
CI / security (pull_request) Successful in 52s
CI / quality (pull_request) Successful in 26s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 25s
CI / unit_tests (pull_request) Successful in 2m56s
CI / integration_tests (pull_request) Successful in 3m51s
CI / e2e_tests (pull_request) Successful in 4m11s
CI / docker (pull_request) Successful in 58s
CI / coverage (pull_request) Successful in 6m40s
CI / benchmark-regression (pull_request) Successful in 37m23s
to 433aa7db21
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 28s
CI / typecheck (pull_request) Successful in 44s
CI / security (pull_request) Successful in 52s
CI / unit_tests (pull_request) Successful in 3m13s
CI / docker (pull_request) Successful in 9s
CI / integration_tests (pull_request) Successful in 3m38s
CI / e2e_tests (pull_request) Successful in 4m18s
CI / coverage (pull_request) Successful in 6m36s
CI / benchmark-regression (pull_request) Successful in 38m17s
2026-03-18 11:56:02 +00:00
Compare
freemo approved these changes 2026-03-19 04:55:12 +00:00
Dismissed
freemo left a comment

Code Review — PR #1051 test: TDD bug-capture test for #969 — plan correct plan_id handling

Clean TDD test with correct tag triplet (@tdd_expected_fail @tdd_bug @tdd_bug_969). Excellent use of shared fixtures in features/mocks/tdd_plan_correct_plan_id_fixtures.py — this eliminates duplication between Behave steps and Robot helper and should be the standard pattern for future TDD PRs. Two scenarios (revert + append modes) thoroughly test the root bug.

Approved. No issues found.

## Code Review — PR #1051 `test: TDD bug-capture test for #969 — plan correct plan_id handling` Clean TDD test with correct tag triplet (`@tdd_expected_fail @tdd_bug @tdd_bug_969`). Excellent use of shared fixtures in `features/mocks/tdd_plan_correct_plan_id_fixtures.py` — this eliminates duplication between Behave steps and Robot helper and should be the standard pattern for future TDD PRs. Two scenarios (revert + append modes) thoroughly test the root bug. **Approved.** No issues found.
hurui200320 force-pushed tdd/m3-plan-correct-plan-id from 433aa7db21
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 28s
CI / typecheck (pull_request) Successful in 44s
CI / security (pull_request) Successful in 52s
CI / unit_tests (pull_request) Successful in 3m13s
CI / docker (pull_request) Successful in 9s
CI / integration_tests (pull_request) Successful in 3m38s
CI / e2e_tests (pull_request) Successful in 4m18s
CI / coverage (pull_request) Successful in 6m36s
CI / benchmark-regression (pull_request) Successful in 38m17s
to 7b8b15f75c
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 18s
CI / quality (pull_request) Successful in 34s
CI / typecheck (pull_request) Successful in 51s
CI / security (pull_request) Successful in 53s
CI / unit_tests (pull_request) Successful in 3m25s
CI / docker (pull_request) Successful in 9s
CI / integration_tests (pull_request) Successful in 3m37s
CI / e2e_tests (pull_request) Successful in 5m10s
CI / coverage (pull_request) Successful in 6m57s
CI / benchmark-regression (pull_request) Successful in 38m14s
2026-03-19 07:23:19 +00:00
Compare
hurui200320 dismissed freemo's review 2026-03-19 07:23:19 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

hurui200320 scheduled this pull request to auto merge when all checks succeed 2026-03-19 07:29:26 +00:00
hurui200320 deleted branch tdd/m3-plan-correct-plan-id 2026-03-19 07:31:13 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!1051
No description provided.