@tdd_issue @tdd_issue_1080 @tdd_expected_fail @tdd_issue_4178 @mock_only
Feature: TDD Bug #1080 — execution environment resolution ignores project-level override
  As a developer
  I want execution environment resolution to honour the 6-level precedence chain
  So that project-level overrides (precedence level 2) take effect correctly

  # Bug #1080: The ExecutionEnvironmentResolver uses a flat priority chain
  # (tool > plan > project > default) that does not distinguish between
  # "override" and "fallback" priority semantics.  Per the spec (§Execution
  # Environment Routing), the correct 6-level precedence is:
  #
  #   1. Plan-level with priority: override
  #   2. Project-level with priority: override
  #   3. Nearest-ancestor devcontainer (auto-detected)
  #   4. Plan-level with priority: fallback
  #   5. Project-level with priority: fallback
  #   6. Host (default)
  #
  # The critical failure: when a project has execution_environment set with
  # priority "override" and a plan has execution_environment set with
  # priority "fallback", the plan incorrectly wins because the resolver
  # treats all plan-level settings as higher priority than project-level.
  #
  # This test captures the bug by asserting the CORRECT precedence behavior.
  # The @tdd_expected_fail tag on the bug-capturing scenario inverts the
  # result: the assertion fails (proving the bug exists) but CI reports it
  # as passed.  When bug #1080 is fixed, the @tdd_expected_fail tag must
  # be removed.
  #
  # The @mock_only tag restricts this feature to in-process mock execution;
  # it does not require any external services or container infrastructure.

  @tdd_expected_fail
  Scenario: Bug #1080 - Project-level override beats plan-level fallback (precedence level 2 vs 4)
    Given a precedence-aware execution environment resolver
    When I resolve precedence with plan env "host" at priority "fallback" and project env "container" at priority "override"
    Then the precedence-resolved environment should be "container"
