# wallet_resilience

OTP application providing resilience domain: health checks, SLO violation tracking, incident command, and back-pressure controls.

## Public Interface

### HealthCheck
- `HealthCheck.liveness/0` — node and supervisor liveness probe.
- `HealthCheck.readiness/1` — store readiness + configurable dependency checks.

### BackPressurePolicy
- `BackPressurePolicy.evaluate/2` — evaluates queue depth: `:ok | :warn | :shed | :block`.
- `BackPressurePolicy.default_queues/0` — pre-built policy set for Phase 5/6 Oban queues.

### SLO Tracking
- `SloSpec.all/0` — all defined SLOs (latency, availability, error rate).
- `Commands.RecordSloViolation.execute/3` — store violation + emit `SloViolated.v1`.
- `SloViolationStore.list_open/0` — open violations.

### Incident Command
- `Commands.TriggerIncident.execute/3` — open incident + emit `IncidentTriggered.v1`.
- `Commands.ResolveIncident.execute/3` — resolve incident + emit `IncidentResolved.v1`.
- `IncidentStore.list_open/0` — all non-resolved incidents.

## Severity Levels
| Level | Meaning |
|---|---|
| :sev1 | Critical — customer-facing financial path down |
| :sev2 | Major — degraded path or risk of financial impact |
| :sev3 | Minor — non-critical degradation |
| :sev4 | Informational — monitoring alert, no user impact |

## SLO Bands
| SLO | Target |
|---|---|
| auth_latency_p95 | <= 150 ms |
| transfer_latency_p95 | <= 250 ms |
| posting_success_rate | >= 99.99% |
| reconciliation_mismatch_rate | <= 0.01% |
| availability | >= 99.9% |

## Back-Pressure Levels
| Level | Meaning |
|---|---|
| :ok | Normal operation |
| :warn | Elevated depth; emit metrics |
| :shed | Reject low-priority enqueues |
| :block | Reject all new enqueues |

## Boundary Rules
- Does not write to any other domain's stores.
- Reads `IncidentStore` data is used by `wallet_production.ReadinessGate`.
- Events are emitted over Phoenix PubSub (configurable via `:pubsub` env key).
