*** Settings ***
Documentation    Integration smoke tests for ACMS Pipeline Orchestrator and Phase 1 components
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
ConfidenceWeightedSelector Selects Strategies
    [Documentation]    ConfidenceWeightedSelector selects and ranks strategies by confidence
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cws-select    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cws-select-ok

ConfidenceWeightedSelector Boosts Preferred
    [Documentation]    ConfidenceWeightedSelector boosts preferred strategies
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cws-preferred    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cws-preferred-ok

ProportionalBudgetAllocator Distributes Budget
    [Documentation]    ProportionalBudgetAllocator distributes tokens proportionally
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pba-proportional    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    pba-proportional-ok

ProportionalBudgetAllocator MinBudget Enforcement
    [Documentation]    ProportionalBudgetAllocator enforces min_useful_budget
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pba-min-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    pba-min-budget-ok

CircuitBreaker Opens After Failures
    [Documentation]    CircuitBreaker opens circuit after consecutive failures
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cb-open    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cb-open-ok

CircuitBreaker Resets On Success
    [Documentation]    CircuitBreaker resets on success
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cb-reset    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    cb-reset-ok

ParallelStrategyExecutor Executes Strategy
    [Documentation]    ParallelStrategyExecutor invokes strategy and returns fragments
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    executor-run    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    executor-run-ok

ContextAssemblyPipeline Assemble With Timings
    [Documentation]    Full pipeline assembly with timing metadata
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pipeline-assemble    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    pipeline-assemble-ok

ContextAssemblyPipeline Custom Components
    [Documentation]    Pipeline accepts custom Phase 1 components
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pipeline-custom    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    pipeline-custom-ok
