freemo
7fb3fc76c8
fix(plan-lifecycle): add rollback_plan method to PlanLifecycleService
...
- What was implemented
- Added PLAN_ROLLED_BACK event type to the EventType enum at src/cleveragents/infrastructure/events/types.py to properly represent successful rollbacks in the domain model.
- Implemented rollback_plan(plan_id: str, checkpoint_id: str) -> RollbackResult in PlanLifecycleService (src/cleveragents/application/services/plan_lifecycle_service.py) with:
- Plan state validation: rejects rollback when the plan is in terminal APPLIED or CANCELLED states.
- Delegation to CheckpointService.selective_rollback() to perform the actual rollback logic and obtain a RollbackResult.
- Emission of PLAN_ROLLED_BACK as a domain event to reflect the completed rollback.
- checkpoint_service is accepted as an optional constructor parameter; if not provided, a PlanError is raised to preserve backward compatibility.
- Updated CLI behavior in src/cleveragents/cli/commands/plan.py so agents plan rollback routes through PlanLifecycleService.rollback_plan() rather than calling CheckpointService.selective_rollback() directly.
- Updated PlanLifecycleService module docstring to include rollback_plan in the documented API.
- Added Behave feature file features/plan_lifecycle_rollback.feature with 11 scenarios covering state validation, domain events, and delegation.
- Added step implementations in features/steps/plan_lifecycle_rollback_steps.py to support the new scenarios.
- Key design decisions
- rollback_plan returns RollbackResult (the same result type produced by CheckpointService.selective_rollback) so the CLI can display rollback details consistently.
- Terminal states APPLIED and CANCELLED are disallowed for rollback to prevent inconsistent or invalid state transitions.
- checkpoint_service is optional in the PlanLifecycleService constructor; when omitted (None), a PlanError is raised to retain backward compatibility while signaling explicit dependency requirements.
- CLI UI remains powered by CheckpointService for metadata enrichment (e.g., confirmation prompts), but the actual rollback action is performed via PlanLifecycleService to ensure proper domain workflow and event emission.
- Technical implications
- All rollback logic now flows through the domain service layer (PlanLifecycleService) to preserve invariants and emit domain events, rather than allowing ad-hoc UI routes to bypass service validation.
- The UI can still retrieve checkpoint metadata for user confirmation, but the operation that modifies state uses the new rollback_plan pathway.
- Tests and behavior coverage were expanded via the new Behave feature and step implementations to validate state handling, events, and delegation.
- Affected modules/components
- src/cleveragents/infrastructure/events/types.py
- src/cleveragents/application/services/plan_lifecycle_service.py
- src/cleveragents/cli/commands/plan.py
- PlanLifecycleService module docstring
- features/plan_lifecycle_rollback.feature
- features/steps/plan_lifecycle_rollback_steps.py
ISSUES CLOSED : #3677
2026-06-03 03:22:59 -04:00
..
2026-05-07 20:05:33 +00:00
2026-04-15 06:37:18 +00:00
2026-04-27 07:33:18 +00:00
2026-06-02 07:19:20 -04:00
2026-05-29 16:36:39 -04:00
2026-06-03 03:22:59 -04:00
2026-04-13 04:56:01 +00:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 23:33:52 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-05-13 06:49:40 +00:00
2026-06-02 15:41:06 -04:00
2026-04-28 03:22:06 +00:00
2026-04-23 11:46:36 +00:00
2026-05-01 09:10:48 +00:00
2026-04-05 21:26:33 +00:00
2026-05-28 20:47:07 -04:00
2026-05-07 20:05:33 +00:00
2026-04-13 04:56:01 +00:00
2026-05-07 20:05:33 +00:00
2026-05-14 08:10:58 +00:00
2026-04-13 04:56:01 +00:00
2026-05-06 01:07:15 +00:00
2026-04-27 05:00:54 +00:00
2026-05-09 23:13:33 +01:00
2026-05-05 01:33:31 +00:00
2026-04-17 16:28:45 +08:00
2026-06-02 08:44:47 -04:00
2026-04-30 10:56:21 +00:00
2026-06-02 04:52:51 -04:00
2026-05-30 00:36:20 -04:00
2026-05-28 17:35:08 -04:00
2026-05-12 13:02:59 +00:00
2026-04-13 04:56:01 +00:00
2026-05-27 12:14:04 -04:00
2026-04-23 12:19:50 +00:00
2026-04-30 10:56:21 +00:00
2026-05-06 04:08:25 +00:00
2026-04-30 02:05:12 +00:00
2026-05-16 13:38:54 +00:00
2026-06-02 21:16:38 -04:00
2026-06-03 00:53:19 -04:00
2026-05-07 20:05:33 +00:00
2026-05-02 21:54:17 +00:00
2026-05-15 22:19:57 +01:00
2026-05-05 02:01:49 +00:00
2026-06-02 17:06:11 -04:00
2026-05-31 10:55:18 -04:00
2026-06-02 01:25:33 -04:00
2026-04-23 09:08:11 +00:00
2026-05-07 07:08:52 +00:00
2026-04-30 02:05:12 +00:00
2026-04-20 13:54:28 +00:00
2026-04-13 04:56:01 +00:00
2026-05-03 00:39:15 +00:00
2026-04-17 18:33:39 +00:00
2026-04-17 11:46:38 +00:00
2026-04-13 04:56:01 +00:00
2026-05-05 02:01:49 +00:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 14:01:59 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-05-12 01:05:10 +00:00
2026-05-05 02:01:49 +00:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-05-05 02:01:49 +00:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 07:37:14 -04:00
2026-06-02 07:37:13 -04:00
2026-04-13 04:56:01 +00:00
2026-06-01 23:37:30 -04:00
2026-06-01 23:37:30 -04:00
2026-06-01 23:37:30 -04:00
2026-04-13 04:56:01 +00:00
2026-05-09 23:13:33 +01:00
2026-05-05 02:01:49 +00:00
2026-05-16 04:14:17 +00:00
2026-04-21 05:14:07 +00:00
2026-05-11 04:39:29 +00:00
2026-05-07 20:05:33 +00:00
2026-05-30 16:14:46 -04:00
2026-05-16 13:38:54 +00:00
2026-04-17 11:46:38 +00:00
2026-04-23 12:19:50 +00:00
2026-04-12 08:15:49 +00:00
2026-06-02 20:37:35 -04:00
2026-05-30 13:08:44 -04:00
2026-04-08 11:02:14 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-09 13:00:47 +00:00
2026-04-15 00:24:13 +00:00
2026-04-12 16:43:30 +00:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-06-01 17:37:24 -04:00
2026-06-01 17:07:39 -04:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-30 10:56:21 +00:00
2026-04-21 16:53:08 +00:00
2026-05-16 06:04:01 +00:00
2026-05-08 05:11:47 +00:00
2026-04-24 05:45:20 +00:00
2026-05-19 21:56:28 +01:00
2026-05-05 17:18:16 +00:00
2026-05-07 23:49:20 +00:00
2026-06-02 20:37:35 -04:00
2026-06-02 20:37:35 -04:00
2026-06-02 20:37:35 -04:00
2026-06-02 20:37:35 -04:00
2026-06-02 20:37:35 -04:00
2026-04-20 06:08:50 +00:00
2026-05-07 20:05:33 +00:00
2026-05-29 07:21:08 -04:00
2026-05-12 08:30:24 +00:00
2026-05-13 12:24:33 +00:00
2026-04-13 04:56:01 +00:00
2026-04-24 22:46:41 +00:00
2026-05-16 16:40:54 +00:00
2026-05-02 01:36:45 +00:00
2026-04-30 14:56:33 +00:00
2026-05-05 05:25:28 +00:00
2026-04-09 14:17:50 +00:00
2026-04-28 04:06:57 +00:00
2026-04-28 04:06:57 +00:00
2026-06-02 19:50:41 -04:00
2026-05-31 20:45:10 -04:00
2026-05-31 20:45:10 -04:00
2026-05-19 21:56:28 +01:00
2026-05-30 10:38:39 -04:00
2026-05-05 02:01:49 +00:00
2026-05-22 20:42:25 +01:00
2026-05-19 12:43:34 +00:00
2026-05-19 12:43:34 +00:00
2026-04-26 11:19:10 +00:00
2026-04-23 09:22:33 +00:00
2026-05-28 11:36:14 -04:00
2026-05-11 04:39:29 +00:00
2026-05-19 12:43:34 +00:00
2026-04-19 17:10:17 +00:00
2026-04-13 04:56:01 +00:00
2026-04-24 10:32:15 +00:00
2026-04-21 03:38:05 +00:00
2026-06-02 16:48:22 -04:00
2026-06-02 16:48:22 -04:00
2026-05-19 12:43:34 +00:00
2026-05-19 12:43:34 +00:00
2026-04-17 08:34:33 +00:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-04-13 04:56:01 +00:00
2026-04-17 08:34:33 +00:00
2026-05-05 02:01:49 +00:00
2026-04-17 08:34:33 +00:00
2026-04-17 08:34:33 +00:00
2026-04-13 04:56:01 +00:00
2026-04-21 11:31:15 +00:00
2026-06-02 05:14:43 -04:00
2026-05-19 19:28:35 +01:00
2026-05-28 00:05:08 -04:00
2026-05-19 19:28:35 +01:00
2026-05-19 19:28:35 +01:00
2026-05-07 20:05:33 +00:00
2026-05-19 12:43:34 +00:00
2026-05-19 12:43:34 +00:00
2026-05-09 12:23:24 +00:00
2026-05-09 12:23:24 +00:00
2026-05-12 08:30:24 +00:00
2026-05-12 08:30:24 +00:00
2026-05-05 02:01:49 +00:00
2026-06-03 03:22:59 -04:00
2026-05-14 22:57:11 +00:00
2026-05-22 20:42:25 +01:00
2026-06-03 00:24:21 -04:00
2026-06-03 03:03:14 -04:00
2026-05-05 02:01:49 +00:00
2026-04-09 06:11:39 +00:00
2026-05-08 09:32:29 +00:00
2026-05-29 03:59:05 -04:00
2026-05-05 17:18:16 +00:00
2026-04-10 18:59:10 +00:00
2026-06-02 04:09:01 -04:00
2026-05-08 09:57:18 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-05-07 20:05:33 +00:00
2026-04-13 04:56:01 +00:00
2026-05-05 06:16:46 +00:00
2026-05-05 06:16:46 +00:00
2026-05-18 06:05:54 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-05-31 15:39:36 -04:00
2026-05-30 15:43:56 -04:00
2026-06-02 20:37:35 -04:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-05-30 15:43:56 -04:00
2026-05-07 20:05:33 +00:00
2026-04-30 10:03:08 +00:00
2026-05-03 00:17:15 +00:00
2026-04-21 11:56:19 +00:00
2026-05-11 08:59:08 +00:00
2026-06-01 00:40:59 -04:00
2026-05-29 07:21:08 -04:00
2026-06-02 19:50:41 -04:00
2026-06-02 15:41:06 -04:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-05-05 02:01:49 +00:00
2026-06-02 15:41:06 -04:00
2026-05-31 19:27:43 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-06-02 15:41:06 -04:00
2026-05-11 04:39:29 +00:00
2026-05-11 04:39:29 +00:00
2026-05-30 08:29:22 -04:00
2026-04-13 04:56:01 +00:00
2026-05-30 04:04:21 -04:00
2026-05-08 06:24:23 +00:00
2026-05-22 20:42:25 +01:00
2026-05-14 06:46:27 +00:00
2026-04-14 02:51:16 +00:00
2026-06-02 19:50:41 -04:00
2026-04-21 01:59:07 +00:00
2026-05-30 02:07:41 -04:00
2026-04-08 11:02:14 +00:00
2026-04-08 11:02:14 +00:00
2026-04-30 02:05:12 +00:00
2026-04-25 04:21:23 +00:00
2026-05-29 15:26:47 -04:00
2026-05-14 22:57:11 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-05-12 10:17:39 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-08 11:02:14 +00:00
2026-06-02 05:51:55 -04:00
2026-05-07 23:39:08 +01:00
2026-04-13 04:56:01 +00:00
2026-04-15 13:37:16 +08:00
2026-06-02 03:39:50 -04:00
2026-04-28 09:23:33 +00:00
2026-04-13 04:56:01 +00:00
2026-04-08 11:02:14 +00:00
2026-04-13 04:56:01 +00:00
2026-05-12 16:45:59 +00:00
2026-04-21 06:42:10 +00:00
2026-04-28 10:12:06 +00:00
2026-05-05 04:04:13 +00:00
2026-04-26 18:23:48 +00:00
2026-04-26 12:19:34 +00:00
2026-05-05 09:37:22 +00:00
2026-05-02 21:57:54 +00:00
2026-04-13 04:56:01 +00:00
2026-05-15 02:41:37 +00:00
2026-05-23 00:01:44 +00:00
2026-04-24 19:01:56 +00:00
2026-05-05 17:48:39 +00:00
2026-05-30 00:09:20 -04:00
2026-04-08 11:02:14 +00:00
2026-04-13 04:56:01 +00:00
2026-06-02 07:19:20 -04:00
2026-04-08 11:02:14 +00:00
2026-04-08 11:02:14 +00:00
2026-05-31 15:00:33 -04:00
2026-05-07 14:22:57 +00:00
2026-06-02 18:42:43 -04:00
2026-05-13 12:24:33 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 04:56:01 +00:00
2026-04-13 21:16:55 +00:00
2026-04-26 17:34:52 +00:00
2026-06-01 00:40:59 -04:00
2026-04-13 04:56:01 +00:00
2026-05-07 19:14:53 +00:00
2026-04-08 11:02:14 +00:00
2026-04-08 11:02:14 +00:00
2026-04-27 01:12:35 +00:00
2026-04-13 04:56:01 +00:00
2026-04-23 18:29:11 +00:00
2026-04-22 00:45:09 +00:00
2026-05-13 07:13:34 +00:00
2026-04-13 04:56:01 +00:00
2026-04-10 20:50:20 +00:00
2026-04-13 04:56:01 +00:00
2026-04-28 07:33:43 +00:00
2026-05-27 23:17:15 -04:00
2026-05-29 05:08:08 -04:00
2026-04-27 07:33:18 +00:00
2026-04-27 07:33:18 +00:00
2026-04-24 04:11:54 +00:00
2026-05-28 12:52:19 -04:00
2026-04-13 04:56:01 +00:00
2026-04-21 08:45:06 +00:00
2026-05-30 03:33:08 -04:00
2026-04-13 04:56:01 +00:00
2026-05-19 12:43:34 +00:00
2026-06-02 00:38:09 -04:00
2026-05-27 00:46:19 -04:00
2026-06-02 00:38:09 -04:00
2026-05-22 15:12:04 +00:00
2026-04-23 23:01:46 +00:00
2026-05-30 02:34:32 -04:00
2026-05-08 11:15:36 +00:00
2026-04-13 04:56:01 +00:00
2026-06-02 00:38:09 -04:00
2026-06-02 00:38:09 -04:00
2026-04-22 06:37:17 +00:00
2026-05-29 03:59:05 -04:00
2026-04-06 07:55:09 +00:00
2026-06-02 04:29:20 -04:00
2026-04-30 10:56:21 +00:00