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

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

*** Test Cases ***
RelevanceCoherenceOrderer Orders Fragments
    [Documentation]    Order fragments by relevance while maintaining narrative coherence
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    orderer-basic    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-orderer-ok

ProvenancePreambleGenerator Generates Preamble
    [Documentation]    Generate structured provenance preamble from fragments
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    preamble-generate    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-preamble-ok

ArceStrategy Iterative Refinement
    [Documentation]    ARCE strategy with multi-backend iterative refinement
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    arce-strategy    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-arce-ok

TemporalArchaeologyStrategy Cold Tier Preference
    [Documentation]    Temporal archaeology strategy prioritises cold-tier fragments
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    temporal-strategy    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-temporal-ok

PlanDecisionContextStrategy Warm Tier Preference
    [Documentation]    Plan decision context strategy prioritises warm/cold tiers
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    plan-decision-strategy    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-plan-decision-ok

Pipeline Integration With Phase3 Components
    [Documentation]    Inject Phase 3 components into ACMSPipeline
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pipeline-integration    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase3-pipeline-ok
