InMemoryAuditLog
AgentPrism.Core.dllAn audit log that keeps entries in process memory.
public sealed class InMemoryAuditLog : IAuditLogInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Use AgentPrism.PostgreSql in production.
The hash chain is computed here too: entries are kept per tenant
(ConcurrentDictionary<string, List<AuditEntry>>) and each
tenant’s list is locked for its own read-last-hash/compute/append sequence —
a single process has no cross-connection writer race the way a SQL provider
does, so a lock (not a retry loop) is enough. Locking ON THE LIST ITSELF
(rather than a dedicated lock field) is deliberate: net8.0 is also targeted
and System.Threading.Lock arrived only with.NET 9 — the same pattern
RunTraceCollector.RunSpanBuffer uses.
Constructors
Section titled “Constructors”InMemoryAuditLog()
Section titled “ InMemoryAuditLog()”public InMemoryAuditLog()Methods
Section titled “Methods”QueryAsync(AuditQuery, CancellationToken)
Section titled “ QueryAsync(AuditQuery, CancellationToken)”Reads the records through a filter.
public ValueTask<IReadOnlyList<AuditEntry>> QueryAsync(AuditQuery query, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”query AuditQuery
The filter.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<AuditEntry>>
The records, newest first.
VerifyChainAsync(AuditChainQuery, CancellationToken)
Section titled “ VerifyChainAsync(AuditChainQuery, CancellationToken)”Walks a tenant’s hash chain and reports whether it is intact.
public ValueTask<AuditChainVerification> VerifyChainAsync(AuditChainQuery query, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”query AuditChainQuery
The scope: tenant and, optionally, a date range.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<AuditChainVerification>
The verification result.
Remarks
Section titled “Remarks”A date range narrows which entries are walked; it does not weaken the check within that range. Because the entry immediately before the range’s start is not read, a break at the range’s own boundary cannot be judged and is not reported — an unbounded query is the only way to check a tenant’s whole history.
WriteAsync(AuditEntry, CancellationToken)
Section titled “ WriteAsync(AuditEntry, CancellationToken)”Writes an audit record.
public ValueTask WriteAsync(AuditEntry entry, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”entry AuditEntry
The record to write.
cancellationToken CancellationToken
The cancellation token.