Provide an immutable mutation trail for core entities and store diver
card credentials so centers can verify certifications at booking time.
Entity audit logging:
- Add entity_audit_logs (migration 0108) for create, update, soft_delete,
hard_delete, restore, import, approve, reject, confirm, cancel, extend,
and ownership_* actions across dive sites, dives, centers, routes,
OCTO bookings, certifications, comments, settings, tags, managers,
ownership requests, and dive-site edit requests.
- Instrument CRUD and governance paths so audit rows share the mutation
transaction (including RouteDeletionService commit=False for hide,
hard-delete, and restore).
- Record structured before/after diffs via snapshot_orm_fields (aligned
field sets) and pre-deletion snapshots; distinguish soft vs hard
delete in the action vocabulary.
- On edit-request approve, log proposed_data and a dive_site-scoped
update so site history includes community-approved changes.
- Cover admin dive update/delete, ownership assign/revoke, dive-site
approve/reject, and OCTO confirm/cancel/extend (status metadata only;
no contact/passport PII).
- Propagate auth provenance on request.state for required and optional
auth: jwt, pat (id/name), or guest, plus IP and User-Agent forensics.
- Redact secrets by field name (passwords, tokens including access_token,
API keys) and settings-shaped {key, value} payloads when the setting
name is sensitive; coerce Decimal/float/date/Enum for stable diffs.
- Expose admin GET /entity-audit-logs and expand the Entity Lifecycle
admin tab with filters, visual diffs, and the new entity/action types.
Certification card ID:
- Add nullable card_id and certification_date on user_certifications.
- Keep card_id/issue date on private my-certifications responses only;
public profile and public cert list use UserCertificationPublicResponse
without those fields.
- Coerce empty-string card_id/date to null in schemas and Profile submit.
- Surface Card ID and Issue Date on the profile form and badges; emit
card_id in booking checkout context and auto-fill BookingWizard
(clear stale numbers when a cert has no card ID).
Tests and polish:
- Add unit/integration coverage for the audit service, directory and
governance instrumentation, admin API authz, auth context (JWT/PAT/
guest), and certification card_id privacy/empty-string behavior.
- Fix admin dark-mode header contrast and Ant Design deprecation noise
where touched by the audit UI work.
Provide an immutable mutation trail for core entities and store diver card credentials so centers can verify certifications at booking time.
Entity audit logging:
Certification card ID:
Tests and polish: