Creates a validated policy from a list of shieldr_rule objects.
Usage
shieldr_policy(
name,
rules,
thresholds,
rate_guard = NULL,
trusted_sources = NULL,
controls = NULL
)Arguments
- name
Policy name.
- rules
A list of
shieldr_ruleobjects.- thresholds
A list containing numeric
redact_atandblock_atvalues between 0 and 1.- rate_guard
A
shieldr_rate_guardenvironment, orNULL.- trusted_sources
Optional character vector of trusted context sources.
- controls
Optional list from
policy_controls().
Details
This is the low-level constructor. Most users should start with policy(),
which returns a ready-to-use built-in policy. shieldr_policy() is exported
so advanced users and tests can construct exact policy objects.
trusted_sources is used by scan_context() only. If it is NULL, all
sources are treated as trusted. If it is a character vector and source_col
is supplied to scan_context(), rows with source values outside the allowlist
receive an OWASP LLM08 finding.
controls is used by secure_chat() after scanner reports have already
resolved to allow, redact, or block. Use policy_controls() to decide
whether blocked prompts or outputs should return block, refuse, or
escalate, and whether blocked context rows should be dropped, kept in
redacted form, or stop the chat call.
