# wallet_production

OTP application providing production readiness domain: secrets/HSM adapter integration, SIEM forwarding, DR rehearsal evidence, and go-live readiness gate.

## Public Interface

### SecretsProvider
- `SecretsProvider.get/1` — fetch secret by key (delegates to configured adapter).
- `SecretsProvider.put/2` — store secret.
- `SecretsProvider.rotate/1` — rotate a secret and return new value.
- Configure adapter via: `Application.put_env(:wallet_production, :secrets_adapter, MyAdapter)`.

### Available Adapters
| Adapter | Usage |
|---|---|
| `EnvAdapter` | Default (dev/test): reads from Application env |
| `AzureVaultAdapter` | Production: Azure Key Vault (configure `:azure_vault_url`) |
| `HsmAdapter` | Production: Thales HSM (configure `:hsm_slot`); also exposes `sign/2` and `decrypt/2` |

### SIEM Integration
- `SiemEvent.from_audit/1` — convert audit map to SIEM-compatible event.
- `SiemForwarder.forward/1` — forward SIEM event to configured sink.
- `SiemForwarder.forward_audit/1` — convenient audit → SIEM pipeline.
- Configure sink: `Application.put_env(:wallet_production, :siem_adapter, :log)` (default `:log`).

### DR Rehearsal
- `Commands.RunDrRehearsal.execute/3` — run rehearsal, store checkpoint, emit `DrRehearsalCompleted.v1`.
- `DrCheckpointStore.list_by_tier/1` — list checkpoints by criticality tier.
- `DrCheckpointStore.list_by_outcome/1` — list checkpoints by outcome (`:pass | :fail | :partial`).

### Readiness Gate
- `ReadinessGate.evaluate/0` — evaluate all go-live gates; returns `%{status: :ready | :not_ready, gates: [...]}`.
- `Commands.RecordReadinessApproval.execute/3` — record go-live approval, emit `ReadinessApproved.v1`.

## Readiness Gate Criteria
| Gate | Pass Condition |
|---|---|
| dr_rehearsal | >= 1 Tier 1 DR checkpoint with `:pass` outcome |
| no_open_sev1_incidents | No unresolved Sev-1 incidents in `WalletResilience.IncidentStore` |
| no_open_slo_violations | No open SLO violations in `WalletResilience.SloViolationStore` |
| readiness_approval | Valid (non-expired) approval on record |

## DR Criticality Tiers
| Tier | RTO Target | RPO Target | Examples |
|---|---|---|---|
| 1 | 30 min | 5 min | Ledger, transfers, auth |
| 2 | 4 hours | 30 min | Notifications, reporting |
| 3 | 24 hours | 24 hours | Batch analytics |

## Boundary Rules
- Reads from `WalletResilience.IncidentStore` and `WalletResilience.SloViolationStore` for gate checks.
- Does not write to any other domain's stores.
- Events emitted over Phoenix PubSub (configurable via `:pubsub` env key).
