Knowledge Freshness and Temporal Updates
Build time-aware knowledge systems with bi-temporal facts, as-of retrieval, versioned index snapshots, and rollback. Manage staleness across any facts.
Language AI HandbookAll chapters Knowledge Freshness and Temporal Updates
Acme's assistant said Alice was CEO in May. In June the store indexed a filing that said Bob had already taken over the year before. A correction reached the index in September and moved Bob's start date back by a month. Replacing each old assertion would erase the evidence needed to explain what the assistant knew in May. We will build a small knowledge store that preserves the earlier belief, answers the historical question, and supports rolling back a retrieval release.
A fact has a period when it applies. A document has a publication date. The database records when a version of the fact was committed, and a retrieval request goes to a particular index snapshot. These dates can differ by months or years.
Earlier chapters introduced parametric knowledge, external knowledge, and edits to model weights. Here we follow an update across the knowledge base, retrieval index, and derived answers.
Why Freshness Is Hard
Before we touch the mechanics, it helps to understand exactly why a time-aware knowledge system is difficult. Four structural problems recur.
Training data has a cutoff. A fixed checkpoint cannot receive a later observation through training that has already finished. An answer about a later event could still be correct through inference, chance, or information in the prompt. Even within the training period, undated documents can create competing associations about the same entity.
Update rates differ. A software release can change next week and a current market quote can change within seconds. Choose a refresh cadence against measured change rates and the stale-answer rate your application can tolerate.
Updates interact. When a person gets a new job title, the same entity may appear in dozens of documents. Editing one fact in isolation can leave the rest of the corpus contradicting it, or worse, can create a system that looks consistent in the single edited statement while remaining inconsistent across everything else. Propagation is the hard part.
Stale answers can sound convincing. A fluent answer can repeat yesterday's fact without signaling that anything changed. Recording the source version and date lets you investigate those cases.
These four pressures motivate the design patterns below. We move from the data model (bi-temporal facts) outward to the operational layer (as-of retrieval, versioned indexes, rollback).
Bi-Temporal Facts: Valid Time vs. Ingestion Time
The foundational primitive is the bi-temporal record. A single fact carries two independent time axes:
- Valid time is the period when an assertion applies in the world being modeled. Acme's current records put Bob's start date at February 1, 2023.
- Transaction time, or system time, is the period when the database recorded that version of the assertion. In this toy it begins when the update is committed to the store.
Why both? Because "what was true in the world" and "what your system knew" diverge constantly:
- A late-arriving document corrects a fact about 2019. Valid time is 2019; ingestion time is today.
- A document can announce an appointment months before it takes effect. Publication precedes the appointment's valid start, while ingestion can occur on either side of the start.
- A retraction can end the period when the database asserted a claim, even if later evidence shows that the claim never held.
A current historical query uses date X for valid time and the latest committed state for transaction time. To reconstruct what the store believed about date X last Tuesday, keep the same valid date and set the transaction cutoff to last Tuesday.
A bitemporal record has a validity interval and a transaction interval . Subscripts and mark the start and end. An open transaction end identifies a version still asserted by the store. A revision closes earlier transaction intervals and appends a new timeline while preserving the earlier assertions.
Ending an older row's transaction interval preserves its payload for historical queries. An in-place replacement of the payload would need a separate history or log to recover what the system believed earlier.
An entity ID determines which rows a revision may replace. A retriever can produce candidates for several companies named Acme, so resolve the intended entity before applying a CEO timeline. Preserve the source ID separately from the entity ID. That lets an auditor distinguish two sources asserting different dates about the same company from two unrelated companies sharing a name. This example treats CEO as a single-valued attribute. A joint role or a concurrent association needs a different representation and should not use the nonoverlap rule below.
Representing the intervals
We can represent a fact as a small dataclass with four timestamps plus the payload. Let us set up the machinery now and use it throughout the chapter.
PythonIn [3]Expand
from dataclasses import dataclass, field
from datetime import datetime, timedelta, timezone
from typing import Optional
def utc(*args) -> datetime:
"""Convenience: build a timezone-aware UTC datetime."""
return datetime(*args, tzinfo=timezone.utc)
@dataclass
class Fact:
subject: str
predicate: str
obj: str
# Valid time: when the fact is true in the world.
valid_start: datetime
valid_end: Optional[datetime] = None # None = still true
# Transaction time: when our system believed it.
trans_start: datetime = field(
default_factory=lambda: datetime.now(timezone.utc)
)
trans_end: Optional[datetime] = None # None = currently believed
source: str = ""
def believed_at(self, t: datetime) -> bool:
"""Was this record the system's belief at transaction time t?"""
return self.trans_start <= t and (
self.trans_end is None or t < self.trans_end
)
def valid_at(self, t: datetime) -> bool:
"""Was the fact true in the world at valid time t?"""
return self.valid_start <= t and (
self.valid_end is None or t < self.valid_end
)The two predicates believed_at and valid_at are the heart of the model. Note the half-open interval convention [start, end): a fact whose valid_end is exactly t is not valid at t, which avoids ambiguity at boundaries. Consistency matters more than the choice; pick half-open and never mix.
For a single-valued attribute like CEO, the toy replaces the complete believed timeline for one key at a time. The key uses a stable entity ID and predicate. Two companies with the same display name need different entity IDs. All fixture dates are UTC and updates run in one process.
PythonIn [4]Expand
class TemporalKnowledgeBase:
def __init__(self):
self.records: list[Fact] = []
self.last_revision: dict[tuple[str, str], datetime] = {}
def revise_timeline(self, subject, predicate, intervals, *, at):
key = (subject, predicate)
if key in self.last_revision and at <= self.last_revision[key]:
raise ValueError("Transaction times must increase per key")
intervals = sorted(intervals, key=lambda interval: interval[1])
replacement = []
for i, (obj, start, end, source) in enumerate(intervals):
if end is not None and end <= start:
raise ValueError("Validity intervals must have positive length")
if i:
previous_end = intervals[i - 1][2]
if previous_end is None or previous_end > start:
raise ValueError("Validity intervals must not overlap")
replacement.append(
Fact(subject, predicate, obj, start, end, at, source=source)
)
for row in self.records:
if (row.subject, row.predicate) == key and row.trans_end is None:
row.trans_end = at
self.records.extend(replacement)
self.last_revision[key] = at
def as_of_belief(self, t: datetime):
return [row for row in self.records if row.believed_at(t)]
def as_of_world(self, t: datetime, *, known_at: Optional[datetime] = None):
rows = (
self.as_of_belief(known_at)
if known_at is not None
else [row for row in self.records if row.trans_end is None]
)
return [row for row in rows if row.valid_at(t)]The store validates the replacement timeline before closing any rows. This lets the new timeline preserve Alice's earlier tenure while adding Bob. A belief query selects the rows recorded at a transaction time. A world query filters that state by valid time. When the caller omits known_at, the world query uses the latest committed state. A valid date in a gap returns no assertion for that key.
A worked example
Let's make the divergence concrete. We track the CEO of a fictional company across a real-world change and a late-arriving correction.
PythonIn [5]Expand
ACME = "acme-industries-us"
kb = TemporalKnowledgeBase()
alice_start = utc(2014, 1, 1)
initial_bob_start = utc(2023, 3, 1)
corrected_bob_start = utc(2023, 2, 1)
kb.revise_timeline(
ACME,
"CEO",
[("Alice", alice_start, None, "initial-filing")],
at=utc(2024, 1, 1),
)
kb.revise_timeline(
ACME,
"CEO",
[
("Alice", alice_start, initial_bob_start, "appointment-filing"),
("Bob", initial_bob_start, None, "appointment-filing"),
],
at=utc(2024, 6, 15),
)
kb.revise_timeline(
ACME,
"CEO",
[
("Alice", alice_start, corrected_bob_start, "corrected-filing"),
("Bob", corrected_bob_start, None, "corrected-filing"),
],
at=utc(2024, 9, 1),
)ConsoleOut [6]Expand
Alice valid [2014-01-01, open) recorded [2024-01-01, 2024-06-15) Alice valid [2014-01-01, 2023-03-01) recorded [2024-06-15, 2024-09-01) Bob valid [2023-03-01, open) recorded [2024-06-15, 2024-09-01) Alice valid [2014-01-01, 2023-02-01) recorded [2024-09-01, open) Bob valid [2023-02-01, open) recorded [2024-09-01, open) May 1 as known on May 1: ['Alice'] May 1 using the corrected history: ['Bob']
Five rows represent three revisions. In May the store still recorded Alice's open interval. In the latest record, Bob covers the same valid date and Alice remains the recorded CEO for dates before February 1, 2023.
The two answers address different requests. One reconstructs the record available in May. The other uses the latest evidence to answer a historical question.
The plot pairs each row's valid and transaction intervals on a shared axis. Open ends extend to the display horizon.
PythonIn [7]Expand
import matplotlib.dates as mdates
# Materialize the interval spans for plotting. "Open" ends are drawn to a
# fixed horizon so the bars have a right edge.
plot_horizon = utc(2025, 1, 1)
record_rows = []
for i, r in enumerate(kb.records):
v_end = r.valid_end or plot_horizon
t_end = r.trans_end or plot_horizon
record_rows.append(
{
"idx": i,
"label": f"{r.obj}, recorded {r.trans_start.date()}",
"valid_start": mdates.date2num(r.valid_start),
"valid_end": mdates.date2num(v_end),
"trans_start": mdates.date2num(r.trans_start),
"trans_end": mdates.date2num(t_end),
}
)
n_records = len(record_rows)VisualizationOut [8]Expand

