UAT: InvariantService persistence fix (#1022) exists in branch but is NOT merged to master — invariants still lost between CLI invocations #2843

Closed
opened 2026-04-04 20:48:06 +00:00 by freemo · 3 comments
Owner

Metadata

  • Branch: bugfix/m4-invariant-persistence-merge
  • Commit Message: fix(invariant): merge persistence fix to master — wire InvariantService to DI container and database
  • Milestone: v3.7.0
  • Parent Epic: #392

Background and Context

Issue #1022 ("InvariantService uses in-memory storage only — invariants lost between CLI invocations") was marked as closed on 2026-03-29, and a fix commit exists (00e8046f7b3b5a7dc3d33e75bb509f92c2b32c14fix(invariant): persist standalone invariants to database). However, this fix is only on the branch remotes/origin/bugfix/m4-invariant-persistence and has never been merged to master.

This is a critical regression: the fix was completed and the issue was closed, but the code was never integrated into the main branch. As a result, the InvariantService on master still uses in-memory storage, meaning all invariants are lost when the CLI process exits. The Invariant Reconciliation Actor at the start of Strategize cannot enforce invariants that were added in previous CLI sessions.

Evidence of unmerged fix:

  • git branch --all --contains 00e8046f shows only remotes/origin/bugfix/m4-invariant-persistence
  • There is no open or merged PR for the bugfix/m4-invariant-persistence branch

Evidence of broken state on master:

  • src/cleveragents/cli/commands/invariant.py lines 59–67: _service: InvariantService | None = None with bare InvariantService() constructor (no DI container injection)
  • src/cleveragents/application/container.py: No InvariantService registration present
  • src/cleveragents/infrastructure/database/models.py: No standalone InvariantModel (only ActionInvariantModel and PlanInvariantModel)

Current Behavior

  1. agents invariant add --project X "some constraint" succeeds and prints an invariant ID
  2. agents invariant list --project X in a new CLI invocation returns "No invariants found."
  3. All invariants are silently discarded when the CLI process exits — no error is raised

Expected Behavior

  • Invariants added via agents invariant add must persist to the database
  • agents invariant list in subsequent CLI invocations must return previously added invariants
  • The InvariantService must be registered in the DI container (application/container.py) and backed by a database-persisted InvariantModel
  • The fix from branch bugfix/m4-invariant-persistence must be reviewed, merged to master, and verified end-to-end

Acceptance Criteria

  • agents invariant add --project X "text" persists the invariant to the database
  • agents invariant list --project X in a new CLI process returns all previously added invariants
  • InvariantService is registered in application/container.py and uses the database repository
  • A standalone InvariantModel exists in infrastructure/database/models.py
  • The Invariant Reconciliation Actor can load and enforce invariants from previous CLI sessions
  • No regression in existing ActionInvariantModel / PlanInvariantModel behaviour
  • All nox stages pass on master after the merge

Supporting Information

  • Unmerged fix branch: remotes/origin/bugfix/m4-invariant-persistence
  • Fix commit: 00e8046f7b3b5a7dc3d33e75bb509f92c2b32c14 (fix(invariant): persist standalone invariants to database)
  • Affected files on master:
    • src/cleveragents/cli/commands/invariant.py (lines 59–67 — in-memory service instantiation)
    • src/cleveragents/application/container.py (missing InvariantService registration)
    • src/cleveragents/infrastructure/database/models.py (missing standalone InvariantModel)
  • Related closed issue: #1022 (marked closed 2026-03-29 but fix never merged)
  • Architectural context: The Invariant Reconciliation Actor runs at the start of Strategize and enforces all applicable invariants as invariant_enforced decisions in the plan's decision tree. Without database persistence, cross-session invariants are invisible to this actor.

Subtasks

  • Cherry-pick or re-apply the fix commit 00e8046f from bugfix/m4-invariant-persistence onto a new branch bugfix/m4-invariant-persistence-merge
  • Verify InvariantService is registered in src/cleveragents/application/container.py with the correct database-backed repository
  • Verify or add standalone InvariantModel in src/cleveragents/infrastructure/database/models.py
  • Update src/cleveragents/cli/commands/invariant.py to inject InvariantService from the DI container (remove bare InvariantService() constructor call)
  • Confirm agents invariant add persists to DB and agents invariant list retrieves across process boundaries (manual smoke test)
  • Tests (Behave): Add/update scenarios covering cross-invocation invariant persistence
  • Tests (Robot): Add integration test verifying invariant add → new process → invariant list round-trip
  • Verify no regression in ActionInvariantModel / PlanInvariantModel behaviour
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors
  • Open PR from bugfix/m4-invariant-persistence-mergemaster, get review, and merge
  • Re-open and then close issue #1022 with a comment linking to the merged PR (to correctly record the resolution)

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): merge persistence fix to master — wire InvariantService to DI container and database), followed by a blank line, then additional lines providing relevant implementation details.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (bugfix/m4-invariant-persistence-merge).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • agents invariant add followed by agents invariant list in a fresh CLI process returns the added invariant on the master branch.
  • All nox stages pass.
  • Coverage >= 97%.

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

