*** Settings ***
Documentation    Integration test for WF03 plan prompt and confidence-threshold
...              pausing verification.
...
...              Exercises:
...              - plan prompt via the A2A facade (§15822)
...              - confidence-threshold pausing with the cautious profile
...                (§37262–37367) where confidence < 0.6 causes escalation
...              - pause-and-resume flow: low-confidence decision triggers
...                pause, then plan prompt guidance resumes execution
...
...              References:
...              - Issue #961 (AC1: plan prompt, AC2: confidence-threshold)
...              - Spec §15822–15931 (plan prompt command)
...              - Spec §37262–37367 (WF03 cautious profile flow)
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment
Force Tags       wf03    v3.4.0    integration    plan-prompt    confidence

*** Variables ***
${HELPER}    ${CURDIR}/helper_wf03_plan_prompt_confidence.py

*** Test Cases ***
WF03 Plan Prompt Via Facade
    [Documentation]    Exercise ``plan prompt`` via the A2A facade dispatch
    ...                path. Sends guidance for a plan and verifies the
    ...                facade returns a stub ``guidance_injected`` response
    ...                with the correct plan ID. (§15822)
    [Tags]    plan-prompt    facade
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-prompt-facade    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    wf03-plan-prompt-ok

WF03 Confidence Threshold Pausing
    [Documentation]    Verify that the cautious profile pauses execution when
    ...                a strategy decision has confidence below the threshold
    ...                (0.6 for ``edit_code``). Seeds factors
    ...                producing confidence 0.55 and asserts ``proceed=False``.
    [Tags]    confidence    cautious    threshold
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    confidence-threshold-pausing    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    wf03-confidence-pause-ok

WF03 Confidence Threshold Proceeds
    [Documentation]    Verify that the cautious profile proceeds when a strategy
    ...                decision has confidence above the threshold. Seeds factors
    ...                producing confidence 0.85 and asserts ``proceed=True``.
    [Tags]    confidence    cautious    threshold
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    confidence-threshold-proceeds    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    wf03-confidence-proceed-ok

WF03 Pause And Resume Via Plan Prompt
    [Documentation]    End-to-end flow: seed a plan with a low-confidence
    ...                decision, verify it pauses, then provide guidance via
    ...                ``plan prompt`` and verify the system accepts the
    ...                guidance (stub path). This covers the WF03 scenario
    ...                from §37262–37367 where the user corrects a paused
    ...                decision by providing guidance.
    [Tags]    plan-prompt    confidence    cautious    pause-resume
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pause-and-resume    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    wf03-pause-resume-ok
