Table of Contents

Interface IMailAnsweringSpendLedger

Namespace
MailFathom.Application.Retrieval.AskMail
Assembly
MailFathom.Application.dll

Counts what answering has cost across the current period, and decides whether another question fits inside it.

public interface IMailAnsweringSpendLedger

Remarks

One ledger for the whole process, because a ceiling over a period is one answer about the deployment: a ledger per scope would let each concurrent question believe it was the first. Every member is safe to call from several runs at once.

It is process-local and is not durable. A restart begins a new period with nothing spent, which is the deliberate trade: making it durable would put a database write on the path of every provider call in every run, to defend against a failure mode — a process restarting often enough to matter — that an operator already has to notice for other reasons.

The admission is a decision and never a wait. A question over the ceiling is refused with an answer the caller can act on rather than held until the period turns over, because holding it would convert a spend ceiling into a queue of requests occupying the endpoint that serves the rest of the surface.

Two members and no way to read what has been spent, because nothing above this boundary acts on that figure: a use case decides whether to answer and never how close the period is to its ceiling. What an operator reads is published by whatever implements this, as instruments rather than as a call.

Methods

RecordSpend(ChatTokenUsage)

Adds what one provider call consumed to the current period.

TryAdmitRun()

Takes an allowance for one run, if the current period has one left.