% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rules.R
\name{shieldr_policy}
\alias{shieldr_policy}
\title{Construct a \code{shieldr_policy}}
\usage{
shieldr_policy(
  name,
  rules,
  thresholds,
  rate_guard = NULL,
  trusted_sources = NULL,
  controls = NULL
)
}
\arguments{
\item{name}{Policy name.}

\item{rules}{A list of \code{shieldr_rule} objects.}

\item{thresholds}{A list containing numeric \code{redact_at} and \code{block_at}
values between 0 and 1.}

\item{rate_guard}{A \code{shieldr_rate_guard} environment, or \code{NULL}.}

\item{trusted_sources}{Optional character vector of trusted context sources.}

\item{controls}{Optional list from \code{\link[=policy_controls]{policy_controls()}}.}
}
\value{
A \code{shieldr_policy} S3 object.
}
\description{
Creates a validated policy from a list of \code{shieldr_rule} objects.
}
\details{
This is the low-level constructor. Most users should start with \code{\link[=policy]{policy()}},
which returns a ready-to-use built-in policy. \code{shieldr_policy()} is exported
so advanced users and tests can construct exact policy objects.

\code{trusted_sources} is used by \code{\link[=scan_context]{scan_context()}} only. If it is \code{NULL}, all
sources are treated as trusted. If it is a character vector and \code{source_col}
is supplied to \code{\link[=scan_context]{scan_context()}}, rows with source values outside the allowlist
receive an OWASP LLM08 finding.

\code{controls} is used by \code{\link[=secure_chat]{secure_chat()}} after scanner reports have already
resolved to \code{allow}, \code{redact}, or \code{block}. Use \code{\link[=policy_controls]{policy_controls()}} to decide
whether blocked prompts or outputs should return \code{block}, \code{refuse}, or
\code{escalate}, and whether blocked context rows should be dropped, kept in
redacted form, or stop the chat call.
}
\examples{
shieldr_policy("empty", list(), list(redact_at = 0.4, block_at = 0.75))
}
