UAT: agents invariant add --plan and --action flags are not repeatable as required by spec #2821

Closed
opened 2026-04-04 20:40:34 +00:00 by freemo · 2 comments
Owner

Background and Context

The specification (docs/specification.md lines 17794–17808) defines the agents invariant add command signature as:

agents invariant add [--global] [--project/-p PROJECT] [--plan PLAN_ID]... [--action ACTION]... <INVARIANT_TEXT>

The ... notation indicates that --plan and --action are repeatable flags — the same invariant can be attached to multiple plans or actions in a single command invocation. The spec explicitly states (line 17808):

"--plan and --action can be repeated to attach the same invariant to multiple plans or actions."

This bug was discovered during UAT testing against the v3.7.0 milestone. The specification is the authoritative source of truth; the implementation must be aligned with it.

Current Behavior

The current implementation in src/cleveragents/cli/commands/invariant.py (lines 121–122) defines these as single-value options:

plan: Annotated[str | None, typer.Option("--plan", help="Plan ID (ULID)")] = None,
action: Annotated[str | None, typer.Option("--action", help="Action name")] = None,

This means:

  1. agents invariant add --plan PLAN1 --plan PLAN2 "some constraint" will fail or silently use only the last value.
  2. The _resolve_scope() helper (lines 70–97) only handles a single plan/action value.
  3. The add_invariant() service method is only called once, not once per plan/action ID.

Expected Behavior

  • --plan should accept multiple values (repeatable flag using typer.Option(..., multiple=True) or list[str]).
  • --action should accept multiple values (repeatable flag).
  • When multiple --plan or --action values are provided, the invariant should be added once per value.
  • The command should output a result for each created invariant.

