*** Settings ***
Documentation    Integration tests for the validation attach type-discriminator guard.
...              Verifies that ``agents validation attach`` rejects plain Tools and
...              accepts genuine Validations end-to-end via the CLI.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment With Database Isolation
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Validation Attach Rejects Plain Tool
    [Documentation]    Attaching a plain Tool (tool_type="tool") must be rejected with a clear error message.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    attach-plain-tool-rejected    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-attach-plain-tool-rejected-ok

Validation Attach Accepts Genuine Validation
    [Documentation]    Attaching a genuine Validation (tool_type="validation") must succeed.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    attach-validation-accepted    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-attach-validation-accepted-ok

Validation Attach Rejects Plain Tool Dict
    [Documentation]    Attaching a plain Tool stored as a dict (tool_type="tool") must be rejected.
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    attach-plain-tool-dict-rejected    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-attach-plain-tool-dict-rejected-ok
