*** Settings ***
Documentation    Smoke tests for Tool and Validation domain model creation,
...              YAML config loading, and validation constraint enforcement.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Create Minimal Tool Model
    [Documentation]    Create a builtin Tool model and verify identity fields
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-tool    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-model-ok

Create Validation Model With Forced Constraints
    [Documentation]    Create a Validation and verify read_only/writes/checkpointable are forced
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-validation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-model-ok

Load Custom Tool From YAML Config
    [Documentation]    Load the custom-tool example YAML and verify Tool.from_config output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    load-tool-yaml    ${CURDIR}/../examples/tools/custom-tool.yaml    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-yaml-ok
    Should Contain    ${result.stdout}    source=custom

Load MCP Tool From YAML Config
    [Documentation]    Load the mcp-tool example YAML and verify Tool.from_config output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    load-tool-yaml    ${CURDIR}/../examples/tools/mcp-tool.yaml    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-yaml-ok
    Should Contain    ${result.stdout}    source=mcp

Load Wrapped Validation From YAML Config
    [Documentation]    Load the wrapped-validation example YAML and verify Validation.from_config output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    load-validation-yaml    ${CURDIR}/../examples/validations/wrapped-validation.yaml    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-yaml-ok
    Should Contain    ${result.stdout}    mode=required

Load Required Validation From YAML Config
    [Documentation]    Load the required-validation example YAML and verify Validation.from_config output
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    load-validation-yaml    ${CURDIR}/../examples/validations/required-validation.yaml    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-yaml-ok
    Should Contain    ${result.stdout}    mode=required

Validate Forced Constraints On Writable Capability
    [Documentation]    Verify Validation forces read_only=True even when given writable capability
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validate-constraints    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validate-constraints-ok

Reject Invalid Tool Configurations
    [Documentation]    Verify that invalid tool name, missing code, and conflicting capabilities are rejected
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validate-invalid-tool    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validate-invalid-ok
