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

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

*** Test Cases ***
ContentHashDeduplicator Removes Duplicates
    [Documentation]    Deduplicate fragments with identical content, keeping highest scored
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    dedup-basic    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase2-dedup-ok

MaxDepthResolver Resolves Depth Conflicts
    [Documentation]    Resolve same UKO node at multiple depths to maximum
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    depth-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase2-depth-ok

WeightedCompositeScorer Scores Fragments
    [Documentation]    Score fragments with configurable weighted factors
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scorer-default    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase2-scorer-ok

GreedyKnapsackPacker Packs Within Budget
    [Documentation]    Pack fragments using greedy knapsack within token budget
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    packer-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase2-packer-ok

ScoredFragment Model Validation
    [Documentation]    Create ScoredFragment model and verify fields
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-fragment    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    phase2-scored-fragment-ok

Pipeline Integration With Phase2 Components
    [Documentation]    Inject all Phase 2 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}    phase2-pipeline-ok
