Pin lexical, vector and permission views to a compatible generation before merging evidence or paginating results.
Snapshot-consistent retrieval across changing indexes
Choose an answer-time snapshot
A retrieval request can span lexical postings, a vector index, metadata storage and a permission service. Each may refresh at a different time. If a document revision enters vector search before its permission update reaches the filter, combining the newest result from every component can create an answer that no coherent system state ever contained. Select a generation or snapshot token that all required components can serve. If one is behind, wait within a bounded budget, fall back to an older common generation, or abstain. Temporal validity answers which revision was true at a requested time; snapshot consistency answers which revision the search system actually observed.
Carry generation through each stage
Attach generation, document revision, tenant and source ID to candidates, reranker inputs and final citations. A merged list with two revisions of one document is not merely a ranking issue; the reader may be shown mutually incompatible facts. Keep tombstones and permission revocations in the same generation discipline. A cached result must include its snapshot and authorization scope, or it may outlive the state it claims to represent. Permission-aware caching handles the authorization half of this contract.
Paginate a frozen view
Offset pagination over a changing index can duplicate or skip documents when new records arrive between page requests. A point-in-time search view and a stable sort key let later pages continue the same result set. Expire the view deliberately and return a restart signal rather than silently switching generations halfway through. A user-facing search may tolerate a short-lived snapshot, while an audit export may need a longer frozen manifest and repeatable IDs. Retrieval traces should record snapshot token and page cursor for reconstruction.
Handle mixed-generation failures
During a blue-green index swap, query both old and new read paths against the same judged questions before activating the new generation. If vector generation 48 is ready but lexical generation 47 is still serving, a generation-48 hybrid answer is premature. A retry is useful only when the lag is expected to clear within the request budget. Never downgrade permission revocation to an old snapshot just to keep an answer available. Security-critical revocations require current authorization even if content indexes remain pinned. Index swap controls govern when a new generation becomes safe to serve.
Test observable consistency
Inject updates between candidate fetch, reranking and pagination. Include a deleted document, a permission withdrawal, a content revision and a vector rebuild that completes later than the lexical refresh. Check that every returned citation resolves to the claimed revision and that all pages share one snapshot. Measure waiting time and abstention separately; an apparently fast system that silently mixes generations has traded correctness for latency without declaring it.
Worked contract
from dataclasses import dataclass
@dataclass(frozen=True)
class IndexView:
name: str
ready_generation: int
@dataclass(frozen=True)
class SearchHit:
document_id: str
revision: str
generation: int
source_index: str
def merge_snapshot(views: list[IndexView], hits: list[SearchHit],
generation: int) -> dict[str, str]:
if not views or any(view.ready_generation < generation for view in views):
raise ValueError("requested generation is not ready everywhere")
allowed_sources = {view.name for view in views}
revisions: dict[str, str] = {}
for hit in hits:
if hit.source_index not in allowed_sources or hit.generation > generation:
continue
previous = revisions.setdefault(hit.document_id, hit.revision)
if previous != hit.revision:
raise ValueError("conflicting document revisions in one snapshot")
return revisions
views = [IndexView("lexical", 48), IndexView("vector", 47)]
hits = [SearchHit("pump-p47", "r4", 47, "lexical"),
SearchHit("pump-p47", "r4", 47, "vector"),
SearchHit("pump-p47", "r5", 48, "lexical")]
assert merge_snapshot(views, hits, 47) == {"pump-p47": "r4"}
try:
merge_snapshot(views, hits, 48)
except ValueError:
pass
else:
raise AssertionError("mixed-generation read was accepted")Performance and operating cost
The demonstration scans V component views and H hits in O(V + H) time with O(H) revision space. A real point-in-time view can retain old index segments and add storage pressure for its lifetime; waiting for the slowest component adds tail latency. Limit snapshot duration, expose timeouts and monitor generation lag. A permission revocation must still be checked against current policy even when content retrieval uses an older coherent generation.
Common Mistakes
- Merging the latest response from each index without a shared generation.
- Using an old permission snapshot after access was revoked.
- Changing generation between search result pages without telling the client.
- Dropping revision IDs before citations are assembled.
Validation drill
Replay 43 synthetic updates across two indexes and a permission view. Verify citation revisions, page continuity, revocation handling and bounded fallback when one index lags.
Read next
- Temporal retrieval: answer as-of questions from valid evidence
- Index freshness: publish complete revisions and remove stale chunks
- Retrieval caches and conversation turns: recheck access every time
- Retrieval traces: locate the stage that lost the answer
