InMemoryProposalProvenanceSink
Models & Types · AiDotNet.Evolution.Programs.Provenance
A bounded in-memory IProposalProvenanceSink for tests and short-lived runs.
Implements: IProposalProvenanceSink
For Beginners
The same notebook as the file-writing sink, but held in memory and capped at a fixed number of pages. Useful when you just want to look at what happened, and do not want files left behind.
How It Works
Keeps the most recent records in insertion order and discards the oldest once the capacity is reached, so it cannot grow without limit on a long run. Nothing is written to disk, which makes it the right sink for a test that wants to assert what the operator recorded, and for an interactive session that only needs to look at the last few exchanges.
Reads and writes are serialized, so one instance may be shared by concurrent workers, and
GetRecords returns a snapshot that is safe to enumerate while a run continues.
Constructors
| Constructor | Summary |
|---|---|
InMemoryProposalProvenanceSink(int capacity) |
Initializes an in-memory sink. |
Properties
| Property | Summary |
|---|---|
long TotalRecorded { get; } |
Gets how many records have been offered since construction, including discarded ones. |
Methods
| Method | Summary |
|---|---|
IReadOnlyList<ProposalProvenanceRecord> GetRecords() |
Gets the retained records, oldest first. |
Task RecordAsync(ProposalProvenanceRecord record, CancellationToken cancellationToken) |
|
void Clear() |
Discards every retained record and resets the total. |
Fields
| Field | Summary |
|---|---|
int DefaultCapacity |
The number of records retained when no capacity is supplied. |