Skip to main content

Module audit

Module audit 

Source
Expand description

Append-only provider invocation audit log.

Records minimal metadata for each provider routing event without storing prompts or tool payloads. File: $SYNAPS_BASE_DIR/extensions/audit.jsonl.

Design constraints:

  • One JSON object per line; missing file is equivalent to no entries.
  • Append-only: each new entry uses O_APPEND so concurrent appenders on Unix produce well-formed line records without locking.
  • Malformed lines (e.g. partial write from a crash) are skipped on read with a tracing::warn! so a corrupt line cannot lock the user out.
  • Never contains prompt text, tool inputs, tool outputs, or tokens.

Structs§

ProviderAuditEntry

Functions§

append_audit_entry
Append a single entry as one JSON line. Creates parent dirs and the file if missing. Atomic per-line via O_APPEND on Unix.
audit_file_path
Path to the audit file under the active base dir. Caller is responsible for creating parent directories when writing.
new_audit_entry
Build a fresh entry with the current UTC timestamp.
read_audit_entries
Read all entries (one per line). Missing file → empty Vec. Malformed lines are skipped with a tracing::warn!.