Class RedbConversationStore
REDB-backed . Tree integrity is enforced by
CreateChildAsync; transcript reads use redb's tree primitives
(TreeQuery<T>(root) for descendants, GetPathToRootAsync
for breadcrumbs — root → leaf order) — server-side tree traversal, not
client-side rebuilding.
Per-row business identifiers live on _objects base columns —
value_string for the conversation/message id (partial index on
PostgreSQL/SQLite; MSSQL cannot index NVARCHAR(MAX)) and value_long
on each message for the conversation FK (== root _objects.id, indexed
on every provider). The conversation id also rides, normalized, in the
root's _objects._value_unique: the per-scheme unique index makes
concurrent creators of one conversation converge on a single root instead
of splitting the transcript.
Conversation isolation is enforced by the value_long FK, not by tree
shape. Head detection and message lookup are scoped by it explicitly, so a
read can never surface — and a write can never attach under — another
conversation's node, independent of how a provider evaluates tree filters.
Content blocks are stored as a typed nested array, no JSON marshalling
for our own schema.
The is resolved per call through
:
when an is supplied (the engine forwards the route
pipeline's exchange) the route framework hands out a per-exchange scoped
instance and disposes it with the exchange. The named instance —
?redb=my-llm-db on the URI — is read from
exchange.Properties[LlmKeys.RedbName]; missing or null falls back to
the default IRedbService registered in the context (the host's
instance from services.AddRedb()).
public sealed class RedbConversationStore : IConversationStore
Inheritance
Implements
Methods
AppendAsync(string, string?, LlmMessage, ConversationMessageMeta, IExchange?, CancellationToken)
Appends message as a child of parentId
public Task<string> AppendAsync(string conversationId, string? parentMessageId, LlmMessage message, ConversationMessageMeta meta, IExchange? exchange = null, CancellationToken ct = default)
LoadPathAsync(string, string?, IExchange?, CancellationToken)
Loads the linear path from the conversation root to leafId.
public Task<IReadOnlyList<ConversationMessage>> LoadPathAsync(string conversationId, string? leafId = null, IExchange? exchange = null, CancellationToken ct = default)
LoadTreeAsync(string, IExchange?, CancellationToken)
Loads the full tree for the conversation (every branch). Used for
public Task<IReadOnlyList<ConversationMessage>> LoadTreeAsync(string conversationId, IExchange? exchange = null, CancellationToken ct = default)
Constructors
RedbConversationStore(IRouteContext, string?)
Creates a new store backed by the route context's redb instance(s).