*** Settings ***
Documentation    Smoke tests for skeleton compressor service
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Compress Fragments At Ratio 0.5
    [Documentation]    Compress sample fragments at 50% ratio and verify output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    compress    0.5    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-compress-ok

Compress Fragments At Ratio 0.0
    [Documentation]    No compression — all fragments should survive
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    compress    0.0    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-compress-ok
    Should Contain    ${result.stdout}    fragment_count=3

Compress Fragments At Ratio 1.0
    [Documentation]    Maximum compression — only top fragment should survive
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    compress    1.0    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-compress-ok
    Should Contain    ${result.stdout}    fragment_count=1

Validate Ratio Bounds
    [Documentation]    Out-of-range ratios must raise ValueError
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validate-ratio-bounds    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-ratio-bounds-ok

Verify Metadata Fields
    [Documentation]    Metadata should record ratio, tokens, and decision IDs
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    metadata-fields    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-metadata-ok

Verify Stable Fragment Ordering
    [Documentation]    Fragments with equal relevance must be ordered deterministically
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    stable-ordering    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-stable-ordering-ok
