Skip to content

World's first open-source enterprise world model.

6.3 KB
Raw Blame

0019 · The second clock can be rewound

  • Status: Implemented (#317, #337, #549) · open: the control on the graph page (#307), full-text recall as of a moment
  • Written: 2026-09-04 (conventions in the README)
  • Related: 0003 put adoption's rewrites on the same append path as human correction, so the prior state is still on disk; 0002 built the proof chain on the same rows. #268 (deleting a document) is what made the gap urgent, and is deliberately a separate change

The write side has kept two clocks since the graph migration: valid_from / valid_to for when a fact held in the world, recorded_at / invalidated_at for when we held it. The read side rewinds only the first. "What did we believe in March?" is answerable from rows we already store and unanswerable through any query we ship.

What is missing

edges_among(at) keeps a fact whose validity window contains at, treating a NULL bound as open — and carries an unconditional invalidated_at IS NULL on top. That hard-coded filter appears 26 times in graph.rs and 54 times across the store.

The recording axis has two readers, and neither answers this question. graph_changes(since, until) covers the whole graph but returns a list of events; its comment draws the line this record acts on — one asks "what did the world look like at that moment", the other "what did we change our minds about". entity_history does not filter invalidated_at at all, but answers one entity at a time. So a fact corrected in March is invisible at every slider position, and the state before that correction can be reached only by opening the entity that carries it.

Deleting a document makes it urgent (#268): a fact whose last source is gone should be invalidated on the recording axis, and after that it is reachable only if the axis can be rewound. The gap predates deletion, though — every retracted or corrected fact is equally unreachable today, which is half of what the README means by "record the whole course of changing understanding".

One predicate

held_at(T) — recorded_at <= T AND (invalidated_at IS NULL OR invalidated_at > T), where None means now. Every read that hard-codes invalidated_at IS NULL takes it instead. derived_facts carries derived_at and invalidated_at, so derivations follow the same rule and a rewound graph keeps the edges the engine had drawn by then.

Write paths keep the hard-coded filter: confirm_fact, reject_fact, the adoption undo and the dedup lookups are guards on the current row, and a correction is never made as of March.

Two parameters, never one control

at (world) and as_of (record) stay separate all the way out to the API. Folded into one slider they would answer "the world in March, as we understand it now" with "the world in March as we understood it then", or the reverse, and both look plausible on screen. graph_changes already warns that mixing the two sets of columns gives a quiet wrong answer; mixing the two controls is the same mistake one layer up.

The risk is a forgotten WHERE

This defence lives in SQL, which is where 0009 was bitten: NULL <> uuid raises nothing and selects nothing, so a guard that reads correctly in Rust ran silently empty. crates/utopia-store/tests/human_type_decisions.rs exists because of it, and its header states the shape of the danger — a defence spread across read sites fails the moment one is missed, and cargo check never says a word.

So the predicate goes in one place per table rather than at every read site, and a database-backed test asserts both directions: a retracted fact is absent at as_of = now, present at an as_of before its invalidated_at, and a fact recorded after T is absent at T.

Read-only throughout. No new column, no migration.

Open questions

  • Entities have no clock. merged_into records that a merge happened, not when. Settled in #337: entity_merges.created_at / reverted_at is the clock, fact_owner_at reads the moved-fact arrays back, and a merge made in March leaves two nodes at an as_of in February. The target's own type and profile at T are recorded (target_type_before, target_profile_before) and still unread.
  • Retrieval has the same two clocks. Settled, with one half left standing. replace_chunks no longer clears embedding on a superseded chunk: the storage that decision saved was the smaller half — the chunk's text was already kept — and the price was that history could not be searched at all. Vector recall and chunk fetch now take as_of, and a document deleted after T comes back with its chunks (#268 leaves the tombstone). Full text stays "now": Tantivy holds one version of a base, so a timed search returns correct hits and misses the ones only history has. Giving the index versions is a separate piece of work, not a filter.
  • A proof has one version. fact_derivations is rewritten in place when a kept conclusion is reproved (0030, cut 2), and proof reads it as it stands. So a rewound panel lists the derivations the engine had drawn by T (#549), but expanding one shows today's premises, with the retracted ones marked. Keeping every proof would mean versioning fact_derivations the way facts is versioned; the row's derived_at already says when the conclusion first stood, and nobody has asked for the rest.
  • What the control is. A second slider doubles the surface for a question most people ask rarely; a mode switch on the existing slider is cheaper but risks reading as the same axis, which is the confusion the section above is written to prevent.

Status history

The status line as it stood on 2026-09-27, before status lines were cut to one line:

implemented in three cuts · #317 gave every graph read the held_at predicate and as_of beside at; #337 gave entities their clock by unwinding entity_merges; this record's second open question landed with retrieval (superseded chunks keep their vectors, and vector recall and chunk fetch both take as_of) · the control on the graph page is still open, and full-text recall is still "now" only · #549 found the one derived read that had kept invalidated_at IS NULL: derived_for_entity now takes as_of, so the entity panel and entity_facts over MCP rewind derivations with the assertions