Struct AuditChainKey
- Namespace
- Excalibur.AuditLogging
- Assembly
- Excalibur.AuditLogging.dll
Names one chain partition — the unit a store chains over on write — so that every read path naming the same partition arrives at the same key.
public readonly record struct AuditChainKey : IEquatable<AuditChainKey>
- Implements
- Inherited Members
Remarks
A store verifying a range asks two questions of its table: which records fall inside the window, and what tag immediately precedes the window. The answers must be matched up per partition, and the matching is by key. Deriving those two keys separately is the defect this type exists to make unwriteable: the halves are built in different methods, from differently-shaped rows, and a fold applied to one is easy to omit from the other. When that happens the lookup misses, the anchor is read as absent, and the verifier is told the first in-range record is the partition's genesis one — which it is not. The result is a report of removal or reordering against a trail nobody touched, and an auditor holding it cannot tell it from the real thing.
There is therefore no public constructor. A key is obtainable only from For(string?, string?), which applies every fold, so a caller cannot hand-build one that skips them. Both folds are idempotent: passing an already-folded value yields the same key as passing the raw stored one, which is what allows the record path — holding events whose tenant has already been mapped back to the signed value — and the anchor path — holding raw columns — to share the one factory.
Properties
ApplicationName
Gets the partition's application.
public string? ApplicationName { get; }
Property Value
TenantId
Gets the partition's tenant, as the record was signed rather than as it is stored.
public string? TenantId { get; }
Property Value
Methods
For(string?, string?)
Derives the key of the partition a stored row belongs to.
public static AuditChainKey For(string? tenantId, string? applicationName)
Parameters
tenantIdstringThe tenant term, either as stored or already mapped back to the signed value.
applicationNamestringThe application name as stored, in any of its spellings.
Returns
- AuditChainKey
The partition key.
Remarks
Empty and null application names are folded together, so a record stored with no application name and one stored with an empty one are not read as two chains when the write path appended them to one.
SignedTenantId(string?)
Maps a stored tenant term back to the value that was signed.
public static string? SignedTenantId(string? storedTenantId)
Parameters
storedTenantIdstringThe tenant term as persisted.
Returns
Remarks
The reserved sentinel is a storage encoding for "no tenant", adopted where the column cannot hold null. The integrity tag, however, is computed over the record as supplied — where an untenanted event carries a null tenant. Returning the sentinel would re-canonicalize a different record than the one that was signed, and every untenanted record would fail verification against its own tag.