Deterministic rules
The engine rules-v1 traverses text values in JSON objects and arrays. Regular expressions identify email, phone, addresses and contextual identifiers. Object keys and numeric values are not examined as text.
CPF and numeric CNPJ undergo modulo-11 checks, comparison of both check digits and rejection of repeated sequences. This validates structure without querying a registry or proving ownership. This detector does not cover alphanumeric CNPJ.
Health card numbers, physician registrations, medical records, insurance identifiers and clinical dates use patterns and contextual words; they do not receive the same mathematical validation as CPF/CNPJ. Names in the deterministic engine depend on a configured list, without general person recognition.
Policies with defined effects
placeholder replaces findings with placeholders and reuses the placeholder for a normalized value within the same category and request. The map is ephemeral, without a persistent restoration table.
redact replaces the passage with [REMOVIDO]. In /v1/privacy/clean, block stops sanitization with HTTP 422 when personal data is found, without returning the blocked text.
In the inference API, monitor observes and records findings but preserves text. The sanitization endpoint does not accept this policy. Organization settings restrict permitted choices; instructions in the text do not change authorization.
How do we calculate check digits?
After removing punctuation, CPF requires 11 digits and numeric CNPJ requires 14. For each check digit, we compute the weighted sum, its remainder modulo 11 and the expected digit. The second calculation includes the first computed digit.
CPF DV1: [10, 9, 8, 7, 6, 5, 4, 3, 2]
CPF DV2: [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
CNPJ DV1: [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
CNPJ DV2: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
r = sum(digit[i] * weight[i]) % 11
dv = r < 2 ? 0 : 11 - r
A sequence rejected by a checksum may still match another pattern, such as a phone number. Classification is per category, without a guarantee that every invalid number will remain unchanged.
Stack and data boundaries
TypeScript gateway on Cloudflare Workers; static pages; D1 for metadata and R2 for the audit archive. The media flow extracts or transcribes content before applying the text privacy layer. OCR or transcription errors can reduce coverage.
Auditing uses AES-256-GCM, a random 96-bit IV and authenticated associated data. When enabled, it may retain original and sanitized content in encrypted form with restricted access and expiration. Operational logs must not contain raw text. Encryption protects the archive; it does not fix detection errors.
NIST SP 800-38D — the GCM specification