Table of Contents

Method RetrieveAsync

Namespace
MailFathom.Application.Discovery.Runs
Assembly
MailFathom.Application.dll

RetrieveAsync(MailQuestion, RetrievalPlan, Func<DiscoveryRetrievalProgress, Task>?, CancellationToken)

Runs the plan's lookups in order, giving each its share of the passages the plan allows.

public Task<DiscoveryEvidence> RetrieveAsync(MailQuestion question, RetrievalPlan plan, Func<DiscoveryRetrievalProgress, Task>? progress, CancellationToken cancellationToken)

Parameters

question MailQuestion

The question, whose scope bounds every lookup.

plan RetrievalPlan

The plan to run.

progress Func<DiscoveryRetrievalProgress, Task>

Told how far the plan has got as each lookup settles, or null where nobody is watching.

cancellationToken CancellationToken

Cancels the retrieval between and during lookups.

Returns

Task<DiscoveryEvidence>

What the run may answer from, with what it took to find it.

Remarks

Every lookup is admitted up to an equal share of MessageAllowance first, and only what that leaves unspent goes to the passages a lookup found beyond its share, taken rank by rank across the lookups. So a later lookup's best passages are never crowded out by an earlier lookup's lower-ranked ones: a plan lists several short wordings because it cannot know which one reaches the evidence, and the one that does is as often the last as the first. A cut of a message already handed over spends no share, since the shares count messages: two lookups cut one message around different words, and the second cut is handed over beside the first rather than crowding out a message nothing else reached. The allowance assures every lookup a share, so every lookup runs; only a deployment whose retrieval returns fewer passages than the plan holds lookups gives each one passage and leaves the lookups past that many unrun, since nothing they found could be admitted.

One refused lookup is skipped rather than fatal: the filters are derived from a question by a model, and a question is not unanswerable because one of several wordings named an address that is not one. A plan whose every lookup was refused is a different thing — there is nothing left to answer from, and the caller is told why rather than handed an empty result that reads as a mailbox holding nothing.

The progress callback is a plain delegate rather than an IProgress<T>, and each report is awaited before the next lookup is issued. That is the whole reason: the standard implementation posts each report to a synchronization context or to the thread pool, so two reports can be observed in the order they were scheduled rather than the order they were made — and a caller turning them into a numbered sequence would write a plan that went backwards. Awaiting is what extends that property to a caller whose report is a write: two writes never overlap, so the run stays the one writer of its own record. A caller wanting them elsewhere hands over a delegate that puts them there.

Exceptions

MailboxQueryFilterInvalidException

Every lookup the plan holds carried a filter this deployment refuses.