# testing/

## Purpose

Dedicated test submodules for the correx kernel. Tests here are NOT co-located with production code — each submodule targets a specific verification concern (approval gates, projection correctness, replay determinism, cross-module contracts, integration flows, etc.).

## Ownership

All test submodules in this subtree. Production source is in `core/` and `infrastructure/`; nothing here is deployed.

## Local Contracts

- Tests must not assert on persisted State — only on event-derived state rebuilt by projectors/reducers.
- No test submodule may import a sibling `testing/*` module except `testing:fixtures`, `testing:kernel`, and `testing:contracts` (shared helpers only).
- `./gradlew check` applies detekt with `ignoreFailures = false` across all submodules.

## Work Guidance

- Always run tests with `--rerun-tasks` to bypass Gradle cache: `./gradlew :testing:<module>:test --rerun-tasks`
- Suspend functions in tests use `runBlocking { ... }` — no test coroutine framework needed.
- Detekt `maxIssues: 120` — do not introduce new rule violations.
- New `EventPayload` subclass used in tests? Register it in `core/events/.../serialization/Serialization.kt` or deserialization silently fails.

## Verification

```
./gradlew check   # all submodules: test + detekt + koverVerify
```

## Child DOX Index

- `testing/approvals` — approval gate logic: grant semantics, security, trigger rules, tier immutability, fuzz
- `testing/contracts` — cross-module interface contracts and reusable contract test fixtures (projection, replay, inference)
- `testing/deterministic` — determinism checks: router, session replay, context compression, prompt rendering, validation pipeline
- `testing/fixtures` — shared test data library: mock implementations, fixture builders, deterministic harness (not a test runner)
- `testing/integration` — end-to-end flows: orchestrator, tool-call gate, freestyle approval, clarification loop, steering, rehydration
- `testing/kernel` — core:kernel internals: retry coordinator, approval-before-emit ordering, replay inference provider, context feedback
- `testing/projections` — reducer and projector correctness for sessions, context, inference, artifacts, router, and journal
- `testing/replay` — replay determinism: session, approval, validation, transition, decision journal, and repo-knowledge replays
- `testing/transitions` — FSM/workflow graph: transition resolver, event serialization, fuzz coverage
