*** Settings ***
Documentation     Smoke tests for DecisionService recording and snapshot store
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_decision_recording.py

*** Test Cases ***
Record And Retrieve Decision
    [Documentation]    Record a decision via DecisionService and retrieve by ID
    [Tags]    service    decision    recording
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    record-retrieve    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    record-retrieve-ok

Record Multiple With Sequencing
    [Documentation]    Record 3 decisions and verify monotonic sequence numbers
    [Tags]    service    decision    sequencing
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    sequencing    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    sequencing-ok

Snapshot Auto-Capture
    [Documentation]    Record a decision and verify context snapshot is auto-captured
    [Tags]    service    decision    snapshot
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    snapshot-capture    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    snapshot-capture-ok

Decision Tree BFS Via Service
    [Documentation]    Build a 3-node tree and verify BFS order via get_tree
    [Tags]    service    decision    tree
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    tree-bfs    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tree-bfs-ok

Mark Decision Superseded Via Service
    [Documentation]    Mark a decision as superseded via the service layer
    [Tags]    service    decision    superseded
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    superseded    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    superseded-ok

Delete Decision Via Service
    [Documentation]    Delete a decision and verify snapshot is also removed
    [Tags]    service    decision    delete
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    delete    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    delete-ok

Snapshot Hash Deduplication
    [Documentation]    Verify hash-based deduplication in SnapshotStore
    [Tags]    service    decision    snapshot    dedup
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    snapshot-dedup    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    snapshot-dedup-ok
