*** Settings ***
Documentation    Smoke tests for Skill context and registry
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Create Skill Context
    [Documentation]    Create SkillContext with plan/project/sandbox info
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-context    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-context-ok

Resolve Resource From Context
    [Documentation]    Resolve a bound resource from SkillContext
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-resource    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-context-resolve-ok

Register Tool Invocation
    [Documentation]    Register a tool invocation in the change tracker
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    track-invocation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-context-track-ok

Enforce Write Guard
    [Documentation]    Enforce read-only write guard raises SkillError
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    write-guard    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-context-guard-ok

Registry Register And Get
    [Documentation]    Register and retrieve a skill from the registry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    registry-crud    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-registry-crud-ok

Registry List All
    [Documentation]    List all skills from the registry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    registry-list    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-registry-list-ok

Registry Resolve Tools
    [Documentation]    Resolve tools from the registry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    registry-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    skill-registry-resolve-ok
