feat(plan): add phase reversion state machine #185

Closed
opened 2026-02-22 23:39:56 +00:00 by freemo · 1 comment
Owner

Metadata

  • Commit: feat(plan): add phase reversion state machine
  • Branch: feature/m4-phase-reversion

Subtasks

  • Implement Execute-to-Strategize reversion in PlanLifecycleService when constraints are too restrictive (validation failures block apply and automation profile permits reversion).
  • Implement Apply-to-Strategize reversion from constrained terminal state, resetting phase to Strategize with preserved context and sandbox state.
  • Add auto_reversion_from_apply threshold check from the resolved AutomationProfile — only auto-revert if the profile's auto_reversion_from_apply flag is set.
  • Record each reversion as a reversion decision in the plan's decision tree with source phase, target phase, reason, and timestamp.
  • Wire reversion into PlanLifecycleService phase transition logic with explicit guard against infinite reversion loops (max 3 reversions per plan execution).
  • Add plan revert <plan_id> --to-phase <phase> CLI command for manual reversion.
  • Add docs/reference/phase_reversion.md documenting reversion triggers, automation profile thresholds, and loop guards.
  • Tests (Behave): Add features/phase_reversion.feature with scenarios for auto-reversion, manual reversion, loop guard, and profile-gated behavior.
  • Tests (Robot): Add robot/phase_reversion.robot for end-to-end reversion flow.
  • Tests (ASV): Add benchmarks/phase_reversion_bench.py for reversion overhead.
  • Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun nox -s coverage_report to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Section: #### M4: Corrections + Subplans + Checkpoints (Day 22)
Status: Open

## Metadata - **Commit**: `feat(plan): add phase reversion state machine` - **Branch**: `feature/m4-phase-reversion` ## Subtasks - [ ] Implement Execute-to-Strategize reversion in `PlanLifecycleService` when constraints are too restrictive (validation failures block apply and automation profile permits reversion). - [ ] Implement Apply-to-Strategize reversion from `constrained` terminal state, resetting phase to Strategize with preserved context and sandbox state. - [ ] Add `auto_reversion_from_apply` threshold check from the resolved `AutomationProfile` — only auto-revert if the profile's `auto_reversion_from_apply` flag is set. - [ ] Record each reversion as a `reversion` decision in the plan's decision tree with source phase, target phase, reason, and timestamp. - [ ] Wire reversion into `PlanLifecycleService` phase transition logic with explicit guard against infinite reversion loops (max 3 reversions per plan execution). - [ ] Add `plan revert <plan_id> --to-phase <phase>` CLI command for manual reversion. - [ ] Add `docs/reference/phase_reversion.md` documenting reversion triggers, automation profile thresholds, and loop guards. - [ ] Tests (Behave): Add `features/phase_reversion.feature` with scenarios for auto-reversion, manual reversion, loop guard, and profile-gated behavior. - [ ] Tests (Robot): Add `robot/phase_reversion.robot` for end-to-end reversion flow. - [ ] Tests (ASV): Add `benchmarks/phase_reversion_bench.py` for reversion overhead. - [ ] Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. **Section**: #### M4: Corrections + Subplans + Checkpoints (Day 22) **Status**: Open
freemo added this to the v3.3.0 milestone 2026-02-22 23:39:56 +00:00
freemo self-assigned this 2026-02-22 23:39:56 +00:00
Author
Owner

Closing as pre-existing inconsistency: PR #380 (phase reversion) was already closed/merged, but this issue remained open. Marking as completed during Day 15 rebaseline sync.

Closing as pre-existing inconsistency: PR #380 (phase reversion) was already closed/merged, but this issue remained open. Marking as completed during Day 15 rebaseline sync.
freemo 2026-02-23 18:34:05 +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#185
No description provided.