## Metadata - **Branch**: `bugfix/m4-invariant-persistence-merge` - **Commit Message**: `fix(invariant): merge persistence fix to master — wire InvariantService to DI container and database` - **Milestone**: v3.7.0 - **Parent Epic**: #392 ## Background and Context Issue #1022 ("InvariantService uses in-memory storage only — invariants lost between CLI invocations") was marked as **closed** on 2026-03-29, and a fix commit exists (`00e8046f7b3b5a7dc3d33e75bb509f92c2b32c14` — `fix(invariant): persist standalone invariants to database`). However, this fix is **only on the branch `remotes/origin/bugfix/m4-invariant-persistence`** and has **never been merged to master**. This is a critical regression: the fix was completed and the issue was closed, but the code was never integrated into the main branch. As a result, the `InvariantService` on master still uses in-memory storage, meaning all invariants are lost when the CLI process exits. The Invariant Reconciliation Actor at the start of Strategize cannot enforce invariants that were added in previous CLI sessions. **Evidence of unmerged fix:** - `git branch --all --contains 00e8046f` shows only `remotes/origin/bugfix/m4-invariant-persistence` - There is no open or merged PR for the `bugfix/m4-invariant-persistence` branch **Evidence of broken state on master:** - `src/cleveragents/cli/commands/invariant.py` lines 59–67: `_service: InvariantService | None = None` with bare `InvariantService()` constructor (no DI container injection) - `src/cleveragents/application/container.py`: No `InvariantService` registration present - `src/cleveragents/infrastructure/database/models.py`: No standalone `InvariantModel` (only `ActionInvariantModel` and `PlanInvariantModel`) ## Current Behavior 1. `agents invariant add --project X "some constraint"` succeeds and prints an invariant ID 2. `agents invariant list --project X` in a **new** CLI invocation returns `"No invariants found."` 3. All invariants are silently discarded when the CLI process exits — no error is raised ## Expected Behavior - Invariants added via `agents invariant add` must persist to the database - `agents invariant list` in subsequent CLI invocations must return previously added invariants - The `InvariantService` must be registered in the DI container (`application/container.py`) and backed by a database-persisted `InvariantModel` - The fix from branch `bugfix/m4-invariant-persistence` must be reviewed, merged to master, and verified end-to-end ## Acceptance Criteria - [ ] `agents invariant add --project X "text"` persists the invariant to the database - [ ] `agents invariant list --project X` in a new CLI process returns all previously added invariants - [ ] `InvariantService` is registered in `application/container.py` and uses the database repository - [ ] A standalone `InvariantModel` exists in `infrastructure/database/models.py` - [ ] The Invariant Reconciliation Actor can load and enforce invariants from previous CLI sessions - [ ] No regression in existing `ActionInvariantModel` / `PlanInvariantModel` behaviour - [ ] All nox stages pass on master after the merge ## Supporting Information - **Unmerged fix branch**: `remotes/origin/bugfix/m4-invariant-persistence` - **Fix commit**: `00e8046f7b3b5a7dc3d33e75bb509f92c2b32c14` (`fix(invariant): persist standalone invariants to database`) - **Affected files on master**: - `src/cleveragents/cli/commands/invariant.py` (lines 59–67 — in-memory service instantiation) - `src/cleveragents/application/container.py` (missing `InvariantService` registration) - `src/cleveragents/infrastructure/database/models.py` (missing standalone `InvariantModel`) - **Related closed issue**: #1022 (marked closed 2026-03-29 but fix never merged) - **Architectural context**: The Invariant Reconciliation Actor runs at the start of Strategize and enforces all applicable invariants as `invariant_enforced` decisions in the plan's decision tree. Without database persistence, cross-session invariants are invisible to this actor. ## Subtasks - [ ] Cherry-pick or re-apply the fix commit `00e8046f` from `bugfix/m4-invariant-persistence` onto a new branch `bugfix/m4-invariant-persistence-merge` - [ ] Verify `InvariantService` is registered in `src/cleveragents/application/container.py` with the correct database-backed repository - [ ] Verify or add standalone `InvariantModel` in `src/cleveragents/infrastructure/database/models.py` - [ ] Update `src/cleveragents/cli/commands/invariant.py` to inject `InvariantService` from the DI container (remove bare `InvariantService()` constructor call) - [ ] Confirm `agents invariant add` persists to DB and `agents invariant list` retrieves across process boundaries (manual smoke test) - [ ] Tests (Behave): Add/update scenarios covering cross-invocation invariant persistence - [ ] Tests (Robot): Add integration test verifying `invariant add` → new process → `invariant list` round-trip - [ ] Verify no regression in `ActionInvariantModel` / `PlanInvariantModel` behaviour - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors - [ ] Open PR from `bugfix/m4-invariant-persistence-merge` → `master`, get review, and merge - [ ] Re-open and then close issue #1022 with a comment linking to the merged PR (to correctly record the resolution) ## 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): merge persistence fix to master — wire InvariantService to DI container and database`), followed by a blank line, then additional lines providing relevant implementation details. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`bugfix/m4-invariant-persistence-merge`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - `agents invariant add` followed by `agents invariant list` in a fresh CLI process returns the added invariant on the master branch. - 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:48:12 +00:00
Author
Owner

