Skip to contents

Persists a shieldr_audit object as JSON Lines, CSV, or RDS for operational auditability across LLM workflows.

Usage

write_audit_log(audit, path, format = "jsonl")

Arguments

audit

A shieldr_audit object.

path

Output file path.

format

One of "jsonl", "csv", or "rds".

Value

The path, invisibly.

Details

JSON Lines is the preferred append-only format for production logs because each call writes one complete audit object as one line. CSV flattens findings into one row per finding, which is convenient for spreadsheets and simple dashboards but loses some nested structure. The CSV path preserves common metadata such as context row index, context source, tool name, conversation role, and reviewer error counts. RDS preserves the R object exactly and overwrites the target path.

Audit logs may contain sensitive source text, raw model output, or redacted findings depending on the workflow. Treat audit paths as sensitive storage in regulated or internal environments.

Examples

audit <- shieldr_audit(NULL, NULL, NULL, "hello", NULL, 0, 1L, "allow")
path <- tempfile(fileext = ".jsonl")
write_audit_log(audit, path)