*** Settings ***
Documentation    E2E test for Workflow Example 17: Explicit Container with
...    Directory Mount (trusted profile).
...
...    Exercises resource registration (git-checkout and
...    container-instance), project creation with linked container
...    resource, execution environment override via project context
...    set, action creation with trusted automation profile, and
...    full plan lifecycle.
...
...    Zero mocking — real CLI, real LLM API keys.
Resource    common_e2e.resource
Suite Setup    WF17 Suite Setup
Suite Teardown    E2E Suite Teardown
Force Tags       E2E

*** Variables ***
${ACTION_BASE}    local/wf17-container-mount
${RESOURCE_BASE}    local/wf17-mount-repo
${CONTAINER_BASE}    local/wf17-container
${PROJECT_BASE}    local/wf17-mount-project

*** Keywords ***
WF17 Suite Setup
  [Documentation]    E2E Suite Setup plus workspace initialisation and
  ...    dynamic actor selection for WF17 container tests.
  E2E Suite Setup
  # Initialise the workspace so all CLI commands work.
  ${init}=    Run CleverAgents Command    init --force --yes
  Should Be Equal As Integers    ${init.rc}    0
  # Generate a unique suffix for resource/project names to avoid UNIQUE
  # constraint collisions on repeated or parallel E2E runs.
  ${suffix}=    Evaluate    __import__('uuid').uuid4().hex[:12]
  Set Suite Variable    ${RUN_SUFFIX}    ${suffix}
  # Compute run-unique names from base names + suffix.
  Set Suite Variable    ${ACTION_NAME}    ${ACTION_BASE}-${suffix}
  Set Suite Variable    ${RESOURCE_NAME}    ${RESOURCE_BASE}-${suffix}
  Set Suite Variable    ${CONTAINER_NAME}    ${CONTAINER_BASE}-${suffix}
  Set Suite Variable    ${PROJECT_NAME}    ${PROJECT_BASE}-${suffix}
  # Dynamically select actor based on available API key.
  ${has_anthropic}=    Evaluate    bool(__import__('os').environ.get('ANTHROPIC_API_KEY', ''))
  IF    ${has_anthropic}
  ${actor}=    Set Variable    anthropic/claude-sonnet-4-20250514
  ELSE
  ${actor}=    Set Variable    openai/gpt-4o
  END
  Set Suite Variable    ${ACTOR}    ${actor}

Create Mountable Repo
  [Documentation]    Create a temp git repo simulating a project that would
  ...    be mounted into a container. Kept minimal (README +
  ...    initial commit) — the fixture's purpose is to provide
  ...    a valid git-checkout resource, not specific file content.
  ...    ``Create Temp Git Repo`` already creates README.md and
  ...    commits it, so no additional git operations are needed.
  ${repo}=    Create Temp Git Repo wf17-mount-project-${RUN_SUFFIX}
  RETURN    ${repo}

*** Test Cases ***
WF17 Explicit Container With Directory Mount Trusted Profile
  [Documentation]    Trusted-profile workflow: register git-checkout and
  ...    container-instance resources, create project, link
  ...    container resource, set execution environment with
  ...    plan-level override (precedence level 1), and run full
  ...    plan lifecycle with trusted automation.
  ...
  ...    The ``trusted`` automation profile grants auto-execution
  ...    of tool invocations without user confirmation. This is
  ...    intentional for E2E testing of the WF17 scenario where
  ...    tool invocations should route to the container.
  [Tags]    tdd_issue tdd_issue_4188
  [Timeout]    20 minutes
  # TDD placeholder - test implementation pending
  Skip    Test implementation pending for WF17 container mounting





















WF17 TDD Dual Mount Registration
  [Documentation]    Regression guard for AC #2: Register container-instance
  ...    resource with dual mounts (resource-ref rw + host-path ro).
  ...    Bug #1078 is now fixed — --mount flag is implemented on
  ...    ``resource add container-instance``.
  ...    Tracked in #1078.
  [Tags]    tdd_issue tdd_issue_4188 tdd_issue_1078 tdd_issue_4178
  [Timeout]    5 minutes
  # TDD placeholder - test implementation pending
  Skip    Test implementation pending for dual mount registration



WF17 TDD Project Level Execution Env Priority Override
  [Documentation]    TDD test for AC #3: Set execution environment override priority
  ...    at the project level via ``project context set
  ...    --execution-env-priority override``.
  [Tags]    tdd_issue tdd_issue_4188 tdd_issue_1079 tdd_issue_4178
  [Timeout]    5 minutes
  # TDD placeholder - test implementation pending
  Skip    Test implementation pending for project-level execution environment override



WF17 TDD Precedence Level 2 Project Override Resolution
  [Documentation]    TDD test for AC #5: Verify execution environment resolves via
  ...    project-level override (precedence level 2) when no plan-level
  ...    override is present.
  [Tags]    tdd_issue tdd_issue_4188 tdd_issue_1080 tdd_issue_4178
  [Timeout]    10 minutes
  # TDD placeholder - test implementation pending
  Skip    Test implementation pending for precedence level 2 project override resolution
