Files
freemo c4f71e930d
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 21s
CI / build (pull_request) Successful in 23s
CI / typecheck (pull_request) Successful in 39s
CI / security (pull_request) Successful in 50s
CI / integration_tests (pull_request) Successful in 4m4s
CI / unit_tests (pull_request) Successful in 9m15s
CI / docker (pull_request) Successful in 1m0s
CI / benchmark-regression (pull_request) Successful in 23m41s
CI / coverage (pull_request) Successful in 43m24s
CI / lint (push) Successful in 22s
CI / build (push) Successful in 24s
CI / quality (push) Successful in 27s
CI / typecheck (push) Successful in 44s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 55s
CI / integration_tests (push) Successful in 4m16s
CI / benchmark-publish (push) Successful in 14m39s
CI / unit_tests (push) Successful in 24m24s
CI / docker (push) Successful in 1m1s
CI / coverage (push) Successful in 45m36s
feat(concurrency): add plan resume
Implement step-level progress persistence and plan resume with graceful
shutdown handling.

- Add ResumeCheckpoint, ResumeMetadata, ResumeEligibility, ResumeSummary
  domain models (resume.py)
- Add PlanResumeService with validate_eligibility(), build_resume_summary(),
  resume_plan(dry_run), record_step_checkpoint(), record_shutdown()
- Add last_completed_step and last_checkpoint_id fields to Plan model
- Add 'plan resume' CLI command with --dry-run flag
- Update plan lifecycle docs (ADR-006) with resume behavior section
- Add Behave tests (24 scenarios in plan_resume.feature)
- Add Robot Framework integration tests (10 tests)
- Add ASV benchmarks for resume overhead

Closes #328
2026-02-25 14:00:04 -05:00

153 lines
6.4 KiB
Gherkin

Feature: Plan Resume
As a developer
I want to resume interrupted or errored plan executions
So that I don't lose progress when something goes wrong
Background:
Given I have a plan lifecycle service for resume tests
And I have a plan resume service
# Resume eligibility validation
Scenario: Eligible plan in errored state can be resumed
Given I have a resume-test plan in execute phase with errored state
When I validate resume eligibility
Then the plan should be eligible for resume
Scenario: Eligible plan in processing state can be resumed
Given I have a resume-test plan in execute phase with processing state
When I validate resume eligibility
Then the plan should be eligible for resume
Scenario: Eligible plan in queued state can be resumed
Given I have a resume-test plan in strategize phase with queued state
When I validate resume eligibility
Then the plan should be eligible for resume
Scenario: Terminal applied plan cannot be resumed
Given I have a resume-test plan in applied terminal state
When I validate resume eligibility
Then the plan should not be eligible for resume
And the ineligible reason should be "terminal_applied"
Scenario: Terminal cancelled plan cannot be resumed
Given I have a resume-test plan in cancelled terminal state
When I validate resume eligibility
Then the plan should not be eligible for resume
And the ineligible reason should be "terminal_cancelled"
Scenario: Terminal constrained plan cannot be resumed
Given I have a resume-test plan in constrained terminal state
When I validate resume eligibility
Then the plan should not be eligible for resume
And the ineligible reason should be "terminal_constrained"
Scenario: Action phase plan cannot be resumed
Given I have a resume-test plan in action phase
When I validate resume eligibility
Then the plan should not be eligible for resume
And the ineligible reason should be "action_phase"
# Resume metadata and checkpoints
Scenario: Record step checkpoint during execution
Given I have a resume-test plan in execute phase with processing state
When I record a resume step checkpoint at index 0 with decision "DEC001"
Then the resume-test plan should have last completed step 0
And the resume-test plan should have a checkpoint ID set
Scenario: Record multiple checkpoints
Given I have a resume-test plan in execute phase with processing state
When I record a resume step checkpoint at index 0 with decision "DEC001"
And I record a resume step checkpoint at index 1 with decision "DEC002"
And I record a resume step checkpoint at index 2 with decision "DEC003"
Then the resume-test plan should have last completed step 2
And the resume metadata should have 3 checkpoints
Scenario: Resume metadata tracks next step correctly
Given I have a resume-test plan in execute phase with processing state
When I record a resume step checkpoint at index 2 with decision "DEC003"
Then the resume metadata next step should be 3
# Resume summary (dry-run)
Scenario: Dry-run shows resume point without changing state
Given I have a resume-test plan in execute phase with errored state
And the resume-test plan has checkpoint at step 2 with decision "DEC003"
When I resume the plan with dry-run
Then I should get a resume summary
And the resume summary next step should be 3
And the resume-test plan processing state should still be errored
Scenario: Resume summary includes decision ID from checkpoint
Given I have a resume-test plan in execute phase with errored state
And the resume-test plan has checkpoint at step 1 with decision "DEC002"
When I resume the plan with dry-run
Then the resume summary decision ID should be "DEC002"
# Live resume
Scenario: Resume errored plan resets to processing
Given I have a resume-test plan in execute phase with errored state
And the resume-test plan has checkpoint at step 1 with decision "DEC002"
When I resume the plan without dry-run
Then the resume-test plan processing state should be processing
And the resume-test plan error message should be cleared
Scenario: Resume queued plan transitions to processing
Given I have a resume-test plan in strategize phase with queued state
When I resume the plan without dry-run
Then the resume-test plan processing state should be processing
# Graceful shutdown
Scenario: Record graceful shutdown marks interrupted
Given I have a resume-test plan in execute phase with processing state
When I record a resume step checkpoint at index 1 with decision "DEC002"
And I record a graceful shutdown for resume
Then the resume metadata should be marked as interrupted
# Error handling
Scenario: Resume with empty plan ID raises validation error
When I try to resume a plan with empty ID
Then a resume validation error should be raised
Scenario: Validate eligibility with empty plan ID raises error
When I try to validate eligibility with empty plan ID
Then a resume validation error should be raised
Scenario: Resume terminal plan raises plan error
Given I have a resume-test plan in applied terminal state
When I try to resume the terminal plan for resume test
Then a plan error should be raised for resume
# Step count tracking
Scenario: Set total steps for a plan
Given I have a resume-test plan in execute phase with processing state
When I set the resume total steps to 5
Then the resume metadata total steps should be 5
Scenario: Set total steps with invalid values raises error
When I try to set resume total steps with empty plan ID
Then a resume validation error should be raised
# ResumeMetadata model properties
Scenario: Resume metadata has_progress when steps completed
Given I have resume metadata with last completed step 2
Then the resume metadata has_progress should be true
Scenario: Resume metadata has no progress initially
Given I have fresh resume metadata
Then the resume metadata has_progress should be false
Scenario: Resume metadata is_complete when all steps done
Given I have resume metadata with 3 total steps and last step 2
Then the resume metadata is_complete should be true
Scenario: Resume metadata is not complete with remaining steps
Given I have resume metadata with 5 total steps and last step 2
Then the resume metadata is_complete should be false