% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/audit.R
\name{write_audit_log}
\alias{write_audit_log}
\title{Write an audit log}
\usage{
write_audit_log(audit, path, format = "jsonl")
}
\arguments{
\item{audit}{A \code{shieldr_audit} object.}

\item{path}{Output file path.}

\item{format}{One of \code{"jsonl"}, \code{"csv"}, or \code{"rds"}.}
}
\value{
The path, invisibly.
}
\description{
Persists a \code{shieldr_audit} object as JSON Lines, CSV, or RDS for operational
auditability across LLM workflows.
}
\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)
}
