PII Redaction in Rust: Why We Strip Sensitive Data Before It Leaves Your Machine
A deep dive into the Serpaix LTM daemon's PII redaction pipeline — Sørensen–Dice deduplication, regex-based stripping, and why doing this in Rust matters for latency and trust.
Why On-Device Redaction?
The Long-Term Memory (LTM) daemon captures your screen and clipboard continuously. That means it will inevitably capture sensitive data: credit card numbers, API keys, passwords, personal emails. The question is not whether sensitive data appears — it's what you do about it.
The Pipeline
The LTM daemon's PII redaction pipeline has four stages:
1. Pattern Detection (15+ Patterns)
We maintain a compiled set of regular expressions covering:
2. Deduplication via Sørensen–Dice
The same sensitive information often appears across multiple captures (e.g., you type an API key, it appears in both screen and clipboard captures). Sørensen–Dice coefficient comparison prevents redundant redaction events and reduces CPU overhead.
3. In-Place Redaction
Redaction happens in the Rust process's memory before any data is serialized for transmission. The raw buffer is zeroed after processing.
4. Exclusion Zones
Password managers (1Password, Bitwarden, Apple Keychain) are excluded at the capture level — their windows are never captured in the first place, using platform-specific window detection APIs.
Why Rust?
The result: sensitive data is stripped before it ever leaves your machine, and the performance impact is negligible. The full threat model, encryption at rest and key handling are covered on the security page, and the daemon itself on long-term memory.
