Table of Contents

Class SensitiveContentEgressGuard

Namespace
MailFathom.Application.SensitiveContent.Egress
Assembly
MailFathom.Application.dll

The one thing every egress point calls before it hands text to somebody else.

public sealed class SensitiveContentEgressGuard
Inheritance
SensitiveContentEgressGuard
Inherited Members

Remarks

One guard rather than a redaction per consumer, for the reason there is one redactor behind it: a placeholder a caller composed itself would drift from the shared one the first time either gained a rule, and a consumer holding the redactor directly would decide for itself what to do with a finding. What a consumer gets here is guarded text and nothing else — the findings stay inside, are counted by category, and are never handed to a caller that might log one.

Guard a value, never a composed document. A detected region is replaced wherever it was found, so a scan of a document this system assembled — an XML envelope, a JSON payload, a formatted listing — can report a region that covers a delimiter as well as the text beside it, and replacing that region would destroy the structure while leaving the value's neighbours in it. Every consumer that owns the values therefore guards the field it is about to write and composes afterwards.

One consumer cannot: a port handed a conversation somebody else built has no way to tell which turn a mailbox reached, so it guards each turn whole and accepts the structural cost above on a turn that happens to be a document. That is the exception rather than a second rule, and it is bounded by the guarantee that makes it necessary — every text leaves that port scanned, whatever its caller composed.

With nothing switched on this guard is inert. It is registered whatever a deployment configured, so no consumer carries a null check or a second code path, and where the mail being published has nothing scanned for, every call returns its argument without constructing a detector, taking a concurrency permit, or touching an instrument. That is what makes an opt-in nobody took cost nothing on any of these paths.

Whose mail is being published is settled before any of it is. A deployment serves several mailboxes and each of them has a posture of its own, so the use case names what it resolved once — with ActingFor(MailAccountSensitiveContentPosture) where it is acting on one account, and with ActingFor(UserSensitiveContentPosture) where it reads across every account one user is assigned — and every value guarded anywhere inside that flow is read under the posture that names. Guarding outside such a scope while this deployment scans anything is a defect rather than a permissive default, and says so.

A read that spans a user's accounts is guarded by the strictest of their postures, because the value being guarded is several layers below the point its account could still be named and a search hands out mail from whichever of them matched. That only ever redacts more than the message's own account asked for, which is the safe direction; where a flow does hold one account it names it, and the message is judged by its own mailbox alone.

It is a scope of its own rather than part of the reported operation because the two cover different stretches of one read. The operation is the payload being published and is opened where that payload is assembled; the user is settled far earlier, since a search embeds its query text through a model provider before it has a page to report on. Folding the user into the operation would leave that call with nobody to answer for it.

Constructors

SensitiveContentEgressGuard(ISensitiveContentPostures, ISensitiveContentEgressTelemetry, TimeProvider)

Initializes the guard of a deployment, whether or not any user it serves is scanned for.

Methods

ActingFor(UserSensitiveContentPosture)

States whose mail everything guarded on this flow from here on belongs to.

ActingFor(MailAccountSensitiveContentPosture)

States that everything guarded on this flow from here on comes out of one account.

BeginGuardedOperation(SensitiveContentEgressPoint, CancellationToken)

Opens the report of one guarded operation, and reports every text guarded inside it as part of it.

GuardAllAsync(SensitiveContentEgressPoint, IReadOnlyList<string>, CancellationToken)

Guards every text of one publication about to cross out of this deployment.

GuardAsync(SensitiveContentEgressPoint, string, CancellationToken)

Guards one text about to cross out of this deployment.

GuardOptionalAsync(SensitiveContentEgressPoint, string?, CancellationToken)

Guards a text that a message need not carry at all.

GuardWithOmissionAsync(SensitiveContentEgressPoint, string, CancellationToken)

Guards one text and reports what the analyzed ceiling kept out of it.

IsActiveAsync(CancellationToken)

Reads whether anything is scanned for on this flow.

ReadPostureAcrossAccountsOfAsync(UserId, CancellationToken)

Reads what a read spanning every account of one user is scanned under, for that read to act for.

ReadPostureOfAsync(MailAccountId, CancellationToken)

Reads what one account's mail is scanned under, for a use case acting on that account to act for.