*** Settings ***
Documentation     Smoke tests for plan execute runtime integration.
...               Covers PlanExecutionContext, changeset capture,
...               RuntimeExecuteActor, and PlanExecutor runtime mode.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_plan_execute_runtime.py

*** Test Cases ***
Plan Execution Context Creation
    [Documentation]    Verify PlanExecutionContext creates with valid plan_id and defaults
    [Tags]    plan    execute    runtime    context
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    context-creation    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-creation-ok

Changeset Start And Record
    [Documentation]    Verify changeset start_changeset and record_change flow
    [Tags]    plan    execute    runtime    changeset
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    changeset-ops    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    changeset-ops-ok

Runtime Execute Actor Dispatch
    [Documentation]    Verify RuntimeExecuteActor dispatches decisions and produces result
    [Tags]    plan    execute    runtime    actor
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    runtime-actor    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    runtime-actor-ok

PlanExecutor Runtime Mode
    [Documentation]    Verify PlanExecutor has_runtime and changeset_store when context provided
    [Tags]    plan    execute    runtime    executor
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    executor-runtime    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    executor-runtime-ok

PlanExecutor Stub Fallback
    [Documentation]    Verify PlanExecutor falls back to stub when no context
    [Tags]    plan    execute    runtime    executor    stub
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    executor-stub    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    executor-stub-ok