The top row is the original Alice assertion. The next two rows show the June timeline, followed by the September revision. Compare Alice's two end dates and Bob's two start dates. The backdating changes the valid boundary while the revision is still recorded in September.
Temporal Benchmarks: Measuring Freshness
A freshness benchmark needs time-sensitive items and metadata that explains how the answers were collected. The task design determines what a score measures.
Two families matter here:
Time-stratified QA. TempLAMA uses fill-in-the-blank questions to probe facts at specified years. TimeQA builds time-sensitive questions from evolving Wikidata facts aligned to Wikipedia passages, with people checking the extracted facts. These tasks test different forms of temporal conditioning.
Current-knowledge benchmarks. The published RealTime QA setup released questions weekly. Its GPT-3 baseline with Google Custom Search scored 34.6 exact match on generation, compared with 15.3 for its closed-book GPT-3 baseline. FreshQA distinguishes never-changing, slow-changing, fast-changing, and false-premise questions.
On your own benchmark, label the relevant dates and report performance by change rate and by relation to a documented training cutoff where known. An aggregate can hide a low score on items that change fastest.
If training includes a benchmark question and its answer, recall can improve the score without establishing temporal reasoning. Record the benchmark version, the model checkpoint, the evidence snapshot and what you know about data overlap.
Update Propagation: Getting the New Fact Everywhere
Identify each surface on which the changed fact can influence a response. A cache can preserve an older value after the underlying source changes.
The update surfaces
For a given fact change, consider where the stale knowledge lives:
- Weights (parametric memory). The model's learned association.
- Retrieval index (external memory). The documents that state the fact.
- Caches and derived artifacts. Summaries, pre-computed embeddings, cached answers, prompt-injected context.
- Downstream consumers. Agents or services that stored a copy.
Update the surfaces that are authoritative for the fact and invalidate affected derived copies. An index-only change can suffice when the serving policy reliably uses the index for that fact. Closed-book queries need a different update path if they must answer from weights alone.
Propagating updates through retrieval
When a serving path can consult trusted sources, maintain volatile facts in an external store and evaluate whether responses follow the retrieved evidence.
- Time-sensitive fact classes (personnel, prices, versions, schedules, sports results) are marked as index-authoritative.
- At inference, prompts first retrieve from the (freshly maintained) index.
- The model is instructed (and, ideally, evaluated) to prefer retrieved current context over its priors.
A retrieval refresh can avoid weight updates. It may still require ingestion, re-embedding, index publication, and cache invalidation. Test that the model uses the dated evidence it retrieves.
Propagating edits into weights
Methods such as ROME and MEMIT update model parameters. An external memory update changes a separate store. If both paths can answer the question, evaluate their interaction.
- Ripple effects. Changing Acme's CEO should affect paraphrases and some dependent facts. RippleEdits found inconsistent propagation among the tested editing methods. Include both related and unrelated probes to catch missed updates and unintended changes.
- Editing in the presence of retrieval. Stale retrieved evidence can compete with an edited association. Test the deployed serving path and state which evidence is authoritative for that fact class.
A minimal propagation ledger
Record the update time, the affected surfaces, and the source. The log can compare planned work with what was recorded. A rollback also needs a retained snapshot.
PythonIn [9]Expand
@dataclass
class UpdateEvent:
fact_id: str
surfaces: list[str] # which stores were touched
at: datetime
source: str
note: str = ""
class UpdateLedger:
def __init__(self):
self.events: list[UpdateEvent] = []
def log(self, fact_id, surfaces, source, note="", at=None):
ev = UpdateEvent(
fact_id=fact_id,
surfaces=list(surfaces),
at=at or datetime.now(timezone.utc),
source=source,
note=note,
)
self.events.append(ev)
return ev
def since(self, t: datetime):
return [e for e in self.events if e.at >= t]
def surfaces_touched(self):
out = set()
for e in self.events:
out.update(e.surfaces)
return out
ledger = UpdateLedger()
ledger.log(
"bob-ceo-1",
["index", "cache"],
"press-release-2023",
note="Bob replaces Alice",
at=utc(2024, 6, 15),
)
ledger.log(
"bob-ceo-2",
["index", "cache"],
"corrected-filing",
note="Backdated effective date",
at=utc(2024, 9, 1),
)ConsoleOut [10]Expand
Update events: 2024-06-15 fact=bob-ceo-1 surfaces=['index', 'cache'] Bob replaces Alice 2024-09-01 fact=bob-ceo-2 surfaces=['index', 'cache'] Backdated effective date Distinct surfaces touched: ['cache', 'index']
The log prints update events and the union of their named surfaces. In a deployment, compare each event with the surfaces its fact class requires and retain the content version separately.
As-Of Retrieval: Reproducible Time-Aware RAG
As-of retrieval narrows the candidate pool before scoring. A world-date request uses the valid intervals applied to the evidence. A historical serving replay starts with what was available in a retained snapshot. A request can specify both dates.
Two flavors again
Mirroring the fact model, an as-of retrieval query has two modes:
- Valid-time retrieval: admit evidence whose recorded validity interval covers the target date. Select the evidence snapshot separately if the question also specifies when the facts had to be known.
- Transaction-time retrieval: admit evidence indexed by the target date in this insert-only toy. A history with removals needs a snapshot or a record of when each document stopped being visible.
A document indexed in September can describe a February fact. It can enter a February lookup over the latest snapshot and remain absent from a replay of the May snapshot.
Consider two queries about February 2023. One asks what the latest corrected record says about February. The other asks what the assistant could have retrieved in June about February. The first lookup can use a September correction. The second uses the June evidence snapshot and the validity intervals recorded in June. Applying the latest intervals to June's documents would change what was retrievable then. When two documents in an admissible set give conflicting dates, a deterministic sort key makes the ordering repeatable. Source authority or an adjudicated timeline is needed to resolve the disagreement.
Filtering, not just ranking
Filter before scoring here so an ineligible candidate cannot occupy a top- slot. Truncating to an unfiltered top first can leave too few results after exclusions.
This NumPy example ranks eligible documents by cosine similarity over deterministic hashed character trigrams. The lexical score does not judge source authority.
PythonIn [11]Expand
from hashlib import blake2b
import numpy as np
DIM = 256
def embed(text: str) -> np.ndarray:
weights = np.zeros(DIM)
normalized = text.lower()
for i in range(len(normalized) - 2):
trigram = normalized[i : i + 3].encode("utf-8")
bucket = (
int.from_bytes(blake2b(trigram, digest_size=8).digest(), "big")
% DIM
)
weights[bucket] += 1
norm = np.linalg.norm(weights)
return weights / norm if norm else weights
@dataclass(frozen=True)
class Doc:
doc_id: str
text: str
published_at: datetime
indexed_at: datetime
valid_from: datetime
valid_to: Optional[datetime] = None
validity_source: Optional[str] = None
validity_recorded_at: Optional[datetime] = None
def cosine(a, b) -> float:
return float(np.dot(a, b))The retrieval function applies the time predicate before scoring. Transaction mode checks the index date, so a published filing can still be ineligible. A lowercased query shorter than three characters has no trigram features. Its scores tie at zero, and document IDs determine the order among eligible candidates.
PythonIn [12]Expand
def admissible_at(doc: Doc, target: datetime, mode: str) -> bool:
if mode == "transaction":
return doc.indexed_at <= target
if mode == "valid":
return doc.valid_from <= target and (
doc.valid_to is None or target < doc.valid_to
)
raise ValueError(f"Unknown mode: {mode}")
def as_of_retrieve(
query: str, docs, k: int, target: datetime, mode: str = "transaction"
) -> list[Doc]:
if k < 0:
raise ValueError("k must be nonnegative")
if mode not in {"transaction", "valid"}:
raise ValueError(f"Unknown mode: {mode}")
candidates = [doc for doc in docs if admissible_at(doc, target, mode)]
query_vector = embed(query)
return sorted(
candidates,
key=lambda doc: (-cosine(query_vector, embed(doc.text)), doc.doc_id),
)[:k]The correction is published in August 2024, indexed in September, and applies from February 2023. This raw evidence pool uses the latest validity metadata and keeps both Bob filings. Both name Bob as CEO in May 2024, but they disagree about his start date. Use this pool to compare the two filters. The serving snapshots below use the adjudicated timeline recorded when each snapshot was sealed.
PythonIn [13]Expand
docs = [
Doc(
"alice-2014",
"Alice was the CEO of Acme.",
published_at=utc(2014, 1, 1),
indexed_at=utc(2024, 1, 1),
valid_from=alice_start,
valid_to=corrected_bob_start,
),
Doc(
"bob-2023",
"Bob became CEO of Acme in March 2023.",
published_at=utc(2023, 3, 1),
indexed_at=utc(2024, 6, 15),
valid_from=initial_bob_start,
),
Doc(
"bob-fix-2024",
"Correction: Bob became CEO of Acme in February 2023.",
published_at=utc(2024, 8, 20),
indexed_at=utc(2024, 9, 1),
valid_from=corrected_bob_start,
),
]
query = "Who is the CEO of Acme"
query_times = [utc(2024, 5, 1), utc(2024, 8, 1), utc(2024, 10, 1)]
retrieval_results = [
(time, mode, as_of_retrieve(query, docs, len(docs), time, mode))
for time in query_times
for mode in ("transaction", "valid")
]ConsoleOut [14]Expand
2024-05-01 transaction ['alice-2014'] 2024-05-01 valid ['bob-2023', 'bob-fix-2024'] 2024-08-01 transaction ['alice-2014', 'bob-2023'] 2024-08-01 valid ['bob-2023', 'bob-fix-2024'] 2024-10-01 transaction ['alice-2014', 'bob-2023', 'bob-fix-2024'] 2024-10-01 valid ['bob-2023', 'bob-fix-2024']
At the May transaction cutoff only Alice's document is eligible. August admits Alice's document and the first Bob filing. October admits all three. This test checks their index arrival dates. In valid mode, both Bob documents cover all three query dates in the latest raw pool. Source authority decides which start date to use.
Count admissible documents before scoring to isolate the filters. The date sweep uses one-day steps. The vertical gap is a difference in counts because either mode can include a document that the other excludes.
PythonIn [15]Expand
import numpy as np
# Sweep target dates at daily resolution and record admissible counts.
sweep_start = utc(2024, 1, 1)
sweep_days = 320
sweep_dates = [sweep_start + timedelta(days=d) for d in range(sweep_days)]
trans_counts = np.zeros(sweep_days, dtype=int)
valid_counts = np.zeros(sweep_days, dtype=int)
for i, t in enumerate(sweep_dates):
trans_counts[i] = sum(admissible_at(doc, t, "transaction") for doc in docs)
valid_counts[i] = sum(admissible_at(doc, t, "valid") for doc in docs)
sweep_x = mdates.date2num(sweep_dates)VisualizationOut [16]Expand

