TDD: NamespacedName.validate_namespace() and validate_name() in plan.py allow names starting with digits — spec requires names to start with a letter #2145

Open
opened 2026-04-03 04:25:28 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: tdd/m7-namespacedname-digit-start-validation
  • Commit Message: test(plan): add TDD issue-capture test for NamespacedName digit-start validation bug
  • Milestone: v3.7.0
  • Parent Epic: #368

Background and Context

Per the Bug Fix Workflow in CONTRIBUTING.md, this TDD issue captures the buggy behavior of NamespacedName.validate_namespace() and validate_name() in src/cleveragents/domain/models/core/plan.py before the fix is implemented.

The spec (§Namespaces and ADR-002) requires namespace and name components to be stable identifiers (kebab-case recommended), consistent with the _BARE_NAME_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9_-]*$") pattern used in project.py. Both validators in plan.py currently fail to enforce the "must start with a letter" rule, allowing digit-starting names such as 123abc/my-action and local/123-action.

Expected Behavior

NamespacedName.validate_namespace() and validate_name() should reject any namespace or name component that begins with a digit, raising a ValueError consistent with the spec's identifier convention and the pattern already enforced in project.py.

Acceptance Criteria

  • A Behave scenario exists that demonstrates NamespacedName.parse("123abc/my-action") raises a ValidationError (currently it does not).
  • A Behave scenario exists that demonstrates NamespacedName(namespace="local", name="123-action") raises a ValidationError (currently it does not).
  • The scenarios are tagged @tdd_issue, @tdd_issue_<N> (where N is the bug issue number), and @tdd_expected_fail.
  • The test suite passes CI with the @tdd_expected_fail tag present (i.e., the test is expected to fail because the bug is unfixed).

Subtasks

  • Identify or create the appropriate Behave feature file under features/ for NamespacedName validation
  • Write Gherkin scenario: NamespacedName.parse() rejects namespace starting with a digit, tagged @tdd_issue @tdd_issue_<N> @tdd_expected_fail
  • Write Gherkin scenario: NamespacedName() constructor rejects name starting with a digit, tagged @tdd_issue @tdd_issue_<N> @tdd_expected_fail
  • Implement Behave step definitions for the new scenarios
  • Verify the test fails as expected (proving the bug exists) before tagging with @tdd_expected_fail
  • Confirm CI passes with @tdd_expected_fail tag in place
  • Run nox (all default sessions), fix any errors unrelated to the captured bug
  • Verify coverage >= 97% via nox -s coverage_report

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, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

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

## Metadata - **Branch**: `tdd/m7-namespacedname-digit-start-validation` - **Commit Message**: `test(plan): add TDD issue-capture test for NamespacedName digit-start validation bug` - **Milestone**: v3.7.0 - **Parent Epic**: #368 ## Background and Context Per the Bug Fix Workflow in CONTRIBUTING.md, this TDD issue captures the buggy behavior of `NamespacedName.validate_namespace()` and `validate_name()` in `src/cleveragents/domain/models/core/plan.py` before the fix is implemented. The spec (§Namespaces and ADR-002) requires namespace and name components to be stable identifiers (kebab-case recommended), consistent with the `_BARE_NAME_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9_-]*$")` pattern used in `project.py`. Both validators in `plan.py` currently fail to enforce the "must start with a letter" rule, allowing digit-starting names such as `123abc/my-action` and `local/123-action`. ## Expected Behavior `NamespacedName.validate_namespace()` and `validate_name()` should reject any namespace or name component that begins with a digit, raising a `ValueError` consistent with the spec's identifier convention and the pattern already enforced in `project.py`. ## Acceptance Criteria - A Behave scenario exists that demonstrates `NamespacedName.parse("123abc/my-action")` raises a `ValidationError` (currently it does not). - A Behave scenario exists that demonstrates `NamespacedName(namespace="local", name="123-action")` raises a `ValidationError` (currently it does not). - The scenarios are tagged `@tdd_issue`, `@tdd_issue_<N>` (where N is the bug issue number), and `@tdd_expected_fail`. - The test suite passes CI with the `@tdd_expected_fail` tag present (i.e., the test is expected to fail because the bug is unfixed). ## Subtasks - [ ] Identify or create the appropriate Behave feature file under `features/` for `NamespacedName` validation - [ ] Write Gherkin scenario: `NamespacedName.parse()` rejects namespace starting with a digit, tagged `@tdd_issue @tdd_issue_<N> @tdd_expected_fail` - [ ] Write Gherkin scenario: `NamespacedName()` constructor rejects name starting with a digit, tagged `@tdd_issue @tdd_issue_<N> @tdd_expected_fail` - [ ] Implement Behave step definitions for the new scenarios - [ ] Verify the test fails as expected (proving the bug exists) before tagging with `@tdd_expected_fail` - [ ] Confirm CI passes with `@tdd_expected_fail` tag in place - [ ] Run `nox` (all default sessions), fix any errors unrelated to the captured bug - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## 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, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 04:26:07 +00:00
freemo self-assigned this 2026-04-03 16:58:01 +00:00
Author
Owner

MoSCoW classification: Must Have

Rationale: This issue addresses a core spec requirement or blocks critical functionality. The project cannot ship without this fix.


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

MoSCoW classification: **Must Have** Rationale: This issue addresses a core spec requirement or blocks critical functionality. The project cannot ship without this fix. --- **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#2145
No description provided.