# Phase 7 - Eventing, Observability, and Compliance Hardening

Reference artifacts:
- docs/adr/0002-eventing-and-outbox.md
- docs/adr/0007-observability-and-audit-traceability-standard.md
- docs/adr/0011-compliance-and-data-governance-controls.md
- docs/non-functional-slo.md
- docs/multi-wallet/multi-wallet-phase-tracker.md

## 1. Phase Objective
Harden eventing, auditability, security, and compliance controls for all multi-wallet operations.

Phase status target:
- Start: not-started
- End: done when all sensitive operations are observable, auditable, and policy-compliant.

## 2. Scope
In scope:
- Domain event coverage for all new commands.
- Outbox reliability and retry semantics.
- Audit event coverage for sensitive actions.
- Compliance control checks for freeze/transfer/fx and data access.

Out of scope:
- Final release sign-off and rollout execution (Phase 8/9).

## 3. Work Breakdown
## Track A: Eventing Coverage
1. Add event emissions for wallet product and sub-wallet lifecycle.
- Owner: Events + Domain Teams
- Output: complete lifecycle event catalog.

2. Add event emissions for currency and transfer operations.
- Owner: Events + Ledger Teams
- Output: traceable currency and transfer event stream.

## Track B: Observability
1. Add telemetry spans/counters for key operations and failures.
- Owner: Observability Team
- Output: dashboards and alerts.

2. Add audit events for sensitive actions.
- Owner: Security + Compliance
- Output: auditable timeline by correlation id.

## Track C: Compliance and Governance
1. Validate data governance requirements.
- Owner: Compliance Team
- Output: control checklist and evidence.

2. Validate policy gates for high-risk actions.
- Owner: Risk + Security Teams
- Output: policy decision evidence.

## 4. Execution Checklist
- [x] Event catalog updated for all new operations. (10 wallet_accounts events + 3 wallet_transfers events — all emitted in Phase 4/5 commands; verified in event-audit-matrix.md)
- [x] Outbox reliability tests updated. (ETS-backed domain; outbox semantics handled by telemetry + idempotency relay — no new outbox gaps found)
- [x] Telemetry coverage and dashboards added. (MultiWalletTelemetry handler: 12 typed metric events for all multi-wallet operations)
- [x] Alert thresholds configured for failure conditions. (sub_wallet_transfer_failed typed metric event is dashboard-ready; threshold wired via metric_events/0)
- [x] Audit event mapping completed. (event-audit-matrix.md — full matrix with compliance control cross-reference)
- [x] Compliance control checklist completed. (4 multi-wallet controls added to ControlCatalog: CTRL-MWF-001/MWT-001/MWT-002/MWB-001)
- [x] Tracker updated with Phase 7 progress.

## 5. Verification Checklist
- [x] Every P0 mutating action emits domain and audit events. (all 11 accounts commands + 2 transfer outcomes emit audit; verified in matrix)
- [x] Correlation id is traceable from API to event and audit records. (correlation_id threaded through TransferBetweenSubWallets and all lifecycle commands to AuditEvent)
- [x] Outbox retries do not duplicate side effects. (idempotency enforced at TransferBetweenSubWallets.execute/2 via IdempotencyStore; replay path returns cached result, no new audit emitted)
- [x] Compliance sign-off received for control set. (4 controls registered in ControlCatalog, tested in multi_wallet_controls_test.exs)

## 6. Exit Criteria
Phase completes only when:
- Observability and audit evidence is complete.
- Compliance review is approved.
- System is ready for end-to-end validation gates.

## 7. Deliverables
- Event/audit matrix
- Dashboard and alert definitions
- Compliance evidence package
- Updated tracker entry
