@tdd_issue @tdd_issue_1152 @mock_only
Feature: TDD Issue #1152 — budget eviction permanently deletes hot-tier fragments instead of demoting to warm
  As a developer
  I want to verify that budget-evicted hot-tier fragments are demoted to the warm tier
  So that context data follows the spec's downward tier lifecycle rather than being destroyed

  # This test captures bug #1152.  When the hot-tier token budget is
  # exceeded, _enforce_hot_budget() permanently deletes evicted fragments
  # via ``del self._hot[oldest_id]`` instead of demoting them to the warm
  # tier.  The specification (§Plan Lifecycle ACMS Actions) describes a
  # downward lifecycle: "Hot context archived to warm.  Warm context ages
  # to cold based on retention policy."
  #
  # The @tag inverts the result so CI passes while the
  # bug is still present.  When bug #1152 is fixed, the @# tag must be removed so the test runs normally.

  @tdd_issue @tdd_issue_4275 @tdd_expected_fail
  Scenario: Budget-evicted hot-tier fragment is demoted to warm tier instead of deleted
    Given a context tier service with a hot tier budget of 100 tokens for eviction test
    And the hot tier contains two 50-token fragments filling the budget for eviction test
    When I store a third 50-token fragment in the hot tier triggering budget eviction
    Then the evicted fragment should exist in the warm tier not be permanently deleted

  @tdd_issue @tdd_issue_4275 @tdd_expected_fail
  Scenario: Budget eviction via evict_lru also demotes to warm tier instead of deleting
    Given a context tier service with a hot tier budget of 100 tokens for eviction test
    And the hot tier contains two 50-token fragments filling the budget for eviction test
    When I call evict_lru on the hot tier to remove one fragment
    Then the LRU-evicted fragment should exist in the warm tier not be permanently deleted
