*** Settings ***
Documentation    Smoke tests for CRP domain model creation and validation
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Create Valid ContextRequest
    [Documentation]    Create a ContextRequest with defaults and verify success
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-request    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-request-ok

Create Valid ContextFragment
    [Documentation]    Create a ContextFragment with valid inputs and verify success
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-fragment    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-fragment-ok

Create Valid ContextBudget
    [Documentation]    Create a ContextBudget and verify available_tokens
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-budget-ok

Create Valid DetailLevelMap
    [Documentation]    Create a DetailLevelMap and resolve a named level
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-map    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-map-ok

Reject Invalid ContextBudget
    [Documentation]    Reject a ContextBudget with reserved > max
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    reject-budget    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-reject-budget-ok

Reject Invalid ContextFragment
    [Documentation]    Reject a ContextFragment with relevance_score > 1.0
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    reject-fragment    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-reject-fragment-ok

Context Skill Tools Registered
    [Documentation]    Verify context skill tools register into the tool registry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    register-tools    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-tools-ok

Create Valid AssembledContext
    [Documentation]    Create an AssembledContext and verify fields
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-assembled    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    crp-assembled-ok
