feat: key-activity audit events for recovery + invitation transitions (task 1.8, KEY-12/NFR-06) #67

Merged
amiryahaya merged 1 commit from feat/1.8-key-audit-events into main 2026-11-06 02:12:11 +01:00
Owner

Closes #23 — task 1.8 audit-events gap closure (KEY-12, NFR-06, ADM-04).

Gap found: ORG/KEY/pairing/wrap/device transitions were already audited (tasks 1.2–1.7); the recovery-request lifecycle had ZERO admin-audit coverage (the "recovery.request"/"recovery.approved" strings in handlers are in-app notification titles, not audit events), and invitation acceptance (INV group per NFR-06) was unaudited.

Adds 5 events via existing AuditService:

  • recovery.requested — CreateRecoveryRequest (public DID path) + InitiateRecoveryRequest (settings path), actor=requester
  • recovery.request.approved — on the threshold flip Pending→Approved only, actor=tipping trustee
  • recovery.trustee_rejected — trustee rejection decision (naming follows recovery.rekey_rejected style)
  • recovery.completed — CompleteRecovery success (alongside existing activity-feed row)
  • invitation.accepted — in InvitationAcceptanceService (single choke point, all 4 accept paths), atomic with the claim transaction (logged before commit)

KEY-12 acceptance: events in admin audit log with actor + device id — wrap/pairing/device events already carry device ids (verified, no change needed).

TDD: 6 red tests first (4 TrusteeRecoveryTests + 1 RecoveryShamirTests + 1 InvitationAcceptanceServiceTests), then green. Suite 798/0/39 Release ×3; coverage gate 82.88% ≥ 80.

Also fixes a latent test footgun discovered en route: POST /api/invitations/{id}/accept with a null body 400s at model binding (Request record) — new test uses an empty JSON body.

Closes #23 — task 1.8 audit-events gap closure (KEY-12, NFR-06, ADM-04). **Gap found**: ORG/KEY/pairing/wrap/device transitions were already audited (tasks 1.2–1.7); the recovery-request lifecycle had ZERO admin-audit coverage (the "recovery.request"/"recovery.approved" strings in handlers are in-app notification titles, not audit events), and invitation acceptance (INV group per NFR-06) was unaudited. **Adds 5 events via existing AuditService**: - `recovery.requested` — CreateRecoveryRequest (public DID path) + InitiateRecoveryRequest (settings path), actor=requester - `recovery.request.approved` — on the threshold flip Pending→Approved only, actor=tipping trustee - `recovery.trustee_rejected` — trustee rejection decision (naming follows recovery.rekey_rejected style) - `recovery.completed` — CompleteRecovery success (alongside existing activity-feed row) - `invitation.accepted` — in InvitationAcceptanceService (single choke point, all 4 accept paths), atomic with the claim transaction (logged before commit) KEY-12 acceptance: events in admin audit log with actor + device id — wrap/pairing/device events already carry device ids (verified, no change needed). TDD: 6 red tests first (4 TrusteeRecoveryTests + 1 RecoveryShamirTests + 1 InvitationAcceptanceServiceTests), then green. Suite 798/0/39 Release ×3; coverage gate 82.88% ≥ 80. Also fixes a latent test footgun discovered en route: POST /api/invitations/{id}/accept with a null body 400s at model binding (Request record) — new test uses an empty JSON body.
feat(recovery): key-activity audit events for recovery + invitation transitions (task 1.8, KEY-12/NFR-06) (#23)
All checks were successful
API CI / build-and-test (pull_request) Successful in 33m34s
3c61c7893e
Closes #23
Sign in to join this conversation.
No description provided.