UAT: CorrectionService never persists to correction_attempts SQLite table — correction history lost across process restarts #6092

Open
opened 2026-04-09 14:31:51 +00:00 by HAL9000 · 0 comments
Owner

Summary

CorrectionService stores all correction state in in-memory Python dictionaries (self._corrections, self._impacts, self._attempts, self._results) and never writes to the correction_attempts SQLite table. This means all correction history is lost when the process exits, making agents plan diff --correction <CORRECTION_ATTEMPT_ID> impossible to use after a restart.

What Was Tested

Code-level analysis of CorrectionService against the spec §Correction Flow (Revert Mode) step 5 and §Data Storage.

Expected Behavior (from spec)

§Correction Flow (Revert Mode), Step 5:

  1. Record correction: Create a correction_attempts record linking old and new decisions.

§Data Storage:

| Correction Attempts | SQLite correction_attempts table + archived artifacts on filesystem | ...

The spec DDL defines:

CREATE TABLE correction_attempts (
    correction_attempt_id TEXT PRIMARY KEY,  -- ULID
    plan_id TEXT NOT NULL,
    original_decision_id TEXT NOT NULL,
    new_decision_id TEXT,
    mode TEXT NOT NULL,
    guidance TEXT NOT NULL,
    archived_artifacts_path TEXT,
    state TEXT NOT NULL,
    created_at TEXT NOT NULL,
    completed_at TEXT
);

Actual Behavior

CorrectionService.__init__ initializes only in-memory dicts:

# src/cleveragents/application/services/correction_service.py
def __init__(self, checkpoint_service=None, event_bus=None):
    self._corrections: dict[str, CorrectionRequest] = {}
    self._impacts: dict[str, CorrectionImpact] = {}
    self._attempts: dict[str, list[CorrectionAttempt]] = {}
    self._results: dict[str, CorrectionResult] = {}

Neither execute_revert() nor execute_append() calls UnitOfWork.correction_attempts.create(). The CorrectionAttemptRepository and CorrectionAttemptModel exist in the infrastructure layer (src/cleveragents/infrastructure/database/repositories.py:5805, src/cleveragents/infrastructure/database/models.py:3151) but are never used by CorrectionService.

The DI container wires CorrectionService as a Singleton with checkpoint_service and event_bus but no unit_of_work or repository:

# src/cleveragents/application/container.py:884
correction_service = providers.Singleton(
    CorrectionService,
    checkpoint_service=checkpoint_service,
    event_bus=event_bus,
)

Steps to Reproduce

  1. Run agents plan correct --mode revert -g "Use FastAPI" <DECISION_ID> --yes
  2. Restart the process
  3. Run agents plan diff --correction <CORRECTION_ATTEMPT_ID>
  4. Observe: correction attempt not found — it was never persisted

Code Locations

  • src/cleveragents/application/services/correction_service.pyCorrectionService.__init__, execute_revert(), execute_append()
  • src/cleveragents/infrastructure/database/repositories.py:5805CorrectionAttemptRepository (exists but unused)
  • src/cleveragents/infrastructure/database/models.py:3151CorrectionAttemptModel (exists but unused)
  • src/cleveragents/application/container.py:884 — DI wiring missing unit_of_work

Spec References

  • §Correction Flow (Revert Mode), Step 5
  • §Data Storage — Correction Attempts table
  • v3.3.0 Acceptance Criterion #9: "Correction flow functional (plan correct --mode revert and --mode append)"

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

## Summary `CorrectionService` stores all correction state in in-memory Python dictionaries (`self._corrections`, `self._impacts`, `self._attempts`, `self._results`) and never writes to the `correction_attempts` SQLite table. This means all correction history is lost when the process exits, making `agents plan diff --correction <CORRECTION_ATTEMPT_ID>` impossible to use after a restart. ## What Was Tested Code-level analysis of `CorrectionService` against the spec §Correction Flow (Revert Mode) step 5 and §Data Storage. ## Expected Behavior (from spec) **§Correction Flow (Revert Mode), Step 5:** > 5. **Record correction**: Create a `correction_attempts` record linking old and new decisions. **§Data Storage:** > | **Correction Attempts** | SQLite `correction_attempts` table + archived artifacts on filesystem | ... The spec DDL defines: ```sql CREATE TABLE correction_attempts ( correction_attempt_id TEXT PRIMARY KEY, -- ULID plan_id TEXT NOT NULL, original_decision_id TEXT NOT NULL, new_decision_id TEXT, mode TEXT NOT NULL, guidance TEXT NOT NULL, archived_artifacts_path TEXT, state TEXT NOT NULL, created_at TEXT NOT NULL, completed_at TEXT ); ``` ## Actual Behavior `CorrectionService.__init__` initializes only in-memory dicts: ```python # src/cleveragents/application/services/correction_service.py def __init__(self, checkpoint_service=None, event_bus=None): self._corrections: dict[str, CorrectionRequest] = {} self._impacts: dict[str, CorrectionImpact] = {} self._attempts: dict[str, list[CorrectionAttempt]] = {} self._results: dict[str, CorrectionResult] = {} ``` Neither `execute_revert()` nor `execute_append()` calls `UnitOfWork.correction_attempts.create()`. The `CorrectionAttemptRepository` and `CorrectionAttemptModel` exist in the infrastructure layer (`src/cleveragents/infrastructure/database/repositories.py:5805`, `src/cleveragents/infrastructure/database/models.py:3151`) but are never used by `CorrectionService`. The DI container wires `CorrectionService` as a `Singleton` with `checkpoint_service` and `event_bus` but no `unit_of_work` or repository: ```python # src/cleveragents/application/container.py:884 correction_service = providers.Singleton( CorrectionService, checkpoint_service=checkpoint_service, event_bus=event_bus, ) ``` ## Steps to Reproduce 1. Run `agents plan correct --mode revert -g "Use FastAPI" <DECISION_ID> --yes` 2. Restart the process 3. Run `agents plan diff --correction <CORRECTION_ATTEMPT_ID>` 4. Observe: correction attempt not found — it was never persisted ## Code Locations - `src/cleveragents/application/services/correction_service.py` — `CorrectionService.__init__`, `execute_revert()`, `execute_append()` - `src/cleveragents/infrastructure/database/repositories.py:5805` — `CorrectionAttemptRepository` (exists but unused) - `src/cleveragents/infrastructure/database/models.py:3151` — `CorrectionAttemptModel` (exists but unused) - `src/cleveragents/application/container.py:884` — DI wiring missing `unit_of_work` ## Spec References - §Correction Flow (Revert Mode), Step 5 - §Data Storage — Correction Attempts table - v3.3.0 Acceptance Criterion #9: "Correction flow functional (`plan correct --mode revert` and `--mode append`)" --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.3.0 milestone 2026-04-09 15:13:44 +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.

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