*** Settings ***
Documentation     Integration tests for built-in context strategies batch 1
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

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

*** Test Cases ***
SimpleKeyword Ranks By Keyword Match
    [Documentation]    SimpleKeywordStrategy ranks keyword-matching fragments first
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    simple-keyword-rank    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: simple-keyword-rank

SimpleKeyword Respects Budget
    [Documentation]    SimpleKeywordStrategy respects token budget
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    simple-keyword-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: simple-keyword-budget

SemanticEmbedding Ranks By Similarity
    [Documentation]    SemanticEmbeddingStrategy ranks by word similarity
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    semantic-embedding-rank    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: semantic-embedding-rank

SemanticEmbedding Filters Unrelated
    [Documentation]    SemanticEmbeddingStrategy filters below similarity threshold
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    semantic-embedding-filter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: semantic-embedding-filter

BreadthDepth Prioritises Near Focus
    [Documentation]    BreadthDepthNavigatorStrategy prioritises fragments near focus
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    breadth-depth-rank    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: breadth-depth-rank

BreadthDepth Respects Budget
    [Documentation]    BreadthDepthNavigatorStrategy respects token budget
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    breadth-depth-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: breadth-depth-budget

Pipeline Registration
    [Documentation]    Register all batch 1 strategies with pipeline
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    pipeline-register    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: pipeline-register

Can Handle Confidence Values
    [Documentation]    Verify can_handle confidence values for all strategies
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    can-handle    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: can-handle

Strategy Capabilities
    [Documentation]    Verify capability flags and names for all strategies
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    capabilities    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    context-strategies-ok: capabilities
