Skip to contents

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
)

Arguments

input_report

A shieldr_report, or NULL.

output_report

A shieldr_report, or NULL.

context_reports

A list of shieldr_report objects, or NULL.

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.

Value

A shieldr_audit S3 object.

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
#> 
#> $prompt_clean
#> [1] "hello"
#> 
#> $output_raw
#> NULL
#> 
#> $elapsed_ms
#> [1] 0
#> 
#> $token_estimate
#> [1] 1
#> 
#> $action
#> [1] "allow"
#> 
#> attr(,"class")
#> [1] "shieldr_audit"