fix(tests): resolve 114 ambiguous Behave step definitions across features/steps/ #1609

Open
opened 2026-04-02 23:10:18 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/behave-ambiguous-step-definitions
  • Commit Message: fix(tests): resolve ambiguous Behave step definitions in features/steps/
  • Milestone: v3.7.0
  • Parent Epic: #739

Problem

A static analysis of features/steps/ reveals 114 cross-file ambiguous step definition patterns — step text strings registered by @given, @when, or @then decorators that are defined in more than one step module. When Behave loads all step modules simultaneously, it cannot deterministically resolve which implementation to invoke, raising an AmbiguousStep error at runtime.

Examples of affected patterns (most severe first):

Pattern # of conflicting files
'the ' 12 files
'a project ' 10 files
'an action ' 7 files
'the file ' 6 files
'a resource ' 6 files
'I have added ' 3 files
'I create a ' 2 files
'the error should mention ' 2 files

Many step files already acknowledge this problem and work around it with ad-hoc prefixes (e.g., m3 smoke, tdd1141, sv, pfg-, idx), but the workarounds are inconsistent and incomplete — 114 patterns still collide.

Root Cause

Step text strings are too generic (e.g., bare 'the ', 'a project ') and were written in isolation without a project-wide naming convention. As the step count grew past 24 000 patterns across hundreds of modules, collisions became inevitable.

Subtasks

  • Audit all 114 ambiguous patterns and group them by domain (plan, actor, tool, resource, project, etc.)
  • Define a project-wide step-naming convention: every step pattern must be prefixed with a short, unique domain token (e.g., plan:, actor:, tool:, res:, proj:)
  • Update CONTRIBUTING.md with the new step-naming convention and a linting rule reference
  • Write a nox -e lint hook (or standalone script) that statically detects duplicate step patterns and fails the build
  • Rename all 114 ambiguous step patterns in both the step files and their corresponding .feature files
  • Verify nox -e unit_tests passes with zero AmbiguousStep errors
  • Verify nox -e coverage_report still reports ≥ 97 %

Definition of Done

  • Zero AmbiguousStep errors reported by behave --dry-run
  • A CI lint gate (nox session or pre-commit hook) prevents future ambiguous step registrations
  • CONTRIBUTING.md documents the step-naming convention
  • All nox stages pass (nox -e lint, nox -e typecheck, nox -e unit_tests, nox -e integration_tests, nox -e coverage_report)
  • Coverage ≥ 97%
  • PR merged and this issue closed

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

## Metadata - **Branch**: `fix/behave-ambiguous-step-definitions` - **Commit Message**: `fix(tests): resolve ambiguous Behave step definitions in features/steps/` - **Milestone**: v3.7.0 - **Parent Epic**: #739 ## Problem A static analysis of `features/steps/` reveals **114 cross-file ambiguous step definition patterns** — step text strings registered by `@given`, `@when`, or `@then` decorators that are defined in more than one step module. When Behave loads all step modules simultaneously, it cannot deterministically resolve which implementation to invoke, raising an `AmbiguousStep` error at runtime. Examples of affected patterns (most severe first): | Pattern | # of conflicting files | |---|---| | `'the '` | 12 files | | `'a project '` | 10 files | | `'an action '` | 7 files | | `'the file '` | 6 files | | `'a resource '` | 6 files | | `'I have added '` | 3 files | | `'I create a '` | 2 files | | `'the error should mention '` | 2 files | | … | … | Many step files already acknowledge this problem and work around it with ad-hoc prefixes (e.g., `m3 smoke`, `tdd1141`, `sv`, `pfg-`, `idx`), but the workarounds are inconsistent and incomplete — 114 patterns still collide. ## Root Cause Step text strings are too generic (e.g., bare `'the '`, `'a project '`) and were written in isolation without a project-wide naming convention. As the step count grew past 24 000 patterns across hundreds of modules, collisions became inevitable. ## Subtasks - [ ] Audit all 114 ambiguous patterns and group them by domain (plan, actor, tool, resource, project, etc.) - [ ] Define a project-wide step-naming convention: every step pattern must be prefixed with a short, unique domain token (e.g., `plan:`, `actor:`, `tool:`, `res:`, `proj:`) - [ ] Update `CONTRIBUTING.md` with the new step-naming convention and a linting rule reference - [ ] Write a `nox -e lint` hook (or standalone script) that statically detects duplicate step patterns and fails the build - [ ] Rename all 114 ambiguous step patterns in both the step files and their corresponding `.feature` files - [ ] Verify `nox -e unit_tests` passes with zero `AmbiguousStep` errors - [ ] Verify `nox -e coverage_report` still reports ≥ 97 % ## Definition of Done - [ ] Zero `AmbiguousStep` errors reported by `behave --dry-run` - [ ] A CI lint gate (nox session or pre-commit hook) prevents future ambiguous step registrations - [ ] `CONTRIBUTING.md` documents the step-naming convention - [ ] All nox stages pass (`nox -e lint`, `nox -e typecheck`, `nox -e unit_tests`, `nox -e integration_tests`, `nox -e coverage_report`) - [ ] Coverage ≥ 97% - [ ] PR merged and this issue closed --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-02 23:10:47 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Priority/High (confirmed) — 114 ambiguous step definitions is a significant test infrastructure problem
  • MoSCoW: MoSCoW/Should Have — ambiguous step definitions can cause non-deterministic test behavior, but the tests currently work (Behave picks one implementation). This is a quality/maintainability issue that should be addressed to prevent future test failures as the step count grows. Should Have.
  • Milestone: v3.7.0 (confirmed)
  • Parent Epic: #739

This is a well-documented issue with clear evidence and a solid remediation plan. The proposed step-naming convention and lint gate are good engineering practices.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Priority/High (confirmed) — 114 ambiguous step definitions is a significant test infrastructure problem - **MoSCoW**: MoSCoW/Should Have — ambiguous step definitions can cause non-deterministic test behavior, but the tests currently work (Behave picks one implementation). This is a quality/maintainability issue that should be addressed to prevent future test failures as the step count grows. Should Have. - **Milestone**: v3.7.0 (confirmed) - **Parent Epic**: #739 This is a well-documented issue with clear evidence and a solid remediation plan. The proposed step-naming convention and lint gate are good engineering practices. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#1609
No description provided.