029f09db1c
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Failing after 14s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 19s
CI / security (pull_request) Successful in 29s
CI / typecheck (pull_request) Failing after 31s
CI / coverage (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 3m41s
CI / unit_tests (pull_request) Successful in 6m31s
CI / docker (pull_request) Has been skipped
212 lines
10 KiB
Gherkin
212 lines
10 KiB
Gherkin
Feature: Correction Model
|
|
As a developer
|
|
I want to create and manage corrections for plan decisions
|
|
So that I can edit the decision tree and recompute affected subtrees
|
|
|
|
# ── Creation ─────────────────────────────────────────────────
|
|
|
|
Scenario: Create correction request in revert mode
|
|
Given a correction service
|
|
When I request a correction for plan "plan-1" decision "DEC-001" in revert mode with guidance "Use FastAPI instead"
|
|
Then the correction should be created
|
|
And the correction mode should be "revert"
|
|
And the correction status should be "pending"
|
|
And the correction plan_id should be "plan-1"
|
|
And the correction target_decision_id should be "DEC-001"
|
|
And the correction guidance should be "Use FastAPI instead"
|
|
|
|
Scenario: Create correction request in append mode
|
|
Given a correction service
|
|
When I request a correction for plan "plan-2" decision "DEC-002" in append mode with guidance "Add caching layer"
|
|
Then the correction should be created
|
|
And the correction mode should be "append"
|
|
And the correction status should be "pending"
|
|
|
|
Scenario: Create dry-run correction request
|
|
Given a correction service
|
|
When I request a dry-run correction for plan "plan-1" decision "DEC-001" in revert mode with guidance "Use SQLite"
|
|
Then the correction should be created
|
|
And the correction dry_run should be true
|
|
|
|
# ── Impact Analysis ──────────────────────────────────────────
|
|
|
|
Scenario: Dry-run returns impact analysis
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Change framework"
|
|
When I analyze the correction impact
|
|
Then the impact should list affected decisions
|
|
And the impact risk level should be "low"
|
|
And the correction status should be "analyzing"
|
|
|
|
# ── Cancellation ─────────────────────────────────────────────
|
|
|
|
Scenario: Cancel a pending correction
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Change approach"
|
|
When I cancel the correction
|
|
Then the correction status should be "cancelled"
|
|
|
|
Scenario: Cancel an already-cancelled correction fails
|
|
Given a correction service
|
|
And a cancelled correction for plan "plan-1" decision "DEC-001"
|
|
When I try to cancel the correction
|
|
Then a validation error should be raised with message containing "cancelled"
|
|
|
|
Scenario: Cancel an applied correction fails
|
|
Given a correction service
|
|
And an applied correction for plan "plan-1" decision "DEC-001"
|
|
When I try to cancel the correction
|
|
Then a validation error should be raised with message containing "applied"
|
|
|
|
# ── Listing ──────────────────────────────────────────────────
|
|
|
|
Scenario: List corrections by plan
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Fix endpoint"
|
|
And a correction request for plan "plan-1" decision "DEC-002" in append mode with guidance "Add logging"
|
|
And a correction request for plan "plan-2" decision "DEC-003" in revert mode with guidance "Change DB"
|
|
When I list corrections for plan "plan-1"
|
|
Then I should get 2 corrections
|
|
When I list corrections for plan "plan-2"
|
|
Then I should get 1 corrections
|
|
When I list all corrections
|
|
Then I should get 3 corrections
|
|
|
|
# ── Retrieval ────────────────────────────────────────────────
|
|
|
|
Scenario: Get correction by ID
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Test retrieval"
|
|
When I get the correction by its ID
|
|
Then the correction should be found
|
|
And the correction guidance should be "Test retrieval"
|
|
|
|
Scenario: Get non-existent correction raises error
|
|
Given a correction service
|
|
When I try to get correction "nonexistent-id"
|
|
Then a resource not found error should be raised
|
|
|
|
# ── Validation ───────────────────────────────────────────────
|
|
|
|
Scenario: Invalid decision ID rejection
|
|
Given a correction service
|
|
When I try to request a correction with empty decision ID
|
|
Then a validation error should be raised with message containing "decision_id"
|
|
|
|
Scenario: Invalid plan ID rejection
|
|
Given a correction service
|
|
When I try to request a correction with empty plan ID
|
|
Then a validation error should be raised with message containing "plan_id"
|
|
|
|
Scenario: Empty guidance is accepted
|
|
Given a correction service
|
|
When I try to request a correction with empty guidance
|
|
Then the correction should be created
|
|
|
|
Scenario: Whitespace-only guidance is accepted
|
|
Given a correction service
|
|
When I try to request a correction with whitespace-only guidance
|
|
Then the correction should be created
|
|
|
|
# ── Status Transitions ───────────────────────────────────────
|
|
|
|
Scenario: Correction status transitions through execution
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Execute me"
|
|
Then the correction status should be "pending"
|
|
When I execute the correction
|
|
Then the correction status should be "applied"
|
|
|
|
Scenario: Execute already-applied correction fails
|
|
Given a correction service
|
|
And an applied correction for plan "plan-1" decision "DEC-001"
|
|
When I try to execute the correction
|
|
Then a validation error should be raised with message containing "applied"
|
|
|
|
Scenario: Execute already-cancelled correction fails
|
|
Given a correction service
|
|
And a cancelled correction for plan "plan-1" decision "DEC-001"
|
|
When I try to execute the correction
|
|
Then a validation error should be raised with message containing "cancelled"
|
|
|
|
# ── Execution Result ─────────────────────────────────────────
|
|
|
|
Scenario: Revert execution produces reverted decisions
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Revert this"
|
|
When I execute the correction
|
|
Then the result should have reverted decisions
|
|
And the result status should be "applied"
|
|
|
|
Scenario: Append execution produces no reverted decisions
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in append mode with guidance "Append this"
|
|
When I execute the correction
|
|
Then the result should have no reverted decisions
|
|
And the result status should be "applied"
|
|
|
|
# ── Attempts ─────────────────────────────────────────────────
|
|
|
|
Scenario: Execution records an attempt
|
|
Given a correction service
|
|
And a correction request for plan "plan-1" decision "DEC-001" in revert mode with guidance "Track attempt"
|
|
When I execute the correction
|
|
Then there should be 1 attempt recorded
|
|
And the attempt should be successful
|
|
|
|
# ── Model Validation ─────────────────────────────────────────
|
|
|
|
Scenario: CorrectionRequest validates non-empty plan_id
|
|
When I try to create a CorrectionRequest with empty plan_id
|
|
Then a pydantic validation error should be raised
|
|
|
|
Scenario: CorrectionRequest validates non-empty target_decision_id
|
|
When I try to create a CorrectionRequest with empty target_decision_id
|
|
Then a pydantic validation error should be raised
|
|
|
|
Scenario: CorrectionRequest accepts empty guidance
|
|
When I try to create a CorrectionRequest with empty guidance
|
|
Then the correction should be created
|
|
|
|
Scenario: CorrectionImpact validates risk_level
|
|
When I try to create a CorrectionImpact with invalid risk_level "extreme"
|
|
Then a pydantic validation error should be raised
|
|
|
|
Scenario: CorrectionImpact accepts valid risk levels
|
|
When I create a CorrectionImpact with risk_level "low"
|
|
Then the impact should be created
|
|
When I create a CorrectionImpact with risk_level "medium"
|
|
Then the impact should be created
|
|
When I create a CorrectionImpact with risk_level "high"
|
|
Then the impact should be created
|
|
|
|
# ── Enum Tests ───────────────────────────────────────────────
|
|
|
|
Scenario: CorrectionMode enum values
|
|
Then CorrectionMode.REVERT should equal "revert"
|
|
And CorrectionMode.APPEND should equal "append"
|
|
|
|
Scenario: CorrectionStatus enum values
|
|
Then CorrectionStatus.PENDING should equal "pending"
|
|
And CorrectionStatus.ANALYZING should equal "analyzing"
|
|
And CorrectionStatus.EXECUTING should equal "executing"
|
|
And CorrectionStatus.APPLIED should equal "applied"
|
|
And CorrectionStatus.FAILED should equal "failed"
|
|
And CorrectionStatus.CANCELLED should equal "cancelled"
|
|
|
|
# ── CorrectionResult Model ──────────────────────────────────
|
|
|
|
Scenario: CorrectionResult with defaults
|
|
When I create a CorrectionResult with correction_id "corr-1" and status "applied"
|
|
Then the result should have empty new_decisions
|
|
And the result should have empty reverted_decisions
|
|
And the result error_message should be none
|
|
|
|
# ── CorrectionAttempt Model ─────────────────────────────────
|
|
|
|
Scenario: CorrectionAttempt default values
|
|
When I create a CorrectionAttempt for correction "corr-1"
|
|
Then the attempt success should be false
|
|
And the attempt completed_at should be none
|
|
And the attempt details should be empty
|