Starting implementation on branch bugfix/m4-invariant-persistence-merge.

Plan:

  1. Cherry-pick fix commit 00e8046f from bugfix/m4-invariant-persistence onto new branch
  2. Verify/complete all wiring: DI container, DB model, CLI injection
  3. Add Behave + Robot Framework tests for cross-invocation persistence
  4. Run nox (all sessions), verify coverage >= 97%
  5. Create PR

Difficulty assessment: Medium-High (critical bug fix with existing patch to apply) → starting at sonnet tier.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

Starting implementation on branch `bugfix/m4-invariant-persistence-merge`. **Plan:** 1. Cherry-pick fix commit `00e8046f` from `bugfix/m4-invariant-persistence` onto new branch 2. Verify/complete all wiring: DI container, DB model, CLI injection 3. Add Behave + Robot Framework tests for cross-invocation persistence 4. Run nox (all sessions), verify coverage >= 97% 5. Create PR Difficulty assessment: Medium-High (critical bug fix with existing patch to apply) → starting at sonnet tier. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

Closing as duplicate of #3539.

Both issues describe the same bug: InvariantService still uses in-memory storage and the persistence fix from branch bugfix/m4-invariant-persistence was never merged to master. Issue #3539 is the more urgent tracking issue (v3.3.0 milestone, Priority/Critical, State/Verified, MoSCoW/Must Have). Please track this work in #3539.


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

Closing as duplicate of #3539. Both issues describe the same bug: `InvariantService` still uses in-memory storage and the persistence fix from branch `bugfix/m4-invariant-persistence` was never merged to master. Issue #3539 is the more urgent tracking issue (v3.3.0 milestone, `Priority/Critical`, `State/Verified`, `MoSCoW/Must Have`). Please track this work in #3539. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Owner

State label reconciliation:

  • Corrected to: State/Completed
  • Reason: Issue is closed but had a non-terminal state label (State/In Review, State/Verified, or State/In Progress). CONTRIBUTING.md requires closed issues to have State/Completed or State/Wont Do.

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

State label reconciliation: - Corrected to: `State/Completed` - Reason: Issue is closed but had a non-terminal state label (`State/In Review`, `State/Verified`, or `State/In Progress`). CONTRIBUTING.md requires closed issues to have `State/Completed` or `State/Wont Do`. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
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.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2843
No description provided.