Community · E2 · artifact verified

Redact PII inside Postgres, by content

A support inbox where Jev decides per span whether text is personal data and of what kind, and a redact() SQL function enforces the masking in Postgres by the viewer's clearance - content-aware, not pattern-based.

01 · Role in the system

What Jev does here

Candidate generation is deliberately dumb - tokenizing structured shapes, capitalized runs, and number-led runs. Each candidate becomes one choice question in a single parallel System One request, answered with a typed label - name, email, phone, address, id_number, or none - plus calibrated probabilities; only confident PII spans are kept. Content-awareness is the point: the front office stays visible while a phone number does not, because the decision is about meaning, not shape. Spans persist as JSONB beside each message, each PII type carries a sensitivity and each role a clearance, and a span is revealed only when clearance meets sensitivity. The API strips unauthorized values before they reach the browser, and the same rule is enforced in-database by a redact() function, so the demo shows what Postgres returns per role: Guest nothing, Support contact fields, Admin all.

Content-aware redaction, enforced in two places

Pattern-based redaction fails on the cases that matter — a phone number in a notes field, a name inside a free-text complaint — because shape is not meaning. This demo makes the decision about meaning: deliberately dumb candidate generation proposes spans, and one parallel System One request classifies each as name, email, phone, address, id_number, or none with calibrated probabilities. Only confident PII spans survive.

Enforcement is doubled by design. Spans persist as JSONB beside each message; the API strips unauthorized values before they reach a browser, and the same sensitivity-versus-clearance rule is enforced inside Postgres by a redact() function — so even a direct SQL query as the wrong role returns Guest-nothing, Support-contact-fields, Admin-everything.

Write-time decisions and their shelf life

The structural limitation is worth restating: classification happens once, at write time, on stored spans. Text whose meaning changes later — a nickname becoming identifying through context added elsewhere — is not re-decided, and redaction quality has not been independently evaluated beyond the repository's own demo data.

Within those limits, the record demonstrates the fullest PII pattern in the security cluster: judgment at the meaning layer, policy at the storage layer, and a live role-based demo that lets a reviewer watch the same rows resolve differently per clearance. The database function is the part most worth stealing, because it puts the enforcement where the data lives.

02 · Control boundary

Where Jev sits

Dumb span candidates to one parallel typed classification; masking enforced twice - in the API and in a Postgres redact() function gated on clearance.

Code owns the loop, permissions, thresholds, validation, and side effects. Jev owns only the bounded judgments described above.

03 · Known limits

What this evidence does not prove

  • Classification runs at write time on stored spans; content that changes meaning later is not re-decided.
  • A live demo application to run on your own Neon Postgres with a server-side key, not a hosted service.
  • Redaction quality was not independently evaluated here beyond the repository's own demo data.

04 · Attribution

Public sources

This is a Community record: the project was published by a third-party community author.