*** Settings ***
Documentation    TDD Bug #1025 — plan correct auto-resolve fails in isolated environments.
...              Integration test verifying that ``plan correct <decision_id>``
...              auto-resolves the active plan when ``--plan`` is omitted, even
...              in isolated E2E subprocess environments where CLEVERAGENTS_HOME
...              is a temp directory.
...
...              Tests are tagged so CI passes via result inversion
...              while the bug remains unfixed.
...
...              Bug: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1025
...              TDD: https://git.cleverthis.com/cleveragents/cleveragents-core/issues/1035
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
TDD Plan Correct Auto Resolve Revert Mode
    [Documentation]    Verify that plan correct auto-resolves the active plan
    ...                when invoked with a decision_id and no --plan flag in
    ...                revert mode.  Bug #1025: auto-resolve fails in isolated
    ...                E2E environments.
    [Tags]  tdd_issue    tdd_issue_1025    tdd_issue    tdd_issue_4319    tdd_expected_fail

    ${result}=    Run Process    ${PYTHON}    ${HELPER}    auto-resolve-revert    cwd=${WORKSPACE}    timeout=30s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-correct-auto-resolve-revert-ok

TDD Plan Correct Auto Resolve Append Mode
    [Documentation]    Verify that plan correct auto-resolves the active plan
    ...                when invoked with a decision_id and no --plan flag in
    ...                append mode.  Bug #1025: auto-resolve fails in isolated
    ...                E2E environments.
    [Tags]  tdd_issue    tdd_issue_1025    tdd_issue    tdd_issue_4319    tdd_expected_fail

    ${result}=    Run Process    ${PYTHON}    ${HELPER}    auto-resolve-append    cwd=${WORKSPACE}    timeout=30s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-plan-correct-auto-resolve-append-ok
