Audits collect the scanner reports and operational metadata from a guarded run.
Usage
shieldr_audit(
input_report = NULL,
output_report = NULL,
context_reports = NULL,
prompt_clean,
output_raw = NULL,
elapsed_ms,
token_estimate,
action,
content_mode = c("metadata", "full"),
tool_reports = NULL,
decision_id = NULL,
policy_version = NULL,
metrics = list(),
fingerprint_key = NULL,
show_stats = FALSE
)Arguments
- input_report
A
shieldr_report, orNULL.- output_report
A
shieldr_report, orNULL.- context_reports
A list of
shieldr_reportobjects, orNULL.- prompt_clean
Cleaned prompt.
- output_raw
Raw model output, or
NULL.- elapsed_ms
Elapsed time in milliseconds.
- token_estimate
Integer token estimate.
- action
Final action.
secure_chat()may return"refuse"or"escalate"when policy controls map a blocked report to those outcomes.- content_mode
"metadata"(default) removes prompt/output text, finding excerpts, and reviewer error details from the audit object."full"retains them and should only be used in explicitly protected storage.write_audit_log()still requiresinclude_content = TRUEto persist the full content.- tool_reports
Optional list of tool-request and tool-output reports.
- decision_id
Correlation identifier. A local identifier is generated when omitted.
- policy_version
Policy configuration version.
- metrics
Privacy-safe structured timing, token, network, and request metrics.
- fingerprint_key
Optional secret key used to HMAC finding matches before metadata-only content removal. The key is never stored.
- show_stats
Show construction time and audit token estimate.
Details
secure_chat() builds this object automatically. elapsed_ms captures
wall-clock elapsed time for the guarded workflow. token_estimate uses an
ellmer token counter when one is available and falls back to
ceiling(nchar(text) / 4) over prompt and output text. It is intended for
guardrails and trend monitoring, not billing reconciliation.
Examples
shieldr_audit(NULL, NULL, NULL, "hello", NULL, 0, 1L, "allow")
#> $input_report
#> NULL
#>
#> $output_report
#> NULL
#>
#> $context_reports
#> NULL
#>
#> $tool_reports
#> NULL
#>
#> $prompt_clean
#> NULL
#>
#> $output_raw
#> NULL
#>
#> $elapsed_ms
#> [1] 0
#>
#> $token_estimate
#> [1] 1
#>
#> $action
#> [1] "allow"
#>
#> $content_mode
#> [1] "metadata"
#>
#> $decision_id
#> [1] "dec_f8523337fc061890aa92"
#>
#> $policy_version
#> NULL
#>
#> $decision_schema_version
#> [1] "1.0"
#>
#> $metrics
#> list()
#>
#> attr(,"class")
#> [1] "shieldr_audit"
