Bug: agents validation attach does not enforce mutual exclusivity of --project and --plan flags #2070

Closed
opened 2026-04-03 03:48:06 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/validation-attach-mutual-exclusivity
  • Commit Message: fix(cli): enforce mutual exclusivity of --project and --plan in validation attach
  • Milestone: v3.7.0
  • Parent Epic: #394

Description

The specification defines the agents validation attach command signature as:

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

The | (pipe) in [--project <PROJECT>|--plan <PLAN_ID>] indicates these flags are mutually exclusive — only one may be provided at a time. However, the current implementation in src/cleveragents/cli/commands/validation.py accepts both flags simultaneously without any validation or error, creating an ambiguous attachment scope.

Expected Behavior (per spec)

Providing both --project and --plan simultaneously must result in a clear error message and abort, consistent with how --required and --informational are mutually exclusive in agents validation add:

if required and informational:
    console.print("[red]Error:[/red] --required and --informational are mutually exclusive")
    raise typer.Abort()

Actual Behavior

The attach() command accepts both --project and --plan simultaneously without any guard:

# In src/cleveragents/cli/commands/validation.py attach()
# No mutual exclusivity check between project and plan_id
service = _get_tool_registry_service()
attachment = service.attach_validation(
    validation_name=validation_name,
    resource_id=resource,
    project_name=project,  # Can be set simultaneously with plan_id
    plan_id=plan_id,        # Can be set simultaneously with project_name
    args=extra_args,
)

Both values are passed to service.attach_validation() and then to the repository, creating an ambiguous attachment scope with undefined behavior.

Steps to Reproduce

agents validation attach --project myproj --plan 01HXYZ1234567890ABCDEFGHIJ my-resource local/my-validation
# Expected: Error — --project and --plan are mutually exclusive
# Actual:   Succeeds without error, creating ambiguous attachment

Severity

Medium — Users can create ambiguous validation attachments with both project and plan scope set simultaneously, leading to undefined behavior in the attachment resolution logic.

Subtasks

  • Write a TDD issue-capture Behave scenario (tagged @tdd_expected_fail) in features/ that demonstrates the missing mutual exclusivity guard
  • Add mutual exclusivity check in attach() in src/cleveragents/cli/commands/validation.py, mirroring the pattern used in add()
  • Update or add unit tests in features/ to cover the error path (both flags provided) and the two valid single-flag paths
  • Run nox -e typecheck to confirm no type regressions
  • Run nox -e unit_tests and nox -e coverage_report to confirm all tests pass and coverage ≥ 97%

Definition of Done

  • All subtasks above are checked off
  • Providing both --project and --plan to agents validation attach prints a clear error and aborts (non-zero exit)
  • Providing only --project or only --plan continues to work correctly
  • The commit is created with the exact message: fix(cli): enforce mutual exclusivity of --project and --plan in validation attach
  • The commit is pushed to branch fix/validation-attach-mutual-exclusivity
  • A Pull Request is submitted, reviewed by ≥ 2 contributors, and merged
  • All nox stages pass
  • Coverage ≥ 97%

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

## Metadata - **Branch**: `fix/validation-attach-mutual-exclusivity` - **Commit Message**: `fix(cli): enforce mutual exclusivity of --project and --plan in validation attach` - **Milestone**: v3.7.0 - **Parent Epic**: #394 ## Description The specification defines the `agents validation attach` command signature as: ``` agents validation attach [--project <PROJECT>|--plan <PLAN_ID>] <RESOURCE> <VALIDATION> [<ARGS>...] ``` The `|` (pipe) in `[--project <PROJECT>|--plan <PLAN_ID>]` indicates these flags are **mutually exclusive** — only one may be provided at a time. However, the current implementation in `src/cleveragents/cli/commands/validation.py` accepts both flags simultaneously without any validation or error, creating an ambiguous attachment scope. ### Expected Behavior (per spec) Providing both `--project` and `--plan` simultaneously must result in a clear error message and abort, consistent with how `--required` and `--informational` are mutually exclusive in `agents validation add`: ```python if required and informational: console.print("[red]Error:[/red] --required and --informational are mutually exclusive") raise typer.Abort() ``` ### Actual Behavior The `attach()` command accepts both `--project` and `--plan` simultaneously without any guard: ```python # In src/cleveragents/cli/commands/validation.py attach() # No mutual exclusivity check between project and plan_id service = _get_tool_registry_service() attachment = service.attach_validation( validation_name=validation_name, resource_id=resource, project_name=project, # Can be set simultaneously with plan_id plan_id=plan_id, # Can be set simultaneously with project_name args=extra_args, ) ``` Both values are passed to `service.attach_validation()` and then to the repository, creating an ambiguous attachment scope with undefined behavior. ### Steps to Reproduce ```bash agents validation attach --project myproj --plan 01HXYZ1234567890ABCDEFGHIJ my-resource local/my-validation # Expected: Error — --project and --plan are mutually exclusive # Actual: Succeeds without error, creating ambiguous attachment ``` ### Severity **Medium** — Users can create ambiguous validation attachments with both project and plan scope set simultaneously, leading to undefined behavior in the attachment resolution logic. ## Subtasks - [ ] Write a TDD issue-capture Behave scenario (tagged `@tdd_expected_fail`) in `features/` that demonstrates the missing mutual exclusivity guard - [ ] Add mutual exclusivity check in `attach()` in `src/cleveragents/cli/commands/validation.py`, mirroring the pattern used in `add()` - [ ] Update or add unit tests in `features/` to cover the error path (both flags provided) and the two valid single-flag paths - [ ] Run `nox -e typecheck` to confirm no type regressions - [ ] Run `nox -e unit_tests` and `nox -e coverage_report` to confirm all tests pass and coverage ≥ 97% ## Definition of Done - [ ] All subtasks above are checked off - [ ] Providing both `--project` and `--plan` to `agents validation attach` prints a clear error and aborts (non-zero exit) - [ ] Providing only `--project` or only `--plan` continues to work correctly - [ ] The commit is created with the exact message: `fix(cli): enforce mutual exclusivity of --project and --plan in validation attach` - [ ] The commit is pushed to branch `fix/validation-attach-mutual-exclusivity` - [ ] A Pull Request is submitted, reviewed by ≥ 2 contributors, and merged - [ ] 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 03:48:10 +00:00
Author
Owner

Closing as duplicate of #1988. Both issues describe the same bug: agents validation attach does not enforce mutual exclusivity of --project and --plan flags. Issue #1988 was filed earlier (milestone v3.4.0) and is the canonical bug report. Issue #1985 is the corresponding TDD test issue.

Please track this work in #1988 and #1985.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Closing as duplicate of #1988. Both issues describe the same bug: `agents validation attach` does not enforce mutual exclusivity of `--project` and `--plan` flags. Issue #1988 was filed earlier (milestone v3.4.0) and is the canonical bug report. Issue #1985 is the corresponding TDD test issue. Please track this work in #1988 and #1985. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
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.

Blocks
#394 Epic: Decision Framework
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2070
No description provided.