World's first open-source enterprise world model.
Rust agent-memorybitemporalgraphragknowledge-baseknowledge-graphllmontologypgvectorpostgresqlragrustself-hostedsemantic-searchtemporal-knowledge-graphworld-model
Use chapter attestation to order unique state timelines (#1054)
Danielb4b1123d99e6
diff --git a/crates/utopia-server/src/time_attestation_tests.rs b/crates/utopia-server/src/time_attestation_tests.rsnew file mode 100644index 00000000..81d9bd8f--- /dev/null+++ b/crates/utopia-server/src/time_attestation_tests.rs@@ -0,0 +1,240 @@+//! Section attestation after materialization reconciles the real timeline without an LLM.+use super::*;+use serde_json::json;+use std::sync::Arc;+use utopia_store::graph::{self, FactObject};++struct Fixture {+ state: AppState,+ org: Uuid,+ kb: Uuid,+ doc: Uuid,+ subject: Uuid,+ _dir: tempfile::TempDir,+}++async fn fixture() -> anyhow::Result<Option<Fixture>> {+ let Some(url) = utopia_store::test_db::url() else {+ return Ok(None);+ };+ let pool = sqlx::PgPool::connect(&url).await?;+ utopia_store::db::migrate(&pool).await?;+ let (org, workspace, kb, doc, subject, property, binding) = (+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ );+ // Only fixture UUIDs are interpolated into SQL.+ sqlx::raw_sql(&format!(+ "INSERT INTO organizations(id,name) VALUES ('{org}','section-attestation');+ INSERT INTO workspaces(id,org_id,name) VALUES ('{workspace}','{org}','section-attestation');+ INSERT INTO knowledge_bases(id,workspace_id,name) VALUES ('{kb}','{workspace}','section-attestation');+ INSERT INTO documents(id,kb_id,filename,sha256,doc_time,doc_time_source)+ VALUES ('{doc}','{kb}','chapters.md','{doc}','2030-01-01','source');+ INSERT INTO entities(id,kb_id,canonical_name) VALUES ('{subject}','{kb}','Widget');+ INSERT INTO relation_types(id,kb_id,key,label,kind,datatype,temporal,functional)+ VALUES ('{property}','{kb}','location','Location','attribute','text','state',TRUE);+ INSERT INTO phrase_bindings(id,kb_id,phrase,object_is_value,relation_type_id,direction,status)+ VALUES ('{binding}','{kb}','is on',TRUE,'{property}','forward','bound');"+ ))+ .execute(&pool)+ .await?;+ utopia_store::documents::record_version(&pool, doc, "chapter-v1", 100).await?;+ let dir = tempfile::tempdir()?;+ let config = utopia_core::config::AppConfig {+ data_dir: dir.path().to_string_lossy().into_owned(),+ ..Default::default()+ };+ let search = Arc::new(utopia_search::SearchIndex::open(+ &dir.path().join("search"),+ )?);+ Ok(Some(Fixture {+ state: AppState::new(pool, &config, search, "test-only".into()),+ org,+ kb,+ doc,+ subject,+ _dir: dir,+ }))+}++async fn chapter(+ fixture: &Fixture,+ seq: i32,+ heading: &str,+ value: &str,+ attested: Option<DateTime<Utc>>,+) -> anyhow::Result<(Uuid, Uuid)> {+ let pool = &fixture.state.pool;+ let chunk = Uuid::now_v7();+ let quote = format!("Widget is on {value}.");+ let prefix = format!("# {heading}\n");+ let text = format!("{prefix}{quote}");+ sqlx::query(+ "INSERT INTO chunks(id,kb_id,document_id,seq,text,doc_version)+ VALUES ($1,$2,$3,$4,$5,+ (SELECT COALESCE(max(version),1) FROM document_versions WHERE document_id=$3))",+ )+ .bind(chunk)+ .bind(fixture.kb)+ .bind(fixture.doc)+ .bind(seq)+ .bind(&text)+ .execute(pool)+ .await?;+ let object = json!({"value": value});+ let (statement, _) = graph::insert_open_statement(+ pool,+ fixture.kb,+ fixture.subject,+ "is on",+ FactObject::Value(&object),+ attested,+ 1.0,+ )+ .await?;+ graph::add_evidence_located(+ pool,+ statement,+ chunk,+ Some("e),+ Some("is on"),+ Some((+ i32::try_from(prefix.chars().count())?,+ i32::try_from(text.chars().count())?,+ )),+ )+ .await?;+ Ok((statement, chunk))+}++fn day(year: i32) -> DateTime<Utc> {+ format!("{year}-01-01T00:00:00Z").parse().unwrap()+}++type StateEnd = (+ String,+ Option<DateTime<Utc>>,+ Option<String>,+ Option<DateTime<Utc>>,+);++#[tokio::test]+async fn section_dates_reconcile_values_materialized_before_attestation() -> anyhow::Result<()> {+ let Some(fixture) = fixture().await? else {+ return Ok(());+ };+ let pool = &fixture.state.pool;+ let run = async {+ chapter(&fixture, 0, "Earlier", "desk", None).await?;+ chapter(&fixture, 1, "Later", "shelf", None).await?;+ let materialized = utopia_store::materialize::materialize(pool, fixture.kb).await?;+ assert_eq!(materialized.added, 2);+ let dated: i64 = sqlx::query_scalar(+ "SELECT count(*) FROM facts WHERE kb_id=$1 AND layer='typed'+ AND invalidated_at IS NULL AND attested_from IS NOT NULL",+ )+ .bind(fixture.kb)+ .fetch_one(pool)+ .await?;+ assert_eq!(dated, 0, "materialization preserves the statements' NULL dates");+ let context: DocumentDating = serde_json::from_value(json!({"entries": [+ {"kind":"now","name":"Report date","words":"2015-01-01",+ "from":{"year":2015,"month":1,"day":1},"scope":["Earlier"]},+ {"kind":"now","name":"Report date","words":"2026-01-01",+ "from":{"year":2026,"month":1,"day":1},"scope":["Later"]}+ ]}))?;+ let doc = utopia_store::documents::get(pool, fixture.doc).await?;+ attest_statements(&fixture.state, &doc, &context).await?;+ let rows: Vec<StateEnd> =+ sqlx::query_as(+ "SELECT object_value->>'value', valid_from, valid_to_precision, attested_to+ FROM facts WHERE kb_id=$1 AND layer='typed' AND invalidated_at IS NULL+ ORDER BY object_value->>'value'",+ )+ .bind(fixture.kb)+ .fetch_all(pool)+ .await?;+ assert_eq!(rows, vec![+ ("desk".into(), None, Some("unknown".into()), Some(day(2026))),+ ("shelf".into(), None, None, None),+ ]);+ let query = format!(+ "SELECT f.object_value->>'value' FROM facts f WHERE f.kb_id=$1+ AND f.layer='typed' AND f.invalidated_at IS NULL AND {}",+ utopia_store::world_axis::facts_hold_at("f", 2)+ );+ for (at, expected) in [(day(2014), vec![]), (day(2020), vec!["desk"]), (day(2026), vec!["shelf"])] {+ let values: Vec<String> = sqlx::query_scalar(&query)+ .bind(fixture.kb)+ .bind(at)+ .fetch_all(pool)+ .await?;+ assert_eq!(values, expected);+ }+ let revisions: i64 = sqlx::query_scalar(+ "SELECT count(*) FROM facts WHERE kb_id=$1 AND layer='typed' AND supersedes IS NOT NULL",+ )+ .bind(fixture.kb)+ .fetch_one(pool)+ .await?;+ assert_eq!(revisions, 1, "the predecessor closes through the ledger");+ attest_statements(&fixture.state, &doc, &context).await?;+ let after_retry: i64 = sqlx::query_scalar(+ "SELECT count(*) FROM facts WHERE kb_id=$1 AND layer='typed' AND supersedes IS NOT NULL",+ )+ .bind(fixture.kb)+ .fetch_one(pool)+ .await?;+ assert_eq!(after_retry, revisions);+ anyhow::Ok(())+ }+ .await;+ sqlx::query("DELETE FROM organizations WHERE id=$1")+ .bind(fixture.org)+ .execute(pool)+ .await?;+ run+}++#[tokio::test]+async fn current_context_does_not_reattest_superseded_chunks() -> anyhow::Result<()> {+ let Some(fixture) = fixture().await? else {+ return Ok(());+ };+ let pool = &fixture.state.pool;+ let run = async {+ let (old, old_chunk) = chapter(&fixture, 0, "Report", "desk", Some(day(2026))).await?;+ sqlx::query("UPDATE chunks SET superseded_at=now() WHERE id=$1")+ .bind(old_chunk)+ .execute(pool)+ .await?;+ utopia_store::documents::record_version(pool, fixture.doc, "chapter-v2", 100).await?;+ let (current, _) = chapter(&fixture, 1, "Report", "shelf", None).await?;+ let context: DocumentDating = serde_json::from_value(json!({"entries": [+ {"kind":"now","name":"Report date","words":"2025-01-01",+ "from":{"year":2025,"month":1,"day":1},"scope":["Report"]}+ ]}))?;+ let doc = utopia_store::documents::get(pool, fixture.doc).await?;+ attest_statements(&fixture.state, &doc, &context).await?;+ for (statement, expected) in [(old, day(2026)), (current, day(2025))] {+ let at: Option<DateTime<Utc>> =+ sqlx::query_scalar("SELECT attested_from FROM facts WHERE id=$1")+ .bind(statement)+ .fetch_one(pool)+ .await?;+ assert_eq!(at, Some(expected), "statement {statement}");+ }+ anyhow::Ok(())+ }+ .await;+ sqlx::query("DELETE FROM organizations WHERE id=$1")+ .bind(fixture.org)+ .execute(pool)+ .await?;+ run+}diff --git a/crates/utopia-server/src/time_resolution.rs b/crates/utopia-server/src/time_resolution.rsindex 371cfdfb..fb6a6317 100644--- a/crates/utopia-server/src/time_resolution.rs+++ b/crates/utopia-server/src/time_resolution.rs@@ -661,7 +661,8 @@ async fn attest_statements(FROM fact_evidence feJOIN facts f ON f.id = fe.fact_idJOIN chunks c ON c.id = fe.chunk_id- WHERE fe.document_id = $1 AND f.layer = 'open' AND f.invalidated_at IS NULL",+ WHERE fe.document_id = $1 AND c.superseded_at IS NULL+ AND f.layer = 'open' AND f.invalidated_at IS NULL",).bind(doc.id).fetch_all(pool)@@ -686,8 +687,15 @@ async fn attest_statements(}// 已经物化出来的、规则算出来的类型化行跟着它们的陈述走let typed = utopia_store::materialize::sync_typed_attestation(pool, doc.kb_id).await?;+ // 见证动了的行换了它在唯一性时间线上的位置:只把这些行所在的时间线重算一遍,不是整个库+ // ——每篇文档都把全库的时间线各开一个事务重算一遍,库一大就是每篇几千个事务。+ // 先提交同步,再拿时间线锁,不在持有 UPDATE 行锁时等咨询锁(与物化提交后对账的顺序一致)+ let reconciled = utopia_store::temporal::reconcile_moved_facts(pool, doc.kb_id, &typed).await?;+ let typed = typed.len();if moved > 0 || typed > 0 {- tracing::info!(document_id = %doc.id, statements = moved, typed, "陈述按它所在那一节的日期作了证");+ tracing::info!(document_id = %doc.id, statements = moved, typed,+ corrected = reconciled.corrected.len(), conflicts = reconciled.conflicts,+ "陈述按它所在那一节的日期作了证");state.emit_graph(doc.kb_id);}Ok(())@@ -697,6 +705,10 @@ async fn attest_statements(#[path = "time_context_tests.rs"]mod context_tests;+#[cfg(test)]+#[path = "time_attestation_tests.rs"]+mod attestation_tests;+#[cfg(test)]mod tests {use super::*;diff --git a/crates/utopia-store/src/materialize.rs b/crates/utopia-store/src/materialize.rsindex dba74c6d..57d7ebb7 100644--- a/crates/utopia-store/src/materialize.rs+++ b/crates/utopia-store/src/materialize.rs@@ -419,7 +419,8 @@ async fn materialize_in_tx(// 3b. 见证跟着来源陈述走(0064 决定 3、5):类型化的行自己没有出处。物化与算隐含行// 用的写入口在陈述没有见证时填的是此刻(那是给人写的事实用的缺省),这里改回陈述的。// 排在 3a 之后:规则算出的行也是这样写下的- sync_typed_attestation(&mut **tx, kb_id).await?;+ // 见证动了的已有行和新写下的行一起,提交后对账:见证是时间线排序用的时刻+ written.extend(sync_typed_attestation(&mut **tx, kb_id).await?);Ok((Outcome {retired,@@ -440,11 +441,15 @@ async fn materialize_in_tx(////// 动的行:有陈述物化进来的,和规则算出来的(`implied`)。人写的行只被规则的结论并进来时/// 不动——它的见证是人写下它的那一刻,并进来时 `attest_earlier` 已经往早挪过+///+/// 回见证动了的那些行。见证是唯一性时间线给没起点的行排序用的时刻(`temporal::DATED_AT`),+/// 所以调用方提交之后要拿这些行去对账(`temporal::reconcile_moved_facts`)——只对这些行+/// 所在的时间线,不是整个库pub async fn sync_typed_attestation<'e>(ex: impl sqlx::Executor<'e, Database = sqlx::Postgres>,kb_id: Uuid,-) -> AppResult<u64> {- let moved = sqlx::query(+) -> AppResult<Vec<Uuid>> {+ let moved = sqlx::query_scalar("UPDATE facts tSET attested_from = src.at, attested_by = src.byFROM (SELECT u.fact_id,@@ -465,12 +470,13 @@ pub async fn sync_typed_attestation<'e>(AND (t.impliedOR EXISTS (SELECT 1 FROM typed_fact_sources ts WHERE ts.fact_id = t.id))AND (t.attested_from IS DISTINCT FROM src.at- OR t.attested_by IS DISTINCT FROM src.by)",+ OR t.attested_by IS DISTINCT FROM src.by)+ RETURNING t.id",).bind(kb_id)- .execute(ex)+ .fetch_all(ex).await?;- Ok(moved.rows_affected())+ Ok(moved)}#[derive(sqlx::FromRow)]diff --git a/crates/utopia-store/src/temporal.rs b/crates/utopia-store/src/temporal.rsindex 4da28909..7b21cef7 100644--- a/crates/utopia-store/src/temporal.rs+++ b/crates/utopia-store/src/temporal.rs@@ -5,7 +5,7 @@//! - 闭合走"作废 + 改写"而非原地改:旧断言 invalidated_at 记下"何时被修正",//! 修正行闭合区间并以 supersedes 链回旧行——"以当时的认知回放当时"得以成立//! - 闭合点只用世界时间:后任的 valid_from;后任没有起点时,前任写成「结束了,不知哪天」,-//! 锚在后任最早那份自带日期的证据上(0022 的形状,#681 §1)。文档日期从不写进日期列+//! 锚在后任的事实见证上(0022 的形状,0064 的章节日期)。见证日期从不写进日期列//! - 拿不准(缺时间/同时开始/低置信)绝不硬闭合,进 fact_conflicts 由人裁决//!//! **一条时间线是一个整体。** 同一 (库, 持有者, 谓词, 唯一性方向) 的所有现存行按时间排成@@ -29,20 +29,9 @@ use utopia_core::models::ConflictView;use utopia_core::AppResult;use uuid::Uuid;-/// 证据文件**自带**的最早日期,按 `facts` 的别名 `f` 投影。只认正文(`content`)与来源-/// (`source`)给的日期:上传时刻、文件修改时间不是文档自己的日期——拿它们排序,-/// 每条没起点的旧行都会被读成「此刻还在」。删掉的文档不再作证。-///-/// 日期取证据**所在那一版**的(`document_versions.doc_time`,#900):同一身份再推一份-/// 新内容会把文档的 `doc_time` 换成新的,证据停在旧版上的行若还按文档当前的日期算,-/// 就和新行「同时」开始,时间线关不上前一段。老版本没记日期的退回文档的日期-const DATED_AT: &str = "(SELECT min(COALESCE(v.doc_time, d.doc_time)) FROM fact_evidence fe- JOIN documents d ON d.id = fe.document_id- LEFT JOIN document_versions v ON v.document_id = fe.document_id- AND v.version = fe.doc_version- WHERE fe.fact_id = f.id AND COALESCE(v.doc_time, d.doc_time) IS NOT NULL- AND d.deleted_at IS NULL- AND d.doc_time_source IN ('content', 'source'))";+/// 事实自己的见证,与世界轴的下界同源(0064)。同一版文档的不同章节可以有不同日期;+/// NULL 明确表示没有时间,不能退回文档日期。类型化行由来源陈述同步这份见证。+const DATED_AT: &str = "f.attested_from";/// 这一行的出处里有看图描述出来的文字吗,按 `facts` 的别名 `f` 投影(0040 决定 4)。/// 类型化的行自己没有出处,它的出处是物化它的那些陈述的(0044 第 2 刀)@@ -163,12 +152,12 @@ impl End {impl Row {/// 这一行的起点锚不到吗:有时间词、代码没能把它放到世界轴上(等级 C)。**没有等级/// 的行不算**——它的日期是直接给的(人写的、规则算的、这一列之前的每一行),不是- /// 从别处猜的。锚不到的行仍进得了时间线(它按文档的日期排),只是不许它改写历史+ /// 从别处猜的。锚不到的行仍进得了时间线(它按见证日期排),只是不许它改写历史fn start_unanchored(&self) -> bool {self.valid_from_grade.as_deref() == Some("C")}- /// 排序用的时刻:起点。没有起点时,最早那份自带日期的证据——但只对还开着、或者由引擎+ /// 排序用的时刻:起点。没有起点时,事实的见证——但只对还开着、或者由引擎/// 关上的行成立:它们的证据说那天还成立。原文说已经结束的行,证据的日期只说明「那天/// 之前结束了」,拿它排序会让一个早就结束的值去关上当下的值(#679 第三轮评审)fn key(&self) -> Option<DateTime<Utc>> {@@ -202,7 +191,7 @@ impl Row {}}/// 前一段止于这一行开始时,终点写成什么:有起点就是那一刻;没有起点,是「结束了,- /// 不知哪天」,锚在这一行自带日期的证据上+ /// 不知哪天」,锚在这一行的见证上fn end_before(&self) -> End {match self.valid_from {Some(start) => {@@ -447,7 +436,7 @@ pub async fn reconcile_new_fact(/// 一条事实来到它的时间线上,记下重算裁不了的,交给人(调用方已持锁):////// - 与别的值同一时刻开始、两边那一刻都还成立:谁接替谁说不清-/// - 两边都还开着,有一边说不出时间(没起点、也没有自带日期的证据):谁先谁后无从谈起。+/// - 两边都还开着,有一边说不出时间(没起点、也没有见证):谁先谁后无从谈起。/// 不论哪一边先到都是这一对冲突,不替人关上任何一边////// `settled`:同一批里已经来过的事实,不再与它们重复成对@@ -494,9 +483,9 @@ struct Plan {/// 一条时间线上每一行该有的终点(纯函数,不碰库):只含终点由引擎定的行。///-/// 能排进时间线的行(有起点,或有自带日期的证据)按时刻排好;终点是写明的行不动。其余+/// 能排进时间线的行(有起点,或有见证)按时刻排好;终点是写明的行不动。其余/// 每一行——开着的、引擎关上的——止于它之后最近的、值不同的那一行开始时;后面没有这样-/// 的行就开着。后任的起点锚不到(等级 C)时跳过它:它在轴上的位置是文档日期给的,不是+/// 的行就开着。后任的起点锚不到(等级 C)时跳过它:它在轴上的位置是见证给的,不是/// 那句话给的(0045 第 3 刀)。后任是看图描述出来的时也跳过,那一对交给人(0040 决定 4)。////// 每一行的终点只取决于各行的时刻、值和起点的来历,改写终点不改这三样,所以一次算完@@ -505,7 +494,12 @@ fn desired_ends(side: Uniqueness, rows: &[Row]) -> (HashMap<Uuid, End>, Vec<(Uuilet mut keyed: Vec<&Row> = rows.iter().filter(|r| r.key().is_some()).collect();// 同一刻开始的几行,写着起点的排前面:后任取它,前任就止于一个日期而不是一个锚点keyed.sort_by_key(|r| (r.key(), r.valid_from.is_none(), r.id));- let mut ends = HashMap::new();+ // 无时间的行不能保留旧引擎仅凭文档日期推出来的终点;人工写明的终点仍不重算。+ let mut ends: HashMap<Uuid, End> = rows+ .iter()+ .filter(|row| row.recomputable() && row.key().is_none())+ .map(|row| (row.id, End::Open))+ .collect();let mut held = Vec::new();for (i, row) in keyed.iter().enumerate() {if !row.recomputable() {@@ -992,13 +986,14 @@ async fn rewrite_end_tx(let corrected = Uuid::now_v7();sqlx::query("INSERT INTO facts (id, kb_id, subject_id, predicate_id, object_id, object_value,- valid_from, valid_from_precision,+ valid_from, valid_from_precision, valid_from_grade,valid_to, valid_to_precision, confidence, supersedes,- attested_from, attested_to, end_derived,+ attested_from, attested_by, attested_to, end_derived,from_statement_id, implied, corrected_ends)SELECT $1, kb_id, subject_id, predicate_id, object_id, object_value,- valid_from, valid_from_precision, $3, $4, confidence, id,- attested_from, CASE WHEN $4::text = 'unknown' THEN COALESCE($5, now()) END, $6,+ valid_from, valid_from_precision, valid_from_grade, $3, $4, confidence, id,+ attested_from, attested_by,+ CASE WHEN $4::text = 'unknown' THEN COALESCE($5, now()) END, $6,from_statement_id, implied,-- 终点在这里被重新写下(文档说了终点,或时间线推了一个),人改过的终点就不在了;-- 起点那一半照旧diff --git a/crates/utopia-store/tests/a_timeline_uses_its_statements_attestation.rs b/crates/utopia-store/tests/a_timeline_uses_its_statements_attestation.rsnew file mode 100644index 00000000..df9b71ec--- /dev/null+++ b/crates/utopia-store/tests/a_timeline_uses_its_statements_attestation.rs@@ -0,0 +1,526 @@+//! Chapter attestation orders functional states; a document date cannot replace it (0064).+//! These tests use production materialization and world-axis predicates, without an LLM.++use chrono::{DateTime, Utc};+use serde_json::json;+use sqlx::PgPool;+use utopia_store::{graph, materialize, phrase_bindings, temporal, world_axis};+use uuid::Uuid;++struct Fixture {+ org: Uuid,+ kb: Uuid,+ subject: Uuid,+ property: Uuid,+ document: Uuid,+}++fn day(date: &str) -> DateTime<Utc> {+ format!("{date}T00:00:00Z").parse().unwrap()+}++async fn pool() -> anyhow::Result<Option<PgPool>> {+ let Some(url) = utopia_store::test_db::url() else {+ return Ok(None);+ };+ Ok(Some(PgPool::connect(&url).await?))+}++async fn seed(pool: &PgPool) -> anyhow::Result<Fixture> {+ let (org, workspace, kb, subject, property, document) = (+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ Uuid::now_v7(),+ );+ sqlx::raw_sql(&format!(+ "INSERT INTO organizations(id,name) VALUES ('{org}','chapter-timeline-test');+ INSERT INTO workspaces(id,org_id,name) VALUES ('{workspace}','{org}','chapter-timeline-test');+ INSERT INTO knowledge_bases(id,workspace_id,name) VALUES ('{kb}','{workspace}','chapter-timeline-test');+ INSERT INTO entities(id,kb_id,canonical_name) VALUES ('{subject}','{kb}','Watch');+ INSERT INTO relation_types(id,kb_id,key,label,kind,datatype,temporal,functional)+ VALUES ('{property}','{kb}','market','market','attribute','text','state',TRUE);+ INSERT INTO documents(id,kb_id,filename,sha256,doc_time,doc_time_source)+ VALUES ('{document}','{kb}','chapters.txt','{document}','2026-09-04','content');+ INSERT INTO document_versions(id,document_id,version,sha256,doc_time)+ VALUES ('{}','{document}',1,'{document}','2026-09-04');",+ Uuid::now_v7()+ ))+ .execute(pool)+ .await?;+ Ok(Fixture {+ org,+ kb,+ subject,+ property,+ document,+ })+}++async fn statement(+ pool: &PgPool,+ fixture: &Fixture,+ value: &str,+ attested: Option<&str>,+ version: i32,+) -> anyhow::Result<Uuid> {+ let object = json!({ "value": value });+ let (statement, _) = graph::insert_open_statement(+ pool,+ fixture.kb,+ fixture.subject,+ "market is",+ graph::FactObject::Value(&object),+ None,+ 0.9,+ )+ .await?;+ let chunk = Uuid::now_v7();+ sqlx::query(+ "INSERT INTO chunks(id,kb_id,document_id,doc_version,seq,text)+ VALUES ($1,$2,$3,$4,$4,$5)",+ )+ .bind(chunk)+ .bind(fixture.kb)+ .bind(fixture.document)+ .bind(version)+ .bind(value)+ .execute(pool)+ .await?;+ graph::add_evidence(pool, statement, chunk, Some(value), Some("market is")).await?;+ if let Some(date) = attested {+ graph::attest_statement(pool, statement, day(date), &format!("chapter {date}")).await?;+ }+ Ok(statement)+}++async fn bind(pool: &PgPool, fixture: &Fixture) -> anyhow::Result<()> {+ for signature in phrase_bindings::signatures(pool, fixture.kb).await? {+ phrase_bindings::decide(+ pool,+ fixture.kb,+ &signature,+ phrase_bindings::Decision {+ relation_type_id: Some(fixture.property),+ direction: Some("forward"),+ status: "bound",+ votes: &json!({}),+ decided_by: "agent",+ basis: None,+ marks: None,+ marks_asked: false,+ },+ )+ .await?;+ }+ Ok(())+}++#[derive(Debug, sqlx::FromRow)]+struct State {+ id: Uuid,+ valid_from: Option<DateTime<Utc>>,+ valid_to: Option<DateTime<Utc>>,+ valid_to_precision: Option<String>,+ attested_from: Option<DateTime<Utc>>,+ attested_by: Option<String>,+ attested_to: Option<DateTime<Utc>>,+ valid_from_grade: Option<String>,+ end_derived: bool,+ supersedes: Option<Uuid>,+}++async fn state(pool: &PgPool, fixture: &Fixture, value: &str) -> anyhow::Result<State> {+ Ok(sqlx::query_as(+ "SELECT id,valid_from,valid_to,valid_to_precision,attested_from,attested_by,attested_to,valid_from_grade,end_derived,supersedes+ FROM facts WHERE kb_id=$1 AND predicate_id=$2 AND layer='typed'+ AND invalidated_at IS NULL AND object_value #>> '{value}'=$3",+ )+ .bind(fixture.kb)+ .bind(fixture.property)+ .bind(value)+ .fetch_one(pool)+ .await?)+}++async fn values_at(pool: &PgPool, fixture: &Fixture, date: &str) -> anyhow::Result<Vec<String>> {+ let held = world_axis::facts_hold_at("f", 3);+ Ok(sqlx::query_scalar(&format!(+ "SELECT object_value #>> '{{value}}' FROM facts f+ WHERE kb_id=$1 AND predicate_id=$2 AND layer='typed' AND invalidated_at IS NULL+ AND {held} ORDER BY object_value #>> '{{value}}'"+ ))+ .bind(fixture.kb)+ .bind(fixture.property)+ .bind(day(date))+ .fetch_all(pool)+ .await?)+}++async fn cleanup(pool: &PgPool, fixture: &Fixture) -> anyhow::Result<()> {+ sqlx::query("DELETE FROM organizations WHERE id=$1")+ .bind(fixture.org)+ .execute(pool)+ .await?;+ Ok(())+}++async fn assert_chapter_timeline(pool: &PgPool, fixture: &Fixture) -> anyhow::Result<()> {+ let old = state(pool, fixture, "old").await?;+ let new = state(pool, fixture, "new").await?;+ assert_eq!(old.valid_from, None, "as-of is not a start");+ assert_eq!(new.valid_from, None, "as-of is not a start");+ assert_eq!(old.attested_from, Some(day("2015-01-01")));+ assert_eq!(old.attested_by.as_deref(), Some("chapter 2015-01-01"));+ assert_eq!(new.attested_from, Some(day("2026-01-01")));+ assert_eq!(old.valid_to, None, "the text did not state an end");+ assert_eq!(old.valid_to_precision.as_deref(), Some("unknown"));+ assert_eq!(old.attested_to, Some(day("2026-01-01")));+ assert!(old.end_derived);+ assert!(old.supersedes.is_some(), "closure must preserve the ledger");+ let historical: bool =+ sqlx::query_scalar("SELECT invalidated_at IS NOT NULL FROM facts WHERE id=$1")+ .bind(old.supersedes.unwrap())+ .fetch_one(pool)+ .await?;+ assert!(historical);+ assert!(!new.end_derived);+ assert_eq!(new.valid_to_precision, None);+ assert_eq!(+ values_at(pool, fixture, "2014-01-01").await?,+ Vec::<String>::new()+ );+ assert_eq!(values_at(pool, fixture, "2020-01-01").await?, ["old"]);+ assert_eq!(values_at(pool, fixture, "2026-01-01").await?, ["new"]);+ Ok(())+}++#[tokio::test]+async fn chapter_dates_before_materialization_close_the_previous_value() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ statement(&pool, &fixture, "new", Some("2026-01-01"), 1).await?;+ bind(&pool, &fixture).await?;+ let result = materialize::materialize(&pool, fixture.kb).await?;+ assert_eq!(result.corrected, 1, "{result:?}");+ assert_eq!(result.conflicts, 0, "different chapter dates are ordered");+ assert_chapter_timeline(&pool, &fixture).await?;+ assert_eq!(+ materialize::materialize(&pool, fixture.kb).await?,+ materialize::Outcome::default()+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn chapter_dates_synced_after_materialization_reconcile_the_existing_timeline(+) -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ let old = statement(&pool, &fixture, "old", None, 1).await?;+ let new = statement(&pool, &fixture, "new", None, 1).await?;+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ graph::attest_statement(&pool, old, day("2015-01-01"), "chapter 2015-01-01").await?;+ graph::attest_statement(&pool, new, day("2026-01-01"), "chapter 2026-01-01").await?;+ let result = materialize::materialize(&pool, fixture.kb).await?;+ assert_eq!(+ result.added, 0,+ "date synchronization must reconcile existing rows"+ );+ assert_eq!(result.corrected, 1, "{result:?}");+ assert_chapter_timeline(&pool, &fixture).await?;+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn equal_chapter_dates_remain_a_real_conflict() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ for value in ["old", "new"] {+ statement(&pool, &fixture, value, Some("2026-01-01"), 1).await?;+ }+ bind(&pool, &fixture).await?;+ let result = materialize::materialize(&pool, fixture.kb).await?;+ assert_eq!(result.corrected, 0);+ assert_eq!(result.conflicts, 1);+ assert_eq!(+ values_at(&pool, &fixture, "2026-01-01").await?,+ ["new", "old"]+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn an_undated_statement_does_not_borrow_a_document_or_version_date() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ statement(&pool, &fixture, "new", None, 1).await?;+ bind(&pool, &fixture).await?;+ let result = materialize::materialize(&pool, fixture.kb).await?;+ assert_eq!(result.corrected, 0, "NULL explicitly means no attestation");+ assert_eq!(state(&pool, &fixture, "new").await?.attested_from, None);+ assert_eq!(+ state(&pool, &fixture, "old").await?.valid_to_precision,+ None+ );+ assert_eq!(values_at(&pool, &fixture, "2014-01-01").await?, ["new"]);+ assert_eq!(+ values_at(&pool, &fixture, "2026-01-01").await?,+ ["new", "old"]+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn explicit_starts_take_priority_and_unresolved_starts_close_nothing() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ for grade in ["A", "C"] {+ let fixture = seed(&pool).await?;+ statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ let attested = if grade == "A" {+ "2010-01-01"+ } else {+ "2026-01-01"+ };+ let new = statement(&pool, &fixture, "new", Some(attested), 1).await?;+ graph::set_open_validity(+ &pool,+ new,+ (grade == "A").then(|| day("2020-01-01")),+ (grade == "A").then_some("day"),+ None,+ None,+ Some(grade),+ )+ .await?;+ bind(&pool, &fixture).await?;+ let result = materialize::materialize(&pool, fixture.kb).await?;+ let old = state(&pool, &fixture, "old").await?;+ if grade == "A" {+ assert_eq!(result.corrected, 1);+ assert_eq!(old.valid_to, Some(day("2020-01-01")));+ assert_eq!(old.valid_to_precision.as_deref(), Some("day"));+ assert_eq!(old.attested_to, None);+ assert_eq!(values_at(&pool, &fixture, "2016-01-01").await?, ["old"]);+ assert_eq!(values_at(&pool, &fixture, "2020-01-01").await?, ["new"]);+ } else {+ assert_eq!(result.corrected, 0);+ assert_eq!(result.conflicts, 0, "grade C waits for resolution");+ assert_eq!(old.valid_to_precision, None);+ }+ cleanup(&pool, &fixture).await?;+ }+ Ok(())+}++#[tokio::test]+async fn a_new_document_version_cannot_redate_earlier_chapter_evidence() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ sqlx::query("UPDATE documents SET doc_time='2030-01-01' WHERE id=$1")+ .bind(fixture.document)+ .execute(&pool)+ .await?;+ sqlx::query("INSERT INTO document_versions(id,document_id,version,sha256,doc_time) VALUES ($1,$2,2,$3,'2030-01-01')")+ .bind(Uuid::now_v7()).bind(fixture.document).bind(Uuid::now_v7().to_string()).execute(&pool).await?;+ statement(&pool, &fixture, "new", Some("2026-01-01"), 2).await?;+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ assert_chapter_timeline(&pool, &fixture).await?;+ let old = state(&pool, &fixture, "old").await?;+ let versions: Vec<i32> =+ sqlx::query_scalar("SELECT doc_version FROM fact_evidence WHERE fact_id=$1")+ .bind(old.id)+ .fetch_all(&pool)+ .await?;+ assert_eq!(+ versions,+ [1],+ "closure preserves the old evidence's version"+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn closing_an_unresolved_predecessor_preserves_its_grade_and_attestation_name(+) -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ let old = statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ graph::set_open_validity(&pool, old, None, None, None, None, Some("C")).await?;+ statement(&pool, &fixture, "new", Some("2026-01-01"), 1).await?;+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ assert_chapter_timeline(&pool, &fixture).await?;+ assert_eq!(+ state(&pool, &fixture, "old")+ .await?+ .valid_from_grade+ .as_deref(),+ Some("C")+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn controlled_reconciliation_reopens_an_undated_derived_end_without_overwriting_history(+) -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ statement(&pool, &fixture, "old", None, 1).await?;+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ let original = state(&pool, &fixture, "old").await?;+ // Simulate a legacy engine boundary based only on document time. The repair+ // must replace this live projection through the ledger, not erase its past.+ sqlx::query("UPDATE facts SET valid_to_precision='unknown',attested_to='2026-09-04',end_derived=TRUE WHERE id=$1")+ .bind(original.id).execute(&pool).await?;+ let repaired = temporal::reconcile_predicate(&pool, fixture.kb, fixture.property).await?;+ assert_eq!(repaired.corrected.len(), 1);+ let reopened = state(&pool, &fixture, "old").await?;+ assert_eq!(reopened.supersedes, Some(original.id));+ assert_eq!(reopened.attested_from, None);+ assert_eq!(reopened.valid_to_precision, None);+ assert_eq!(reopened.attested_to, None);+ assert!(!reopened.end_derived);+ assert_eq!(values_at(&pool, &fixture, "2030-01-01").await?, ["old"]);+ let historical: (bool, Option<String>, Option<DateTime<Utc>>) = sqlx::query_as(+ "SELECT invalidated_at IS NOT NULL,valid_to_precision,attested_to FROM facts WHERE id=$1",+ )+ .bind(original.id)+ .fetch_one(&pool)+ .await?;+ assert_eq!(+ historical,+ (true, Some("unknown".to_string()), Some(day("2026-09-04")))+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn merge_conflict_checks_use_the_same_chapter_dates_as_timeline_reconciliation(+) -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ sqlx::query("UPDATE relation_types SET kind='relation',datatype=NULL WHERE id=$1")+ .bind(fixture.property)+ .execute(&pool)+ .await?;+ let (other_subject, old_market, new_market) = (Uuid::now_v7(), Uuid::now_v7(), Uuid::now_v7());+ for (entity, name) in [+ (other_subject, "Other Watch"),+ (old_market, "Old Market"),+ (new_market, "New Market"),+ ] {+ sqlx::query("INSERT INTO entities(id,kb_id,canonical_name) VALUES ($1,$2,$3)")+ .bind(entity)+ .bind(fixture.kb)+ .bind(name)+ .execute(&pool)+ .await?;+ }+ let mut later_statement = None;+ for (subject, object, date) in [+ (fixture.subject, old_market, "2015-01-01"),+ (other_subject, new_market, "2026-01-01"),+ ] {+ let (statement, _) = graph::insert_open_statement(+ &pool,+ fixture.kb,+ subject,+ "market is",+ graph::FactObject::Entity(object),+ None,+ 0.9,+ )+ .await?;+ graph::attest_statement(&pool, statement, day(date), &format!("chapter {date}")).await?;+ let chunk = Uuid::now_v7();+ sqlx::query("INSERT INTO chunks(id,kb_id,document_id,doc_version,seq,text) VALUES ($1,$2,$3,1,0,$4)")+ .bind(chunk).bind(fixture.kb).bind(fixture.document).bind(date).execute(&pool).await?;+ graph::add_evidence(&pool, statement, chunk, Some(date), Some("market is")).await?;+ later_statement = Some(statement);+ }+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ assert!(+ temporal::merge_would_overlap(&pool, fixture.kb, fixture.subject, other_subject)+ .await?+ .is_empty(),+ "different chapter dates can form one timeline after a merge"+ );+ graph::attest_statement(+ &pool,+ later_statement.unwrap(),+ day("2015-01-01"),+ "chapter 2015-01-01",+ )+ .await?;+ materialize::materialize(&pool, fixture.kb).await?;+ assert_eq!(+ temporal::merge_would_overlap(&pool, fixture.kb, fixture.subject, other_subject).await?,+ ["market"],+ "equal chapter dates remain a merge conflict"+ );+ cleanup(&pool, &fixture).await+}++#[tokio::test]+async fn chapter_attestation_reconciliation_preserves_a_stated_end() -> anyhow::Result<()> {+ let Some(pool) = pool().await? else {+ return Ok(());+ };+ let fixture = seed(&pool).await?;+ let old = statement(&pool, &fixture, "old", Some("2015-01-01"), 1).await?;+ graph::set_open_validity(+ &pool,+ old,+ None,+ None,+ Some(day("2018-01-01")),+ Some("day"),+ Some("A"),+ )+ .await?;+ statement(&pool, &fixture, "new", Some("2026-01-01"), 1).await?;+ bind(&pool, &fixture).await?;+ materialize::materialize(&pool, fixture.kb).await?;+ temporal::reconcile_predicate(&pool, fixture.kb, fixture.property).await?;+ let old = state(&pool, &fixture, "old").await?;+ assert_eq!(old.valid_to, Some(day("2018-01-01")));+ assert_eq!(old.valid_to_precision.as_deref(), Some("day"));+ assert!(+ !old.end_derived,+ "only engine-derived ends may be recomputed"+ );+ assert_eq!(+ values_at(&pool, &fixture, "2020-01-01").await?,+ Vec::<String>::new()+ );+ assert_eq!(values_at(&pool, &fixture, "2026-01-01").await?, ["new"]);+ cleanup(&pool, &fixture).await+}diff --git a/crates/utopia-store/tests/store/a_timeline_holds_whatever_the_order.rs b/crates/utopia-store/tests/store/a_timeline_holds_whatever_the_order.rsindex f02f8324..c4fbbc68 100644--- a/crates/utopia-store/tests/store/a_timeline_holds_whatever_the_order.rs+++ b/crates/utopia-store/tests/store/a_timeline_holds_whatever_the_order.rs@@ -138,6 +138,13 @@ async fn arrive_on(confidence,).await?;+ if doc.is_some_and(|(at, _)| at.is_none()) {+ // 模拟文档抽取的无时间行(0064);人工写入口的 None 缺省是此刻。+ sqlx::query("UPDATE facts SET attested_from = NULL WHERE id = $1")+ .bind(id)+ .execute(pool)+ .await?;+ }if let Some(c) = chunk {utopia_store::graph::add_evidence(pool, id, c, Some(value), None).await?;}diff --git a/crates/utopia-store/tests/store/an_automatic_merge_is_gated_by_what_it_can_undo.rs b/crates/utopia-store/tests/store/an_automatic_merge_is_gated_by_what_it_can_undo.rsindex 2281ae46..d378acc3 100644--- a/crates/utopia-store/tests/store/an_automatic_merge_is_gated_by_what_it_can_undo.rs+++ b/crates/utopia-store/tests/store/an_automatic_merge_is_gated_by_what_it_can_undo.rs@@ -109,8 +109,8 @@ async fn seed(pool: &PgPool) -> anyhow::Result<Fixture> {async fn fact(pool: &PgPool, kb: Uuid, s: Uuid, p: Uuid, o: Uuid) -> anyhow::Result<Uuid> {let id = Uuid::now_v7();sqlx::query(- "INSERT INTO facts (id, kb_id, subject_id, predicate_id, object_id)- VALUES ($1, $2, $3, $4, $5)",+ "INSERT INTO facts (id, kb_id, subject_id, predicate_id, object_id, attested_from)+ VALUES ($1, $2, $3, $4, $5, NULL)",).bind(id).bind(kb)diff --git a/crates/utopia-store/tests/the_engine_redraws_only_what_it_drew.rs b/crates/utopia-store/tests/the_engine_redraws_only_what_it_drew.rsindex dfcfd1e6..8108ce5f 100644--- a/crates/utopia-store/tests/the_engine_redraws_only_what_it_drew.rs+++ b/crates/utopia-store/tests/the_engine_redraws_only_what_it_drew.rs@@ -170,6 +170,13 @@ async fn observe(pool: &PgPool, f: &Fixture, x: Seen<'_>) -> anyhow::Result<Uuidx.confidence,).await?;+ if x.from.is_none() && x.doc.is_none() {+ // 模拟文档没有时间(0064),不使用人工写入口的此刻见证。+ sqlx::query("UPDATE facts SET attested_from = NULL WHERE id = $1")+ .bind(id)+ .execute(pool)+ .await?;+ }if let Some(c) = chunk {if x.described {// 描述出来的块必须带锚(0058 的 CHECK):图在文件里的哪一块diff --git a/docs/decisions/0022-an-unknown-date-is-not-an-open-one.md b/docs/decisions/0022-an-unknown-date-is-not-an-open-one.mdindex 6684fd72..59b70bb1 100644--- a/docs/decisions/0022-an-unknown-date-is-not-an-open-one.md+++ b/docs/decisions/0022-an-unknown-date-is-not-an-open-one.md@@ -1,6 +1,6 @@# 0022 · An unknown date is not an open one-- **Status**: Implemented in five cuts (#394, #393, #679)+- **Status**: Implemented in five cuts (#394, #393, #679) · revised 2026-10-03 (#1054): the timeline orders a start-less row by its attestation- **Written**: 2026-09-06 (conventions in the [README](README.md))- **Related**: [0003](0003-ontology-growth-loop.md)'s graph migration gave the end of a fact three states and refused to store a document's date as an indeterminate instant; this record keeps that refusal and puts the date in a column that says what it is. [0019](0019-the-second-clock-can-be-rewound.md) put the record-axis predicate in one place (`record_axis`) and kept `at` and `as_of` apart; this record does the same for the world axis. [0017](0017-a-contradiction-points-upstream.md) gave derived rows their own precisions, and [0021](0021-a-rule-reads-attributes-and-concludes-a-type.md)'s evaluator intersects premise intervals — both inherit the rule below. From #345 and #352, both found by the temporal benchmark (#306).@@ -90,6 +90,8 @@ Why not the document's date in `valid_from` / `valid_to` with a marker precision>> The ordering date is `min(doc_time)` over the row's evidence, counting only documents whose own date is known (`doc_time_source` of `content` or `source`). It is not `attested_from`, for the reason section 3 gives in reverse. An undated document anchors `attested_from` at the moment of recording, and ordering by that would read every start-less row as holding now, turning an ordinary "X, then Y from 2021" into a conflict. A row with no dated evidence has no place in the timeline; when it and another value are both open, the pair goes to a person, whichever arrived first. A start-less row whose text says it has ended is not placed by its evidence either: that date shows it ended by then, not that it held then. Evidence from a deleted document no longer places a row. The concern above about copied evidence does not bite here: a superseding row's evidence is the same documents, and the earliest of them is still the earliest date the row is known to hold.>+> > **Revised 2026-10-03 (#1054, after [0064](0064-extraction-reads-time-as-it-goes.md) cut 3): the ordering date is the row's attestation.** The reason given above no longer holds. Since migration 0100 an undated document leaves `attested_from` null instead of the moment of recording, and a statement is attested by the date its own section speaks from. Ordering by `min(doc_time)` then disagreed with the reads: two start-less statements under the 2015 and the 2026 chapters of one document shared the document's date, were read as simultaneous, and both stayed open, while the reads placed them eleven years apart. The engine now orders a start-less row by `attested_from`, the same anchor the reads use, and anchors the ended-unknown predecessor there. What stays: a row with no attestation has no place in the timeline and its pair goes to a person; an as-of is never written as a start; a row whose text says it has ended is not placed by its attestation. A typed row follows the attestation of its statements, and a row whose attestation moves has its timeline recomputed. An end the old engine drew from a document date the row no longer has a basis for is reopened through the supersedes ledger; stated ends are not touched. Not changed, and weaker than the rule above: when a document is deleted or restored, attestation is rebuilt from the dates of the documents that remain (`documents::reattest_tx`), not from chapter dates, and a row left with no dated document keeps the attestation it had, so there a deleted document's date can still place a row.+>> A value the text gives only relative to an event, such as a deadline of "45 days after the Trigger Date", has no calendar date. The extractor marks it `relative` (the model decides; the server matches no wording), and the server stores it as written. It is still the current value, so it closes the dated value before it in the same way, anchored at its own document. It is never compared or sorted as a date. An unflagged value that is not a date is still dropped as `attr_datatype`.### 3. Where the anchor comes fromdiff --git a/docs/design/time.md b/docs/design/time.mdindex b4a0ff6c..04260713 100644--- a/docs/design/time.md+++ b/docs/design/time.md@@ -22,16 +22,17 @@ evaluator; a clock time without a zone is a date; world time renders in UTC, recviewer's zone [0024, 0013]. GitHub and Jira timestamps are written to the second [0013].**An unknown bound reaches as far as the evidence.** A missing start is not "since always": the lower-bound is `valid_from` or else `attested_from`, the earliest document date among the row's evidence.+bound is `valid_from` or else `attested_from`, the date the text of the row's own section speaks+from, and null when the document states none [0064].An ending with no date is not "still holds": `valid_to_precision = 'unknown'` with `attested_to`,the date of the document that said it was over. An open end still reads as holds until toldotherwise [0022]. Anchors are copied by every superseding writer and moved only earlier.**The temporal engine** (`temporal.rs`) works only on `state` relations declared functional orinverse-functional. A new value closes the open one before it; an undated or dated ending closes-the open row it ends through a superseding row; a start-less row is ordered by its earliest dated-evidence (`doc_time_source` content or source only) and closes its predecessor as ended-unknown-there; ends the engine drew are marked `end_derived` and recomputed in one pass whenever a timeline+the open row it ends through a superseding row; a start-less row is ordered by its attestation,+the same anchor the reads use, and closes its predecessor as ended-unknown there; one with no+attestation has no place and its pair goes to a person [0022 revised 2026-10-03, #1054]; ends the engine drew are marked `end_derived` and recomputed in one pass whenever a timelinechanges, so the result depends on which rows exist and not on arrival order; a relation unique onboth sides sits on two timelines under one lock; a deadline stated relative to an event is stored aswritten and flagged `relative` [0022 revised, #679]. **A successor takes over on how its start was