*** Settings ***
Documentation    M5 ACMS pipeline and context integration tests
Library          OperatingSystem
Library          Collections
Library          helper_m5_acms_smoke.py

*** Test Cases ***

Load ACMS Context Policy Fixture
    [Documentation]    Load and validate M5 ACMS context policy fixture
    ${policy}=    Load Acms Context Policy Fixture
    Dictionary Should Contain Key    ${policy}    default_view
    Dictionary Should Contain Key    ${policy}    strategize_view
    Dictionary Should Contain Key    ${policy}    execute_view

Load Large Project Context Fixture
    [Documentation]    Load and validate large project context fixture
    ${project}=    Load Large Project Context Fixture
    Should Be Equal As Integers    ${project}[file_count]    500
    Length Should Be    ${project}[file_entries]    5

Resolve Default View From Empty Policy
    [Documentation]    Empty policy resolves to default view with no filtering
    ${view}=    Resolve View For Phase    default
    Length Should Be    ${view}[include_paths]    0
    Length Should Be    ${view}[exclude_paths]    0

Resolve Strategize Inherits From Default
    [Documentation]    Strategize phase inherits from default when not overridden
    ${view}=    Resolve Strategize Inheriting Default
    Should Be Equal As Integers    ${view}[max_file_size]    262144

Resolve Strategize With Override
    [Documentation]    Strategize override takes precedence over default
    ${view}=    Resolve Strategize With Override
    Should Be Equal As Integers    ${view}[max_file_size]    131072

Budget Max File Size Enforcement
    [Documentation]    Files exceeding max_file_size are detected
    ${result}=    Check Budget Enforcement    1024    2048    512
    Should Be True    ${result}[oversized]
    Should Be True    ${result}[within_budget]

Budget Max Total Size Enforcement
    [Documentation]    Aggregate context exceeding max_total_size is detected
    ${result}=    Check Total Budget Enforcement    8192    10000    4096
    Should Be True    ${result}[oversized]
    Should Be True    ${result}[within_budget]

Invalid Phase Raises Error
    [Documentation]    Resolving an invalid phase produces an error
    ${result}=    Attempt Resolve Invalid Phase    invalid
    Should Be Equal    ${result}[error]    True

Context Analysis Fixture Has Required Fields
    [Documentation]    Analysis results fixture has summary, dependencies, scores
    ${analysis}=    Load Context Analysis Fixture
    Should Not Be Empty    ${analysis}[summary]
    Should Not Be Empty    ${analysis}[dependencies]
    Should Not Be Empty    ${analysis}[relevance_scores]

Multi Project Independent Context
    [Documentation]    Two projects maintain independent context entries
    ${result}=    Create Multi Project Context    3    5
    Should Be Equal As Integers    ${result}[proj_a_count]    3
    Should Be Equal As Integers    ${result}[proj_b_count]    5