Acceptance Criteria

  • agents invariant add --plan PLAN1 --plan PLAN2 "Never delete production data" creates two separate invariants, one scoped to each plan.
  • agents invariant add --action action_a --action action_b "Always log output" creates two separate invariants, one scoped to each action.
  • Mixing --plan and --action in a single invocation creates one invariant per value provided.
  • Providing a single --plan or --action (existing behaviour) continues to work correctly.
  • The CLI output lists a result entry for each invariant created.
  • Type annotations satisfy Pyright (nox -e typecheck passes with no errors or # type: ignore suppressions).
  • All nox default sessions pass.
  • Unit test coverage ≥ 97%.

Supporting Information

  • Spec reference: docs/specification.md lines 17794–17808
  • Code locations:
    • src/cleveragents/cli/commands/invariant.py lines 121–122 — option definitions
    • src/cleveragents/cli/commands/invariant.py lines 70–97 — _resolve_scope() helper
    • src/cleveragents/cli/commands/invariant.py lines 112–147 — add command body
  • Steps to reproduce:
    1. Run: agents invariant add --plan PLAN1 --plan PLAN2 "Never delete production data"
    2. Observe that only one invariant is created (or an error occurs) instead of two.

Metadata

  • Branch: fix/v3.7.0-invariant-add-repeatable-plan-action-flags
  • Commit Message: fix(invariant): make --plan and --action flags repeatable in invariant add command
  • Milestone: v3.7.0
  • Parent Epic: #392

Subtasks

  • Update --plan option in add command to use list[str] / multiple=True
  • Update --action option in add command to use list[str] / multiple=True
  • Refactor _resolve_scope() to accept and iterate over a sequence of plan/action IDs
  • Update add command body to call add_invariant() once per plan/action value
  • Update CLI output to display a result entry for each created invariant
  • Tests (Behave): Add scenarios for repeatable --plan flag (single, multiple, mixed)
  • Tests (Behave): Add scenarios for repeatable --action flag (single, multiple, mixed)
  • Tests (Robot): Add integration test for invariant add with multiple --plan flags
  • Tests (Robot): Add integration test for invariant add with multiple --action flags
  • Verify coverage ≥ 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

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 (fix(invariant): make --plan and --action flags repeatable in invariant add command), 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 (fix/v3.7.0-invariant-add-repeatable-plan-action-flags).
  • 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

## Background and Context The specification (`docs/specification.md` lines 17794–17808) defines the `agents invariant add` command signature as: ``` agents invariant add [--global] [--project/-p PROJECT] [--plan PLAN_ID]... [--action ACTION]... <INVARIANT_TEXT> ``` The `...` notation indicates that `--plan` and `--action` are **repeatable** flags — the same invariant can be attached to multiple plans or actions in a single command invocation. The spec explicitly states (line 17808): > "`--plan` and `--action` can be repeated to attach the same invariant to multiple plans or actions." This bug was discovered during UAT testing against the v3.7.0 milestone. The specification is the authoritative source of truth; the implementation must be aligned with it. ## Current Behavior The current implementation in `src/cleveragents/cli/commands/invariant.py` (lines 121–122) defines these as single-value options: ```python plan: Annotated[str | None, typer.Option("--plan", help="Plan ID (ULID)")] = None, action: Annotated[str | None, typer.Option("--action", help="Action name")] = None, ``` This means: 1. `agents invariant add --plan PLAN1 --plan PLAN2 "some constraint"` will fail or silently use only the last value. 2. The `_resolve_scope()` helper (lines 70–97) only handles a single plan/action value. 3. The `add_invariant()` service method is only called once, not once per plan/action ID. ## Expected Behavior - `--plan` should accept multiple values (repeatable flag using `typer.Option(..., multiple=True)` or `list[str]`). - `--action` should accept multiple values (repeatable flag). - When multiple `--plan` or `--action` values are provided, the invariant should be added once per value. - The command should output a result for each created invariant. ## Acceptance Criteria - [ ] `agents invariant add --plan PLAN1 --plan PLAN2 "Never delete production data"` creates two separate invariants, one scoped to each plan. - [ ] `agents invariant add --action action_a --action action_b "Always log output"` creates two separate invariants, one scoped to each action. - [ ] Mixing `--plan` and `--action` in a single invocation creates one invariant per value provided. - [ ] Providing a single `--plan` or `--action` (existing behaviour) continues to work correctly. - [ ] The CLI output lists a result entry for each invariant created. - [ ] Type annotations satisfy Pyright (`nox -e typecheck` passes with no errors or `# type: ignore` suppressions). - [ ] All nox default sessions pass. - [ ] Unit test coverage ≥ 97%. ## Supporting Information - **Spec reference**: `docs/specification.md` lines 17794–17808 - **Code locations**: - `src/cleveragents/cli/commands/invariant.py` lines 121–122 — option definitions - `src/cleveragents/cli/commands/invariant.py` lines 70–97 — `_resolve_scope()` helper - `src/cleveragents/cli/commands/invariant.py` lines 112–147 — `add` command body - **Steps to reproduce**: 1. Run: `agents invariant add --plan PLAN1 --plan PLAN2 "Never delete production data"` 2. Observe that only one invariant is created (or an error occurs) instead of two. ## Metadata - **Branch**: `fix/v3.7.0-invariant-add-repeatable-plan-action-flags` - **Commit Message**: `fix(invariant): make --plan and --action flags repeatable in invariant add command` - **Milestone**: v3.7.0 - **Parent Epic**: #392 ## Subtasks - [ ] Update `--plan` option in `add` command to use `list[str]` / `multiple=True` - [ ] Update `--action` option in `add` command to use `list[str]` / `multiple=True` - [ ] Refactor `_resolve_scope()` to accept and iterate over a sequence of plan/action IDs - [ ] Update `add` command body to call `add_invariant()` once per plan/action value - [ ] Update CLI output to display a result entry for each created invariant - [ ] Tests (Behave): Add scenarios for repeatable `--plan` flag (single, multiple, mixed) - [ ] Tests (Behave): Add scenarios for repeatable `--action` flag (single, multiple, mixed) - [ ] Tests (Robot): Add integration test for `invariant add` with multiple `--plan` flags - [ ] Tests (Robot): Add integration test for `invariant add` with multiple `--action` flags - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## 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 (`fix(invariant): make --plan and --action flags repeatable in invariant add command`), 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 (`fix/v3.7.0-invariant-add-repeatable-plan-action-flags`). - 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-04 20:40:40 +00:00
Author
Owner

⚠️ Potential duplicate detected — closing as duplicate of #2818.

Both issues describe the same bug: agents invariant add --plan and --action flags not being repeatable as required by spec. Issue #2818 was created 1 minute earlier (20:39 vs 20:40), has State/Verified and milestone v3.3.0, making it the more complete tracking issue.

Closing #2821 as duplicate. If there are meaningful differences between these issues, please reopen and clarify.


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

⚠️ **Potential duplicate detected** — closing as duplicate of #2818. Both issues describe the same bug: `agents invariant add --plan` and `--action` flags not being repeatable as required by spec. Issue #2818 was created 1 minute earlier (20:39 vs 20:40), has `State/Verified` and milestone v3.3.0, making it the more complete tracking issue. Closing #2821 as duplicate. If there are meaningful differences between these issues, please reopen and clarify. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Author
Owner

State label reconciliation:

  • Previous state: State/Unverified
  • Corrected to: State/Completed
  • Reason: Issue is closed but had a non-terminal state label. Per CONTRIBUTING.md, closed issues must have State/Completed or State/Wont Do.

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

State label reconciliation: - Previous state: `State/Unverified` - Corrected to: `State/Completed` - Reason: Issue is closed but had a non-terminal state label. Per CONTRIBUTING.md, closed issues must have `State/Completed` or `State/Wont Do`. --- **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
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2821
No description provided.