The transaction-time steps mark June 15 and September 1, the indexing dates of the two Bob documents. The valid-time count stays at two because both Bob documents cover the entire plotted period in the latest supplied evidence pool.
Log the query, target, mode, and index version to identify a retrieval request. Keep the encoder, ranking configuration, and retrieved document IDs to investigate the replay. A past answer also depends on the prompt and model execution. Retain the original response when the audit requires it and your retention policy allows it.
Versioning the Index and the Model
Version the inputs to an answer. Besides the snapshot, retrieval-augmented answers can depend on the embedding and reranking implementations, prompt template, model checkpoint, and decoding configuration.
The practical pattern is immutable index snapshots with mutable pointers:
- Never mutate a live index in place for a release.
- Build the new index (or apply an update batch) into a new, sealed snapshot with a monotonic
snapshot_idand asealed_attimestamp. - Atomically flip the serving pointer from the old snapshot to the new one.
- Keep old snapshots addressable for a defined retention window.
The recorded snapshot ID identifies the evidence pool used by a request. If an older snapshot is retained and its dependencies are compatible, a pointer change can restore that retrieval version.
The toy uses frozen documents, immutable tuples, and a single in-memory pointer. Each snapshot pairs source text with the adjudicated intervals the store recorded when it sealed the snapshot. The document ID identifies the text. The validity source and recording date identify the assertion that supplied its interval. The September snapshot uses Bob's corrected filing. The earlier Bob filing remains in the June snapshot and in the raw pool above. A deployed system needs atomic publication of the serving configuration, including any coupled components.
PythonIn [17]Expand
@dataclass(frozen=True)
class Snapshot:
snapshot_id: int
docs: tuple[Doc, ...]
sealed_at: datetime
class IndexStore:
def __init__(self):
self.snapshots: dict[int, Snapshot] = {}
self.next_id = 0
self.serving_id: Optional[int] = None
def build_snapshot(self, docs, *, sealed_at) -> Snapshot:
snapshot = Snapshot(self.next_id, tuple(docs), sealed_at)
self.snapshots[snapshot.snapshot_id] = snapshot
self.next_id += 1
return snapshot
def promote(self, snapshot_id: int):
if snapshot_id not in self.snapshots:
raise ValueError("Unknown snapshot")
self.serving_id = snapshot_id
def rollback(self, to_id: int):
self.promote(to_id)
def serving(self) -> Snapshot:
if self.serving_id is None:
raise RuntimeError("No snapshot promoted")
return self.snapshots[self.serving_id]PythonIn [18]Expand
from dataclasses import replace
store = IndexStore()
doc_by_assertion = {
("Alice", alice_start): docs[0],
("Bob", initial_bob_start): docs[1],
("Bob", corrected_bob_start): docs[2],
}
def snapshot_documents(knowledge_base, sealed_at):
selected = []
for row in knowledge_base.as_of_belief(sealed_at):
if (row.subject, row.predicate) != (ACME, "CEO"):
continue
source = doc_by_assertion[(row.obj, row.valid_start)]
if source.indexed_at <= sealed_at:
selected.append(
replace(
source,
valid_from=row.valid_start,
valid_to=row.valid_end,
validity_source=row.source,
validity_recorded_at=row.trans_start,
)
)
return tuple(selected)
s0, s1, s2 = (
store.build_snapshot(snapshot_documents(kb, sealed_at), sealed_at=sealed_at)
for sealed_at in (utc(2024, 1, 1), utc(2024, 6, 15), utc(2024, 9, 1))
)
store.promote(s0.snapshot_id)
store.promote(s1.snapshot_id)
fixed_target = utc(2024, 10, 1)
snapshot_results = [
(sid, as_of_retrieve(query, snap.docs, 1, fixed_target))
for sid, snap in store.snapshots.items()
]
history_results = [
(
snap.sealed_at.date(),
world.date(),
as_of_retrieve(query, snap.docs, len(snap.docs), world, mode="valid"),
)
for snap, world in (
(s0, utc(2024, 5, 1)),
(s1, corrected_bob_start),
(s2, corrected_bob_start),
)
]
earlier_tenure = as_of_retrieve(
query, s2.docs, len(s2.docs), utc(2022, 6, 1), mode="valid"
)ConsoleOut [19]Expand
Serving before validation: 1 snapshot v0: top-1 = alice-2014 snapshot v1: top-1 = alice-2014 snapshot v2: top-1 = alice-2014 snapshot sealed 2024-01-01, valid on 2024-05-01: ['alice-2014'] snapshot sealed 2024-06-15, valid on 2023-02-01: ['alice-2014'] snapshot sealed 2024-09-01, valid on 2023-02-01: ['bob-fix-2024'] September snapshot, June 2022: payload alice-2014, validity from corrected-filing recorded 2024-09-01
The top-1 comparison holds the query, transaction filter, target date, and scorer fixed. The January snapshot admits Alice for May. At the February boundary, the June snapshot admits Alice and the September snapshot admits Bob's corrected filing. For June 2022, the September snapshot still retrieves the original Alice text, with its validity interval recorded from the corrected filing. Snapshot 2 waits for validation before promotion.
To compare a rollout and a replay, hold the query, time filter, and ranking configuration fixed. Identify the snapshot each request used before interpreting any accuracy change. If a snapshot was replaced during a long-running request, acquire the version once and pass it to later reads. Repeatedly looking up a mutable serving pointer can make one request combine evidence from multiple releases. The in-memory example has no simultaneous request threads.
Rollback and Correction Semantics
Rollback is not just "undo." Three distinct operations get conflated and should not be:
- Rollback: serve an earlier version of the system, typically because the new one regressed. The earlier version's knowledge may itself be stale, so rollback trades freshness for stability. Use for incident recovery.
- Retraction: withdraw an assertion when its supporting evidence was withdrawn or judged invalid. Record the withdrawal and keep the previous record when retention policy permits.
- Correction: revise the content or valid interval of an assertion. The previous record remains distinguishable from the corrected version.
A retraction records that an assertion was withdrawn. A correction records what changed. A rollback changes the serving pointer and preserves the previous serving history.
Rollback can restore a previous retrieval version while the newer version stays addressable. It still takes compatible serving dependencies. Deleting information from retained history is a separate operation.
A correction workflow
Putting the pieces together, a disciplined update workflow looks like this:
- Detect a candidate change (source polling, user report, scheduled re-validation of volatile facts).
- Adjudicate: is the new source authoritative? What is the new valid interval? Does it correct, retract, or extend?
- Assert into the knowledge base (close old belief, insert new record) with both time axes set.
- Propagate to every surface the ledger says this fact class requires (index chunk rewrite, cache invalidation, optional weight edit).
- Rebuild an immutable index snapshot containing the change.
- Validate on a freshness probe bundle (paraphrases, multi-hop, the timed query that motivated the change).
- Promote the snapshot (and edited checkpoint) atomically; keep the prior one addressable.
- Log the update event and the new version IDs. Capture the request inputs and serving dependencies needed for a later investigation or replay.
Build and validate before promoting. The gate runs all required timeline and candidate retrieval checks itself. It also checks that the supplied payloads were indexed by the seal time and that they match the source and valid-time metadata from the trusted fixture. Add generated-answer checks when the deployed system has a generator.
The CEO example runs five timeline checks, then checks which documents the candidate snapshot retrieves. It rejects a candidate missing the corrected filing before it promotes the complete one.
PythonIn [20]Expand
def freshness_probe(kb, subject, predicate, when, expected, *, known_at=None):
hits = kb.as_of_world(when, known_at=known_at)
values = {
row.obj
for row in hits
if row.subject == subject and row.predicate == predicate
}
return values == {expected}
def required_timeline_checks(knowledge_base):
probes = (
("corrected current view", utc(2024, 5, 1), "Bob", None),
("corrected historical view", utc(2022, 6, 1), "Alice", None),
("historical belief", utc(2024, 5, 1), "Alice", utc(2024, 5, 1)),
("corrected boundary", corrected_bob_start, "Bob", None),
(
"June view of February",
corrected_bob_start,
"Alice",
utc(2024, 6, 15),
),
)
return tuple(
(
label,
when.date(),
expected,
freshness_probe(
knowledge_base, ACME, "CEO", when, expected, known_at=known_at
),
)
for label, when, expected, known_at in probes
)
results = required_timeline_checks(kb)ConsoleOut [21]Expand
corrected current view 2024-05-01 expected Bob: PASS corrected historical view 2022-06-01 expected Alice: PASS historical belief 2024-05-01 expected Alice: PASS corrected boundary 2023-02-01 expected Bob: PASS June view of February 2023-02-01 expected Alice: PASS
PythonIn [22]Expand
def candidate_retrieval_checks(candidate):
queries = [
(utc(2022, 6, 1), ["alice-2014"]),
(corrected_bob_start, ["bob-fix-2024"]),
]
return [
[
doc.doc_id
for doc in as_of_retrieve(
query, candidate.docs, len(candidate.docs), world, mode="valid"
)
]
== expected
for world, expected in queries
]
def promote_after_probes(
index_store, candidate_id, knowledge_base: TemporalKnowledgeBase
):
candidate = index_store.snapshots[candidate_id]
timeline_results = required_timeline_checks(knowledge_base)
checks = candidate_retrieval_checks(candidate)
expected_docs = {
doc.doc_id: doc
for doc in snapshot_documents(knowledge_base, candidate.sealed_at)
}
actual_docs = {doc.doc_id: doc for doc in candidate.docs}
contents_match = (
len(actual_docs) == len(candidate.docs) and actual_docs == expected_docs
)
all_indexed = all(
doc.indexed_at <= candidate.sealed_at for doc in candidate.docs
)
if (
not all(passed for _, _, _, passed in timeline_results)
or not all(checks)
or not contents_match
or not all_indexed
):
raise RuntimeError(
"Keep the previous snapshot when a required probe fails"
)
index_store.promote(candidate_id)
return timeline_results, checks
test_store = IndexStore()
previous = test_store.build_snapshot(s1.docs, sealed_at=s1.sealed_at)
test_store.promote(previous.snapshot_id)
incomplete = test_store.build_snapshot(
[doc for doc in s2.docs if doc.doc_id != "bob-fix-2024"],
sealed_at=s2.sealed_at,
)
try:
promote_after_probes(test_store, incomplete.snapshot_id, kb)
except RuntimeError:
rejected_incomplete_candidate = (
test_store.serving_id == previous.snapshot_id
)
else:
rejected_incomplete_candidate = False
accepted_timeline, accepted_checks = promote_after_probes(
store, s2.snapshot_id, kb
)
promoted_id = store.serving_id
ledger.log(
"bob-ceo-2",
["serving-pointer"],
"corrected-filing",
note=f"promoted snapshot v{promoted_id} after {len(accepted_timeline) + len(accepted_checks)} passed probes",
at=utc(2024, 9, 2),
)
store.rollback(s1.snapshot_id)
ledger.log(
"rollback-bob",
["serving-pointer"],
"incident-4471",
note=f"rolled back to snapshot v{store.serving_id}",
at=utc(2024, 9, 5),
)ConsoleOut [23]Expand
Required checks on complete candidate: [True, True] Missing filing blocked promotion: True Promoted snapshot: 2 Serving after rollback: 1 Retained snapshots: [0, 1, 2]
Five knowledge-base probes pass, including the corrected boundary and what the store recorded in June. The incomplete snapshot fails the corrected-boundary retrieval check and leaves the prior pointer in place. Both retrieval checks pass on snapshot 2. The example promotes it, then simulates a rollback to snapshot 1. The newer snapshot remains available.
Visualizing Staleness Over Time
The simulation gives 40 fast-changing and 40 slow-changing facts independent daily chances of changing. Each change produces a new value. On a refresh day, the index synchronizes after that day's changes, so the stale fraction resets to zero.
PythonIn [24]Expand
import numpy as np
def simulate_staleness(
n_days=180, refresh_every=14, n_fast=40, n_slow=40, seed=1
):
"""Average fraction of facts that are stale on each day.
The mean wait for a change is 20 days for fast facts and 400 for slow facts.
index fixed-refresh every 'refresh_every' days.
"""
r = np.random.default_rng(seed)
# Per-fact change probability per day.
p_fast = 1.0 / 20.0
p_slow = 1.0 / 400.0
stale_fast = np.zeros(n_days)
stale_slow = np.zeros(n_days)
for f in range(n_fast):
last_sync_value = 0
true_value = 0
for d in range(n_days):
if r.random() < p_fast:
true_value += 1
if d % refresh_every == 0:
last_sync_value = true_value
stale_fast[d] += true_value != last_sync_value
for f in range(n_slow):
last_sync_value = 0
true_value = 0
for d in range(n_days):
if r.random() < p_slow:
true_value += 1
if d % refresh_every == 0:
last_sync_value = true_value
stale_slow[d] += true_value != last_sync_value
return stale_fast / n_fast, stale_slow / n_slow
fast_stale, slow_stale = simulate_staleness()
days = np.arange(len(fast_stale))VisualizationOut [25]Expand

