feat(correction): implement CorrectionService DB persistence, dry-run report, and plan.attempt tracking #8913

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

Metadata

  • Commit message: feat(correction): implement CorrectionService DB persistence, dry-run report, and plan.attempt tracking
  • Branch name: feat/m3-m4/correction-service-persistence

Background and Context

Epic #4959 (Correction Engine — Revert & Append Modes) requires that CorrectionService persists correction attempts to the correction_attempts SQLite table (currently it stores them in-memory only), that plan correct --dry-run calls generate_dry_run_report() instead of analyze_impact(), and that the dry-run output includes spec-required fields (warnings, estimated_recompute_time, decisions_to_invalidate).

This issue implements the persistence layer for the correction engine, the dry-run report generation, and the plan.attempt tracking infrastructure shared by both revert and append modes.

This issue blocks Epic #4959.

Acceptance Criteria

  • CorrectionService persists correction attempts to correction_attempts SQLite table (not in-memory)
  • correction_attempts table schema includes original_subtree_snapshot field per spec DDL
  • plan correct --dry-run calls generate_dry_run_report() (not analyze_impact())
  • Dry-run output includes: warnings, estimated_recompute_time, decisions_to_invalidate
  • plan.attempt field on the Plan model is incremented atomically after each correction
  • CorrectionService is thread-safe (uses proper locking for shared state)
  • Unit tests (Behave) cover persistence, dry-run, and attempt tracking scenarios
  • Test coverage >= 97% for all new/modified modules

Subtasks

  • Add correction_attempts table migration with original_subtree_snapshot column
  • Implement CorrectionService._persist_attempt() to write to DB
  • Replace in-memory dict storage with DB-backed storage in CorrectionService
  • Implement generate_dry_run_report() method in CorrectionService
  • Wire plan correct --dry-run CLI to call generate_dry_run_report() instead of analyze_impact()
  • Add thread safety to CorrectionService (replace plain dicts with thread-safe structures)
  • Implement atomic plan.attempt increment using DB transaction
  • Write Behave unit tests for persistence, dry-run output, and attempt tracking
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All acceptance criteria met
  • Tests written and passing (coverage >= 97%)
  • Code reviewed and approved
  • Documentation updated if needed
  • No regressions introduced

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit message:** `feat(correction): implement CorrectionService DB persistence, dry-run report, and plan.attempt tracking` - **Branch name:** `feat/m3-m4/correction-service-persistence` ## Background and Context Epic #4959 (Correction Engine — Revert & Append Modes) requires that `CorrectionService` persists correction attempts to the `correction_attempts` SQLite table (currently it stores them in-memory only), that `plan correct --dry-run` calls `generate_dry_run_report()` instead of `analyze_impact()`, and that the dry-run output includes spec-required fields (`warnings`, `estimated_recompute_time`, `decisions_to_invalidate`). This issue implements the persistence layer for the correction engine, the dry-run report generation, and the `plan.attempt` tracking infrastructure shared by both revert and append modes. This issue blocks Epic #4959. ## Acceptance Criteria - [ ] `CorrectionService` persists correction attempts to `correction_attempts` SQLite table (not in-memory) - [ ] `correction_attempts` table schema includes `original_subtree_snapshot` field per spec DDL - [ ] `plan correct --dry-run` calls `generate_dry_run_report()` (not `analyze_impact()`) - [ ] Dry-run output includes: `warnings`, `estimated_recompute_time`, `decisions_to_invalidate` - [ ] `plan.attempt` field on the Plan model is incremented atomically after each correction - [ ] `CorrectionService` is thread-safe (uses proper locking for shared state) - [ ] Unit tests (Behave) cover persistence, dry-run, and attempt tracking scenarios - [ ] Test coverage >= 97% for all new/modified modules ## Subtasks - [ ] Add `correction_attempts` table migration with `original_subtree_snapshot` column - [ ] Implement `CorrectionService._persist_attempt()` to write to DB - [ ] Replace in-memory dict storage with DB-backed storage in `CorrectionService` - [ ] Implement `generate_dry_run_report()` method in `CorrectionService` - [ ] Wire `plan correct --dry-run` CLI to call `generate_dry_run_report()` instead of `analyze_impact()` - [ ] Add thread safety to `CorrectionService` (replace plain dicts with thread-safe structures) - [ ] Implement atomic `plan.attempt` increment using DB transaction - [ ] Write Behave unit tests for persistence, dry-run output, and attempt tracking - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All acceptance criteria met - [ ] Tests written and passing (coverage >= 97%) - [ ] Code reviewed and approved - [ ] Documentation updated if needed - [ ] No regressions introduced --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.3.0 milestone 2026-04-14 04:03:44 +00:00
Author
Owner

Verified — CorrectionService DB persistence is a v3.3.0 deliverable. MoSCoW: Must-have. Priority: Medium.


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

✅ **Verified** — CorrectionService DB persistence is a v3.3.0 deliverable. MoSCoW: Must-have. Priority: Medium. --- **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.

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