T-CQRS: Causal State Reconstruction and State-Determination-Aware Retrieval for Distributed RAG in .NET 11
Distributed systems often rely on message logs to keep data consistent. But networks drop, delay, and reorder messages in real-world conditions. When out-of-order events arrive, sorting them on the .NET managed heap triggers repeated garbage collection cycles. This hurts tail latency. Querying these event streams with Retrieval-Augmented Generation (RAG) brings a separate challenge. Embedding search matches text by similarity alone. It cannot tell whether an event is active or superseded. As a result, outdated facts often enter the model prompt. We address these issues with Topological Command Query Responsibility Segregation (T-CQRS) and State Determination Frontier (SDF) retrieval. T-CQRS re-sequences out-of-order events in memory with value structs and pooled buffers in .NET 11 Preview. In our tests with 10,000 disordered events, no Gen-0 garbage collections were observed. Building on this graph, SDF finds the latest state-changing event (Fq) and extracts its prerequisite causal ancestors (Cq). Across 5,000 benchmark queries with five random seeds, SDF achieved a precision of 1.000 compared to 0.585 for dense vector search (d = 11.00). It maintained complete recall (SDR = 1.000), removed all observed stale evidence, and reduced prompt tokens by 30.0%. In-memory lookups averaged 18.02 microseconds.
Authors
- Gheorghe Chesler
- Mateus Yonathan (ORCID: https://orcid.org/0009-0008-5999-7366)
Institutions
- Software (Germany) (DE)
- R2M Solution (Italy) (IT)
Publication Details
- Journal
- HAL (Le Centre pour la Communication Scientifique Directe)
- Published
- 2026-08-25
- DOI
- https://doi.org/10.5281/zenodo.22100371
- Primary Topic
- Software System Performance and Reliability
- Type
- preprint