Back to projects

Case study

CloakData

A Polars-based library for explicit, configurable data masking and transformation.

CloakData packages sensitive-field transformations behind validated configuration, conditional rules, documented methods, and a controlled extension API.

Validated configuration and predictable input constraints
Conditional Polars transformations with documented boundaries
Registered extension methods protected from name collisions

Problem

Sensitive-field transformations often grow as one-off scripts with implicit parameters and inconsistent failure behavior. That makes the intended rules harder to review, reuse, and test.

Outcome

The result is a reusable transformation library with explicit behavior and tested extension boundaries. It supports masking workflows, but it does not claim compliance, irreversible anonymization, cryptographic protection, or production adoption.

What I built

  • A typed Python package that applies masking, replacement, generalization, randomization, and cleanup methods to Polars DataFrames.
  • Config validation plus nested all/any/not conditions and sequential rules per column.
  • A method registry for custom transformations, with signature checks and protection against overriding native methods.

Technical decisions

  • Keep transformation rules explicit in configuration and reject invalid parameters in individual methods.
  • Use deterministic methods where stable pseudonyms are needed while documenting collision-prone hash buckets separately.
  • Ship runnable examples, pytest coverage, type information, and PyPI packaging as part of the public API.

Interactive illustration · not the Python runtime

Preview the transformation flow

This browser interaction illustrates representative CloakData inputs and outputs. It does not execute the Python package; the repository, tests, and PyPI package are the technical source of truth.

masked dataset
Polars DataFrame
fieldvalue
nameM.S.
emailxxxxx@example.com
age30-39
statusA

rules applied

initials_only()
mask_email()
generalize_age()
replace_exact(mapping=...)
CloakData | Jeferson Peter