safeslice

Masking

The eleven masking rules, why they are deterministic, how they respect column constraints, and the honest limit of free text.

Masking happens in transit — values are replaced between reading them from the source and writing them to the target, so nothing unmasked is ever written to disk.

The rules

RuleProducesExample output
emailAn address at example.invaliduser_0b1343bf051a1e1c@example.invalid
phoneA 555 number, reserved for fiction+15550563127
first_nameA name from a fixed listRiley
last_nameA name from a fixed listKowalski
nameFirst and last togetherKai Park
addressA street address545 Placeholder St
govidUppercase hex — for SSNs, cards, tax IDs00D1AF1CBD6
ipAn address in the TEST-NET-3 range203.0.113.68
secretThe literal REDACTEDREDACTED
redactNothing — the value is droppedNULL, or '' when NOT NULL
keepThe original value, unchanged—

Those outputs are real, at seed safeslice.

Determinism

The same input and the same seed always produce the same replacement. That is what keeps a slice usable: a customer’s email appearing in users, invoices and audit_log masks identically in all three, so every join still works.

Change the seed and every value changes. Share the seed across a team and everyone’s snapshots agree on what a given customer was renamed to.

Constraint awareness

Masking has to produce a value the column will actually accept:

  • Key columns are never masked. Rewriting a primary or foreign key would destroy the referential integrity the slice exists to preserve.
  • NOT NULL is respected. redact on a NOT NULL column writes an empty string rather than NULL.
  • varchar(n) is not overflowed. Output is clamped to the declared length.
  • Types are matched. An integer column receives an integer, a numeric a decimal, a uuid a well-formed UUID, an inet an address.
  • UNIQUE is retried. A collision is re-generated with a salt until the value is free. A rule that cannot produce distinct values — redact on a NOT NULL unique column — is refused before a table is read, rather than failing halfway through a load.
  • Unmaskable types are refused. A geometry, array or enum column cannot take a fake string, so Safeslice stops and asks you to set keep or redact instead of corrupting the row.

Free text is the limit

No regular expression reliably scrubs a support ticket that happens to quote a customer’s address, and Safeslice does not pretend otherwise. Columns it cannot judge are surfaced for a decision, and strict mode — on by default — refuses to run while any remain unreviewed.

That refusal is the feature. Silently passing an unreviewed text column through is exactly how personal data reaches a laptop.