Skip to main content
The masking policy is the YAML file that drives every decision Masker makes at runtime: which entity types to scan for, which detection passes to run, whether to tokenize or redact each entity, and which key to use when minting tokens. Masker ships a default policy at configs/mask_policy.yaml named healthcare-default that covers HIPAA Safe Harbor identifiers out of the box. You can tune that file, create per-agent policies, or switch tokenization schemes — all without touching code.

Sample mask_policy.yaml

The annotated example below matches the structure Masker expects. Every field is optional except those marked required.
mask_policy.yaml

Field reference

Top-level fields

Per-entity fields

Audit fields

Tokenization schemes

Masker stores a mapping of (plaintext, entity_kind) → token in a local SQLite vault. The same input always produces the same token, so LLM responses referring to MSKV1.PHONE.K_HEALTHCARE.abc123 can be correctly rehydrated even across turns.Best for: single-node deployments where vault state is easy to persist.Drawback: requires a shared vault in multi-replica setups. Use a Postgres database via MASKER_DATABASE_URL or switch to reversible-aead instead.

Tuning detection sensitivity

Every entity’s confidence_threshold controls how aggressively the NER pass fires. Lower values catch more but may introduce false positives; higher values are more precise but may miss edge cases.
Start with the defaults, run masker detect against real transcripts (with PHI scrubbed from the samples), and raise or lower thresholds based on what you observe.
To disable NER for a specific entity and rely only on regex, set ner: false. SSN and EMAIL are good candidates — their formats are regular enough that NER adds noise rather than coverage. To disable an entity type entirely, set enabled: false. This prevents Masker from running any detection pass for that kind.

Applying a policy

Global policy

Set MASKER_POLICY_PATH to point to your policy file before starting Masker. The default is configs/mask_policy.yaml. To reload a running server without restarting it:
The reload is atomic — in-flight requests complete on the old policy; new requests immediately pick up the updated one.

Per-agent policy overrides

Each agent inherits the global policy by default. To assign a custom policy to one agent, pass policy_yaml when creating or updating the agent:
The custom YAML is stored alongside the agent record and loaded only for that agent’s requests.

CLI: validate and diff

Use the masker policy subcommands to validate and compare policies before deploying them.

Validate before deploying

Validation catches the three most common errors:
  • unknown_kid — the policy references a kid with no matching MASKER_KEY_<kid> environment variable
  • invalid_pass — the passes list contains a name Masker doesn’t recognize
  • missing_entity — an entity referenced in passes is not declared under entities
Validation errors prevent boot in production mode. In development mode (MASKER_DEV=1) Masker logs the error and falls through to defaults — never rely on this in production.

Diff two policy versions

The diff shows which entities were added or removed, which thresholds changed, and which actions changed. Run this before replacing a live policy to understand the impact on detection coverage.