luplo.core.audit

Operations for the audit_log table.

Every write operation (create, update, delete, sync, approve) is logged here for compliance traceability. v0.5 is append-only — no query API is exposed yet (queries come in v1.0 with the compliance view).

Functions

record_audit(→ None)

Append an entry to the audit log.

Module Contents

async luplo.core.audit.record_audit(conn: psycopg.AsyncConnection[Any], *, actor_id: str, action: str, target_type: str | None = None, target_id: str | None = None, metadata: dict[str, Any] | None = None) None

Append an entry to the audit log.

This is fire-and-forget — it returns nothing. The caller does not need to wait for or inspect the result.

Parameters:
  • conn – Async psycopg connection.

  • actor_id – Who performed the action.

  • action – Action type — create, update, delete, sync, approve, reject, login, etc.

  • target_type – Entity type (e.g. "item", "work_unit").

  • target_id – Entity ID.

  • metadata – Optional JSONB payload with extra context.