Docs Index
dlp service.md

Proof Card: DLP Service (PII Detection & Redaction)

Status: production Last verified: 2026-04-28 · git sha 562e3ab4

Claim

DLPService is the single source of truth for PII detection and redaction across the platform. It exposes a registry of 14 PII pattern types via getRegisteredPatterns(), splits them into 8 unconditional patterns and 6 field-name-gated patterns (requiresFieldContext: true), and provides two scanning entry points: scanForPII(data) for objects (preserves dotted paths so field gates can fire) and scanText(text) for strings (gated patterns skipped because empty path → helper returns false). The 14 patterns and the 6/8 split are pinned by a unit guard test that breaks CI if the registry drifts.

Source

Tests

Live vs Fixture

Known Gaps

Verification (60-second AI-reviewer recipe)

npm test -- tests/unit/services/security/DLPService.test.ts
grep -n "requiresFieldContext: true" src/services/security/DLPService.ts | wc -l   # expect 6
node -e "const ts = require('fs').readFileSync('src/services/security/DLPService.ts','utf8'); console.log('total patterns: ', (ts.match(/^[[:space:]]*name:\s*'[a-z_]+'/gm) || []).length);"
# Or hit the live endpoint after npm start:
# curl http://localhost:3003/api/compliance/dlp-patterns | jq '.data.patterns | length'   # expect 14

The wc -l should print 6 (the field-gated patterns). The grep over getRegisteredPatterns() proves the public API and the metadata view are wired through a single function.