fix(cli): remove extra --mode/-m flag from validation attach #913

Closed
opened 2026-03-13 23:59:08 +00:00 by freemo · 4 comments
Owner

Background

The validation attach command in the current implementation (src/cleveragents/cli/commands/validation.py:268) includes a --mode/-m flag:

mode: Annotated[
    str,
    typer.Option("--mode", "-m", help="Validation mode: required or informational"),
] = "required",

The specification (spec lines 9535-9549) defines validation attach as:

agents validation attach [--project <PROJECT>|--plan <PLAN_ID>]
                         <RESOURCE> <VALIDATION> [<ARGS>...]

The spec does not include --mode on validation attach. The validation mode is an inherent property of the validation definition itself, set at registration time via validation add, not an override at attachment time.

The spec's example output does show Mode: required in the response, but this reflects the validation's own mode property — not a per-attachment override.

Acceptance Criteria

  • The --mode/-m flag is removed from validation attach
  • If the mode needs to be displayed in output, it is read from the validation's registered definition
  • CLI --help output for validation attach matches the specification signature
  • Existing tests pass; any tests relying on --mode on validation attach are updated

Metadata

  • Suggested commit message: fix(cli): remove extra --mode flag from validation attach
  • Suggested branch name: fix/validation-attach-remove-mode-flag

Definition of Done

Code merged to main, validation attach no longer accepts --mode, validation mode is determined by the validation definition.

## Background The `validation attach` command in the current implementation (`src/cleveragents/cli/commands/validation.py:268`) includes a `--mode/-m` flag: ```python mode: Annotated[ str, typer.Option("--mode", "-m", help="Validation mode: required or informational"), ] = "required", ``` The specification ([spec lines 9535-9549](../docs/specification.md)) defines `validation attach` as: ``` agents validation attach [--project <PROJECT>|--plan <PLAN_ID>] <RESOURCE> <VALIDATION> [<ARGS>...] ``` The spec does **not** include `--mode` on `validation attach`. The validation mode is an inherent property of the validation definition itself, set at registration time via `validation add`, not an override at attachment time. The spec's example output does show `Mode: required` in the response, but this reflects the validation's own mode property — not a per-attachment override. ## Acceptance Criteria - [x] The `--mode/-m` flag is removed from `validation attach` - [x] If the mode needs to be displayed in output, it is read from the validation's registered definition - [x] CLI `--help` output for `validation attach` matches the specification signature - [x] Existing tests pass; any tests relying on `--mode` on `validation attach` are updated ## Metadata - **Suggested commit message:** `fix(cli): remove extra --mode flag from validation attach` - **Suggested branch name:** `fix/validation-attach-remove-mode-flag` ## Definition of Done Code merged to `main`, `validation attach` no longer accepts `--mode`, validation mode is determined by the validation definition.
freemo added this to the v3.4.0 milestone 2026-03-13 23:59:39 +00:00
freemo self-assigned this 2026-04-02 06:13:53 +00:00
Author
Owner

Starting implementation on branch fix/validation-attach-remove-mode-flag.

Changes made:

  1. Removed --mode/-m parameter from validation attach CLI command in src/cleveragents/cli/commands/validation.py
  2. CLI now reads mode from the validation's registered definition via service.get_tool(validation_name) before calling service.attach_validation
  3. Updated features/tool_cli.feature - removed "Attach validation with mode informational" scenario
  4. Updated features/steps/tool_cli_steps.py - removed step_run_validation_attach_mode step, updated mock setup for attach scenarios to include get_tool returning a validation definition
  5. Updated features/steps/tool_cli_coverage_steps.py - updated step_object_like_attachment and step_attachment_svc_returns to set up get_tool mock
  6. Added new BDD feature features/tdd_validation_attach_no_mode_flag.feature with 4 scenarios verifying the flag is gone

Quality gates: lint , typecheck , unit_tests (all scenarios pass)

All subtasks complete. Creating PR.

Starting implementation on branch `fix/validation-attach-remove-mode-flag`. **Changes made:** 1. Removed `--mode/-m` parameter from `validation attach` CLI command in `src/cleveragents/cli/commands/validation.py` 2. CLI now reads mode from the validation's registered definition via `service.get_tool(validation_name)` before calling `service.attach_validation` 3. Updated `features/tool_cli.feature` - removed "Attach validation with mode informational" scenario 4. Updated `features/steps/tool_cli_steps.py` - removed `step_run_validation_attach_mode` step, updated mock setup for attach scenarios to include `get_tool` returning a validation definition 5. Updated `features/steps/tool_cli_coverage_steps.py` - updated `step_object_like_attachment` and `step_attachment_svc_returns` to set up `get_tool` mock 6. Added new BDD feature `features/tdd_validation_attach_no_mode_flag.feature` with 4 scenarios verifying the flag is gone **Quality gates:** lint ✅, typecheck ✅, unit_tests ✅ (all scenarios pass) All subtasks complete. Creating PR.
Author
Owner

PR #1305 created on branch fix/validation-attach-remove-mode-flag. PR review and merge handled by continuous review stream.

#1305

PR #1305 created on branch `fix/validation-attach-remove-mode-flag`. PR review and merge handled by continuous review stream. https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/1305
Member

Implementation Notes

