@wf03 @plan_prompt @confidence
Feature: WF03 plan prompt and confidence-threshold pausing verification
  As a cautious-profile user
  I want confidence-threshold pausing to halt plan execution when confidence is low
  So that I can provide guidance via plan prompt before the system proceeds

  # --------------------------------------------------------------------------
  # AC1: plan prompt exercises -- verifying the A2A facade path (S15822)
  # --------------------------------------------------------------------------

  Scenario: Plan prompt via facade injects guidance and returns stub response
    Given a plan prompt facade with no services
    When I dispatch plan prompt for plan "PLAN-WF03-001" with guidance "Use separate models/ directory"
    Then the plan prompt response status should be "guidance_injected"
    And the plan prompt response should contain the plan id "PLAN-WF03-001"
    And the plan prompt response should echo the guidance "Use separate models/ directory"
    # TODO(#885): Verify guidance_added.scope, state_transition, decision_created.type per S15894-15913

  Scenario: Plan prompt via facade with minimal guidance returns stub response
    Given a plan prompt facade with no services
    When I dispatch plan prompt for plan "PLAN-WF03-002" with guidance "ok"
    Then the plan prompt response status should be "guidance_injected"
    And the plan prompt response should contain the plan id "PLAN-WF03-002"
    And the plan prompt response should echo the guidance "ok"

  Scenario: Plan prompt via facade with empty guidance
    Given a plan prompt facade with no services
    When I dispatch plan prompt for plan "PLAN-WF03-003" with empty guidance
    Then the plan prompt response status should be "guidance_injected"
    And the plan prompt response should contain the plan id "PLAN-WF03-003"
    And the plan prompt response should echo empty guidance

  # --------------------------------------------------------------------------
  # AC2: Confidence-threshold pausing with cautious profile (S37262-37367)
  # --------------------------------------------------------------------------

  Scenario: Cautious profile pauses on low-confidence strategy decision
    Given a default autonomy controller
    And the automation profile "cautious"
    And the cautious edit_code threshold should be 0.6
    When I evaluate escalation for operation "edit_code" with confidence factors past_success_rate 0.4 codebase_familiarity 0.5 risk_assessment 0.6 invariant_complexity 0.5
    Then the escalation decision proceed should be false
    And the escalation confidence should be below the cautious threshold 0.6

  Scenario: Cautious profile proceeds on high-confidence strategy decision
    Given a default autonomy controller
    And the automation profile "cautious"
    When I evaluate escalation for operation "edit_code" with confidence factors past_success_rate 0.9 codebase_familiarity 0.8 risk_assessment 0.1 invariant_complexity 0.1
    Then the escalation decision proceed should be true
    And the escalation confidence should be at or above the cautious threshold 0.6

  Scenario: Cautious profile pauses when confidence equals 0.55 for strategy decisions
    Given a default autonomy controller
    And the automation profile "cautious"
    When I evaluate escalation for operation "edit_code" with factors producing confidence 0.55
    Then the escalation decision proceed should be false
    And the decision explanation should mention threshold

  Scenario: Cautious profile proceeds when confidence equals 0.6 exactly for strategy decisions
    Given a default autonomy controller
    And the automation profile "cautious"
    When I evaluate escalation for operation "edit_code" with factors producing confidence 0.6
    Then the escalation decision proceed should be true

  # --------------------------------------------------------------------------
  # AC2+: Full pause-and-resume flow (S37262-37367)
  # NOTE: Full causal resume testing (guidance -> re-evaluation) requires
  # the wired actor/provider stack from #885. This scenario establishes
  # a logical connection via plan_id but cannot prove causality yet.
  # --------------------------------------------------------------------------

  Scenario: WF03 full pause-and-resume flow with cautious profile
    Given a default autonomy controller
    And the automation profile "cautious"
    And a decision seeded with confidence 0.55 for operation "edit_code"
    When I check whether the system should proceed automatically
    Then the escalation decision proceed should be false
    And the decision explanation should mention escalation to user
    When I provide plan prompt guidance "Use separate models/ directory" for the paused plan
    Then the guidance should be recorded as a user intervention
    And the guidance response plan id should match the paused decision context
    When I re-evaluate with corrected confidence 0.85 for operation "edit_code"
    Then the escalation decision proceed should be true
