# task-022

status: done

## goal
Test `RouterContextBuilder` — verify budget enforcement, L0 immutability, L2 oldest-first eviction, and layer classification.

## target artifact
testing/deterministic/src/test/kotlin/RouterContextBuilderTest.kt

## execution steps
- Artifact already exists at target path (576 lines, 20 test methods)
- Verify dependencies: task-012 (`RouterContextBuilder` implementation) and task-019 (`testing:deterministic` build config) are complete
- Run `./gradlew :testing:deterministic:test --tests RouterContextBuilderTest --rerun-tasks`
- All 28 tests pass — no modifications needed

## changed artifacts
- None (artifact was pre-existing, verified correct)

## blockers
- None

## notes
- Test coverage spans all four verification areas from the task spec:
  - Budget enforcement: 4 tests (`build fits within budget`, `build drops entries when budget exceeded`, `build drops entries oldest-first for L2`, `build drops conversation turns oldest-first`)
  - L0 immutability: 4 tests (`L0 system prompt always present`, `L0 workflow status always present`, `L0 entries survive zero budget`, `L0 entries survive budget that cannot cover L1 or L2`)
  - L2 oldest-first eviction: 2 tests (`L2 entries evicted in insertion order`, `L2 entries fit within budget all retained`)
  - Layer classification: 4 tests (`system prompt is L0`, `workflow status is L0`, `conversation turns are L1`, `l2 memory entries are L2`, `no entries other than L0/L1/L2`)
  - Additional coverage: keepLast capping (2), empty state (2), content formatting (4), token budget accounting (2), full lifecycle (1), null sessionId (1)
- No deviations from original task scope.