Design Decisions

  1. CLI layer (src/cleveragents/cli/commands/validation.py): Removed the --mode/-m Typer option from the attach() command function. Updated the docstring to clarify that mode is determined by the validation's registered definition. Removed the example that showed --mode informational.

  2. Service layer (src/cleveragents/application/services/tool_registry_service.py): Removed mode from the attach_validation() method signature entirely. The method now derives the mode from the validation's registered definition by reading it from the existing tool object returned by self._tool_repo.get_by_name(). This aligns with the specification which states that the validation mode is an inherent property set at registration time, not an override at attachment time. The unused ValidationError import was also removed since the mode validation check (if mode not in {...}) is no longer needed.

  3. Repository layer (src/cleveragents/infrastructure/database/repositories.py): Added mode to the _to_legacy_domain() method in ToolRegistryRepository so that the mode field from ToolModel is available on the SimpleNamespace returned by get_by_name(). The repository's attach() method still accepts mode as a parameter since it's now passed from the service after reading the validation definition.

Test Updates

  • Removed scenario: "Attach validation with mode informational" from features/tool_cli.feature (and its step step_run_validation_attach_mode in features/steps/tool_cli_steps.py) since the CLI no longer accepts --mode.
  • Removed scenarios: "attach_validation raises ValidationError for invalid mode" from features/consolidated_tool.feature (3 occurrences across different test origins) since the service no longer accepts mode as a parameter.
  • Updated scenarios: "attach_validation raises NotFoundError" and "attach_validation delegates to attachment repo" to not pass mode.
  • Updated step definitions: Removed mode= keyword arguments from all attach_validation() calls in tool_registry_steps.py, tool_registry_service_coverage_steps.py, tool_registry_service_fallback_coverage_steps.py, tool_registry_service_uncovered_branches_steps.py.
  • Updated mock sentinel: Added "mode": "required" to the sentinel dict in tool_registry_service_coverage_steps.py so the service can read the mode from the mock.
  • Updated Robot Framework helpers: Removed mode= from attach_validation() calls in robot/wf02_test_generation_validation.py, robot/helper_wf07_cicd.py, robot/helper_wf04_multi_project_dependency.py.

Quality Gate Results

All 11 nox sessions pass:

  • lint:
  • format:
  • typecheck:
  • security_scan:
  • dead_code:
  • unit_tests:
  • integration_tests:
  • docs:
  • build:
  • benchmark:
  • coverage_report: (98.7% >= 97%)
## Implementation Notes ### Design Decisions 1. **CLI layer** (`src/cleveragents/cli/commands/validation.py`): Removed the `--mode/-m` Typer option from the `attach()` command function. Updated the docstring to clarify that mode is determined by the validation's registered definition. Removed the example that showed `--mode informational`. 2. **Service layer** (`src/cleveragents/application/services/tool_registry_service.py`): Removed `mode` from the `attach_validation()` method signature entirely. The method now derives the mode from the validation's registered definition by reading it from the `existing` tool object returned by `self._tool_repo.get_by_name()`. This aligns with the specification which states that the validation mode is an inherent property set at registration time, not an override at attachment time. The unused `ValidationError` import was also removed since the mode validation check (`if mode not in {...}`) is no longer needed. 3. **Repository layer** (`src/cleveragents/infrastructure/database/repositories.py`): Added `mode` to the `_to_legacy_domain()` method in `ToolRegistryRepository` so that the mode field from `ToolModel` is available on the SimpleNamespace returned by `get_by_name()`. The repository's `attach()` method still accepts `mode` as a parameter since it's now passed from the service after reading the validation definition. ### Test Updates - **Removed scenario**: "Attach validation with mode informational" from `features/tool_cli.feature` (and its step `step_run_validation_attach_mode` in `features/steps/tool_cli_steps.py`) since the CLI no longer accepts `--mode`. - **Removed scenarios**: "attach_validation raises ValidationError for invalid mode" from `features/consolidated_tool.feature` (3 occurrences across different test origins) since the service no longer accepts mode as a parameter. - **Updated scenarios**: "attach_validation raises NotFoundError" and "attach_validation delegates to attachment repo" to not pass mode. - **Updated step definitions**: Removed `mode=` keyword arguments from all `attach_validation()` calls in `tool_registry_steps.py`, `tool_registry_service_coverage_steps.py`, `tool_registry_service_fallback_coverage_steps.py`, `tool_registry_service_uncovered_branches_steps.py`. - **Updated mock sentinel**: Added `"mode": "required"` to the sentinel dict in `tool_registry_service_coverage_steps.py` so the service can read the mode from the mock. - **Updated Robot Framework helpers**: Removed `mode=` from `attach_validation()` calls in `robot/wf02_test_generation_validation.py`, `robot/helper_wf07_cicd.py`, `robot/helper_wf04_multi_project_dependency.py`. ### Quality Gate Results All 11 nox sessions pass: - lint: ✅ - format: ✅ - typecheck: ✅ - security_scan: ✅ - dead_code: ✅ - unit_tests: ✅ - integration_tests: ✅ - docs: ✅ - build: ✅ - benchmark: ✅ - coverage_report: ✅ (98.7% >= 97%)
Author
Owner

PR #1305 reviewed, approved, and merged. The --mode/-m flag has been removed from validation attach to align with the specification. Validation mode is now correctly read from the validation's registered definition at attach time.

PR #1305 reviewed, approved, and merged. The `--mode/-m` flag has been removed from `validation attach` to align with the specification. Validation mode is now correctly read from the validation's registered definition at attach time.
Sign in to join this conversation.
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.

Dependencies

No dependencies set.

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