After independent daily opportunities for change since a refresh, a fact is stale with probability , where is its daily change probability. At day 13 this is about 49% for and 3% for . Those are expectations under the illustrative model. Daily sample proportions vary. Choose cadences against measured change rates and acceptable staleness.
The calculation follows from the complement event. At age zero the index already includes the current value, so staleness is zero. With s elapsed daily change opportunities, all s must pass without an update for the cached value to remain current in this nonreverting model. Multiply their unchanged probabilities, then subtract from one. The maximum age within a full 14-day cycle is 13 days because the next refresh resets the age. A process that returns to an earlier value, queues updates, or has dependent changes needs a different probability model.
Limitations & Impact
The techniques in this chapter make freshness a managed property, but they come with costs and failure modes worth weighing explicitly.
History has storage and query costs. Retaining revisions grows storage until a retention or compaction policy applies. A historical query needs enough versions to select the requested state. This toy scans in-memory rows. Production performance depends on indexing and workload.
Admissibility leaves the answer unresolved. Candidates can disagree and a generator can ignore evidence. Evaluate retrieval and answer behavior separately, including how the system responds when it lacks an authoritative source.
Rollback can reduce freshness. The serving snapshot may omit changes added after it was sealed. Record why it was restored, how long it serves, and what checks a replacement must pass.
Surfaces can disagree. The serving index, weights, and caches can expose different versions of the same fact. Log the relevant versions per request and test the actual deployed path.
The same evidence history lets you investigate what a past request could have seen and choose an earlier retrieval release after a regression.
Per-user memories also change over time. Machine unlearning addresses cases where facts must be removed from use. Continual learning addresses weight updates as training data changes.
Summary
Record when a fact applies, when a version entered the store, and which snapshot answered a request.
We covered, in order of increasing operational scope:
- Bi-temporal facts:
[v_s, v_e)for validity,[t_s, t_e)for belief, close-on-revise to keep history. - Temporal benchmarks: time-stratified QA (TempLAMA, TimeQA) and recency benchmarks (RealTimeQA, FreshQA), with change-rate stratification and explicit contamination tracking.
- Update propagation: track versions across weights, indexes, caches, and consumers. Use the update ledger to diagnose disagreement between surfaces.
- As-of retrieval: filter before scoring. Use a valid date and a knowledge cutoff when the question needs both.
- Versioning: retain sealed snapshots and record the serving dependencies needed to interpret a replay.
- Correction semantics: distinguishing rollback, retraction, and correction, and running a validate-then-promote workflow with a probe bundle.
- Refresh cadence: measure stale answers by fact class and choose the cadence against a stated tolerance.
Filter before ranking and check the candidate snapshot before promotion. The snapshots preserve what retrieval could see at each release. Replaying a past answer also requires its request inputs and compatible model, prompt, and decoding state. A pointer change can restore a retained retrieval release when its serving dependencies are compatible.
Quiz
Ready to test your understanding? Take this quick quiz to reinforce what you've learned about knowledge freshness and temporal updates.
Knowledge Freshness and Temporal Updates
Join the discussionAsk a question or share what you learned.
Keep exploring
Reference
Citation details
Cite or share this article.


Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!