# testing/deterministic

## Purpose

Pins determinism invariants across the core. Every test here asserts that a given computation produces identical output for identical event input — no randomness, no external I/O. Covers: router reducer and projector, session replay, context compression, prompt renderer ordering, token budget enforcement, approval engine, validation pipeline short-circuit, context pack builder, and L3 metadata rehydration.

## Ownership

Tests in this submodule. Production modules exercised: `core:events`, `core:router`, `core:sessions`, `core:transitions`, `core:validation`, `core:approvals`, `core:context`, `core:inference`, `infrastructure:persistence`.

## Local Contracts

- No test in this submodule may call an external service or live LLM — hard invariant #8 (replay is environment-independent).
- Every tested path must produce byte-identical state for the same event log on repeated runs.
- `PromptRendererOrderingTest` pins the rule that all SYSTEM-role entries fold into the leading system message; non-system messages order by `ContextEntry.ordinal`.

## Work Guidance

- Suspend tests use `runBlocking { ... }`.
- If a new deterministic component is added to `core:router` or `core:context`, add a matching test here.

## Verification

```
./gradlew :testing:deterministic:test --rerun-tasks
```

## Child DOX Index

No child AGENTS.md (leaf module).
