UAT: agents invariant add accepts no-scope silently (defaults to global instead of erroring) #6776

Open
opened 2026-04-10 02:05:31 +00:00 by HAL9000 · 1 comment
Owner

What Was Tested

Code analysis of _resolve_scope() and the add command in src/cleveragents/cli/commands/invariant.py.

Expected Behavior (From Spec)

Per docs/specification.md §agents invariant (line 17873):

Scope Requirements: Exactly one scope flag is required for add and list.

And line 17900:

At least one scope flag (--global, --project, --plan, or --action) must be provided.

Running agents invariant add "some text" without any scope flag should produce an error such as:

Error: At least one scope flag is required: --global, --project, --plan, or --action

Actual Behavior

The CLI docstring in invariant.py contradicts the spec and silently defaults to --global:

# src/cleveragents/cli/commands/invariant.py lines 16-17 (module docstring)
"""...
If no scope flag is given, ``--global`` is assumed.
"""

# _resolve_scope() lines 96-97
# Default to global
return InvariantScope.GLOBAL, "system"

When no scope flag is given, the command silently attaches the invariant as a global invariant rather than raising an error. This is a silent data-correctness bug: a user who forgets to specify --project myapp would unintentionally create a global invariant affecting all plans.

Steps to Reproduce

# Should error, but silently creates a global invariant instead
agents invariant add "Only applies to project X"

The invariant is silently added at global scope instead of failing with a helpful error message.

Impact

  • Violates the spec's explicit "exactly one scope flag is required" contract
  • Can lead to accidental global invariants being created when project/plan/action scope was intended
  • User gets no feedback that their command was missing a required parameter

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## What Was Tested Code analysis of `_resolve_scope()` and the `add` command in `src/cleveragents/cli/commands/invariant.py`. ## Expected Behavior (From Spec) Per `docs/specification.md` §agents invariant (line 17873): > **Scope Requirements**: Exactly **one scope flag** is required for `add` and `list`. And line 17900: > At least one scope flag (`--global`, `--project`, `--plan`, or `--action`) **must be provided**. Running `agents invariant add "some text"` without any scope flag should produce an error such as: ``` Error: At least one scope flag is required: --global, --project, --plan, or --action ``` ## Actual Behavior The CLI docstring in `invariant.py` contradicts the spec and silently defaults to `--global`: ```python # src/cleveragents/cli/commands/invariant.py lines 16-17 (module docstring) """... If no scope flag is given, ``--global`` is assumed. """ # _resolve_scope() lines 96-97 # Default to global return InvariantScope.GLOBAL, "system" ``` When no scope flag is given, the command silently attaches the invariant as a global invariant rather than raising an error. This is a silent data-correctness bug: a user who forgets to specify `--project myapp` would unintentionally create a global invariant affecting all plans. ## Steps to Reproduce ```bash # Should error, but silently creates a global invariant instead agents invariant add "Only applies to project X" ``` The invariant is silently added at global scope instead of failing with a helpful error message. ## Impact - Violates the spec's explicit "exactly one scope flag is required" contract - Can lead to accidental global invariants being created when project/plan/action scope was intended - User gets no feedback that their command was missing a required parameter --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.4.0 milestone 2026-04-10 02:05:36 +00:00
Author
Owner

Verified — UAT bug: invariant add silently defaults to global scope instead of requiring explicit scope. MoSCoW: Must-have. Priority: High — spec violation.


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

✅ **Verified** — UAT bug: invariant add silently defaults to global scope instead of requiring explicit scope. MoSCoW: Must-have. Priority: High — spec violation. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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