A prompt template should only merge fields someone has classified

Pattern masking finds emails and card numbers, not a diagnosis note. Decide per field, store the decision as classification metadata, and block templates on unclassified fields.

Catalog Prompt template Field gate Pattern masker Model gateway Demasker Audit log field classes allow, mask or deny every decision denied fields skip the model
A catalog of field classes feeds a gate that allows, masks or denies each merged field, and denials go straight to the audit log.
On this page
  1. What a pattern can see
  2. The decision already has a place on the field
  3. One join lists every merged field
  4. Brightwater’s nine templates
  5. Four rough edges
  6. The gate, item by item

The field picker in a prompt template lists every field on the record the same way. On a Case, Subject and Diagnosis Note are two rows in one dropdown, and nothing on the screen says the second is a health record.

Masking at the prompt boundary doesn’t settle it. A masker reads text and finds things with a shape, like an email address or a card number. Whether a field may leave the CRM at all is a different question, and I think a person has to answer it per field, ahead of time, where a machine can read the answer. The masker runs second, and both steps write to one audit log.

A template has ten checks to pass before it goes live, and the full list is at the end. The policy file and one query make the first three automatic.

What a pattern can see

Salesforce’s Einstein Trust Layer masks at the boundary. Its pattern detectors find sensitive values in the assembled prompt, swap them for placeholders, and put them back in the response. That works for an email address or a card number, where a detector can test the format.

A negotiated discount is two digits and a percent sign. A diagnosis note is ordinary sentences. By the time a detector sees either, the template has resolved and the field name is gone.

Masking by field instead of by pattern would be the better input, reading the classification metadata I describe below. But any masker only masks, and a field nobody classified goes through as typed.

Field-level security doesn’t answer it either. It decides whether this user may see the field, and a claims adjuster should see the diagnosis note. Whether the note may travel to a model is a separate permission, and it doesn’t exist until someone writes it down.

The decision already has a place on the field

For several years now, a Salesforce field has been able to carry four pieces of classification metadata: Data Owner, Field Usage, Data Sensitivity Level and Compliance Categorization. Sensitivity ships with five levels, Public through MissionCritical, and compliance with values such as PII and HIPAA. Admins can edit both lists, hence the unknown-value rule in check 3.

The catalog is one query per object:

SELECT QualifiedApiName, DataType, SecurityClassification,
       ComplianceGroup, BusinessOwnerId
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName = 'Case'

SecurityClassification is the sensitivity level. A policy file turns it and ComplianceGroup into an action:

# prompt-field-policy.yml
# Level and category names are Salesforce's defaults.
version: 1
unclassified: block          # empty sensitivity level: the template doesn't run
unknown_value: never         # a picklist value this file doesn't list

sensitivity:
  Public: allow
  Internal: allow
  Confidential: mask
  Restricted: never
  MissionCritical: never

compliance:                  # the stricter of the two actions wins
  PII: mask
  GDPR: mask
  CCPA: mask
  COPPA: never
  PCI: never
  HIPAA: never

free_text:                   # check 4
  data_type_starts_with: ["Text Area", "Long Text Area", "Rich Text Area"]
  least_strict_action: mask

prompt_log:                  # check 10
  store: masked_prompt
  retention_days: 90

Mask swaps the whole value for a placeholder before the prompt is built, and the demasker restores it in the response. Never drops the field and logs the denial, the thin line in the diagram, and the template runs without it.

Unclassified means nobody has decided, and the gate shouldn’t decide for them. The whole template stops until an owner sets a level.

I’d run the gate twice. Prompt Builder templates are retrievable metadata, with merge fields such as {!$Input:Case.Contact.Email} in plain text, so a deployment check can parse them. A second pass at request time, in whatever code assembles the prompt, covers a level that changes after it ships.

One join lists every merged field

Load two tables into anything that speaks SQL: prompt_template_field, one row per merge field parsed from each template, and field_catalog, the FieldDefinition export.

SELECT t.template_name,
       t.merge_path,
       t.object_name,
       t.field_name,
       c.data_type,
       COALESCE(c.sensitivity_level, 'UNCLASSIFIED') AS sensitivity,
       c.compliance_group,
       c.data_owner
FROM prompt_template_field AS t
LEFT JOIN field_catalog AS c
       ON c.object_name = t.object_name
      AND c.field_name  = t.field_name
ORDER BY CASE WHEN c.sensitivity_level IS NULL THEN 0 ELSE 1 END,
         t.template_name,
         t.merge_path;

merge_path keeps the route, Case.Contact.Email, while object_name and field_name name the field at the far end. A field missing from the catalog and a field with an empty level both come out as UNCLASSIFIED and sort to the top.

Brightwater’s nine templates

The query needs rows to return, so give it an insurer of my own invention, Brightwater Insurance: 412 custom fields across Account, Contact and Case, 96 of them with a sensitivity level. Nine prompt templates are live.

The query returns 23 distinct fields. Fourteen are classified and permitted: nine merge as they are and five get masked. Two are Restricted, a claim diagnosis note on Case and a bank IBAN on Account. Seven have no level at all.

A pattern masker would probably have caught the IBAN. The diagnosis note would have gone through word for word.

With the gate on, the two Restricted fields are dropped and logged, and their templates run with thinner output. The seven unclassified fields sit in four other templates, which stop until an owner sets a level. Five keep working.

Brightwater has 316 unclassified custom fields, and a project to classify them all would stall. The gate asks for seven decisions.

Four rough edges

The template author gets the block, and only the field’s owner can set a level. Check 2 needs a fallback owner per object for the week the real one is out.

Classifying free text for its worst case is blunt. Most case descriptions are harmless, and now every one is masked or dropped, which leaves a case-summary template little to summarize. I’d accept that.

The level also becomes a lever. Changing Confidential to Internal is a one-click way around the gate, so I’d review classification changes like permission changes.

And the gate only knows about fields. What a user types into a copilot conversation has no field behind it, so the masker is the only check that text gets.

The gate, item by item

  1. Every field the template merges has a Data Sensitivity Level. An empty one blocks the template. It doesn’t default to Internal.
  2. Every merged field has a Data Owner, so a blocked template comes with a name to ask.
  3. A policy file maps each sensitivity level and compliance category to allow, mask or never. An unknown value counts as never.
  4. Free-text fields are classified for the worst thing anyone could type into them, and never rank below mask.
  5. A merge across a relationship is checked at the far end: Case.Contact.Email is a Contact field. A related list is every merged field times every row.
  6. A flow or Apex class that feeds a template declares the fields it reads. No declaration, no template.
  7. Attachments and email bodies have no classification, so they’re never merged whole. An extraction step pulls out named values, which are classified like fields.
  8. The pattern masker runs on everything the gate allowed, and its test set includes the org’s own formats, such as claim numbers.
  9. The log records every gate decision: template, field, class and action. A denial is logged without the value.
  10. A stored prompt copies every field in it, so it takes the class of its most sensitive field and a retention period. The model provider’s retention is in the contract.