Distinguish when a fact was true from when it was indexed, and resolve overlapping revisions before producing a dated answer.
Temporal retrieval: answer as-of questions from valid evidence
Store two clocks
Temporal retrieval answers questions about a specified point in time. A policy may be valid from 1 March to 30 June yet ingested on 4 March. Valid time describes when the policy applies; system time describes when the search system learned or changed it. Conflating the two makes historical answers wrong after a late upload or backdated correction. Record both intervals and the source revision. Index freshness explains availability, while valid time determines which fact belongs in the answer.
Parse the user's time boundary
An as-of question needs a date, time zone and boundary convention. 'On 30 June' may mean any instant that day; an interval ending at midnight on 30 June may already be invalid then. Choose half-open intervals consistently: start inclusive, end exclusive. If the user gives only a month, do not quietly pick its last day for a rule that changed mid-month. Ask for a date or return the change range. Query routing should preserve the time constraint across every retrieval leg.
Filter before ranking
Restrict candidates to the requested valid-time interval and authorized corpus before semantic ranking. A newer policy is often lexically similar and may rank above the old one even when the user asks about last year. An answer must cite the applicable revision and the effective interval. For a comparison across dates, retrieve each date separately and keep the two evidence sets distinct. A revision's publication timestamp is not a substitute for its effective timestamp.
Resolve overlap explicitly
Two active records may cover the same instant because of a correction, overlapping jurisdiction or bad source data. Prefer a documented supersession rule only if the source provides one. Otherwise report the conflict with both citations and abstain from a single definitive value. A deletion may remove public availability without erasing the historical audit record; retrieval policy decides whether that archived evidence remains eligible. Access control applies even to historical answers.
Judge temporal slices
Build cases just before and after effective boundaries, retroactive corrections, delayed ingestion, unknown end dates, conflicting overlaps and no eligible history. Measure valid-revision recall and answer support separately from plain passage recall. A search that finds the right policy family but the wrong revision should fail the dated slice. Keep the corpus generation in the judgment so a changing source does not invalidate the comparison.
Worked contract
from dataclasses import dataclass
from datetime import date
@dataclass(frozen=True)
class PolicyRevision:
revision: str
tenant: str
valid_from: date
valid_until: date | None
refund_days: int
def applicable_policy(revisions: list[PolicyRevision], tenant: str,
as_of: date) -> PolicyRevision | None:
matches = [policy for policy in revisions if policy.tenant == tenant
and policy.valid_from <= as_of
and (policy.valid_until is None or as_of < policy.valid_until)]
if len(matches) > 1:
raise ValueError("overlapping eligible policy revisions")
return matches[0] if matches else None
policies = [PolicyRevision("r3", "north", date(2026, 3, 1), date(2026, 7, 1), 47),
PolicyRevision("r4", "north", date(2026, 7, 1), None, 29),
PolicyRevision("private", "south", date(2026, 3, 1), None, 83)]
assert applicable_policy(policies, "north", date(2026, 6, 30)).refund_days == 47
assert applicable_policy(policies, "north", date(2026, 7, 1)).refund_days == 29
assert applicable_policy(policies, "north", date(2026, 2, 28)) is NonePerformance and operating cost
The example scans R revisions in O(R) time and stores O(M) matches, where M is the number valid at the requested instant. A database interval index and tenant key can reduce candidate reads. Store valid-time and ingestion-time metadata separately; two extra timestamps are cheap compared with an unsupported historical answer.
Common Mistakes
- Using ingestion time as the policy's effective date.
- Treating an interval end as inclusive in one service and exclusive in another.
- Returning the newest revision for every historical question.
- Silently choosing one of two overlapping eligible revisions.
Validation drill
Create 61 dated questions around four policy transitions, including six backdated corrections and five overlaps. Require explicit ambiguity when the source cannot determine the applicable revision.
Read next
- Index freshness: publish complete revisions and remove stale chunks
- Retrieval query routing: preserve exact constraints before search
- Retrieval evaluation labels: build a trustworthy judged set
- Retrieval corpus contracts: identity, permissions and document lifecycle
