*** 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 Budget 500
    [Documentation]    Compress sample fragments with budget of 500 tokens and verify output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    compress    500    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-compress-ok budget=500

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

Compress Fragments At Budget Zero
    [Documentation]    Zero budget — no fragments should survive
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    compress    0    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-compress-ok budget=0
    Should Contain    ${result.stdout}    fragment_count=0

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

Verify Protocol Conformance
    [Documentation]    SkeletonCompressorService must satisfy the SkeletonCompressor protocol
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    protocol-check    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skeleton-protocol-check-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
