VG-DOC · rev 0.1.0PII / DLP redaction firewall for LLM pipelinesMIT · Node 22+
VeilgateDocumentation
Flow 12 / 14ReferenceStage 03

The policy model

How Veilgate policies work — rules, detectors, operators, actions, placeholder types, and how overlapping rules resolve by action priority.

A policy is a named list of rules. Each rule compares one detector against a threshold and, if it fires, proposes an action.

policy.d.ts
interface Policy {
  name: string;
  rules: PolicyRule[];
}

interface PolicyRule {
  detector: DetectorName;   // e.g. "direct_pii"
  op: "gt" | "gte" | "lt" | "lte";
  threshold: number;        // 0..1
  action: "ALLOW" | "REDACT_AND_FORWARD" | "REROUTE_LOCAL" | "BLOCK";
  placeholderType?: string; // label used in the placeholder, default "PII"
}

Detectors

The five values Jev returns per span, each in [0,1]:

Detector Primitive Evaluates
direct_pii Noul Explicit names, addresses, IDs
contextual_quasi_identifier Noul Combined indirect identifiers
credentials_or_secrets Noul API keys, tokens, passwords
regulated_health_or_financial Noul HIPAA / PCI data
sensitivity_severity Score 0.0–1.0 structural-context severity

Operators

gt, gte, lt, lte — compare the detector value against threshold. A rule fires when the comparison is true.

Actions and priority

When several rules fire for one span, the highest-priority action wins (ACTION_PRIORITY):

Plaintext
BLOCK (3)  >  REDACT_AND_FORWARD (2)  >  REROUTE_LOCAL (1)  >  ALLOW (0)
Action What happens
ALLOW Span passes through untouched
REDACT_AND_FORWARD Span replaced with a typed placeholder; original stored in the vault
REROUTE_LOCAL Payload diverted to a trusted local model
BLOCK blocked set; the caller must refuse to forward

Placeholder types

When a rule redacts a span, placeholderType (default "PII") labels the inserted placeholder — [REDACTED_<TYPE>_<n>], incrementing per type. A readable type makes decisions and audit logs legible: [REDACTED_SSN_1], [REDACTED_PII_2].

Example

example.ts
const policy = {
  name: "example",
  rules: [
    { detector: "credentials_or_secrets", op: "gt", threshold: 0.9, action: "BLOCK" },
    { detector: "regulated_health_or_financial", op: "gt", threshold: 0.15, action: "REDACT_AND_FORWARD", placeholderType: "PHI" },
    { detector: "direct_pii", op: "gt", threshold: 0.8, action: "REDACT_AND_FORWARD", placeholderType: "PII" },
    { detector: "sensitivity_severity", op: "gte", threshold: 0.5, action: "REROUTE_LOCAL" },
  ],
};

A span that trips both the secrets rule and the PII rule is blocked — the higher-priority action wins.

Tip

You rarely write policies by hand: start from a preset and override only what you need with extends in a YAML/JSON policy.