# Context guide
## Scope
Projects session history into provider conversations and estimates request budgets.
## Where to look
| Context types and event visibility | `mod.rs` |
| Turn reconstruction and compaction cutoff | `replay.rs` |
| Session replay reuse | `replay_cache.rs` |
| Test-only conversation material for replay checks | `cache.rs` |
| Token projection | `tokens.rs` |
| Behavioral coverage | `tests/replay.rs`, `tests/replay_cache.rs`, `tests/cache.rs`, `tests/tokens.rs` |
## Local rules
- Keep replay filtering separate from tolerant JSONL parsing in `../sessions/read.rs`. Local-only events and reasoning summaries are not ordinary provider messages.
- Reconstruct ordered turns and matched tool calls/results, not a flat list of persisted event payloads.
- Preserve cancelled/failed assistant text through terminal status; the root manual companion defines this replay requirement.
- `ConversationReplayCache` tracks session identity, replay generation, file stamps, and a content digest. Do not reduce validity checks to file size alone.
- In-memory replay reuse must not become durable session truth. `cache.rs` is test-only; normal runs do not read or write disk conversation snapshots, and existing snapshots stay untouched.
- Keep request budget estimates distinct from observed provider usage. Changes to projection must be checked against agent request construction as well as local token tests.