VG-DOC · rev 0.1.0PII / DLP redaction firewall for LLM pipelinesMIT · Node 22+
VeilgateDocumentation
Flow 06 / 14PackagesTaps stage 0319 tests

Policy — veilgate-policy

Compliance presets (balanced, gdpr-strict, hipaa-safe-harbor, soc2-secrets) and a declarative YAML/JSON policy loader with preset inheritance for Veilgate.

veilgate-policy provides ready-made compliance presets and a declarative loader for custom policies. 19 tests.

terminal
npm install veilgate-policy

Presets

Four deep-frozen presets:

Preset Posture
balanced Sensible default (same as core’s DEFAULT_POLICY)
gdpr-strict Aggressive PII redaction
hipaa-safe-harbor Health / financial data redaction
soc2-secrets Credentials & secrets focus
presets.ts
import { redact } from "veilgate";
import { PRESETS, getPreset } from "veilgate-policy";

await redact(text, { policy: PRESETS["hipaa-safe-harbor"] });
await redact(text, { policy: getPreset("gdpr-strict") });   // throws, listing valid names, if unknown

The presets are deep-frozen so a consumer can’t accidentally mutate shared rule state.

Declarative policies

Load a policy from YAML or JSON, optionally inheriting a preset with extends:

load.ts
import { loadPolicy } from "veilgate-policy";

const policy = loadPolicy(`
name: strict-secrets
extends: soc2-secrets
rules:
  - { detector: direct_pii, op: gt, threshold: 0.5, action: REDACT_AND_FORWARD, placeholderType: PII }
`);

await redact(text, { policy });

Building in code

define.ts
import { definePolicy } from "veilgate-policy";

const policy = definePolicy({
  name: "my-policy",
  rules: [
    { detector: "credentials_or_secrets", op: "gt", threshold: 0.9, action: "BLOCK" },
    { detector: "direct_pii", op: "gt", threshold: 0.8, action: "REDACT_AND_FORWARD", placeholderType: "PII" },
  ],
});

Validation

validate.ts
import { validatePolicy, PolicyValidationError } from "veilgate-policy";

try {
  validatePolicy(somePolicy);
} catch (err) {
  if (err instanceof PolicyValidationError) {
    // malformed detector name, op, threshold, or action — surfaced early
  }
}

Both loadPolicy and definePolicy validate, so a malformed rule fails fast rather than at redaction time.

Note

A policy is a named list of rules; see The policy model for the rule shape, operators, and how overlapping rules resolve by action priority.