hydromodpy.results.catalog.audit#

Audit log writer for catalog events.

Hosts a single helper, emit_audit_event(), which writes one row into the audit_log table opened by the catalog DuckDB connection. Callers emit events at the boundaries of state-changing operations (delete, purge, …). The helper resolves the OS user, hostname, and HydroModPy git commit best-effort; failures fall back to empty strings rather than breaking the surrounding transaction.

The accepted event_type values are constrained at the schema level by the CHECK on audit_log.event_type; this module mirrors the live list as a literal type so a typo at the call site fails at type-check time as well as at SQL-execution time.

Functions

apply_retention(db, *[, dry_run])

Sweep audit_log against active retention_policies.

audited(event_type, *[, sim_id_arg, ...])

Decorator that emits one audit_log row after the wrapped method succeeds.

emit_audit_event(db, *, event_type[, ...])

Write one event into audit_log and return the generated event_id.

emit_deletion_tombstone(db, *, sim_id, ...)

Insert one GDPR tombstone row into deletions.

verify_chain(db)

Recompute and verify the entire audit_log chain.