Sub topic 17
Access, Masking, and Governance
This chapter covers what controls who can see grounded content, what happens to sensitive values on the way to the model, and what you should govern as the system grows. It assumes you know basic Salesforce administration (permission sets, sharing, fields). It also assumes you have followed the earlier chapters, so you can already build a search index, a retriever, and an agent knowledge action.
Why governance matters for grounded answers
A grounded answer is built from content you retrieved. Anything the retriever returns can end up in the reply. So every access mistake in the retrieval path becomes a possible data leak in a customer-facing answer.
Three separate layers apply, and each one answers a different question:
| Layer | Question it answers | Where you configure it |
|---|---|---|
| Source access | Who may see this article or record at all? | Knowledge data categories, article channels, object and field permissions |
| Retrieval scope | Which content can this retriever or agent return? | Retriever filters, returned fields, Data Library or index choice |
| Model-request protection | What leaves Salesforce toward the model? | Einstein Trust Layer settings (masking, zero data retention, audit) |
Fixing one layer does not fix the others. A well-masked prompt does not help if the retriever returns an internal-only article to an external customer.
Access to the source content
Knowledge articles carry their own visibility rules. Before ingestion, an article is visible according to its channels (internal app, customer, partner, public knowledge base) and its data categories. Data Cloud ingestion copies the article text into a data model object. Your ingestion setup decides which article versions are copied, not the channel setting of each reader.
This is the most common governance gap. The index is built from whatever you ingested. If you ingested drafts, internal-only articles, or articles meant for partners, those chunks are searchable by anything that queries the index.
Check what is eligible before you ingest, using the query from the earlier chapter, and extend it to look at channel visibility:
SELECT Id, Title, UrlName, PublishStatus, Language,
IsVisibleInApp, IsVisibleInPkb, IsVisibleInCsp, IsVisibleInPrm
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
AND IsVisibleInPkb = false
LIMIT 50This lists online articles that are not visible in the public knowledge base. If your agent talks to anonymous web visitors, none of these should be in the index it uses. The visibility field names depend on which channels are enabled in your org, so confirm them in the object's field list first.
Keep separate indexes for separate audiences
Because the index itself has no notion of "who is asking", the safest design is one index (or one Data Library) per audience. For example:
- A customer-facing index built only from articles visible in the public knowledge base.
- An internal index that adds employee-only articles, used by agents that serve your own staff.
A single mixed index with filters is possible, and the next section shows how, but a filter is a rule you must remember to apply. A separate index cannot leak what it does not contain.
Retriever filters as an access control
A retriever can filter on fields stored with each chunk. If you mapped a field such as audience, channel, or data category into the index, you can restrict results by it. This is useful, but understand its limits:
- Filters are part of the retriever definition or the prompt template that calls it. They are not a per-user security check.
- A filter on a fixed value (for example,
Audience = Customer) is reliable. A filter that depends on a value the model or the user supplies is not, because the value can be wrong or manipulated. - Only fields included in the index can be filtered. If the field was not mapped during ingestion, you must re-create or update the index.
Also limit the returned fields. Return the chunk text and the title or URL needed for citation. Do not return fields such as author email, internal notes, or case numbers unless the answer needs them. Anything returned can be quoted by the model.
Running user and agent permissions
An Agentforce agent runs as a user or as a dedicated agent user, and its permissions limit what it can call. Check these items:
- The agent user has the permission set that grants the Agentforce and Data Cloud capabilities your retriever needs.
- Only the intended agent topics expose the knowledge action. A topic that is not needed should not have access to a broad index.
- Prompt templates that call retrievers are usable only by the profiles or permission sets you intend.
- Any Flow or Apex action used alongside the retriever respects field-level security and sharing, unless you deliberately run it in system mode.
Keep one rule in mind. The retriever reads from the index with the access of the index, not necessarily the access of the end customer. This is why audience separation at ingestion matters more than any later check.
Masking and the Einstein Trust Layer
When a prompt, including retrieved chunks, is sent to a large language model, the Einstein Trust Layer applies protections around that call. The ones that matter for grounding:
- Data masking replaces detected sensitive values (such as names, email addresses, phone numbers, and card-like patterns) with placeholders before the request leaves Salesforce. The response is then unmasked on the way back, so the user sees real values.
- Zero data retention means the model provider does not store the prompt or response, under the agreement Salesforce has with it.
- Toxicity detection and audit trail record and score generated responses so you can review them.
What masking does not do
Masking protects values in transit to the model. It has gaps you should plan for:
- It depends on detection. Unusual identifiers, such as an internal account code, may not be recognized unless you configure them.
- It does not decide what content is allowed. A masked chunk from an internal-only article is still an internal-only article, and the answer can still reveal its meaning.
- It changes what the model sees. Masked placeholders can lower answer quality if a question depends on the exact value. Test this explicitly.
Because of the last point, review masking settings together with your testing, not separately.
Governance practices that keep answers trustworthy
Governance is ongoing work, because both content and configuration change.
Content lifecycle
- Archive or unpublish outdated articles and confirm the ingestion refresh removes them from the index. An archived article that remains in the index will still be retrieved.
- Assign an owner for each article category. Retrieval quality and compliance both depend on the article text being correct.
- Do not put secrets, credentials, or personal data in articles. Once ingested and chunked, they are copied into more places.
Change control
- Treat the index, the retriever, and the prompt template as a versioned set. Changing a filter or returned field changes what customers can see.
- Test in a sandbox with representative questions from both allowed and disallowed audiences before promoting.
- Record who changed retriever filters and when, using your normal change process and the Setup audit trail.
Monitoring
Review audit and feedback data on a schedule. Look for answers that quote content from the wrong audience, answers produced when retrieval returned nothing, and repeated escalations about the same topic. These point to a filter gap, a prompt instruction gap, or a missing article.
A review checklist
Use this before releasing a knowledge-grounded agent:
- Every article in the index is approved for the agent's audience.
- Draft, archived, and internal-only content is excluded or filtered.
- Returned fields contain only what the answer needs.
- The agent user and prompt template permissions are scoped to the right users.
- Masking behavior is tested with realistic questions.
- The grounding instructions tell the agent to decline when retrieval returns nothing.
- An owner and a refresh schedule exist for the content.
Exercise
Your company has a public help-bot agent and an internal support agent. Both use one index that contains public and employee-only Knowledge articles. A retriever filter for the public bot excludes employee-only content. Name two reasons this is weaker than separate indexes, and describe the safer design.
Show answer
A filter is a rule attached to a retriever or template, so a new retriever, a misconfigured template, or a missing filter can expose employee-only chunks, and the filter works only if the audience field was mapped into the index. Also, filter values that are not fixed can be wrong. The safer design is two indexes (or Data Libraries): one built only from articles approved for the public audience, used by the public bot, and one that adds employee-only content, used by the internal agent. The public index then cannot return content it never ingested. Keep the filter as a second check, limit returned fields, and test with questions that should be declined.
Exercise
A customer asks the agent about a refund policy. The reply quotes an article that was archived last month. Which governance layer failed, and what do you check first?
Show answer
This is a content lifecycle and ingestion refresh problem, not a masking problem. Check whether the article is still in the data model object and search index, whether the ingestion refresh and index update ran after the archive, and whether the retriever returns the old chunk. Then fix the refresh schedule or rebuild the index, and add a recurring check that archived articles disappear from retrieval.