Human-readable specifications for eviction policies used as the source of truth for test-side oracles.
docs/testing/specs/
├── README.md, matrix.md, template.md, tla-guide.md # hub docs
├── _includes/ # shared fragments (Op mapping, maturity levels)
├── policies/ # human operational specs by tier
│ ├── exact/ # FIFO, LRU, LFU, …
│ ├── mirror/ # Clock, 2Q, …
│ ├── bounded/ # ARC, S3-FIFO, …
│ └── composed/ # TTL
└── formal/ # TLA+ modules + TLC runbooks
├── fifo/
└── lru/
Canonical index: matrix.md (maturity, harness mode, model paths per policy).
policies/<tier>/<policy>.md
→ reference/ PolicyModel (optional — independent formulation)
→ exact/ PolicyModel (deque / DS-shaped oracle)
→ policy_semantics dual-run vs implementation
| Tier | Harness mode | Oracle |
|---|---|---|
| Exact / mirror | DualRun | exact/ PolicyModel vs impl |
Exact (policies with reference/ rows) |
CrossModel | reference/ vs exact/ |
| Bounded | InvariantOnly | structural invariants on impl |
| Composed (TTL) | DualRun + deadlines | LruOccupancyModel + TTL layer |
Cross-model tests prove reference/ agrees with exact/ on the same traces. Impl dual-run proves exact/ agrees with real caches.
Use template.md as the skeleton:
- Maturity banner —
stub,reference, and/ortla - State variables — abstract state at rest between operations
- Init — empty cache at capacity
C - Per-
Optransitions — match the harnessOp<K>alphabet - Tie-breaks — deterministic victim and rank when multiple keys qualify
- Observables —
resident,peek_victim,recency_rank(if applicable),hitclassification - API mapping — how each
Opmaps to cache traits (peekmust not promote on LRU, etc.)
Shared harness Op table: _includes/harness-op-mapping.md. Trait semantics: trait hierarchy.
When a spec changes, update in order:
- Spec doc under
policies/<tier>/ tests/abstract_models/reference/<policy>.rs(if reference model exists)- Cross-model test expectations (if behavior changed)
tests/abstract_models/exact/<policy>.rsif the exact model was wrongformal/<policy>/TLA+ module andtlc.mdalignment notes (if applicable)- Row in matrix.md
FIFO and LRU include TLA+ pilots under formal/. Read first: tla-guide.md. TLC is not run in CI.
./scripts/run-tlc.sh fifo # or ./scripts/run-fifo-tlc.sh
./scripts/run-tlc.sh lru # or ./scripts/run-lru-tlc.shSuccess: no SemanticOK violation on the bundled config. Runbooks: formal/fifo/tlc.md, formal/lru/tlc.md.
TLC vs Rust: TLC proves SemanticOK on reachable states for a finite instance; proptest runs long sequential traces on u8 keys. They are complementary.
- Policy matrix — canonical index
- Policy specs by tier
- Spec template — new policy skeleton
- TLA+ guide — contributor guide
- Abstract models README
- Policy semantic testing
- Testing strategy