Skip to contents

policy() is the easiest way to start. It returns a ready-to-use policy for common safety profiles such as "enterprise_default", "pharma_gxp", and "comprehensive".

Usage

policy(name = "enterprise_default", overrides = list())

Arguments

name

Built-in policy name. Defaults to "enterprise_default".

overrides

Optional list with rules, thresholds, rate_guard, or trusted_sources entries. controls may be supplied with policy_controls() to tune orchestration behavior in secure_chat().

Value

A shieldr_policy.

Details

Built-in policies are assembled from the rule helpers in R/rules.R. They use OWASP GenAI / LLM Top 10 categories as the organizing taxonomy, then add common controls such as PII patterns, secret patterns, system-prompt extraction checks, excessive-agency language, domain-specific claims, and optional rate guards.

Policy names:

  • enterprise_default: broad production baseline for injection, NLP intent, PII/PHI, secrets, system prompt extraction, and agency language.

  • pharma_gxp: enterprise_default plus clinical identifiers, diagnosis and treatment language, unsafe code checks, and stricter thresholds.

  • finance_strict: enterprise_default plus account numbers, investment advice language, autonomous trading language, and a token-rate guard.

  • education_safe: enterprise_default plus minor-related PII and academic-integrity bypass language.

  • open_research: a smaller open-workflow profile focused on injection and secrets, with higher thresholds.

  • comprehensive: a maximum-coverage profile combining the enterprise, pharma, finance, education, code-safety, and rate-guard controls. Uses moderate thresholds (redact_at = 0.4, block_at = 0.7). For pharma-tier strictness, supply overrides = list(thresholds = list(redact_at = 0.3, block_at = 0.6)) explicitly.

  • custom: no rules, default thresholds.

  • baseline: backward-compatible alias for enterprise_default.

These policies are starting points. They are transparent, testable, and can be extended with add_rule() for application-specific requirements.

Examples

policy()
#> llmshieldr policy
#> name: enterprise_default
#> rules: 14
#> redact_at: 0.4
#> block_at: 0.75
policy("open_research", overrides = list(thresholds = list(redact_at = 0.7)))
#> llmshieldr policy
#> name: open_research
#> rules: 8
#> redact_at: 0.7
#> block_at: 0.95