Skip to content

World's first open-source enterprise world model.

A timeline closes on how a date was got (#762)

WaylandYang816d4a39255b
diff --git a/crates/utopia-core/src/models.rs b/crates/utopia-core/src/models.rs
index cad33c00..df5111d2 100644
--- a/crates/utopia-core/src/models.rs
+++ b/crates/utopia-core/src/models.rs
@@ -1042,7 +1042,8 @@ pub struct Readiness {
#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
pub struct ConflictView {
pub id: Uuid,
- /// no_time | simultaneous | low_confidence
+ /// no_time | simultaneous | described_evidence(`low_confidence` 是 0045 第 3 刀
+ /// 之前记下的,历史行还带着它)
pub reason: String,
pub created_at: DateTime<Utc>,
pub predicate_label: String,
diff --git a/crates/utopia-server/src/api/graph_routes.rs b/crates/utopia-server/src/api/graph_routes.rs
index 842eb026..e3684399 100644
--- a/crates/utopia-server/src/api/graph_routes.rs
+++ b/crates/utopia-server/src/api/graph_routes.rs
@@ -388,6 +388,8 @@ pub async fn update_fact_time(
from_precision: req.valid_from_precision.as_deref(),
to: req.valid_to,
to_precision: req.valid_to_precision.as_deref(),
+ // 人改的区间:日期是直接给的,没经过时间解析(0045 第 3 刀按 A 算)
+ from_grade: None,
// 修正行从被替代的行继承锚点(correct_interval 的 SQL 里):改区间是重述
// 同一份证据,不是更新的证据
attested_at: None,
diff --git a/crates/utopia-server/src/extraction.rs b/crates/utopia-server/src/extraction.rs
index ecb0e129..68f22bd0 100644
--- a/crates/utopia-server/src/extraction.rs
+++ b/crates/utopia-server/src/extraction.rs
@@ -90,11 +90,11 @@ pub(crate) async fn chat_retrying_rate_limits_at(
unreachable!("循环内必定 return")
}
-/// 模型看图描述出来的事实,置信度压到这里(0040 决定 4):低于时态引擎自动关闭的门槛,
-/// 它能进图、能被搜到和引用,却不能单独把一段正确的旧值关掉——看柱状图读错一个数字是常事,
-/// 按普通事实入库的话,错的数会关掉它反驳的那个对的数,而库里没有一行说这次关闭靠的是一张图。
-/// 真要关,时态引擎记一条低置信冲突,交给人或治理去判
-const DESCRIBED_CEILING: f32 = utopia_store::temporal::AUTO_CLOSE_MIN_CONFIDENCE - 0.05;
+/// 模型看图描述出来的事实,置信度压到这里(0040 决定 4):低于审核的低置信阈值,于是
+/// 它在待审里露面。**「不许它单独关掉一段正确的旧值」这一条不再靠这个数字**:0045 第 3 刀
+/// 之后时态引擎读的是出处与起点的来历,看图描述出来的行照旧不关、记一条矛盾交给人
+/// (柱状图读错一个数是常事,而库里没有一行会说这次关闭靠的是一张图)
+const DESCRIBED_CEILING: f32 = utopia_store::review::LOW_CONFIDENCE_BELOW - 0.05;
/// 这块文字的来源给事实置信度设的上限
pub(crate) fn origin_ceiling(origin: &str, confidence: f32) -> f32 {
@@ -361,7 +361,7 @@ mod origin_ceiling_tests {
#[test]
fn a_described_fact_cannot_close_a_value_by_itself() {
let ceiling = origin_ceiling("described", 0.95);
- assert!(ceiling < utopia_store::temporal::AUTO_CLOSE_MIN_CONFIDENCE);
+ assert!(ceiling < utopia_store::review::LOW_CONFIDENCE_BELOW);
assert_eq!(ceiling, DESCRIBED_CEILING, "it still enters the graph");
assert_eq!(origin_ceiling("described", 0.62), 0.62);
for origin in ["stated", "ocr", "transcribed"] {
diff --git a/crates/utopia-server/src/time_resolution.rs b/crates/utopia-server/src/time_resolution.rs
index d516c99e..bb09b247 100644
--- a/crates/utopia-server/src/time_resolution.rs
+++ b/crates/utopia-server/src/time_resolution.rs
@@ -522,12 +522,22 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Re
let mut dated = 0usize;
for (fact_id, (when, ended)) in per_fact {
let r = combine(when, ended);
- if r.from.is_none() && r.to.is_none() && r.to_p.is_none() {
+ // 起点的等级只看起点那条提及。combine 在起点锚不到时借结束端的等级来报数,
+ // 这里不借:引擎问的是「这一行的起点是怎么来的」(0045 第 3 刀)
+ let grade = when.map(|w| w.grade);
+ let placed = r.from.is_some() || r.to.is_some() || r.to_p.is_some();
+ // 什么都没算出来也要写等级 C:只有这一列说得出「这句话有时间词、我们没能把它
+ // 放到轴上」,否则它和「整句没有时间词」在库里长得一模一样
+ if !placed && grade != Some("C") {
continue;
}
- utopia_store::graph::set_open_validity(pool, fact_id, r.from, r.from_p, r.to, r.to_p)
- .await?;
- dated += 1;
+ utopia_store::graph::set_open_validity(
+ pool, fact_id, r.from, r.from_p, r.to, r.to_p, grade,
+ )
+ .await?;
+ if placed {
+ dated += 1;
+ }
}
tracing::info!(
%document_id,
diff --git a/crates/utopia-store/src/graph.rs b/crates/utopia-store/src/graph.rs
index 0e912007..ceacf4c0 100644
--- a/crates/utopia-store/src/graph.rs
+++ b/crates/utopia-store/src/graph.rs
@@ -338,6 +338,10 @@ pub struct Validity<'a> {
/// 没有起点的事实从它起成立,结束了不知哪天的到它为止——**它不是起点**,所以
/// 不写进 `from`(0003 拒绝过把文档日期填进日期列)
pub attested_at: Option<chrono::DateTime<chrono::Utc>>,
+ /// 起点是怎么来的(0045 第 3 刀):`A` 文档写明、`B` 按文档自己的锚点算出、
+ /// `C` 有时间词但锚不到。`None` = 没经过时间解析(人写的、规则算的),按 A 算。
+ /// 时态引擎读它决定这一行能不能关上前任
+ pub from_grade: Option<&'a str>,
}
/// `valid_to_precision` 表示「结束了,但不知道是哪天」。
@@ -452,6 +456,7 @@ impl<'a> Validity<'a> {
to: None,
to_precision: None,
attested_at: None,
+ from_grade: None,
}
}
@@ -732,17 +737,17 @@ async fn insert_fact_inner(
"INSERT INTO facts (id, kb_id, subject_id, predicate_id, object_id,
valid_from, valid_from_precision,
valid_to, valid_to_precision, confidence,
- attested_from, attested_to)
+ attested_from, attested_to, valid_from_grade)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, COALESCE($11, now()),
- CASE WHEN $9::text = 'unknown' THEN COALESCE($11, now()) END)"
+ CASE WHEN $9::text = 'unknown' THEN COALESCE($11, now()) END, $12)"
}
FactObject::Value(_) => {
"INSERT INTO facts (id, kb_id, subject_id, predicate_id, object_value,
valid_from, valid_from_precision,
valid_to, valid_to_precision, confidence,
- attested_from, attested_to)
+ attested_from, attested_to, valid_from_grade)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, COALESCE($11, now()),
- CASE WHEN $9::text = 'unknown' THEN COALESCE($11, now()) END)"
+ CASE WHEN $9::text = 'unknown' THEN COALESCE($11, now()) END, $12)"
}
};
let mut ins = sqlx::query(insert_sql)
@@ -760,6 +765,7 @@ async fn insert_fact_inner(
.bind(validity.to_precision)
.bind(confidence)
.bind(validity.attested_at)
+ .bind(validity.from_grade)
.execute(pool)
.await?;
@@ -960,13 +966,17 @@ pub async fn set_open_validity(
from_precision: Option<&str>,
to: Option<chrono::DateTime<chrono::Utc>>,
to_precision: Option<&str>,
+ // 起点是怎么来的(0045 第 3 刀)。**锚不到(`C`)也要写**:那时两端都是空,
+ // 只有这一列说得出「这句话有时间词、我们没能把它放到轴上」,物化把它带给
+ // 类型化的行,时态引擎才不会让一个猜出来的位置改写前任的历史
+ grade: Option<&str>,
) -> AppResult<()> {
let from = from.map(|t| truncate_to(t, from_precision));
let to = to.map(|t| truncate_to(t, to_precision));
let done = sqlx::query(
"UPDATE facts
SET valid_from = $2, valid_from_precision = $3,
- valid_to = $4, valid_to_precision = $5,
+ valid_to = $4, valid_to_precision = $5, valid_from_grade = $6,
attested_to = CASE WHEN $4 IS NULL AND $5 = 'unknown'
THEN COALESCE(attested_to, attested_from) END
WHERE id = $1 AND layer = 'open' AND invalidated_at IS NULL",
@@ -976,6 +986,7 @@ pub async fn set_open_validity(
.bind(from_precision)
.bind(to)
.bind(to_precision)
+ .bind(grade)
.execute(pool)
.await?;
if done.rows_affected() == 0 {
@@ -2747,6 +2758,7 @@ mod temporal_shape_tests {
to: Some(at("2025-01-01T00:00:00Z")),
to_precision: Some("day"),
attested_at: None,
+ from_grade: None,
}
.under(Temporal::Event);
assert_eq!(span.from, Some(at("2024-03-15T00:00:00Z")));
@@ -2762,6 +2774,7 @@ mod temporal_shape_tests {
to: Some(at("2024-05-01T00:00:00Z")),
to_precision: Some("month"),
attested_at: None,
+ from_grade: None,
}
.under(Temporal::Event);
assert_eq!(end_only.from, Some(at("2024-05-01T00:00:00Z")));
diff --git a/crates/utopia-store/src/materialize.rs b/crates/utopia-store/src/materialize.rs
index 51c8bcf0..7ec7c0cf 100644
--- a/crates/utopia-store/src/materialize.rs
+++ b/crates/utopia-store/src/materialize.rs
@@ -49,6 +49,7 @@ struct Due {
object_value: Option<serde_json::Value>,
valid_from: Option<chrono::DateTime<chrono::Utc>>,
valid_from_precision: Option<String>,
+ valid_from_grade: Option<String>,
valid_to: Option<chrono::DateTime<chrono::Utc>>,
valid_to_precision: Option<String>,
attested_from: Option<chrono::DateTime<chrono::Utc>>,
@@ -100,7 +101,8 @@ pub async fn materialize(pool: &PgPool, kb_id: Uuid) -> AppResult<Outcome> {
let due: Vec<Due> = sqlx::query_as(&format!(
"SELECT s.id AS statement, b.relation_type_id AS property, b.direction,
s.subject_id, s.object_id, s.object_value,
- s.valid_from, s.valid_from_precision, s.valid_to, s.valid_to_precision,
+ s.valid_from, s.valid_from_precision, s.valid_from_grade,
+ s.valid_to, s.valid_to_precision,
s.attested_from, s.confidence
FROM facts s
JOIN entities se ON se.id = s.subject_id
@@ -126,6 +128,7 @@ pub async fn materialize(pool: &PgPool, kb_id: Uuid) -> AppResult<Outcome> {
let validity = Validity {
from: d.valid_from,
from_precision: d.valid_from_precision.as_deref(),
+ from_grade: d.valid_from_grade.as_deref(),
to: d.valid_to,
to_precision: d.valid_to_precision.as_deref(),
attested_at: d.attested_from,
diff --git a/crates/utopia-store/src/pending.rs b/crates/utopia-store/src/pending.rs
index 383853fb..750bbbed 100644
--- a/crates/utopia-store/src/pending.rs
+++ b/crates/utopia-store/src/pending.rs
@@ -313,6 +313,8 @@ pub async fn confirm(pool: &PgPool, kb_id: Uuid, id: Uuid) -> AppResult<Confirme
to: v.valid_to,
to_precision: v.valid_to_precision.as_deref(),
attested_at,
+ // 待定的事实是人或代理提的,日期是直接给的,没经过时间解析
+ from_grade: None,
};
let (fact_id, created) = match (v.object_id, v.object_value.as_ref()) {
(Some(object_id), _) => {
diff --git a/crates/utopia-store/src/temporal.rs b/crates/utopia-store/src/temporal.rs
index bdf5bbdb..90c97acc 100644
--- a/crates/utopia-store/src/temporal.rs
+++ b/crates/utopia-store/src/temporal.rs
@@ -29,9 +29,6 @@ use utopia_core::models::ConflictView;
use utopia_core::AppResult;
use uuid::Uuid;
-/// 低于此置信度的后任不允许自动改写前任的历史(进审)。
-pub const AUTO_CLOSE_MIN_CONFIDENCE: f32 = 0.75;
-
/// 证据文件**自带**的最早日期,按 `facts` 的别名 `f` 投影。只认正文(`content`)与来源
/// (`source`)给的日期:上传时刻、文件修改时间不是文档自己的日期——拿它们排序,
/// 每条没起点的旧行都会被读成「此刻还在」。删掉的文档不再作证
@@ -41,6 +38,16 @@ const DATED_AT: &str = "(SELECT min(d.doc_time) FROM fact_evidence fe
AND d.deleted_at IS NULL
AND d.doc_time_source IN ('content', 'source'))";
+/// 这一行的出处里有看图描述出来的文字吗,按 `facts` 的别名 `f` 投影(0040 决定 4)。
+/// 类型化的行自己没有出处,它的出处是物化它的那些陈述的(0044 第 2 刀)
+const DESCRIBED: &str = "(EXISTS (SELECT 1 FROM fact_evidence fe
+ JOIN chunks ch ON ch.id = fe.chunk_id
+ WHERE fe.fact_id = f.id AND ch.origin = 'described')
+ OR EXISTS (SELECT 1 FROM typed_fact_sources ts
+ JOIN fact_evidence fe ON fe.fact_id = ts.statement_id
+ JOIN chunks ch ON ch.id = fe.chunk_id
+ WHERE ts.fact_id = f.id AND ch.origin = 'described'))";
+
/// 唯一性方向:functional = 主语侧(张三同时只 reports_to 一人);
/// inverse functional = 宾语侧(一个项目同时只有一个 leads 它的人)。
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -100,9 +107,13 @@ struct Row {
valid_to: Option<DateTime<Utc>>,
valid_to_precision: Option<String>,
attested_to: Option<DateTime<Utc>>,
- confidence: f32,
end_derived: bool,
dated_at: Option<DateTime<Utc>>,
+ /// 起点是怎么来的:`A` 写明、`B` 按文档自己的锚点算出、`C` 有时间词却锚不到;
+ /// `None` = 没经过时间解析(人写的、规则算的),按 A 算
+ valid_from_grade: Option<String>,
+ /// 这一行的出处里有看图描述出来的文字(0040 决定 4)
+ described: bool,
}
/// 一行的终点
@@ -139,6 +150,13 @@ impl End {
}
impl Row {
+ /// 这一行的起点锚不到吗:有时间词、代码没能把它放到世界轴上(等级 C)。**没有等级
+ /// 的行不算**——它的日期是直接给的(人写的、规则算的、这一列之前的每一行),不是
+ /// 从别处猜的。锚不到的行仍进得了时间线(它按文档的日期排),只是不许它改写历史
+ fn start_unanchored(&self) -> bool {
+ self.valid_from_grade.as_deref() == Some("C")
+ }
+
/// 排序用的时刻:起点。没有起点时,最早那份自带日期的证据——但只对还开着、或者由引擎
/// 关上的行成立:它们的证据说那天还成立。原文说已经结束的行,证据的日期只说明「那天
/// 之前结束了」,拿它排序会让一个早就结束的值去关上当下的值(#679 第三轮评审)
@@ -280,7 +298,8 @@ async fn load_timeline(
let rows = sqlx::query_as(&format!(
"SELECT f.id, f.subject_id, f.object_id, f.object_value,
f.valid_from, f.valid_from_precision, f.valid_to, f.valid_to_precision,
- f.attested_to, f.confidence, f.end_derived, {DATED_AT} AS dated_at
+ f.attested_to, f.end_derived, {DATED_AT} AS dated_at,
+ f.valid_from_grade, {DESCRIBED} AS described
FROM facts f
WHERE f.kb_id = $1 AND {holder_column} = $2 AND f.predicate_id = $3
AND f.invalidated_at IS NULL
@@ -458,7 +477,7 @@ async fn arrive(
struct Plan {
/// (行, 它该有的终点)
ends: Vec<(Uuid, End)>,
- /// (行, 置信度不够、没让它关上的最近那个后任):交给人
+ /// (行, 看图描述出来、没让它关上的最近那个后任):交给人
held: Vec<(Uuid, Uuid)>,
}
@@ -466,10 +485,11 @@ struct Plan {
///
/// 能排进时间线的行(有起点,或有自带日期的证据)按时刻排好;终点是写明的行不动。其余
/// 每一行——开着的、引擎关上的——止于它之后最近的、值不同的那一行开始时;后面没有这样
-/// 的行就开着。那一行置信度不够时不许它改写历史:跳过它、交给人,再看下一行。
+/// 的行就开着。后任的起点锚不到(等级 C)时跳过它:它在轴上的位置是文档日期给的,不是
+/// 那句话给的(0045 第 3 刀)。后任是看图描述出来的时也跳过,那一对交给人(0040 决定 4)。
///
-/// 每一行的终点只取决于各行的时刻、值和置信度,改写终点不改这三样,所以一次算完就是
-/// 最终的样子,不必一轮一轮地来;行怎么排进来的也不影响结果
+/// 每一行的终点只取决于各行的时刻、值和起点的来历,改写终点不改这三样,所以一次算完
+/// 就是最终的样子,不必一轮一轮地来;行怎么排进来的也不影响结果
fn desired_ends(side: Uniqueness, rows: &[Row]) -> (HashMap<Uuid, End>, Vec<(Uuid, Uuid)>) {
let mut keyed: Vec<&Row> = rows.iter().filter(|r| r.key().is_some()).collect();
// 同一刻开始的几行,写着起点的排前面:后任取它,前任就止于一个日期而不是一个锚点
@@ -486,7 +506,14 @@ fn desired_ends(side: Uniqueness, rows: &[Row]) -> (HashMap<Uuid, End>, Vec<(Uui
.iter()
.filter(|later| later.key() > row.key() && !same_value(side, row, later))
{
- if later.confidence < AUTO_CLOSE_MIN_CONFIDENCE {
+ // 起点锚不到:不关,也不记矛盾——这一对没有什么可判的,待锚的提及归时间
+ // 锚点队列(0045:等级 C 既不关时间线也不开矛盾)
+ if later.start_unanchored() {
+ continue;
+ }
+ // 看图描述出来的事实能进图、能被引用,却不许单独关掉一段正确的旧值:柱状图
+ // 读错一个数是常事,而库里没有一行会说这次关闭靠的是一张图(0040 决定 4)
+ if later.described {
doubtful.get_or_insert(later.id);
continue;
}
@@ -566,7 +593,7 @@ async fn tidy(
for (row, later) in held {
let row = rewritten.get(&row).copied().unwrap_or(row);
let later = rewritten.get(&later).copied().unwrap_or(later);
- if record_conflict_tx(tx, kb_id, row, later, "low_confidence").await? {
+ if record_conflict_tx(tx, kb_id, row, later, "described_evidence").await? {
report.conflicts += 1;
}
}
@@ -632,7 +659,8 @@ pub async fn merge_would_overlap(
let mut rows: Vec<Row> = sqlx::query_as(&format!(
"SELECT f.id, f.subject_id, f.object_id, f.object_value,
f.valid_from, f.valid_from_precision, f.valid_to, f.valid_to_precision,
- f.attested_to, f.confidence, f.end_derived, {DATED_AT} AS dated_at
+ f.attested_to, f.end_derived, {DATED_AT} AS dated_at,
+ f.valid_from_grade, {DESCRIBED} AS described
FROM facts f
WHERE f.kb_id = $1 AND {holder_column} = ANY($2) AND f.predicate_id = $3
AND f.invalidated_at IS NULL AND f.object_id IS NOT NULL"
@@ -1344,6 +1372,8 @@ pub struct OpenValue {
pub name: String,
pub valid_from: Option<DateTime<Utc>>,
pub confidence: f32,
+ /// 起点是怎么来的(同 [`Row::start_unanchored`])
+ pub valid_from_grade: Option<String>,
}
/// 每个候选带几个例子。
@@ -1365,6 +1395,7 @@ pub async fn uniqueness_candidates(
other_name: Option<String>,
object_value: Option<serde_json::Value>,
valid_from: Option<DateTime<Utc>>,
+ valid_from_grade: Option<String>,
confidence: f32,
}
// 两端各查一遍。`crowded` 先按 (谓词, 持有者) 数不同的值,再把那些持有者
@@ -1374,7 +1405,7 @@ pub async fn uniqueness_candidates(
"WITH open AS (
SELECT f.id, f.predicate_id, f.subject_id AS holder, f.object_id, f.object_value,
COALESCE(f.object_id::text, f.object_value::text) AS value_key,
- f.valid_from, f.confidence, f.recorded_at
+ f.valid_from, f.valid_from_grade, f.confidence, f.recorded_at
FROM facts f JOIN relation_types r ON r.id = f.predicate_id
WHERE f.kb_id = $1 AND f.invalidated_at IS NULL
AND f.valid_to IS NULL AND f.valid_to_precision IS NULL
@@ -1389,7 +1420,7 @@ pub async fn uniqueness_candidates(
)
SELECT o.id, o.predicate_id, r.key, r.label, r.kind, r.functional AS declared,
h.canonical_name AS holder_name, e.canonical_name AS other_name,
- o.object_value, o.valid_from, o.confidence
+ o.object_value, o.valid_from, o.valid_from_grade, o.confidence
FROM open o
JOIN crowded c ON c.predicate_id = o.predicate_id AND c.holder = o.holder
JOIN relation_types r ON r.id = o.predicate_id
@@ -1403,7 +1434,7 @@ pub async fn uniqueness_candidates(
let object_side: Vec<Row> = sqlx::query_as(
"WITH open AS (
SELECT f.id, f.predicate_id, f.object_id AS holder, f.subject_id,
- f.valid_from, f.confidence, f.recorded_at
+ f.valid_from, f.valid_from_grade, f.confidence, f.recorded_at
FROM facts f JOIN relation_types r ON r.id = f.predicate_id
WHERE f.kb_id = $1 AND f.invalidated_at IS NULL
AND f.valid_to IS NULL AND f.valid_to_precision IS NULL
@@ -1416,7 +1447,7 @@ pub async fn uniqueness_candidates(
)
SELECT o.id, o.predicate_id, r.key, r.label, r.kind, r.inverse_functional AS declared,
h.canonical_name AS holder_name, e.canonical_name AS other_name,
- NULL::jsonb AS object_value, o.valid_from, o.confidence
+ NULL::jsonb AS object_value, o.valid_from, o.valid_from_grade, o.confidence
FROM open o
JOIN crowded c ON c.predicate_id = o.predicate_id AND c.holder = o.holder
JOIN relation_types r ON r.id = o.predicate_id
@@ -1463,6 +1494,7 @@ pub async fn uniqueness_candidates(
.or_else(|| r.object_value.as_ref().map(literal_name))
.unwrap_or_else(|| "?".to_string()),
valid_from: r.valid_from,
+ valid_from_grade: r.valid_from_grade.clone(),
confidence: r.confidence,
});
i += 1;
@@ -1485,7 +1517,7 @@ pub async fn uniqueness_candidates(
/// 一个持有者的开放值按年表排好后,对账会怎么处置:(闭合数, 进人审数)。
///
/// 把 `reconcile_predicate` 的过程干跑一遍,不落库:逐条当"新落库的观察",与
-/// 后面还开着的每一条比——起点更早者止于后任起点(自己置信度够才许改写历史);
+/// 后面还开着的每一条比——起点更早者止于后任起点(自己的起点锚得住才许改写历史);
/// 两条都没起点、或同一天开始,说不清谁接替谁,进人审,两条都还开着;后任没起点
/// 的,它止于前任的起点。三条都没起点的持有者会报三对冲突,与引擎一致。
/// 这是估算——真跑一遍的结果才作数
@@ -1507,7 +1539,7 @@ fn plan_closures(values: &[OpenValue]) -> (usize, usize) {
(_, None) => review += 1,
(Some(of), Some(nf)) if of == nf => review += 1,
(Some(of), Some(nf)) if nf < of => {
- if new.confidence < AUTO_CLOSE_MIN_CONFIDENCE {
+ if new.valid_from_grade.as_deref() == Some("C") {
review += 1;
} else {
close += 1;
@@ -1516,7 +1548,7 @@ fn plan_closures(values: &[OpenValue]) -> (usize, usize) {
}
}
(_, Some(_)) => {
- if new.confidence < AUTO_CLOSE_MIN_CONFIDENCE {
+ if new.valid_from_grade.as_deref() == Some("C") {
review += 1;
} else {
close += 1;
@@ -1557,12 +1589,13 @@ mod tests {
use super::*;
use chrono::TimeZone;
- fn v(from: Option<(i32, u32, u32)>, confidence: f32) -> OpenValue {
+ fn v(from: Option<(i32, u32, u32)>, grade: Option<&str>) -> OpenValue {
OpenValue {
fact_id: Uuid::now_v7(),
name: String::new(),
valid_from: from.map(|(y, m, d)| Utc.with_ymd_and_hms(y, m, d, 0, 0, 0).unwrap()),
- confidence,
+ valid_from_grade: grade.map(str::to_string),
+ confidence: 0.9,
}
}
@@ -1582,9 +1615,10 @@ mod tests {
valid_to: None,
valid_to_precision: None,
attested_to: None,
- confidence: 0.9,
end_derived: false,
dated_at: dated,
+ valid_from_grade: None,
+ described: false,
}
}
@@ -1723,15 +1757,37 @@ mod tests {
assert!(still_overlaps(Uniqueness::SubjectSide, &eternal, false));
}
- /// 置信度不够的后任不许关上前任,交给人;前任止于它之后第一个够格的后任
+ /// 起点锚不到的后任不许关上前任,也不开矛盾(0045 第 3 刀:等级 C 两样都不做);
+ /// 前任止于它之后第一个锚得住的后任
+ #[test]
+ fn an_unanchored_successor_closes_nothing_and_opens_no_conflict() {
+ let mut rows = vec![
+ row("A", Some(day(2020, 1, 1)), None),
+ row("B", Some(day(2020, 2, 1)), None),
+ row("C", Some(day(2020, 3, 1)), None),
+ ];
+ rows[1].valid_from_grade = Some("C".to_string());
+ let plan = plan_timeline(Uniqueness::SubjectSide, &rows);
+ assert_eq!(
+ plan.ends,
+ vec![
+ (rows[0].id, End::At(day(2020, 3, 1), "day".into())),
+ (rows[1].id, End::At(day(2020, 3, 1), "day".into())),
+ ]
+ );
+ assert!(plan.held.is_empty(), "锚不到的一对没有什么可判的");
+ }
+
+ /// 看图描述出来的后任不许单独关上前任,这一对交给人(0040 决定 4);
+ /// 前任止于它之后第一个不是描述出来的后任
#[test]
- fn a_doubtful_successor_is_held_and_the_next_sure_one_closes() {
+ fn a_described_successor_is_held_and_the_next_stated_one_closes() {
let mut rows = vec![
row("A", Some(day(2020, 1, 1)), None),
row("B", Some(day(2020, 2, 1)), None),
row("C", Some(day(2020, 3, 1)), None),
];
- rows[1].confidence = 0.5;
+ rows[1].described = true;
let plan = plan_timeline(Uniqueness::SubjectSide, &rows);
assert_eq!(
plan.ends,
@@ -1746,9 +1802,9 @@ mod tests {
#[test]
fn a_chain_of_three_closes_twice() {
let values = [
- v(Some((2023, 2, 1)), 0.9),
- v(Some((2024, 7, 5)), 0.9),
- v(Some((2025, 9, 1)), 0.9),
+ v(Some((2023, 2, 1)), None),
+ v(Some((2024, 7, 5)), None),
+ v(Some((2025, 9, 1)), None),
];
assert_eq!(plan_closures(&values), (2, 0));
}
@@ -1757,31 +1813,34 @@ mod tests {
fn what_the_engine_would_not_close_goes_to_review() {
// 同一天开始
assert_eq!(
- plan_closures(&[v(Some((2024, 1, 1)), 0.9), v(Some((2024, 1, 1)), 0.9)]),
+ plan_closures(&[v(Some((2024, 1, 1)), None), v(Some((2024, 1, 1)), None)]),
(0, 1)
);
// 两条都没起点
- assert_eq!(plan_closures(&[v(None, 0.9), v(None, 0.9)]), (0, 1));
- // 起点更早的那条置信度不够,不许它改写历史
+ assert_eq!(plan_closures(&[v(None, None), v(None, None)]), (0, 1));
+ // 起点更早的那条锚不到,不许它改写历史
assert_eq!(
- plan_closures(&[v(Some((2023, 1, 1)), 0.5), v(Some((2024, 1, 1)), 0.9)]),
+ plan_closures(&[
+ v(Some((2023, 1, 1)), Some("C")),
+ v(Some((2024, 1, 1)), None)
+ ]),
(0, 1)
);
// 后任没起点:它止于前任的起点(落库时的"旧事实无起点也适用")
assert_eq!(
- plan_closures(&[v(Some((2023, 1, 1)), 0.9), v(None, 0.9)]),
+ plan_closures(&[v(Some((2023, 1, 1)), None), v(None, None)]),
(1, 0)
);
// 一条不成对
- assert_eq!(plan_closures(&[v(Some((2023, 1, 1)), 0.9)]), (0, 0));
+ assert_eq!(plan_closures(&[v(Some((2023, 1, 1)), None)]), (0, 0));
// 三条都没起点:每一对都说不清,三对冲突,与引擎一致
assert_eq!(
- plan_closures(&[v(None, 0.9), v(None, 0.9), v(None, 0.9)]),
+ plan_closures(&[v(None, None), v(None, None), v(None, None)]),
(0, 3)
);
// 有起点的一条闭合两条没起点的:它们都止于它的起点
assert_eq!(
- plan_closures(&[v(Some((2023, 1, 1)), 0.9), v(None, 0.9), v(None, 0.9)]),
+ plan_closures(&[v(Some((2023, 1, 1)), None), v(None, None), v(None, None)]),
(2, 0)
);
}
diff --git a/crates/utopia-store/tests/a_bound_statement_becomes_a_typed_fact.rs b/crates/utopia-store/tests/a_bound_statement_becomes_a_typed_fact.rs
index 112ece97..36149b9e 100644
--- a/crates/utopia-store/tests/a_bound_statement_becomes_a_typed_fact.rs
+++ b/crates/utopia-store/tests/a_bound_statement_becomes_a_typed_fact.rs
@@ -94,8 +94,8 @@ async fn a_bound_statement_becomes_a_typed_fact() -> anyhow::Result<()> {
for (id, phrase) in [(stated, "is based in"), (planned, "will move to"), (again, "is based in")] {
sqlx::query(
"INSERT INTO facts (id, kb_id, subject_id, object_id, layer, phrase, confidence,
- valid_from, valid_from_precision)
- VALUES ($1, $2, $3, $4, 'open', $5, 0.9, '2019-01-01', 'year')",
+ valid_from, valid_from_precision, valid_from_grade)
+ VALUES ($1, $2, $3, $4, 'open', $5, 0.9, '2019-01-01', 'year', 'B')",
)
.bind(id)
.bind(kb)
@@ -181,8 +181,9 @@ async fn a_bound_statement_becomes_a_typed_fact() -> anyhow::Result<()> {
let first = materialize(&pool, kb).await?;
assert_eq!(first, Outcome { retired: 0, added: 2, merged: 1 });
let live = |pool: PgPool| async move {
- sqlx::query_as::<_, (Uuid, Uuid, Uuid, Uuid, Uuid, Option<chrono::DateTime<chrono::Utc>>)>(
- "SELECT id, subject_id, object_id, predicate_id, from_statement_id, valid_from
+ sqlx::query_as::<_, (Uuid, Uuid, Uuid, Uuid, Uuid, Option<chrono::DateTime<chrono::Utc>>, Option<String>)>(
+ "SELECT id, subject_id, object_id, predicate_id, from_statement_id, valid_from,
+ valid_from_grade
FROM facts WHERE kb_id = $1 AND layer = 'typed' AND invalidated_at IS NULL",
)
.bind(kb)
@@ -191,9 +192,11 @@ async fn a_bound_statement_becomes_a_typed_fact() -> anyhow::Result<()> {
};
let rows = live(pool.clone()).await?;
assert_eq!(rows.len(), 1, "同一个三元组只有一行");
- let (typed_id, subject, object, predicate, from, vf) = rows[0];
+ let (typed_id, subject, object, predicate, from, vf, grade) = rows[0].clone();
assert_eq!((subject, object, predicate, from), (bakery, port, hq, stated));
assert!(vf.is_some(), "世界轴时间抄过来");
+ // 起点是怎么来的也抄过来:时态引擎在类型化的行上判,读不到等级就只能回去猜(0045 第 3 刀)
+ assert_eq!(grade.as_deref(), Some("B"), "起点的来历随日期一起抄过来");
let sources: i64 =
sqlx::query_scalar("SELECT count(*) FROM typed_fact_sources WHERE fact_id = $1")
.bind(typed_id)
diff --git a/crates/utopia-store/tests/a_fact_awaits_a_nod.rs b/crates/utopia-store/tests/a_fact_awaits_a_nod.rs
index f72f3842..0249cc06 100644
--- a/crates/utopia-store/tests/a_fact_awaits_a_nod.rs
+++ b/crates/utopia-store/tests/a_fact_awaits_a_nod.rs
@@ -119,6 +119,7 @@ async fn a_remembered_fact_waits_for_a_nod() -> anyhow::Result<()> {
to: None,
to_precision: None,
attested_at: None,
+ from_grade: None,
},
confidence: 0.9,
chunk_id: f.chunk,
diff --git a/crates/utopia-store/tests/a_path_joins_two_entities.rs b/crates/utopia-store/tests/a_path_joins_two_entities.rs
index cf42b57b..4c58c738 100644
--- a/crates/utopia-store/tests/a_path_joins_two_entities.rs
+++ b/crates/utopia-store/tests/a_path_joins_two_entities.rs
@@ -108,6 +108,7 @@ async fn seed(pool: &PgPool) -> anyhow::Result<Fixture> {
to: to.map(t),
to_precision: to.map(|_| "month"),
attested_at: None,
+ from_grade: None,
};
let mut direct = Uuid::nil();
for (s, p, o, v) in [
diff --git a/crates/utopia-store/tests/a_time_mention_is_resolved_against_its_document.rs b/crates/utopia-store/tests/a_time_mention_is_resolved_against_its_document.rs
index b2f4aa3a..697db59d 100644
--- a/crates/utopia-store/tests/a_time_mention_is_resolved_against_its_document.rs
+++ b/crates/utopia-store/tests/a_time_mention_is_resolved_against_its_document.rs
@@ -372,6 +372,7 @@ async fn a_mention_is_read_then_computed_then_written_to_the_open_row() -> anyho
Some("day"),
Some(day(2019, 6, 1)),
Some("year"),
+ Some("A"),
)
.await?;
assert_eq!(
@@ -391,6 +392,7 @@ async fn a_mention_is_read_then_computed_then_written_to_the_open_row() -> anyho
Some("day"),
None,
Some("unknown"),
+ Some("A"),
)
.await?;
assert_eq!(
@@ -415,7 +417,7 @@ async fn a_mention_is_read_then_computed_then_written_to_the_open_row() -> anyho
"an unknown ending is anchored on its own document"
);
// 又算不出来了:清空,锚点也跟着走
- graph::set_open_validity(&pool, fact, None, None, None, None).await?;
+ graph::set_open_validity(&pool, fact, None, None, None, None, None).await?;
assert_eq!(
span_of(&pool, fact).await?,
Span {
@@ -441,9 +443,16 @@ async fn a_mention_is_read_then_computed_then_written_to_the_open_row() -> anyho
.bind(f.beta)
.execute(&pool)
.await?;
- let refused =
- graph::set_open_validity(&pool, typed, Some(day(2011, 3, 4)), Some("day"), None, None)
- .await;
+ let refused = graph::set_open_validity(
+ &pool,
+ typed,
+ Some(day(2011, 3, 4)),
+ Some("day"),
+ None,
+ None,
+ None,
+ )
+ .await;
assert!(refused.is_err(), "a typed row keeps to insert_fact_inner");
assert_eq!(
span_of(&pool, typed).await?,
@@ -461,6 +470,7 @@ async fn a_mention_is_read_then_computed_then_written_to_the_open_row() -> anyho
Some(day(2009, 1, 1)),
Some("year"),
None,
+ None,
None
)
.await
diff --git a/crates/utopia-store/tests/a_timeline_is_recomputed_from_the_rows_it_has.rs b/crates/utopia-store/tests/a_timeline_is_recomputed_from_the_rows_it_has.rs
index 90eb369e..f6216db5 100644
--- a/crates/utopia-store/tests/a_timeline_is_recomputed_from_the_rows_it_has.rs
+++ b/crates/utopia-store/tests/a_timeline_is_recomputed_from_the_rows_it_has.rs
@@ -86,7 +86,7 @@ fn t(day: &str) -> chrono::DateTime<chrono::Utc> {
format!("{day}T00:00:00Z").parse().unwrap()
}
-/// 一次观察:值、起止、出自哪天的哪种文档、置信度
+/// 一次观察:值、起止、出自哪天的哪种文档、置信度、起点的来历
#[derive(Clone, Copy)]
struct Seen<'a> {
subject: Uuid,
@@ -95,6 +95,8 @@ struct Seen<'a> {
to: Option<&'a str>,
doc: Option<&'a str>,
confidence: f32,
+ /// `None` = 没经过时间解析(这些测试的默认),`Some("C")` = 有时间词却锚不到
+ grade: Option<&'a str>,
}
fn seen<'a>(f: &Fixture, value: &'a str, from: &'a str) -> Seen<'a> {
@@ -105,6 +107,7 @@ fn seen<'a>(f: &Fixture, value: &'a str, from: &'a str) -> Seen<'a> {
to: None,
doc: None,
confidence: 0.9,
+ grade: None,
}
}
@@ -116,6 +119,7 @@ async fn observe(pool: &PgPool, f: &Fixture, x: Seen<'_>) -> anyhow::Result<Uuid
to: x.to.map(t),
to_precision: x.to.map(|_| "day"),
attested_at: None,
+ from_grade: x.grade,
};
let mut chunk = None;
if let Some(doc_time) = x.doc {
@@ -414,7 +418,7 @@ async fn a_closed_value_and_an_open_one_meet_the_same_way_in_either_order() -> a
/// 七十个置信度不够的值排在前面,一个够格的值到了:每一个都关上,没有轮数用完这回事
#[tokio::test]
-async fn doubtful_values_do_not_keep_a_sure_one_from_closing_them() -> anyhow::Result<()> {
+async fn unanchored_values_do_not_keep_a_placed_one_from_closing_them() -> anyhow::Result<()> {
let Some(pool) = pool().await? else {
return Ok(());
};
@@ -428,7 +432,7 @@ async fn doubtful_values_do_not_keep_a_sure_one_from_closing_them() -> anyhow::R
&pool,
&f,
Seen {
- confidence: 0.5,
+ grade: Some("C"),
..seen(&f, &value, &day)
},
)
@@ -441,6 +445,34 @@ async fn doubtful_values_do_not_keep_a_sure_one_from_closing_them() -> anyhow::R
Ok(())
}
+/// 起点锚不到的后任不关前任(0045 第 3 刀):它进得了图、排得进时间线,可它在轴上的
+/// 位置是文档日期给的,不是那句话给的,拿它改写历史就是拿一个猜的位置改写历史
+#[tokio::test]
+async fn an_unanchored_successor_closes_nothing() -> anyhow::Result<()> {
+ let Some(pool) = pool().await? else {
+ return Ok(());
+ };
+ let f = seed(&pool).await?;
+ observe(&pool, &f, seen(&f, "first", "2020-01-01")).await?;
+ observe(
+ &pool,
+ &f,
+ Seen {
+ grade: Some("C"),
+ ..seen(&f, "second", "2021-01-01")
+ },
+ )
+ .await?;
+ let open = open_rows(&pool, &f, f.lease).await?;
+ // 再来一个锚得住的:这一个才关得了前面两个
+ observe(&pool, &f, seen(&f, "third", "2022-01-01")).await?;
+ let after = open_rows(&pool, &f, f.lease).await?;
+ cleanup(&pool, &f).await?;
+ assert_eq!(open, 2, "锚不到的那一行关不了它前面的");
+ assert_eq!(after, 1, "锚得住的一来,前面两行都关上");
+ Ok(())
+}
+
/// 两条各一百个值的时间线交错着合并:一次重算排好,没有轮数上限
#[tokio::test]
async fn a_merge_of_two_long_timelines_leaves_one_timeline() -> anyhow::Result<()> {
@@ -588,6 +620,7 @@ async fn a_revert_keeps_the_interval_a_person_corrected() -> anyhow::Result<()>
to: Some(t("2020-04-01")),
to_precision: Some("day"),
attested_at: None,
+ from_grade: None,
},
)
.await?
diff --git a/crates/utopia-store/tests/a_wrong_time_can_be_corrected.rs b/crates/utopia-store/tests/a_wrong_time_can_be_corrected.rs
index d2abb215..d06286d1 100644
--- a/crates/utopia-store/tests/a_wrong_time_can_be_corrected.rs
+++ b/crates/utopia-store/tests/a_wrong_time_can_be_corrected.rs
@@ -256,6 +256,7 @@ async fn an_end_that_was_never_there_can_be_taken_back() -> anyhow::Result<()> {
to: Some(t("2024-01-01T00:00:00Z")),
to_precision: Some("year"),
attested_at: None,
+ from_grade: None,
},
)
.await?
diff --git a/crates/utopia-store/tests/an_end_date_closes_the_open_span.rs b/crates/utopia-store/tests/an_end_date_closes_the_open_span.rs
index 00ca2be2..0d2a2cd2 100644
--- a/crates/utopia-store/tests/an_end_date_closes_the_open_span.rs
+++ b/crates/utopia-store/tests/an_end_date_closes_the_open_span.rs
@@ -25,6 +25,7 @@ fn span(
to: to.map(day),
to_precision: to.map(|_| "day"),
attested_at: Some(day(attested)),
+ from_grade: None,
}
}
@@ -52,6 +53,7 @@ fn ends(to: &str, attested: &str) -> utopia_store::graph::Validity<'static> {
to: Some(day(to)),
to_precision: Some("day"),
attested_at: Some(day(attested)),
+ from_grade: None,
}
}
@@ -144,6 +146,7 @@ async fn an_end_date_closes_the_open_span() -> anyhow::Result<()> {
to: None,
to_precision: None,
attested_at: Some(day("2025-08-01")),
+ from_grade: None,
},
0.9,
)
diff --git a/crates/utopia-store/tests/an_event_holds_at_the_moment_it_names.rs b/crates/utopia-store/tests/an_event_holds_at_the_moment_it_names.rs
index 2fafef0e..53ac19c7 100644
--- a/crates/utopia-store/tests/an_event_holds_at_the_moment_it_names.rs
+++ b/crates/utopia-store/tests/an_event_holds_at_the_moment_it_names.rs
@@ -311,6 +311,7 @@ async fn a_span_an_ending_or_an_unknown_end_given_to_an_event_collapses() -> any
to: Some(t("2025-01-01T00:00:00Z")),
to_precision: Some("day"),
attested_at: None,
+ from_grade: None,
},
)
.await?;
@@ -336,6 +337,7 @@ async fn a_span_an_ending_or_an_unknown_end_given_to_an_event_collapses() -> any
to: Some(t("2024-05-01T00:00:00Z")),
to_precision: Some("month"),
attested_at: None,
+ from_grade: None,
},
)
.await?;
@@ -578,6 +580,7 @@ async fn a_person_correcting_an_event_leaves_it_one_moment() -> anyhow::Result<(
to: Some(t("2024-06-01T00:00:00Z")),
to_precision: Some("day"),
attested_at: None,
+ from_grade: None,
},
)
.await?
diff --git a/crates/utopia-store/tests/an_unknown_date_is_not_an_open_one.rs b/crates/utopia-store/tests/an_unknown_date_is_not_an_open_one.rs
index 254d50ad..302a93db 100644
--- a/crates/utopia-store/tests/an_unknown_date_is_not_an_open_one.rs
+++ b/crates/utopia-store/tests/an_unknown_date_is_not_an_open_one.rs
@@ -391,6 +391,7 @@ async fn the_anchor_moves_earlier_and_is_inherited() -> anyhow::Result<()> {
to: Some(t("2025-06-01T00:00:00Z")),
to_precision: Some("day"),
attested_at: None,
+ from_grade: None,
},
)
.await?
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.rs
index 20ca6af1..501af9de 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
@@ -97,6 +97,8 @@ struct Seen<'a> {
ended_unknown: bool,
doc: Option<&'a str>,
confidence: f32,
+ /// 这次观察出自一块看图描述出来的文字(0040 决定 4):它不许单独关掉一段正确的旧值
+ described: bool,
}
fn seen<'a>(f: &Fixture, value: &'a str, from: &'a str) -> Seen<'a> {
@@ -108,6 +110,7 @@ fn seen<'a>(f: &Fixture, value: &'a str, from: &'a str) -> Seen<'a> {
ended_unknown: false,
doc: None,
confidence: 0.9,
+ described: false,
}
}
@@ -141,6 +144,7 @@ async fn observe(pool: &PgPool, f: &Fixture, x: Seen<'_>) -> anyhow::Result<Uuid
let mut validity = Validity {
from: x.from.map(t),
from_precision: x.from.map(|_| "day"),
+ from_grade: None,
to: x.to.map(t),
to_precision: if x.ended_unknown {
Some("unknown")
@@ -167,6 +171,16 @@ async fn observe(pool: &PgPool, f: &Fixture, x: Seen<'_>) -> anyhow::Result<Uuid
)
.await?;
if let Some(c) = chunk {
+ if x.described {
+ // 描述出来的块必须带锚(0058 的 CHECK):图在文件里的哪一块
+ sqlx::query(
+ "UPDATE chunks SET origin = 'described', origin_model = 'test-vision',
+ anchor = jsonb_build_object('page', 1, 'image', 0) WHERE id = $1",
+ )
+ .bind(c)
+ .execute(pool)
+ .await?;
+ }
utopia_store::graph::add_evidence(pool, id, c, Some(x.value), None).await?;
}
utopia_store::temporal::reconcile_new_fact(
@@ -604,7 +618,8 @@ async fn a_pair_a_person_kept_is_not_asked_again_after_a_rewrite() -> anyhow::Re
&pool,
&f,
Seen {
- confidence: 0.5,
+ described: true,
+ doc: Some("2020-03-01"),
..seen(&f, "B", "2020-03-01")
},
)
@@ -783,7 +798,8 @@ async fn the_migration_marks_the_ends_the_old_engine_drew() -> anyhow::Result<()
&f,
Seen {
subject: other,
- confidence: 0.5,
+ described: true,
+ doc: Some("2020-03-01"),
..seen(&f, "h2", "2020-03-01")
},
)
diff --git a/docs/decisions/0040-a-chunk-says-where-its-words-came-from.md b/docs/decisions/0040-a-chunk-says-where-its-words-came-from.md
index 62c814c1..1026de84 100644
--- a/docs/decisions/0040-a-chunk-says-where-its-words-came-from.md
+++ b/docs/decisions/0040-a-chunk-says-where-its-words-came-from.md
@@ -114,7 +114,14 @@ Deciding the anchor now is what makes deferring video cost nothing.
Facts extracted from a `described` chunk are inserted with a confidence below
`AUTO_CLOSE_MIN_CONFIDENCE`. The temporal engine already refuses to auto-close on such a fact:
where it would have closed the open interval, it records a `low_confidence` conflict and a person
-decides. No new branch in `temporal.rs` is needed. The fact still enters the graph, search and
+decides. No new branch in `temporal.rs` is needed.
+
+> Revised by [0045](0045-a-time-mention-is-resolved-against-its-document.md) cut 3, which took
+> confidence out of the temporal engine. The guarantee is unchanged and now stands on the chunk's
+> origin: the engine reads whether a row's evidence is described and opens a `described_evidence`
+> conflict where it would have closed. This is the branch in `temporal.rs` that this decision
+> expected not to need. The confidence ceiling stays, below the review threshold, so the fact also
+> shows up in the low-confidence queue. The fact still enters the graph, search and
chat. It can be read, found and cited; it cannot, alone, rewrite what the ledger holds.
The conflict queue is the right place because it only sees the facts that would act. Most
diff --git a/docs/decisions/0045-a-time-mention-is-resolved-against-its-document.md b/docs/decisions/0045-a-time-mention-is-resolved-against-its-document.md
index 0257fde1..95556339 100644
--- a/docs/decisions/0045-a-time-mention-is-resolved-against-its-document.md
+++ b/docs/decisions/0045-a-time-mention-is-resolved-against-its-document.md
@@ -1,6 +1,6 @@
# 0045 · A time mention is resolved against its document
-- **Status**: Accepted 2026-09-17 · cuts 1 and 2 built (#740): a document is dated from its own text, each time mention is interpreted by the model and computed by code, upload time is used nowhere · cut 3 (grades replace the confidence gate in the temporal engine) and cut 4 (re-resolution when a person sets a document's date, the time-anchor review queue) not built · current state in [design/time](../design/time.md) · expands decision 5 of [0044](0044-the-ontology-is-a-view-over-what-documents-say.md) and revises decision 3 of [0022](0022-an-unknown-date-is-not-an-open-one.md) for undated documents · #714 closed
+- **Status**: Accepted 2026-09-17 · cuts 1, 2 and 3 built (#740, #761): a document is dated from its own text, each time mention is interpreted by the model and computed by code, upload time is used nowhere, and a timeline closes on how a start was got rather than on a confidence number · cut 4 (re-resolution when a person sets a document's date, the time-anchor review queue) not built · current state in [design/time](../design/time.md) · expands decision 5 of [0044](0044-the-ontology-is-a-view-over-what-documents-say.md) and revises decision 3 of [0022](0022-an-unknown-date-is-not-an-open-one.md) for undated documents · #714 closed
- **Written**: 2026-09-16 (conventions in the [README](README.md))
- **Related**: [0019](0019-the-second-clock-can-be-rewound.md) and [0022](0022-an-unknown-date-is-not-an-open-one.md) gave facts a world axis, a record axis and an attestation; [0024](0024-the-world-axis-reaches-the-second.md) fixed the precision ladder; [0031](0031-an-event-holds-at-the-moment-it-names.md) made a predicate's temporal kind normalise what is written; #679 made a timeline independent of arrival order; #680 read the opening of a document into every chunk; #688 accepted spelled-out dates; #714 found upload time used as the document date; [0041](0041-a-name-is-a-claim-about-an-entity.md) is the pattern this record copies for time.
diff --git a/docs/design/ledger.md b/docs/design/ledger.md
index 8763a640..1da7df67 100644
--- a/docs/design/ledger.md
+++ b/docs/design/ledger.md
@@ -25,8 +25,10 @@ guards every read path [0010].
**Evidence.** `fact_evidence (fact, chunk NOT NULL, quote, proposed_predicate, quote_start,
quote_end)`, one row per observation; offsets are computed on the server. A chunk carries `origin`
(stated, ocr, transcribed, described), `origin_model` and an `anchor` into the original bytes, so
-evidence says how the words were obtained [0040]. A fact from a described chunk is inserted below
-`AUTO_CLOSE_MIN_CONFIDENCE`, so it opens a conflict instead of closing a correct fact [0040 d4].
+evidence says how the words were obtained [0040]. A fact from a described chunk closes nothing
+by itself: the temporal engine reads the chunk's origin and opens a `described_evidence` conflict
+instead of closing a correct fact [0040 d4, 0045 cut 3]. Its confidence is also capped below the
+review threshold, which is what puts it in front of a person.
**Beside the row.** `statement_qualifiers (fact, role, value | entity)` keyed by the document's role
word for open statements; `fact_qualifiers (fact, qualifier_type, value | entity)` keyed by a
diff --git a/docs/design/ontology.md b/docs/design/ontology.md
index 07fec107..7533a50a 100644
--- a/docs/design/ontology.md
+++ b/docs/design/ontology.md
@@ -149,8 +149,7 @@ the prompt, a description is read by people and by the aligner.
- **Alignment** (0044 cut 2), the rest: implication rules proposed by the aligner, approved on
the workbench, executed by code with cached readings (the sign of "下降 1.4%" is such a
- reading); a signature that tells a figure from words on the value side; merging the typed rows
- that several statements produce for one triple, with the timeline's refinement rules. The prototype aligner reached 14.7% and
+ reading); a signature that tells a figure from words on the value side. The prototype aligner reached 14.7% and
12.1% of gold recall in two runs against 15.5% for the withdrawn bound pass, so the bar for cut 2
is parity over two clean runs [0044, #729].
- **The workbench** (0044 cut 5): the ontology page fed by suggestions from the open graph (frequent
diff --git a/docs/design/time.md b/docs/design/time.md
index d5f49f63..c1d19c43 100644
--- a/docs/design/time.md
+++ b/docs/design/time.md
@@ -34,9 +34,16 @@ evidence (`doc_time_source` content or source only) and closes its predecessor a
there; ends the engine drew are marked `end_derived` and recomputed in one pass whenever a timeline
changes, so the result depends on which rows exist and not on arrival order; a relation unique on
both sides sits on two timelines under one lock; a deadline stated relative to an event is stored as
-written and flagged `relative` [0022 revised, #679]. A successor below `AUTO_CLOSE_MIN_CONFIDENCE`
-(0.75) may not take over: it opens a `low_confidence` conflict instead; confirming a fact changes
-the value and recomputes its timelines [0040, 0043 d5]. Two values that still hold at one moment are
+written and flagged `relative` [0022 revised, #679]. **A successor takes over on how its start was
+got, not on a number** [0045 cut 3]: `valid_from_grade` carries the resolution grade from the time
+mention to the statement and on through materialisation to the typed row, and a successor whose
+start could not be anchored (grade C) closes nothing and opens no conflict, because its place on the
+axis comes from its document's date rather than from the sentence. A successor read off a picture
+closes nothing either and opens a `described_evidence` conflict, which is what a misread chart is
+for [0040 d4]; that guarantee used to ride on the confidence ceiling and now stands on the chunk's
+origin. `AUTO_CLOSE_MIN_CONFIDENCE` is gone and the engine reads no confidence at all; the number stays on the
+row for review queues and display. Confirming a fact changes the value and recomputes its
+timelines [0040, 0043 d5]. Two values that still hold at one moment are
a conflict; a succession is not, for the consistency check and for the merge gate alike [0017,
0027 revised].
@@ -87,9 +94,8 @@ only when that date came from the content or a dating source, else null [#731].
or none) and granularity; code computes the interval; a document carries its own date, calendars
and narrative anchors from chunk to chunk; an unanchored mention waits and is recomputed when an
anchor arrives; `attested_at` is null for an undated document (revising 0022 d3, which anchored it
- at the moment of recording; #731 already writes null on open rows); timelines close on resolution
- grade (A written, B anchored, C unresolved) and the confidence gate leaves the engine; no time
- words in code. Cuts: interpretation columns; context and code resolution (closes #714); grades;
+ at the moment of recording; #731 already writes null on open rows); no time words in code.
+ Cuts: interpretation columns; context and code resolution (closes #714); grades **(built)**;
re-resolution and a time-anchor review queue.
- Thresholds before cut 2: 95% on absolute and 85% on anchored mentions across corpora; the lease
bench no lower than 17 of 18 on both runs [0045].
diff --git a/migrations/0069_a_timeline_closes_on_how_a_date_was_got.sql b/migrations/0069_a_timeline_closes_on_how_a_date_was_got.sql
new file mode 100644
index 00000000..5981022d
--- /dev/null
+++ b/migrations/0069_a_timeline_closes_on_how_a_date_was_got.sql
@@ -0,0 +1,22 @@
+-- 时间线按解析等级收口(0045 第 3 刀)。
+--
+-- 引擎至今用一个数字决定后任能不能改写前任的历史:`facts.confidence` 低于 0.75 就不许它
+-- 关上前一行,改记一条待审的矛盾。那个数字是个代理——它说的是抽取有多确信这条关系,
+-- 不是这条关系的日期是怎么来的。0045 第 1、2 刀已经把后者算了出来,写在
+-- `time_mentions.grade` 上:A 是文档写明的日期,B 是从文档自己的锚点算出来的,C 是锚不到。
+-- 至今没有人读它。
+--
+-- 这一刀把等级带到行上,让引擎读它:起点是 A 或 B 的后任照常关上前任,起点是 C 的不许
+-- 改写历史(它的位置本来就是猜的),跳过它、这一对交给人。数字从引擎里出去,仍留在
+-- 列上给排序和显示用。
+--
+-- facts.valid_from_grade 这一行的起点是怎么来的。NULL = 没经过时间解析:人写的日期、
+-- 规则算的、以及这张表在这一刀之前的每一行。**NULL 按 A 算**:
+-- 日期是直接给的,不是从别处猜的,引擎照旧让它关上前任
+--
+-- 纯增量,不回填。
+ALTER TABLE facts ADD COLUMN valid_from_grade TEXT
+ CHECK (valid_from_grade IN ('A', 'B', 'C'));
+
+COMMENT ON COLUMN facts.valid_from_grade IS
+ '起点是怎么来的:A 写明、B 按锚点算出、C 锚不到;NULL 是没经过时间解析,按 A 算';
diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts
index cd682c8f..dd315ed8 100644
--- a/web/src/i18n/en.ts
+++ b/web/src/i18n/en.ts
@@ -2036,6 +2036,8 @@ export const en = {
conflictReason: {
no_time: "new fact has no date",
simultaneous: "same start date",
+ described_evidence: "the newer fact was read off a picture",
+ low_confidence: "the newer fact was not sure enough",
} as Record<string, string>,
conflictVs: "vs",
conflictSince: (d: string) => `since ${d}`,
diff --git a/web/src/i18n/zh.ts b/web/src/i18n/zh.ts
index 1804bc1b..0336f1bb 100644
--- a/web/src/i18n/zh.ts
+++ b/web/src/i18n/zh.ts
@@ -1777,6 +1777,8 @@ export const zh: Strings = {
conflictReason: {
no_time: "新事实没有日期",
simultaneous: "起始日期相同",
+ described_evidence: "新的那条是看图读出来的",
+ low_confidence: "新的那条不够确信",
},
conflictVs: "对",
conflictSince: (d: string) => `自 ${d} 起`,