Legal

Protect privileged matters, limit unauthorized legal practice, check citations and retain defensible audit records.

Industry starter · Regulated SaaS

What it checks

Policies in the Legal template, in the order the gateway runs them
PolicyOnChecksAction
prompt-injectionRequest4 attack patterns; similarity threshold 0.78Block
pii-detectorRequest4 custom identifier patternsRedact
dlp-filterRequest12 blocked terms such as “settlement amount” and “plea offer”; 3 custom patterns; classification markers; near-miss spellingsBlock
legal-privilegeResponse9 privilege markers such as “attorney-client privilege” and “privileged and confidential”Block
upl-filterResponse9 legal-advice phrases such as “you should sue” and “file this motion”; adds a disclaimerBlock, add disclaimer
citation-verifierResponseRequires cited sources; confidence ≥ 0.95; groundedness ≥ 0.92Block
quality-scorerResponseAccuracy ≥ 0.93; relevancy ≥ 0.90; combined score ≥ 0.91; at least 220 characters and 3 sentencesFallback
audit-loggerRequestAdds an allow-only audit marker to the decisionRecord
Policy YAML
pack:
  id: "cfg_demo_legal"
  name: "demo-legal-ethics"
  version: "0.2.0"
  enabled: true
  author: "local"
  description: "Law firm starter with privilege protection, UPL controls, and citation verification"

# The current schema-safe way to avoid raw retention is metadata-only history capture with blocked-event visibility.
history:
  capture:
    enabled: true
    mode: metadata_only
    include_blocked: true
    fail_open: false

policies:
  chain: [prompt-injection, pii-detector, dlp-filter, legal-privilege, upl-filter, citation-verifier, quality-scorer, audit-logger]

policy:
  # A prompt attack against a legal assistant can become a privilege-waiver event, so boundary defense comes first.
  prompt-injection:
    embedding_threshold: 0.78
    attack_patterns: ["ignore.*privilege.*warning", "reveal.*confidential.*memo", "summarize.*sealed.*material", "pretend.*you are.*outside counsel"]
    encoding: {decode_base64: true, normalize_unicode: true, detect_homoglyphs: true}
    boundaries: {enforce_delimiters: true, reject_fake_boundaries: true}

  # Redact matter identifiers and privilege cues before support or research prompts reach the model.
  pii-detector:
    action: redact
    detect_patterns: ['(?i)\b(?:case|matter|docket)\s*(?:no\.?|number)?\s*[:#-]?\s*[0-9]{2,4}-[A-Z]{1,6}-[0-9]{2,8}\b', '(?i)\bclient\s*(?:id|number)?\s*[:#-]?\s*[A-Z]{2,8}-[0-9]{4,10}\b', '(?i)\b(?:attorney-client privileged|privileged and confidential|attorney work product|joint defense)\b', '(?i)\b(?:litigation hold|common interest agreement|for settlement purposes only)\b']
    redaction:
      marker_format: label
      include_metadata: true
      custom_markers: {generic_id: "[REDACTED-LEGAL-ID]"}

  # Duties of confidentiality extend beyond names, so sealed, grand-jury, and settlement-sensitive prompts are blocked outright.
  dlp-filter:
    blocked_terms: ["settlement amount", "plea offer", "sealed record", "grand jury", "litigation strategy", "expert report draft", "outside counsel memo", "witness preparation notes", "privilege log", "attorneys eyes only", "mediation statement", "common interest agreement"]
    detect_patterns: ['(?i)\b(?:sealed|ex parte|in camera)\s+(?:filing|submission|exhibit)\b', '(?i)\b(?:plea|settlement)\s+(?:offer|terms|proposal)\b', '(?i)\b(?:grand jury|subpoena)\s+(?:material|transcript|return)\b']
    action: block
    fuzzy_matching: true
    max_distance: 1
    sensitivity_level: high

  # Output markers are a hard stop because accidental disclosure can waive privilege and expand discovery risk.
  legal-privilege:
    privilege_markers: ["attorney-client privilege", "privileged and confidential", "attorney work product", "for legal review only", "litigation hold", "joint defense", "common interest privilege", "outside counsel only", "prepared at the direction of counsel"]

  # The assistant may educate, but it must not direct legal action or give individualized legal advice.
  upl-filter:
    blocked_patterns: ["you should sue", "file this motion", "sign this settlement", "accept the plea", "waive your rights", "terminate the contract immediately", "serve this subpoena", "you are legally required to", "plead guilty"]
    require_disclaimer: true
    rewrite_to_educational: false

  # Hallucinated citations create direct liability, so unverified authorities should never pass as final work product.
  citation-verifier:
    require_sources: true
    require_source_match: true
    min_confidence: 0.95
    min_groundedness: 0.92
    extract_patterns: [case_law, quote, url, statistic]
    output_action: {unverified_action: block}
    response: {include_verification_report: true}

  # Briefs, memos, and client updates need a higher accuracy floor because they are often reused with minimal editing.
  quality-scorer:
    min_output_chars: 220
    min_sentences: 3
    thresholds: {min_aggregate: 0.91, min_relevancy: 0.90, min_accuracy: 0.93}
    weights: {relevancy: 0.35, accuracy: 0.65}
    failure_action:
      action: fallback
      fallback_message: "Unable to provide a sufficiently grounded legal response. Route this request to licensed counsel for review."
    industry_profiles: {legal: {min_aggregate: 0.91, min_relevancy: 0.90, min_accuracy: 0.93}}

  # Keep the audit marker active so blocked privilege and UPL events remain visible in evidence exports.
  audit-logger: {}