Skip to contents

Opens (or creates) a JSONL file at {output_dir}/ai_decisions.jsonl and returns an AuditLog S3 object that can be passed to log_ai_decision throughout the pipeline.

Usage

init_audit_log(output_dir, config = NULL)

Arguments

output_dir

Character. Base output directory for the current run.

config

A ThematicConfig (or NULL). When non-NULL, config$methodology$mode is captured and auto-stamped on every subsequent audit record.

Value

An AuditLog S3 object (a list with class attribute).

Details

If the file already exists it is opened in append mode so that resumed runs continue the same log.

Two behaviours are worth noting:

  • It accepts config so methodology metadata flows into every audit record. When config$methodology$mode is set, log_ai_decision auto-stamps it on every JSONL record, which makes every logged decision unambiguously attributable to the methodology it was made under. Cross-mode comparison relies on this.

  • Counter state (n_written) lives in an internal environment so that increments from log_ai_decision mutate correctly across function calls rather than being lost to R's pass-by-value semantics.