pii-redaction-gate
A rule-based engine that removes personal identifiers from free text before it reaches a model or a datastore, and blocks the send when the redactor itself fails.
decision
An application developer chooses a source profile and decides whether text may proceed to a model or store. A blocked result must stop the send. A successful result still needs review for identifiers the rules miss.
baseline
This is the rules baseline. A model is unnecessary for its fixed patterns, and would add a transfer of the very text being protected. Better recall would require new evidence beyond these rules.
review
A developer inspects the published misses and false positives before choosing a profile. When the engine fails, the send gate blocks the record until the rule or input is corrected. Passing the gate is not permission to send real patient text.
data
The example runs the copied rules in this browser on fixed synthetic text. Redaction itself makes no model call. In a consuming application, later transfer, logging, retention, access and deletion belong to that application and are not established by this engine.
platform
The reusable engine returns text, hit types and a blocked flag. A consuming send gate must enforce that flag. Profiles control which tiers run. The fixed evaluation checks both removed identifiers and preserved clinical content before a rule change can be judged.
limits
The 182 synthetic snippets are not real-record validation. Dates, ages and unlabeled identifiers can survive. A developer cannot infer privacy compliance from these scores.
Evaluation
Original baseline. Run 2026-10-30, npm run eval. 182 synthetic snippets (85 clinical-style note fragments, 35 patient messages, 22 general free-text and 40 clinical-only hard negatives), 207 labeled identifiers and 227 labeled hard negatives. I wrote the set after the engine code was final for this release and changed no rule after seeing the results. Each output is aligned back to its input. An identifier counts as caught only if every letter and digit in it was removed. A hard negative counts as damaged if any of its characters were removed. Latency is one sample per call: 200 rounds over all 182 snippets after 20 warm-up rounds.
Results by profile: identifiers | 70.5% (146/207) | 7 | 82.6% (190 spans) | 88.1% | 27/40 | 3.1 µs | 5.0 µs
Results by profile: strict | 74.4% (154/207) | 6 | 73.2% (213 spans) | 43.2% | 16/40 | 4.4 µs | 6.5 µs
Results by profile: standard | 33.3% (69/207) | 0 | 97.1% (69 spans) | 97.8% | 40/40 | 3.4 µs | 5.0 µs
Results by profile: light | 30.0% (62/207) | 0 | 100.0% (62 spans) | 100.0% | 40/40 | 2.2 µs | 3.3 µs
Identifiers profile, by labeled type: NAME | 51 | 43 | 4 | 4 | 84.3%
Identifiers profile, by labeled type: RELATIVE | 26 | 21 | 1 | 4 | 80.8%
Identifiers profile, by labeled type: FACILITY | 21 | 20 | 1 | 0 | 95.2%
Identifiers profile, by labeled type: DOB | 11 | 10 | 0 | 1 | 90.9%
Identifiers profile, by labeled type: DATE (visit, admission, other) | 25 | 0 | 0 | 25 | 0.0%
Identifiers profile, by labeled type: AGE | 14 | 0 | 0 | 14 | 0.0%
Identifiers profile, by labeled type: PHONE | 19 | 19 | 0 | 0 | 100.0%
Identifiers profile, by labeled type: EMAIL | 8 | 8 | 0 | 0 | 100.0%
Identifiers profile, by labeled type: ADDRESS (incl. GPS, PO box) | 13 | 12 | 1 | 0 | 92.3%
Identifiers profile, by labeled type: ID (MRN, SSN, member, account, card, license) | 19 | 13 | 0 | 6 | 68.4%
Tests: npm test | 79 tests, 79 pass, 0 fail (Node 24.14.1)
Tests: Fail-closed tests | 11 tests: throwing rules, people maps, name entries and topic categories, misspelled profiles, non-string input, record and writer failures
Tests: Mutation check | Rethrow instead of block: 7 of 11 failed. Pass non-strings through: 2 failed. Fall back to the default profile on an unknown name: 1 failed.
- This is pattern-based redaction. It is not certified de-identification, it has not been validated against any regulatory standard, and it should not be the only control for protected health information.
- The evaluation set is synthetic, small and written by one person. It measures behavior on these shapes, not on real clinical documentation.
- US-centric shapes and English keyword lists. No rules for URLs, IP addresses or device identifiers. Text only.