Knowledge Freshness and Temporal Updates › Rollback and Correction Semantics

Michael BrenndoerferDecember 1, 20265 min read
Language AI HandbookAll chapters
Part 45 of 67Knowledge, Memory, Editing, and Unlearning
Chapter 348Knowledge Freshness and Temporal Updates › Rollback and Correction Semantics
Reading section 8 of 12 · Rollback and Correction Semantics · 5 minSection 8 of 12 · 5 min

Section 8 of 12 · 5 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

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 ≠ forgetting

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:

  1. Detect a candidate change (source polling, user report, scheduled re-validation of volatile facts).
  2. Adjudicate: is the new source authoritative? What is the new valid interval? Does it correct, retract, or extend?
  3. Assert into the knowledge base (close old belief, insert new record) with both time axes set.
  4. Propagate to every surface the ledger says this fact class requires (index chunk rewrite, cache invalidation, optional weight edit).
  5. Rebuild an immutable index snapshot containing the change.
  6. Validate on a freshness probe bundle (paraphrases, multi-hop, the timed query that motivated the change).
  7. Promote the snapshot (and edited checkpoint) atomically; keep the prior one addressable.
  8. 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]
CollapseExpand
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]
CollapseExpand
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]
CollapseExpand
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]
CollapseExpand
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.

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!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy