UAT: InvariantService uses in-memory storage — invariants do not persist between CLI invocations, making agents invariant list/remove non-functional across calls #6507

Open
opened 2026-04-09 21:11:59 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area

Invariants & Automation Profiles

Spec Reference

docs/specification.md lines 17867-17870:

Manage invariants — named constraints that guide and constrain plan execution. Invariants can be attached to any scope: global (all plans), project (all plans targeting that project), plan (a specific plan and its child plans), or action (carried forward when the action is used).

The spec implies invariants are persistent system-level constraints that survive across CLI invocations.

Expected Behavior

Invariants added via agents invariant add should persist to the database and be retrievable in subsequent CLI invocations via agents invariant list and removable via agents invariant remove.

Actual Behavior

InvariantService uses a module-level in-memory dict (self._invariants: dict[str, Invariant] = {}) that is reset on every new process. This means:

  1. agents invariant add --global "Never delete production data" → succeeds, returns ID
  2. agents invariant list --global → "No invariants found." (fresh process, empty dict)
  3. agents invariant remove <ID> → "Invariant not found" (fresh process, empty dict)

Runtime Verification

$ agents invariant add --global "Test invariant" --format json
# Returns: {"data": {"id": "01KNT1274BCCBVPC5PD65F79M4", ...}}

$ agents invariant list --global
# Returns: "No invariants found."

$ agents invariant remove 01KNT1274BCCBVPC5PD65F79M4 --yes
# Returns: "Invariant not found: 01KNT1274BCCBVPC5PD65F79M4"

Code Location

  • src/cleveragents/application/services/invariant_service.py__init__() method: self._invariants: dict[str, Invariant] = {}
  • src/cleveragents/cli/commands/invariant.py_service: InvariantService | None = None (module-level, per-process)

Root Cause

Unlike AutomationProfileService which uses a database-backed repository, InvariantService uses in-memory storage only. There is no database table for standalone invariants (only action_invariants and plan_invariants child tables exist).

Impact

  • agents invariant add/list/remove commands are effectively non-functional for cross-invocation use
  • Users cannot build up a set of global or project-level invariants via the CLI
  • The invariant management feature is broken for any real-world use case

Severity

Critical — The invariant management CLI commands are non-functional for their primary use case (persistent constraints across plan executions).


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

## Bug Report ### Feature Area Invariants & Automation Profiles ### Spec Reference `docs/specification.md` lines 17867-17870: > Manage invariants — named constraints that guide and constrain plan execution. Invariants can be attached to any scope: global (all plans), project (all plans targeting that project), plan (a specific plan and its child plans), or action (carried forward when the action is used). The spec implies invariants are persistent system-level constraints that survive across CLI invocations. ### Expected Behavior Invariants added via `agents invariant add` should persist to the database and be retrievable in subsequent CLI invocations via `agents invariant list` and removable via `agents invariant remove`. ### Actual Behavior `InvariantService` uses a module-level in-memory dict (`self._invariants: dict[str, Invariant] = {}`) that is reset on every new process. This means: 1. `agents invariant add --global "Never delete production data"` → succeeds, returns ID 2. `agents invariant list --global` → "No invariants found." (fresh process, empty dict) 3. `agents invariant remove <ID>` → "Invariant not found" (fresh process, empty dict) ### Runtime Verification ```bash $ agents invariant add --global "Test invariant" --format json # Returns: {"data": {"id": "01KNT1274BCCBVPC5PD65F79M4", ...}} $ agents invariant list --global # Returns: "No invariants found." $ agents invariant remove 01KNT1274BCCBVPC5PD65F79M4 --yes # Returns: "Invariant not found: 01KNT1274BCCBVPC5PD65F79M4" ``` ### Code Location - `src/cleveragents/application/services/invariant_service.py` — `__init__()` method: `self._invariants: dict[str, Invariant] = {}` - `src/cleveragents/cli/commands/invariant.py` — `_service: InvariantService | None = None` (module-level, per-process) ### Root Cause Unlike `AutomationProfileService` which uses a database-backed repository, `InvariantService` uses in-memory storage only. There is no database table for standalone invariants (only `action_invariants` and `plan_invariants` child tables exist). ### Impact - `agents invariant add/list/remove` commands are effectively non-functional for cross-invocation use - Users cannot build up a set of global or project-level invariants via the CLI - The invariant management feature is broken for any real-world use case ### Severity **Critical** — The invariant management CLI commands are non-functional for their primary use case (persistent constraints across plan executions). --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 21:12:09 +00:00
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#6507
No description provided.