TDD: context tier service has no runtime promotion/demotion/eviction logic (bug #821) #840

Closed
opened 2026-03-13 21:15:28 +00:00 by freemo · 3 comments
Owner

Background and Context

Bug #821 (bug(acms): context tier service has no runtime promotion/demotion/eviction logic) identifies a defect where only the data models for context tiers exist but there is no runtime logic for promotion (cold→warm, warm→hot), demotion (hot→warm, warm→cold), eviction (hot tier budget exceeded), or tier-aware queries. Per the mandatory TDD bug-fix workflow (CONTRIBUTING.md §Bug Fix Workflow), a failing test must be written before the fix is implemented.

This issue tracks the TDD test-writing phase for bug #821.

Current Behavior

No test exists that verifies context fragments are promoted, demoted, or evicted based on access patterns, recency, or budget constraints.

Expected Behavior

A Behave BDD scenario and/or Robot Framework test tagged with @tdd_expected_fail, @tdd_bug, and @tdd_bug_821 should exist that:

  1. Creates context fragments in the cold tier
  2. Accesses a fragment enough times to trigger promotion threshold
  3. Asserts the fragment moves to warm or hot tier
  4. Asserts budget-based eviction when hot tier exceeds max tokens
  5. Currently fails (proving the bug exists), but passes CI via the @tdd_expected_fail inversion

Acceptance Criteria

  • At least one Behave scenario in features/tdd_context_tier_runtime.feature
  • Scenario tagged with @tdd_expected_fail @tdd_bug @tdd_bug_821
  • At least one Robot Framework test in robot/tdd_context_tier_runtime.robot
  • Test tagged with tdd_expected_fail, tdd_bug, tdd_bug_821
  • Full test suite passes (nox -s unit_tests integration_tests)
  • ruff check and ruff format pass

Metadata

  • Commit message: test(acms): TDD failing tests for context tier runtime logic (bug #821)
  • Branch name: tdd/m5-context-tier-runtime
  • Type: Testing
  • Priority: Critical
  • MoSCoW: Must have
  • Points: 2
  • Milestone: v3.4.0

Subtasks

  • Write Behave scenario exercising tier promotion on access
  • Write Behave scenario exercising tier demotion on staleness
  • Write Behave scenario exercising hot tier eviction on budget overflow
  • Write Robot Framework test exercising full tier lifecycle
  • Apply @tdd_expected_fail tags
  • Verify tests fail (bug present) but CI passes (inversion working)

Definition of Done

  • TDD tests exist and are tagged correctly
  • Tests demonstrate the bug (fail without @tdd_expected_fail)
  • Full CI suite passes with the inversion
  • PR merged to master
## Background and Context Bug #821 (`bug(acms): context tier service has no runtime promotion/demotion/eviction logic`) identifies a defect where only the data models for context tiers exist but there is no runtime logic for promotion (cold→warm, warm→hot), demotion (hot→warm, warm→cold), eviction (hot tier budget exceeded), or tier-aware queries. Per the mandatory TDD bug-fix workflow (CONTRIBUTING.md §Bug Fix Workflow), a failing test must be written **before** the fix is implemented. This issue tracks the TDD test-writing phase for bug #821. ## Current Behavior No test exists that verifies context fragments are promoted, demoted, or evicted based on access patterns, recency, or budget constraints. ## Expected Behavior A Behave BDD scenario and/or Robot Framework test tagged with `@tdd_expected_fail`, `@tdd_bug`, and `@tdd_bug_821` should exist that: 1. Creates context fragments in the cold tier 2. Accesses a fragment enough times to trigger promotion threshold 3. Asserts the fragment moves to warm or hot tier 4. Asserts budget-based eviction when hot tier exceeds max tokens 5. Currently **fails** (proving the bug exists), but passes CI via the `@tdd_expected_fail` inversion ## Acceptance Criteria - [ ] At least one Behave scenario in `features/tdd_context_tier_runtime.feature` - [ ] Scenario tagged with `@tdd_expected_fail @tdd_bug @tdd_bug_821` - [ ] At least one Robot Framework test in `robot/tdd_context_tier_runtime.robot` - [ ] Test tagged with `tdd_expected_fail`, `tdd_bug`, `tdd_bug_821` - [ ] Full test suite passes (`nox -s unit_tests integration_tests`) - [ ] `ruff check` and `ruff format` pass ## Metadata - **Commit message**: `test(acms): TDD failing tests for context tier runtime logic (bug #821)` - **Branch name**: `tdd/m5-context-tier-runtime` - **Type**: Testing - **Priority**: Critical - **MoSCoW**: Must have - **Points**: 2 - **Milestone**: v3.4.0 ## Subtasks - [ ] Write Behave scenario exercising tier promotion on access - [ ] Write Behave scenario exercising tier demotion on staleness - [ ] Write Behave scenario exercising hot tier eviction on budget overflow - [ ] Write Robot Framework test exercising full tier lifecycle - [ ] Apply `@tdd_expected_fail` tags - [ ] Verify tests fail (bug present) but CI passes (inversion working) ## Definition of Done - TDD tests exist and are tagged correctly - Tests demonstrate the bug (fail without `@tdd_expected_fail`) - Full CI suite passes with the inversion - PR merged to `master`
freemo added this to the v3.4.0 milestone 2026-03-13 21:15:57 +00:00
Author
Owner

Dependency (TDD workflow): This TDD test issue blocks bug fix #821. This issue must be completed and merged first so the @tdd_expected_fail test exists before the fix is implemented.

Blocks: #821

**Dependency (TDD workflow):** This TDD test issue blocks bug fix #821. This issue must be completed and merged first so the `@tdd_expected_fail` test exists before the fix is implemented. **Blocks:** #821
Author
Owner

PM Status — Day 37

Status: Not started. This TDD issue blocks bug #821 (v3.4.0) and has had no activity since the dependency note on Day 34.

@brent.edwards — Per the Week 6 schedule, TDD issues must be prioritized. Please provide an ETA or flag blockers by Day 38 EOD.


PM status — Day 37

## PM Status — Day 37 **Status**: Not started. This TDD issue blocks bug #821 (v3.4.0) and has had no activity since the dependency note on Day 34. @brent.edwards — Per the Week 6 schedule, TDD issues must be prioritized. Please provide an ETA or flag blockers by Day 38 EOD. --- *PM status — Day 37*
Member

Implementation Notes — #840

Branch: tdd/m5-context-tier-runtime | Commit: 30a88287 | PR: #1058

Tests Written

3 Behave scenarios + 3 Robot Framework tests, all tagged @tdd_expected_fail @tdd_bug @tdd_bug_821:

  1. Promotion on repeated access — Creates a fragment in COLD, accesses it 8 times (above the 5-access threshold), asserts tier changed to WARM or HOT. Fails because: ContextTierService.get() updates access_count metadata but doesn't auto-promote.

  2. Demotion on staleness — Creates a fragment in HOT, calls staleness enforcement methods. Fails because: No enforce_staleness(), apply_tier_policy(), tick(), or equivalent method exists on ContextTierService.

  3. Eviction on budget overflow — Sets hot tier budget to 100 tokens, stores 3 fragments totaling 150 tokens. Fails because: store() does not check TierBudget.max_tokens_hot or trigger LRU eviction.

Key Discovery

ContextTierService has a solid data model (tier levels, budgets, access metadata) and correct basic CRUD operations, but zero runtime lifecycle logic. The service acts as a key-value store with tier labels — it never moves fragments between tiers or enforces budget constraints.

Quality Gates

  • Lint: PASS | Typecheck: PASS | Unit tests: 3/3 pass (via @tdd_expected_fail inversion)
## Implementation Notes — #840 **Branch:** `tdd/m5-context-tier-runtime` | **Commit:** `30a88287` | **PR:** #1058 ### Tests Written 3 Behave scenarios + 3 Robot Framework tests, all tagged `@tdd_expected_fail @tdd_bug @tdd_bug_821`: 1. **Promotion on repeated access** — Creates a fragment in COLD, accesses it 8 times (above the 5-access threshold), asserts tier changed to WARM or HOT. **Fails because**: `ContextTierService.get()` updates access_count metadata but doesn't auto-promote. 2. **Demotion on staleness** — Creates a fragment in HOT, calls staleness enforcement methods. **Fails because**: No `enforce_staleness()`, `apply_tier_policy()`, `tick()`, or equivalent method exists on `ContextTierService`. 3. **Eviction on budget overflow** — Sets hot tier budget to 100 tokens, stores 3 fragments totaling 150 tokens. **Fails because**: `store()` does not check `TierBudget.max_tokens_hot` or trigger LRU eviction. ### Key Discovery `ContextTierService` has a solid data model (tier levels, budgets, access metadata) and correct basic CRUD operations, but zero runtime lifecycle logic. The service acts as a key-value store with tier labels — it never moves fragments between tiers or enforces budget constraints. ### Quality Gates - Lint: PASS | Typecheck: PASS | Unit tests: 3/3 pass (via @tdd_expected_fail inversion)
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#840
No description provided.