*** Settings ***
Documentation    Smoke tests for Skill resolver output ordering, de-duplication, inline tools, and cycle detection
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Resolve Skill With Flat Includes Preserves Depth-First Order
    [Documentation]    Resolve a skill including another and verify included tools appear first
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-flat    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-resolve-flat-ok

Resolve Skill With Overlapping Includes De-Duplicates
    [Documentation]    Resolve overlapping includes and verify shared tools appear once with last-wins semantics
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-dedup    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-resolve-dedup-ok

Resolve Skill With Inline Tools And MCP Sources
    [Documentation]    Resolve a skill with anonymous inline tools and MCP sources and verify keying
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-inline    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-resolve-inline-ok

Resolve Skill With Cycle Raises Error
    [Documentation]    Attempt to resolve skills with circular includes and verify cycle detection
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-cycle    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-resolve-cycle-ok
