World's first open-source enterprise world model.
Rust agent-memorybitemporalgraphragknowledge-baseknowledge-graphllmontologypgvectorpostgresqlragrustself-hostedsemantic-searchtemporal-knowledge-graphworld-model
Each chunk reports the dates its passage states, and a time word is measured from the date of its own section (#991)
WaylandYange6c7647849bf
diff --git a/crates/utopia-extract/src/open.rs b/crates/utopia-extract/src/open.rsindex df5b92c3..6ba87705 100644--- a/crates/utopia-extract/src/open.rs+++ b/crates/utopia-extract/src/open.rs@@ -93,6 +93,8 @@ pub struct OpenExtraction {pub entities: Vec<OpenEntity>,pub statements: Vec<OpenStatement>,pub names: Vec<OpenName>,+ /// what the passage states about the document's own time (0064): dates with their names+ pub time: Vec<crate::time::TimeEntry>,/// items skipped because they were malformed (counted per array item; must be reported by the caller)pub skipped: usize,/// the reply was truncated and repaired to the last complete object@@ -107,7 +109,8 @@ Output one JSON object and nothing else, shaped like this:\n\\n\{\"e\": [[\"name or description\", \"kind word\", 1]],\n\\"s\": [[\"the sentence that states it, verbatim\", \"subject name\", \"relation phrase as written\", \"object name\", null, {\"to\": \"name of a listed thing\", \"amount\": \"$2 million\"}, \"when it holds or happened, as written\", \"when it ended, as written\"]],\n\- \"n\": [[\"name as listed in e\", \"another name\", \"the sentence that uses it, verbatim\"]]}\n\+ \"n\": [[\"name as listed in e\", \"another name\", \"the sentence that uses it, verbatim\"]],\n\+ \"t\": [[\"now\", \"label as written\", \"the date as written\", {\"y\": 2011, \"m\": 3, \"d\": 4}, null]]}\n\\n\1. \"e\" lists the things the passage talks about, one entry each: [name, kind, named]. Every \thing a statement refers to is listed here once, under exactly the name the statements use. \@@ -180,22 +183,36 @@ the coating are part of the description.\n\words that say when it stopped, each copied exactly as written (\"March 4, 2011\", \"去年冬天\", \\"by the end of next season\"). Never compute, convert or normalise a date, and never write one \the passage does not. Each is null when the passage gives none.\n\+ Words that say when go in when or ended and nowhere else, never in the phrase, the \+object, the value or a qualifier; also when they count from now or from another event \+(\"三个月后\", \"last week\", \"six months after the launch\") and when the statement is \+planned. If that leaves no value, the value is the word for what happened (\"发布\"). A \+statement with no time of its own, under a heading that names one time and nothing else \+(\"## 2025年第三季度\"), takes the heading's words as when.\n\6. Every \"s\" and \"n\" entry carries its own quote, copied verbatim from the passage: the first \slot of an \"s\" entry, the last slot of an \"n\" entry.\n\7. \"n\" lists other names, one entry each: [name as listed, other name, quote] — a short form, \a former name, a spelling in another script that this passage uses for a thing in \"e\" or a \thing already recorded. Only names actually written in the passage; never a pronoun or a \description.\n\-8. State nothing the passage does not state, and state each thing once: with a value or with \+8. \"t\" lists the dates the passage states about the document itself, one entry each: \+[kind, label, words, from, to]. kind is \"now\" for the moment the text speaks from (a \+dateline, the date a report was submitted or published, a meeting's date), \"date\" for any \+other labelled date (a cut-off, an effective date, a deadline), \"period\" for a named period \+with stated bounds. label and words are copied as written; from and to transcribe the numbers \+the words state (y, m, d), to only for a period. A date inside a sentence about something that \+happened is that statement's when and is not listed. [] when there are none.\n\+9. State nothing the passage does not state, and state each thing once: with a value or with \an object, not both. The Document line, the opening of the document and the list of things \already recorded only say where the passage comes from; write nothing about them. If the \-passage states nothing, output {\"e\":[],\"s\":[],\"n\":[]}.\n\+passage states nothing, output {\"e\":[],\"s\":[],\"n\":[],\"t\":[]}.\n\\n\Example. The passage \"The city council awarded the paving contract to Brightway Builders for \$2 million on March 4, 2011.\" gives:\n\{\"e\": [[\"city council\", \"council\", 0], [\"paving contract\", \"contract\", 0], [\"Brightway Builders\", \"builders\", 1]],\n\\"s\": [[\"The city council awarded the paving contract to Brightway Builders for $2 million on March 4, 2011.\", \"city council\", \"awarded\", \"paving contract\", null, {\"to\": \"Brightway Builders\", \"amount\": \"$2 million\"}, \"March 4, 2011\", null]],\n\- \"n\": []}";+ \"n\": [],\n\+ \"t\": []}";/// 构造开放抽取的两条消息:常量系统消息 + `Document:` / 开头 / 已知实体 / `Passage:`。///@@ -446,6 +463,12 @@ pub fn parse_open_response(raw: &str) -> anyhow::Result<OpenExtraction> {None => out.skipped += 1,}}+ for item in items(&value, "t") {+ match crate::time::time_entry(item) {+ Some(t) => out.time.push(t),+ None => out.skipped += 1,+ }+ }Ok(out)}@@ -765,10 +788,16 @@ mod tests {assert!(!s.contains("Relation types"), "{s}");assert!(!s.contains("Attributes ("), "{s}");assert!(!s.contains("\"q\""), "没有引文表: {s}");- assert!(!s.contains("\"t\""), "没有时间表: {s}");assert!(!s.contains("k1"), "句柄不给模型看: {s}");}assert!(system.contains("Never compute, convert or normalise a date"));+ // 0064:文档自己说到的日期由这一块报上来(`t`),时间词只进 when / ended;+ // 提示词里仍然没有文档日期,也不让模型算+ assert!(+ system.contains("\"t\" lists the dates the passage states about the document itself")+ );+ assert!(system.contains("go in when or ended and nowhere else"));+ assert!(system.contains("transcribe the numbers"));assert!(system.contains("do not translate it into any vocabulary of your own"));assert!(system.contains("written exactly as listed in \"e\""));assert!(system.contains("copied verbatim"));diff --git a/crates/utopia-extract/src/time.rs b/crates/utopia-extract/src/time.rsindex c7339789..dd723960 100644--- a/crates/utopia-extract/src/time.rs+++ b/crates/utopia-extract/src/time.rs@@ -36,6 +36,10 @@ use crate::{json_block, json_text};#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]pub struct DateParts {pub year: i32,+ /// 写明的年里的第几季度(「2025年第三季度」「Q3 2025」),1–4;有它就没有月。+ /// 季度到月份是日历算术,归代码(0045 决定 2):模型只抄「第三」这个数+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub quarter: Option<u32>,pub month: Option<u32>,pub day: Option<u32>,pub hour: Option<u32>,@@ -55,7 +59,7 @@ impl DateParts {Granularity::Hour} else if self.day.is_some() {Granularity::Day- } else if self.month.is_some() {+ } else if self.month.is_some() || self.quarter.is_some() {Granularity::Month} else {Granularity::Year@@ -67,6 +71,9 @@ impl DateParts {impl fmt::Display for DateParts {fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {write!(f, "{}", self.year)?;+ if let Some(q) = self.quarter {+ write!(f, "-Q{q}")?;+ }if let Some(m) = self.month {write!(f, "-{m:02}")?;}@@ -94,10 +101,106 @@ pub struct NamedPeriod {pub to: DateParts,}+/// 文档说到的一个日期,连它的名字和它管到哪(0064 决定 1)。抽取每一块时报上来,+/// 服务端核对字在块里、算出它所在的标题路径,存在文档的时间语境里。+///+/// 一篇文档不止一个日期,哪个都不比别的大:提报日期、数据统计截止、生效日期各管各的事。+/// 相对的时间词从哪天起算,看它所在的那一节里哪个 `now` 在管([`now_in_force`])+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]+pub struct TimeEntry {+ /// `now`:文本说话的那一刻(电头、报告的提报日、会议的日期);+ /// `date`:文本给了名字的别的日期(截止、生效、期限);`period`:命名的期间+ pub kind: String,+ /// the label as written ("提报日期", "Data as of"); empty for a bare dateline+ pub name: String,+ /// the date words as written+ pub words: String,+ pub from: DateParts,+ pub to: Option<DateParts>,+ /// the headings the entry was stated under, outermost first; it governs what sits under them+ #[serde(default)]+ pub scope: Vec<String>,+ /// the chunk that stated it and where in it (set by the server)+ #[serde(default)]+ pub chunk: Option<String>,+ #[serde(default)]+ pub char_start: Option<i32>,+}++/// 块的正文里,这个字符位置之前还在管着的标题,由外到内。+///+/// 判据是结构的:行首连着的 `#` 是标题的级,同级或更深的旧标题被新标题顶掉。分块器让+/// 每一块以它所在的标题开头,所以一块自己的正文就说得出它在哪一节——不靠块与块的先后,+/// 块并行抽的时候照样成立(#588)+pub fn headings_at(text: &str, char_pos: usize) -> Vec<String> {+ let mut stack: Vec<(usize, String)> = Vec::new();+ let mut seen = 0usize;+ for line in text.split_inclusive('\n') {+ if seen > char_pos {+ break;+ }+ let trimmed = line.trim();+ let level = trimmed.chars().take_while(|c| *c == '#').count();+ if (1..=6).contains(&level) {+ let title = trimmed[level..].trim();+ if !title.is_empty() && trimmed[level..].starts_with(char::is_whitespace) {+ stack.retain(|(l, _)| *l < level);+ stack.push((level, title.to_string()));+ }+ }+ seen += line.chars().count();+ }+ stack.into_iter().map(|(_, t)| t).collect()+}++/// 这个位置上管事的那个 `now`:所在的标题路径以它的范围开头的里面,范围最深的那个;+/// 同一层有几个时取先说的。没有就是 `None`——相对的时间词锚不到,等着(0045 决定 4)+pub fn now_in_force<'a>(entries: &'a [TimeEntry], path: &[String]) -> Option<&'a TimeEntry> {+ let mut best: Option<&TimeEntry> = None;+ for e in entries.iter().filter(|e| e.kind == "now") {+ if e.scope.len() <= path.len()+ && e.scope.iter().zip(path).all(|(a, b)| a == b)+ && best.is_none_or(|b| e.scope.len() > b.scope.len())+ {+ best = Some(e);+ }+ }+ best+}++/// 抽取回复里的一条 `t`:`[kind, name, words, from, to]`。部件是照字抄的数字,出界的、+/// 缺字的都是坏条目+pub fn time_entry(item: &Value) -> Option<TimeEntry> {+ let a = item.as_array()?;+ let text = |i: usize| a.get(i).and_then(Value::as_str).map(str::trim);+ let kind = text(0)?.to_lowercase();+ if !matches!(kind.as_str(), "now" | "date" | "period") {+ return None;+ }+ let words = text(2).filter(|w| !w.is_empty())?;+ let from = parts(a.get(3)?)?;+ let to = match a.get(4) {+ None | Some(Value::Null) => None,+ Some(v) => Some(parts(v)?),+ };+ Some(TimeEntry {+ kind,+ name: text(1).unwrap_or("").to_string(),+ words: words.to_string(),+ from,+ to,+ scope: Vec::new(),+ chunk: None,+ char_start: None,+ })+}+/// 文档自己的时间语境(决定 3):从开头读出来、存在文档上、每块都带着#[derive(Debug, Clone, Default, Serialize, Deserialize)]#[serde(default)]pub struct DocumentDating {+ /// 抽取时各块报上来的日期(0064):有它们就不再另问一次开头+ pub entries: Vec<TimeEntry>,/// the document's own date as the text states it (a dateline, a filing date, a bulletin's/// reporting year); None when the text gives nonepub date: Option<DateParts>,@@ -132,6 +235,9 @@ pub enum Shape {pub enum Granularity {Year,Month,+ /// 阶梯上没有「周」(0024):说到周的提法(「上周」)落在日这一档。模型照字报 week,+ /// 从前整条解释因此被当成坏条目丢掉,「上周」就永远没有日期+ #[serde(alias = "week")]Day,Hour,Minute,@@ -288,7 +394,9 @@ Output one JSON object and nothing else, shaped like this:\n\{\"kind\": \"absolute\", \"from\": {\"y\": 2011, \"m\": 3, \"d\": 4}} — the words state the \value. Parts are transcribed digits: y the year, m the month (a month name becomes its number), \d the day, and h, min, s for a clock time; write only the parts the words state. A bare year \-(\"2019\") is {\"y\": 2019} with granularity \"year\". \"to\" is added only for an interval the \+(\"2019\") is {\"y\": 2019} with granularity \"year\". A quarter of a stated year is written \+with q, the number of the quarter as the words give it, and no month: \"Q3 2025\" and \"2025年\+第三季度\" are {\"y\": 2025, \"q\": 3} with granularity \"month\". \"to\" is added only for an interval the \words write out with both bounds (\"from March to May 2024\": from {\"y\": 2024, \"m\": 3}, to \{\"y\": 2024, \"m\": 5}).\n\{\"kind\": \"anchored\", \"anchor\": {\"kind\": \"document\"}, \"offset\": {\"count\": 1, \@@ -444,7 +552,12 @@ fn parts(v: &Value) -> Option<DateParts> {return None;}let year = i32::try_from(int(v.get("y")?)?).ok()?;+ let quarter = part(v, "q", 1..=4)?;let month = part(v, "m", 1..=12)?;+ // 季度和月不同时写:写了季度就是说到季度为止+ if quarter.is_some() && month.is_some() {+ return None;+ }let day = part(v, "d", 1..=31)?;let hour = part(v, "h", 0..=23)?;let minute = part(v, "min", 0..=59)?;@@ -461,6 +574,7 @@ fn parts(v: &Value) -> Option<DateParts> {}Some(DateParts {year,+ quarter,month,day,hour,@@ -644,8 +758,126 @@ pub fn parse_interpretation_response(mod tests {use super::*;+ #[test]+ fn the_headings_in_force_are_read_from_the_chunk_itself() {+ let text = "# 周报汇编\n\n## 第35周周报\n\n提报日期:2026年8月28日\n\n### 风险\n无。\n\n## 第36周周报\n\n上周开售。\n";+ let at = |needle: &str| {+ text.chars().count() - text[text.find(needle).unwrap()..].chars().count()+ };+ assert_eq!(+ headings_at(text, at("提报日期")),+ vec!["周报汇编", "第35周周报"]+ );+ assert_eq!(+ headings_at(text, at("无。")),+ vec!["周报汇编", "第35周周报", "风险"]+ );+ // 同级的新标题顶掉旧的,连同它下面更深的+ assert_eq!(+ headings_at(text, at("上周开售")),+ vec!["周报汇编", "第36周周报"]+ );+ // `#` 后面没有空白的不是标题(`#588`、`#标签`)+ assert_eq!(+ headings_at("#588 是一个编号\n正文", 12),+ Vec::<String>::new()+ );+ }++ #[test]+ fn the_now_in_force_is_the_one_of_the_innermost_section_that_holds_the_position() {+ let entry = |words: &str, scope: &[&str], kind: &str| TimeEntry {+ kind: kind.into(),+ name: "提报日期".into(),+ words: words.into(),+ from: DateParts {+ quarter: None,+ year: 2026,+ month: Some(9),+ day: Some(4),+ hour: None,+ minute: None,+ second: None,+ },+ to: None,+ scope: scope.iter().map(|s| s.to_string()).collect(),+ chunk: None,+ char_start: None,+ };+ let entries = vec![+ entry("2026年3月28日", &["汇编"], "now"),+ entry("2026年8月28日", &["汇编", "第35周"], "now"),+ entry("2026年9月4日", &["汇编", "第36周"], "now"),+ entry("2026年8月31日", &["汇编", "第36周"], "date"),+ ];+ let path = |p: &[&str]| p.iter().map(|s| s.to_string()).collect::<Vec<_>>();+ assert_eq!(+ now_in_force(&entries, &path(&["汇编", "第36周"]))+ .unwrap()+ .words,+ "2026年9月4日"+ );+ assert_eq!(+ now_in_force(&entries, &path(&["汇编", "第35周", "风险"]))+ .unwrap()+ .words,+ "2026年8月28日"+ );+ // 别的节里的不管这里;退到整篇的那个+ assert_eq!(+ now_in_force(&entries, &path(&["汇编", "附录"]))+ .unwrap()+ .words,+ "2026年3月28日"+ );+ assert!(now_in_force(&entries[1..], &path(&["别的文档"])).is_none());+ }++ #[test]+ fn a_quarter_of_a_stated_year_is_transcribed_not_computed() {+ let q = parts(&serde_json::json!({"y": 2025, "q": 3})).unwrap();+ assert_eq!((q.year, q.quarter, q.month), (2025, Some(3), None));+ assert_eq!(q.granularity(), Granularity::Month);+ assert_eq!(q.to_string(), "2025-Q3");+ // 季度和月不同时写;第五季度不存在+ assert!(parts(&serde_json::json!({"y": 2025, "q": 3, "m": 7})).is_none());+ assert!(parts(&serde_json::json!({"y": 2025, "q": 5})).is_none());+ // 老数据里没有这一格:读回来是 None,写出去不带这一格+ let old: DateParts = serde_json::from_value(serde_json::json!({+ "year": 2024, "month": 3, "day": null, "hour": null, "minute": null, "second": null+ }))+ .unwrap();+ assert_eq!(old.quarter, None);+ assert!(serde_json::to_value(&old).unwrap().get("quarter").is_none());+ }++ #[test]+ fn a_context_entry_is_read_with_its_parts_and_a_bad_one_is_refused() {+ let ok = serde_json::json!(["now", "提报日期", "2026年9月4日", {"y": 2026, "m": 9, "d": 4}, null]);+ let e = time_entry(&ok).unwrap();+ assert_eq!(+ (e.kind.as_str(), e.name.as_str(), e.words.as_str()),+ ("now", "提报日期", "2026年9月4日")+ );+ assert_eq!(e.from.to_string(), "2026-09-04");+ let period = serde_json::json!(["period", "报告期", "2025年1月1日至2025年12月31日", {"y": 2025, "m": 1, "d": 1}, {"y": 2025, "m": 12, "d": 31}]);+ assert_eq!(+ time_entry(&period).unwrap().to.unwrap().to_string(),+ "2025-12-31"+ );+ for bad in [+ serde_json::json!(["today", "x", "2026", {"y": 2026}, null]),+ serde_json::json!(["now", "x", "", {"y": 2026}, null]),+ serde_json::json!(["now", "x", "13月", {"y": 2026, "m": 13}, null]),+ serde_json::json!(["now", "x", "2026"]),+ ] {+ assert!(time_entry(&bad).is_none(), "{bad}");+ }+ }+fn ymd(y: i32, m: u32, d: u32) -> DateParts {DateParts {+ quarter: None,year: y,month: Some(m),day: Some(d),@@ -657,6 +889,7 @@ mod tests {fn year(y: i32) -> DateParts {DateParts {+ quarter: None,year: y,month: None,day: None,@@ -820,6 +1053,7 @@ mod tests {items[8].reference,Reference::Absolute {from: DateParts {+ quarter: None,year: 2024,month: Some(3),day: None,@@ -828,6 +1062,7 @@ mod tests {second: None},to: Some(DateParts {+ quarter: None,year: 2024,month: Some(5),day: None,diff --git a/crates/utopia-server/src/extraction_open.rs b/crates/utopia-server/src/extraction_open.rsindex 430f1ade..ea25b66b 100644--- a/crates/utopia-server/src/extraction_open.rs+++ b/crates/utopia-server/src/extraction_open.rs@@ -748,6 +748,19 @@ fn locate_time(chunk: &str, quote: Option<(&str, Option<(i32, i32)>)>, words: &sif on_table_row {return locate(chunk, words).map(|(s, _)| s);}+ // 标题上的时间(0064):一节的标题只说了一个时间(「## 2025年第三季度」),它下面没写+ // 时间的陈述拿它当 when。判据也是结构的:这几个字在块里一行 `#` 开头的标题行上+ let (start, _) = locate(chunk, words)?;+ let byte = chunk+ .char_indices()+ .nth(start.max(0) as usize)+ .map_or(chunk.len(), |(b, _)| b);+ let line_start = chunk[..byte].rfind('\n').map_or(0, |i| i + 1);+ let line = chunk[line_start..].lines().next().unwrap_or("");+ let level = line.trim_start().chars().take_while(|c| *c == '#').count();+ if (1..=6).contains(&level) {+ return Some(start);+ }None}@@ -921,6 +934,10 @@ pub(crate) async fn run_open(// 名字向量的嵌入客户端(0041 决定 3 通道 2)。没配嵌入模型就是 None:召回退回// 字面相等,抽取照常let embed = settings.and_then(crate::llm_util::embed_client);+ // 文档自己说到的日期(0064 决定 1):每一块报上来的,连它所在的标题路径。块与块之间+ // 不传——一条日期管到哪,看的是它自己那一块正文里的标题,块并行抽的时候照样成立(#588)+ let mut time_entries: Vec<utopia_extract::time::TimeEntry> = Vec::new();+ let mut extracted_chunks: Vec<Uuid> = Vec::new();for chunk in chunks.iter() {// 被接管则安静退场(重抽自增 epoch):检查放在调用模型之前if utopia_store::documents::extract_epoch(pool, document_id).await? != my_epoch {@@ -970,6 +987,36 @@ pub(crate) async fn run_open(extraction,name_vecs,} = parsed;+ extracted_chunks.push(chunk.id);+ for entry in &extraction.time {+ // 字要原样在这一块里(与名字、引文同一条规矩);核不到的不算+ let Some((start, _)) = locate(&chunk.text, &entry.words) else {+ drop_signal(+ state,+ kb_id,+ document_id,+ reason::TIME_NOT_IN_QUOTE,+ "a date the passage was said to state is not in the passage",+ Some(&entry.words),+ )+ .await;+ continue;+ };+ let scope =+ utopia_extract::time::headings_at(&chunk.text, usize::try_from(start).unwrap_or(0));+ if time_entries+ .iter()+ .any(|e| e.kind == entry.kind && e.words == entry.words && e.scope == scope)+ {+ continue;+ }+ time_entries.push(utopia_extract::time::TimeEntry {+ scope,+ chunk: Some(chunk.id.to_string()),+ char_start: Some(start),+ ..entry.clone()+ });+ }apply_open_extraction(state,pool,@@ -1013,6 +1060,36 @@ pub(crate) async fn run_open(utopia_store::documents::set_graph_status(pool, document_id, "done").await?;state.emit_document(kb_id, document_id);state.emit_graph(kb_id);+ // 文档的时间语境(0064):这一轮各块报上来的日期并进文档上存着的那份。没抽到的块+ // (增量抽取时认领的未变段落)原来报的留着;这一轮抽过的块以这一轮的为准。+ // 一条都没有就不写:解析那一步照旧读一次开头(老路是它的兜底)+ let mut context: utopia_extract::time::DocumentDating = doc+ .time_context+ .clone()+ .and_then(|json| serde_json::from_value(json).ok())+ .unwrap_or_default();+ let redone: HashSet<String> = extracted_chunks.iter().map(Uuid::to_string).collect();+ context+ .entries+ .retain(|e| e.chunk.as_ref().is_some_and(|c| !redone.contains(c)));+ context.entries.extend(time_entries);+ if !context.entries.is_empty() {+ // 整篇的起算点:范围最浅的那个 `now`,同一层取先说的。它只是相对时间词在没有更近的+ // 起算点时的基准,不盖在任何一条事实上(0064 决定 2)+ let whole = context+ .entries+ .iter()+ .filter(|e| e.kind == "now")+ .min_by_key(|e| e.scope.len());+ context.date = whole.map(|e| e.from.clone());+ context.date_words = whole.map(|e| e.words.clone());+ utopia_store::documents::set_time_context(+ pool,+ document_id,+ &serde_json::to_value(&context)?,+ )+ .await?;+ }// 时间词的解析是它后面的任务(0045):文档时间上下文 + 每个提及的解释 + 算区间utopia_store::jobs::enqueue_unless_queued(pool,diff --git a/crates/utopia-server/src/time_context_tests.rs b/crates/utopia-server/src/time_context_tests.rsnew file mode 100644index 00000000..0cf4a730--- /dev/null+++ b/crates/utopia-server/src/time_context_tests.rs@@ -0,0 +1,215 @@+//! 相对的时间词从它自己那一节的日期起算(0064 决定 1、4)。+//!+//! 一篇文档收了两份周报,每一节有自己的提报日期,每一节里都有一句「上周……」。抽取每一块+//! 报上它那一段说到的日期(`t`),服务端从那一块正文里的标题算出这条日期管到哪;解析时+//! 每条时间词按它所在的那一节找起算点。所以两句「上周」算出来差一周,而不是都从第一份+//! 周报的日期起算。模型照字报的粒度 `week` 落在日这一档。事后不再另问一次开头。+//!+//! 块与块之间什么都不传:两块的提示词里都没有对方的日期(#588,块并行抽的时候照样成立)。+//!+//! 脚本化的模型端点、真库,与 `extraction_open_known_flow_tests.rs` 同一个做法。+//! 没有 `UTOPIA_DATABASE_URL` 时跳过而不是失败。自建自拆,绝不碰已有的库。+use super::*;+use axum::{extract::State, response::IntoResponse, routing::post, Json, Router};+use serde_json::{json, Value};+use std::sync::{Arc, Mutex};++#[derive(Clone)]+struct Model {+ replies: Arc<Mutex<Vec<String>>>,+ requests: Arc<Mutex<Vec<Value>>>,+}++async fn reply(State(m): State<Model>, Json(body): Json<Value>) -> impl IntoResponse {+ m.requests.lock().unwrap().push(body);+ let text = {+ let mut replies = m.replies.lock().unwrap();+ if replies.is_empty() {+ panic!("unexpected model request");+ }+ replies.remove(0)+ };+ let frame = json!({"choices":[{"delta":{"content":text}}]});+ let done = json!({"choices":[{"delta":{},"finish_reason":"stop"}]});+ (+ [("content-type", "text/event-stream")],+ format!("data: {frame}\n\ndata: {done}\n\ndata: [DONE]\n\n"),+ )+}++const WEEK_35: &str =+ "# 周报汇编\n\n## 第35周周报\n\n提报日期:2026年8月28日\n\n上周,码表一代在韩国市场开售。";+const WEEK_36: &str =+ "# 周报汇编\n\n## 第36周周报\n\n提报日期:2026年9月4日\n\n上周,码表一代在泰国市场开售。";++#[tokio::test]+async fn last_week_is_counted_from_the_date_of_its_own_section() -> anyhow::Result<()> {+ let Some(url) = utopia_store::test_db::url() else {+ return Ok(());+ };+ let pool = sqlx::PgPool::connect(&url).await?;+ utopia_store::db::migrate(&pool).await?;+ let ids: Vec<Uuid> = (0..6).map(|_| Uuid::now_v7()).collect();+ let (org, ws, kb, doc, chunk0, chunk1) = (ids[0], ids[1], ids[2], ids[3], ids[4], ids[5]);+ sqlx::raw_sql(&format!(+ "INSERT INTO organizations(id,name) VALUES ('{org}','time-context');+ INSERT INTO workspaces(id,org_id,name) VALUES ('{ws}','{org}','time-context');+ INSERT INTO knowledge_bases(id,workspace_id,name) VALUES ('{kb}','{ws}','time-context');+ INSERT INTO documents(id,kb_id,filename,sha256) VALUES ('{doc}','{kb}','周报汇编.md','x');"+ ))+ .execute(&pool)+ .await?;+ for (id, seq, text) in [(chunk0, 0, WEEK_35), (chunk1, 1, WEEK_36)] {+ sqlx::query("INSERT INTO chunks(id,kb_id,document_id,seq,text) VALUES ($1,$2,$3,$4,$5)")+ .bind(id)+ .bind(kb)+ .bind(doc)+ .bind(seq)+ .bind(text)+ .execute(&pool)+ .await?;+ }+ let anchored = json!({+ "kind": "anchored", "anchor": {"kind": "document"},+ "offset": {"count": 1, "unit": "week", "direction": "before"}+ });+ let model = Model {+ replies: Arc::new(Mutex::new(vec![+ json!({+ "e": [["码表一代", "产品", 1], ["韩国市场", "市场", 1]],+ "s": [["上周,码表一代在韩国市场开售。", "码表一代", "开售于", "韩国市场", null, null, "上周", null]],+ "n": [],+ "t": [["now", "提报日期", "2026年8月28日", {"y": 2026, "m": 8, "d": 28}, null]]+ })+ .to_string(),+ json!({+ "e": [["泰国市场", "市场", 1]],+ "s": [["上周,码表一代在泰国市场开售。", "码表一代", "开售于", "泰国市场", null, null, "上周", null]],+ "n": [],+ "t": [+ ["now", "提报日期", "2026年9月4日", {"y": 2026, "m": 9, "d": 4}, null],+ // 字不在这一块里的日期不算+ ["date", "数据截止", "2026年8月31日", {"y": 2026, "m": 8, "d": 31}, null]+ ]+ })+ .to_string(),+ // 解析:两条「上周」字和句子都不同,各是一条;粒度照字报 week+ json!({ "m": [[0, "point", anchored, "week"], [1, "point", anchored, "week"]] })+ .to_string(),+ ])),+ requests: Arc::new(Mutex::new(Vec::new())),+ };+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?;+ let endpoint = format!("http://{}", listener.local_addr()?);+ let router = Router::new()+ .route("/chat/completions", post(reply))+ .with_state(model.clone());+ let server = tokio::spawn(async move { axum::serve(listener, router).await.unwrap() });+ utopia_store::settings::upsert(+ &pool,+ ws,+ Some(&endpoint),+ None,+ Some("scripted"),+ None,+ None,+ None,+ None,+ )+ .await?;+ let dir = tempfile::tempdir()?;+ let cfg = 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"),+ )?);+ let state = AppState::new(pool.clone(), &cfg, search, "test-only".into());++ let run = async {+ crate::extraction::extract_document(&state, doc, utopia_core::models::Proposer::default())+ .await?;+ // 文档上存下了两条起算点,各带它所在的标题路径;字不在块里的那条没进来+ let context: DocumentDating = serde_json::from_value(+ sqlx::query_scalar::<_, Value>("SELECT time_context FROM documents WHERE id=$1")+ .bind(doc)+ .fetch_one(&pool)+ .await?,+ )?;+ let entries: Vec<(String, String, Vec<String>)> = context+ .entries+ .iter()+ .map(|e| (e.kind.clone(), e.words.clone(), e.scope.clone()))+ .collect();+ assert_eq!(+ entries,+ vec![+ (+ "now".to_string(),+ "2026年8月28日".to_string(),+ vec!["周报汇编".to_string(), "第35周周报".to_string()]+ ),+ (+ "now".to_string(),+ "2026年9月4日".to_string(),+ vec!["周报汇编".to_string(), "第36周周报".to_string()]+ ),+ ]+ );+ // 块与块之间什么都没传:第二块的提示词里没有第一块的日期之外的东西可依赖——+ // 它自己的正文里本来就有自己的标题和日期+ let second = model.requests.lock().unwrap()[1]["messages"][1]["content"]+ .as_str()+ .unwrap_or("")+ .to_string();+ assert!(second.contains("第36周周报") && second.contains("2026年9月4日"));++ resolve_document(&state, doc).await?;+ assert_eq!(+ model.requests.lock().unwrap().len(),+ 3,+ "two extraction calls and one interpretation call: the opening is not asked for a date"+ );+ let dated: Vec<(String, Option<DateTime<Utc>>, Option<String>)> = sqlx::query_as(+ "SELECT o.canonical_name, f.valid_from, f.valid_from_grade+ FROM facts f JOIN entities o ON o.id = f.object_id+ WHERE f.kb_id = $1 AND f.layer = 'open' ORDER BY o.canonical_name",+ )+ .bind(kb)+ .fetch_all(&pool)+ .await?;+ let day = |y, m, d| Utc.with_ymd_and_hms(y, m, d, 0, 0, 0).unwrap();+ assert_eq!(+ dated,+ vec![+ // 第 36 周的「上周」从 9 月 4 日起算+ (+ "泰国市场".to_string(),+ Some(day(2026, 8, 28)),+ Some("B".to_string())+ ),+ // 第 35 周的「上周」从 8 月 28 日起算+ (+ "韩国市场".to_string(),+ Some(day(2026, 8, 21)),+ Some("B".to_string())+ ),+ ]+ );+ Ok::<(), anyhow::Error>(())+ }+ .await;++ server.abort();+ sqlx::query("DELETE FROM jobs WHERE payload->>'document_id'=$1 OR payload->>'kb_id'=$2")+ .bind(doc.to_string())+ .bind(kb.to_string())+ .execute(&pool)+ .await?;+ sqlx::query("DELETE FROM organizations WHERE id=$1")+ .bind(org)+ .execute(&pool)+ .await?;+ run+}diff --git a/crates/utopia-server/src/time_resolution.rs b/crates/utopia-server/src/time_resolution.rsindex dc1a5c11..83637081 100644--- a/crates/utopia-server/src/time_resolution.rs+++ b/crates/utopia-server/src/time_resolution.rs@@ -20,9 +20,10 @@ use crate::state::AppState;use chrono::{DateTime, Duration, Months, NaiveDate, NaiveTime, TimeZone, Utc};use std::collections::HashMap;use utopia_extract::time::{- build_dating_messages, build_interpretation_messages, parse_dating_response,- parse_interpretation_response, Anchor, DateParts, Direction, DocumentDating, Granularity,- Interpretation, MentionInput, Offset, Reference, Shape, TimeContext, Unit,+ build_dating_messages, build_interpretation_messages, headings_at, now_in_force,+ parse_dating_response, parse_interpretation_response, Anchor, DateParts, Direction,+ DocumentDating, Granularity, Interpretation, MentionInput, NamedPeriod, Offset, Reference,+ Shape, TimeContext, Unit,};use utopia_store::graph::{truncate_to, ENDED_UNKNOWN, WORLD_PRECISIONS};use uuid::Uuid;@@ -53,6 +54,9 @@ const UNRESOLVED: Resolved = Resolved {/// 数字部分 → 时刻与精度。精度是字写到的那一档:只有年就是年。fn parts_to_time(p: &DateParts) -> Option<(DateTime<Utc>, &'static str)> {+ // 写明的季度从它的头一个月起(日历季度;财年的季度走命名的期间)+ let month = p.month.or(p.quarter.map(|q| (q - 1) * 3 + 1));+ let p = &DateParts { month, ..p.clone() };let date = NaiveDate::from_ymd_opt(p.year, p.month.unwrap_or(1), p.day.unwrap_or(1))?;let time = NaiveTime::from_hms_opt(p.hour.unwrap_or(0),@@ -248,6 +252,15 @@ fn resolve_one(return UNRESOLVED;};let until = to.as_ref().and_then(parts_to_time);+ // 一个季度是三个月的区间:到它最后一个月为止+ if let (Some(_), None) = (from.quarter, &until) {+ let last = t.checked_add_months(Months::new(2)).map(|m| (m, "month"));+ let shape = match interp.shape {+ Shape::Point | Shape::Duration => Shape::Interval,+ s => s,+ };+ return place(shape, Some((t, "month")), last, "A");+ }place(interp.shape, Some((t, coarser(p, g))), until, "A")}Reference::Anchored { anchor, offset } => {@@ -369,9 +382,18 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Relet client = llm_util::chat_client(&settings).ok_or_else(|| anyhow::anyhow!("Chat model not configured; cannot resolve time"))?;- // 1. 文档时间上下文:一篇只问一次+ // 1. 文档时间上下文:一篇只问一次。抽取已经报上来的(0064)不再问let context: DocumentDating = match doc.time_context.clone() {- Some(json) => serde_json::from_value(json)?,+ Some(json) => {+ let context: DocumentDating = serde_json::from_value(json)?;+ // 整篇的起算点照旧记成文档的日期(文库排序、引擎给没起点的行排次序都读它)+ if crate::extraction_open::dated_at(&doc).is_none() {+ if let Some((t, _)) = context.date.as_ref().and_then(parts_to_time) {+ utopia_store::documents::set_content_date(pool, document_id, t).await?;+ }+ }+ context+ }None => {let opening = utopia_store::documents::opening_chunk(pool, document_id).await?@@ -404,20 +426,73 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Re}};+ // 抽取报上来的期间(0064)并进文档命名的期间里:解释时按名字指它+ let mut context = context;+ for e in context+ .entries+ .clone()+ .iter()+ .filter(|e| e.kind == "period")+ {+ let name = if e.name.is_empty() { &e.words } else { &e.name };+ if let (Some(to), false) = (+ e.to.clone(),+ context+ .periods+ .iter()+ .any(|p| p.name.eq_ignore_ascii_case(name)),+ ) {+ context.periods.push(NamedPeriod {+ name: name.clone(),+ from: e.from.clone(),+ to,+ });+ }+ }+ let context = context;+// 2. 提及:同一篇里同样的字在同样的句子里只解释一次let mentions = utopia_store::time_mentions::for_document(pool, document_id).await?;if mentions.is_empty() {return Ok(());}- let mut distinct: Vec<(String, String)> = Vec::new();- let mut index: HashMap<(String, String), usize> = HashMap::new();+ // 每条提及所在的那一节里管事的起算点(0064 决定 4):从它那一块正文里的标题读出所在的+ // 节,再在文档报上来的日期里找范围最深的那个 `now`。一篇文档里两份周报各有各的提报日,+ // 「上周」在哪一节就从哪一节的日期起算。没有条目的文档(老的、推送来的)照旧用文档的日期+ let chunk_text: HashMap<Uuid, String> =+ sqlx::query_as::<_, (Uuid, String)>("SELECT id, text FROM chunks WHERE document_id = $1")+ .bind(document_id)+ .fetch_all(pool)+ .await?+ .into_iter()+ .collect();+ let now_of = |m: &utopia_store::time_mentions::MentionToResolve| -> Option<usize> {+ let text = chunk_text.get(&m.chunk_id)?;+ let path = headings_at(text, usize::try_from(m.char_start).unwrap_or(0));+ let found = now_in_force(&context.entries, &path)?;+ context.entries.iter().position(|e| std::ptr::eq(e, found))+ };+ type Key = (String, String, Option<usize>);+ let mut distinct: Vec<Key> = Vec::new();+ let mut index: HashMap<Key, usize> = HashMap::new();+ let mut key_of: HashMap<Uuid, Key> = HashMap::new();for m in &mentions {- let key = (m.text.clone(), m.sentence.clone());+ let key = (m.text.clone(), m.sentence.clone(), now_of(m));+ key_of.insert(m.id, key.clone());if !index.contains_key(&key) {index.insert(key.clone(), distinct.len());distinct.push(key);}}+ // 算的时候文档的日期换成那一节的起算点+ let context_at = |now: Option<usize>| -> DocumentDating {+ let mut c = context.clone();+ if let Some(e) = now.and_then(|i| context.entries.get(i)) {+ c.date = Some(e.from.clone());+ c.date_words = Some(e.words.clone());+ }+ c+ };let ctx = TimeContext {date: context.date.as_ref(),date_words: context.date_words.as_deref(),@@ -426,22 +501,36 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Re};let mut resolved: HashMap<usize, (Interpretation, Resolved)> = HashMap::new();let mut malformed = 0usize;- for (batch_no, batch) in distinct.chunks(BATCH).enumerate() {- let base = (batch_no * BATCH) as i64;- let inputs: Vec<MentionInput<'_>> = batch- .iter()- .enumerate()- .map(|(i, (text, sentence))| MentionInput {- id: base + i as i64,- text,- sentence,- })- .collect();- let ids: Vec<i64> = inputs.iter().map(|m| m.id).collect();- let messages = build_interpretation_messages(&ctx, &inputs);- let reply =- match chat_retrying_rate_limits_at(state, &settings, &client, &messages, Some(0.0))- .await+ // 问两轮:第一轮全部,第二轮只问第一轮没答到的。模型漏答的提及从前就留着字、没有解释,+ // 也没有人再问(测量台上的「上周」三遍都是这样)+ let mut todo: Vec<usize> = (0..distinct.len()).collect();+ for round in 0..2 {+ if round == 1 {+ todo.retain(|i| !resolved.contains_key(i));+ if todo.is_empty() {+ break;+ }+ tracing::info!(%document_id, unanswered = todo.len(), "时间解释有没答到的,再问一次");+ }+ for batch in todo.clone().chunks(BATCH) {+ let inputs: Vec<MentionInput<'_>> = batch+ .iter()+ .map(|&i| MentionInput {+ id: i as i64,+ text: &distinct[i].0,+ sentence: &distinct[i].1,+ })+ .collect();+ let ids: Vec<i64> = inputs.iter().map(|m| m.id).collect();+ let messages = build_interpretation_messages(&ctx, &inputs);+ let reply = match chat_retrying_rate_limits_at(+ state,+ &settings,+ &client,+ &messages,+ Some(0.0),+ )+ .await{Ok(r) => r,Err(e) => {@@ -449,34 +538,43 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Recontinue;}};- let (interps, skipped) = match parse_interpretation_response(&reply.text, &ids) {- Ok(x) => x,- Err(e) => {- tracing::warn!(%document_id, error = %e, "时间解释回复解析失败,这一批留作未解析");- continue;- }- };- malformed += skipped;- // 两遍:先算不靠别的提及的,再算指着别的提及的- let mut earlier: HashMap<i64, Resolved> = HashMap::new();- let anchored_to_mention = |i: &Interpretation| {- matches!(- &i.reference,- Reference::Anchored {- anchor: Anchor::Mention { .. },- ..+ let (interps, skipped) = match parse_interpretation_response(&reply.text, &ids) {+ Ok(x) => x,+ Err(e) => {+ tracing::warn!(%document_id, error = %e, "时间解释回复解析失败,这一批留作未解析");+ continue;}- )- };- for pass in 0..2 {- for interp in interps- .iter()- .filter(|i| anchored_to_mention(i) == (pass == 1))- {- let r = resolve_one(interp, &context, &earlier);- earlier.insert(interp.id, r);- if let Ok(i) = usize::try_from(interp.id) {- resolved.insert(i, (interp.clone(), r));+ };+ malformed += skipped;+ if skipped > 0 {+ // 坏条目要看得见是哪一条、坏在哪:只报一个数的话,「上周」三遍都没日期也查不出原因+ tracing::warn!(%document_id, skipped, reply = %reply.text.chars().take(600).collect::<String>(), "时间解释里有读不了的条目");+ }+ // 两遍:先算不靠别的提及的,再算指着别的提及的+ let mut earlier: HashMap<i64, Resolved> = HashMap::new();+ let anchored_to_mention = |i: &Interpretation| {+ matches!(+ &i.reference,+ Reference::Anchored {+ anchor: Anchor::Mention { .. },+ ..+ }+ )+ };+ for pass in 0..2 {+ for interp in interps+ .iter()+ .filter(|i| anchored_to_mention(i) == (pass == 1))+ {+ let now = usize::try_from(interp.id)+ .ok()+ .and_then(|i| distinct.get(i))+ .and_then(|k| k.2);+ let r = resolve_one(interp, &context_at(now), &earlier);+ earlier.insert(interp.id, r);+ if let Ok(i) = usize::try_from(interp.id) {+ resolved.insert(i, (interp.clone(), r));+ }}}}@@ -486,7 +584,7 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::Relet mut per_fact: HashMap<Uuid, (Option<Resolved>, Option<Resolved>)> = HashMap::new();let (mut a, mut b, mut c) = (0usize, 0usize, 0usize);for m in &mentions {- let Some(&i) = index.get(&(m.text.clone(), m.sentence.clone())) else {+ let Some(&i) = key_of.get(&m.id).and_then(|k| index.get(k)) else {continue;};let Some((interp, r)) = resolved.get(&i) else {@@ -555,6 +653,10 @@ pub async fn resolve_document(state: &AppState, document_id: Uuid) -> anyhow::ReOk(())}+#[cfg(test)]+#[path = "time_context_tests.rs"]+mod context_tests;+#[cfg(test)]mod tests {use super::*;@@ -562,6 +664,7 @@ mod tests {fn parts(y: i32, m: Option<u32>, d: Option<u32>) -> DateParts {DateParts {+ quarter: None,year: y,month: m,day: d,@@ -575,6 +678,7 @@ mod tests {}fn ctx_dated(y: i32, m: u32, d: u32) -> DocumentDating {DocumentDating {+ entries: Vec::new(),date: Some(parts(y, Some(m), Some(d))),date_words: Some("x".into()),periods: vec![NamedPeriod {@@ -702,6 +806,28 @@ mod tests {);}+ #[test]+ fn a_stated_quarter_is_the_three_months_it_names() {+ let i = Interpretation {+ id: 0,+ shape: Shape::Point,+ reference: Reference::Absolute {+ from: DateParts {+ quarter: Some(3),+ ..parts(2025, None, None)+ },+ to: None,+ },+ granularity: Granularity::Month,+ };+ let r = resolve_one(&i, &DocumentDating::default(), &HashMap::new());+ assert_eq!(r.grade, "A");+ assert_eq!(r.from, Some(at("2025-07-01T00:00:00Z")));+ assert_eq!(r.from_p, Some("month"));+ assert_eq!(r.to, Some(at("2025-09-01T00:00:00Z")));+ assert_eq!(r.to_p, Some("month"));+ }+#[test]fn two_years_later_follows_the_mention_it_names() {let mut earlier = HashMap::new();diff --git a/docs/decisions/0064-extraction-reads-time-as-it-goes.md b/docs/decisions/0064-extraction-reads-time-as-it-goes.mdindex a3f6ce4e..20bd30ee 100644--- a/docs/decisions/0064-extraction-reads-time-as-it-goes.md+++ b/docs/decisions/0064-extraction-reads-time-as-it-goes.md@@ -1,6 +1,6 @@# 0064 · Extraction reads time as it goes-- **Status**: Accepted 2026-09-28 · nothing built · the time context is carried from chunk to chunk during extraction, as [0045](0045-a-time-mention-is-resolved-against-its-document.md) decision 3 wrote it and cut 2 did not build it; a statement without time words may take an as-of from the context; there is no single document date stamped on facts; a fact with no time holds at every moment+- **Status**: In progress · accepted 2026-09-28 · cut 1 built (#990, the bench) · cut 2 built (#991): each chunk reports the dates its passage states with the headings they sit under, a relative expression is measured from the reference point of its own section, a heading that names one time dates the statements under it, a quarter and a week are read · open: cut 3 (as-of, null attestation, reads, the workbench line), cut 4 · decision 1 is revised below: the context does not depend on the order chunks are read in- **Written**: 2026-09-28 (conventions in the [README](README.md))- **Related**: [#987](https://github.com/deeplethe/utopia/issues/987) (every relation of an entity reads "undated"); [0045](0045-a-time-mention-is-resolved-against-its-document.md) decisions 1–5, which this record keeps and whose cut 2 it replaces; [0022](0022-an-unknown-date-is-not-an-open-one.md) decision 3 and the lower bound of a start-less row; [0044](0044-the-ontology-is-a-view-over-what-documents-say.md) cut 1 (open statements); [#714](https://github.com/deeplethe/utopia/issues/714); draft [#988](https://github.com/deeplethe/utopia/pull/988), which this supersedes@@ -27,14 +27,16 @@ Three things are wrong and they are one thing.## Decisions-**1. The time context is built while extracting, chunk by chunk.** Chunks of a document are already extracted in order, each seeing the named things recorded before it. The time context travels the same way. Each extraction call receives it and returns, beside statements and time mentions, what the chunk adds to it. It holds four kinds of entry, each with the words as written and the chunk they came from:+**1. The time context is built while extracting, from what each chunk states.** Each extraction call returns, beside statements and time mentions, the dates its passage states about the document's own time. It holds four kinds of entry, each with the words as written and the chunk they came from:- **reference points**: the moment the text speaks from ("提报日期 2026年9月4日", a dateline, "会议时间"), with the span it governs: the document, or the section under a heading;- **named dates**: every date the text gives a name to ("数据统计截止", "生效日期", "下次评审"), kept with its name, none promoted over another;- **periods and calendars**: as 0045 decision 3 has them;- **anchors the narrative sets**: an event the text has dated ("上市" is 2024-03), so a later "上市半年后" or "验厂后两个月" has something to be measured from.-The separate dating call over the opening goes away. The context is stored with the document as today.+The separate dating call over the opening goes away when extraction reported any entry, and stays as the fallback when it reported none. The context is stored with the document as today.++*Revised with cut 2 (2026-09-28).* As first written this decision had the context travel from chunk to chunk in the prompt, the way the list of recorded things does. That ties time to the order chunks are read in, and #588 is moving the model calls of one document to run at once. What an entry governs is decided by structure instead: the chunker opens every chunk with the headings it lives under, so the chunk's own text says which section a date was stated in and which section a time word sits in. The scope of an entry is the heading path at its position; the reference point in force for a mention is the `now` entry with the deepest scope that is a prefix of the mention's path. Nothing is passed between calls, and the result is the same whether chunks are read one after another or together. Narrative anchors (the fourth kind) stay with the mentions of 0045: a dated mention is already an anchor for a later one in the same document.**2. There is no document date on facts.** A date a source system gives (a feed's publish time, a filing date) enters the context as a reference point like any other. Nothing picks one date for the document and writes it on every statement. `documents.doc_time` stays for sources that date documents and for sorting the library; it is not an attestation.@@ -52,6 +54,8 @@ As-of is not a start. "码表所属市场为全球" in a report of 4 September s**6. Interpretation rides with extraction.** With the context present, the mention and its interpretation are returned by the same call. The batch interpretation step stays only for re-resolution when an anchor arrives later (0045 cut 4).+*Not built with cut 2.* The batch step stays as it is; it asks once more for the mentions a reply left out, and says in the log which item it could not read. Folding it into the extraction call is measured separately: the extraction prompt is the one every other number depends on.+## Not doing- A single date per document chosen by a model, for any purpose.@@ -65,11 +69,11 @@ A bench before any change, `scripts/bench/timewords.mjs`: documents in Chinese a| Number | Today | Threshold for cut 2 ||---|---|---|-| time expressions recorded as mentions | 2 of 7 on the weekly report | 90% |-| recorded mentions resolved to the right interval | 2 of 2 | 95% absolute, 85% anchored (0045's) |+| time expressions recorded as mentions | 18–20 of 29 (the bench; the first hand check said 2 of 7 on one report and was too low) | 90% · cut 2: 27–29 of 29 |+| starts right | absolute 4 of 4, relative to now 9 of 15, relative to a dated event 3 of 3, on a heading 0 of 6 | 95% absolute, 85% anchored (0045's) · cut 2: 11 of 12, 42 of 45, 9 of 9, 18 of 18 over three runs || statements with no time words given the right as-of | none | 80%, and none given a start |-| the same document, three runs: statements dated the same | differs | 90% agree |-| tokens per chunk | measured with cut 1 | no higher than extraction + dating + interpretation today |+| the same document, three runs: sentences with the same outcome | 34 of 39 | 90% agree · cut 2: 34 of 39, the differences are sentences not extracted at all |+| tokens per chunk | 5.7k–7.3k | no higher than today · cut 2: 6.1k–8.5k, about a tenth higher |## Cutsdiff --git a/docs/decisions/README.md b/docs/decisions/README.mdindex 1e02e1c5..5755b526 100644--- a/docs/decisions/README.md+++ b/docs/decisions/README.md@@ -144,7 +144,7 @@ By domain; the domains are the files of [../design/](../design/README.md). **Sta| 0042 | [The chat loop is a runner with hooks](0042-the-chat-loop-is-a-runner-with-hooks.md) | Implemented | || 0046 | [The app surface is MCP](0046-the-app-surface-is-mcp.md) | Accepted | || 0063 | [Stopping a chat ends the generation](0063-stopping-a-chat-ends-the-generation.md) | Implemented | |-| 0064 | [Extraction reads time as it goes](0064-extraction-reads-time-as-it-goes.md) | Accepted | |+| 0064 | [Extraction reads time as it goes](0064-extraction-reads-time-as-it-goes.md) | In progress | |### processdiff --git a/scripts/bench/README.md b/scripts/bench/README.mdindex c1f4a037..c7c71137 100644--- a/scripts/bench/README.md+++ b/scripts/bench/README.md@@ -289,7 +289,7 @@ node scripts/bench/agent.mjs --kb <kb-id> --db utopia_bench4 --reset --arms trim## 时间词的测量台(0064)-`timewords.mjs` 把 `truth/timewords.json` 里五篇写好的文档(三篇中文、两篇英文,31 句)各传进一个新库,+`timewords.mjs` 把 `truth/timewords.json` 里七篇写好的文档(五篇中文、两篇英文,39 句)各传进一个新库,抽取、解析之后逐句对:这句话抽出来没有、它的时间说法记成时间词没有、起点落在期望的区间里没有、没写时间的句子有没有被硬给一个起点、「截至」对不对,以及几遍之间每句话的结果一不一样。每一遍建一个新库,不删任何东西。@@ -302,24 +302,30 @@ BENCH_SERVER_LOG=/path/to/server.log node scripts/bench/timewords.mjs --db utopi句子按种类分:`absolute`(写明的日期)、`relative_now`(相对文本说话的那一刻:三个月后、上周、today)、`relative_event`(相对一件有日期的事:上市半年后)、`relative_undated_event`(相对一件没日期的事,期望不写起点)、`section`(时间在节标题上)、`none`(没写时间,期望没有起点,「截至」来自上下文)。+语料里有三篇是为了跨块写的:发出比开会晚一个月的会议纪要(起算点选错看得出来)、两份周报汇编成的+一篇(每一节有自己的提报日期)、季度写在节标题上而且离开头很远的年度回顾。-**基线,2026-09-28,dev d7756a4,gemini-3.5-flash,三遍:**+**2026-09-28,gemini-3.5-flash,各三遍(三遍的数用 / 隔开):**-| | 第 1 遍 | 第 2 遍 | 第 3 遍 |-|---|---|---|---|-| 句子抽到了 | 30/31 | 29/31 | 31/31 |-| 时间说法记成了时间词 | 16/21 | 16/21 | 16/21 |-| 起点对:写明的 | 4/4 | 4/4 | 4/4 |-| 起点对:相对此刻 | 7/11 | 7/11 | 7/11 |-| 起点对:相对有日期的事 | 3/3 | 3/3 | 3/3 |-| 起点对:节标题上的时间 | 0/2 | 0/2 | 0/2 |-| 没写时间的没被给起点 | 10/10 | 10/10 | 10/10 |-| 「截至」对 | 0/10 | 0/10 | 0/10 |-| 每块 token | 7,990 | 9,047 | 10,207 |--三遍里结果一致的句子 28/31。丢的是四种:「三个月后发布」「下个月启动」没记成时间词(词进了宾语);-「上周」记下了但没算出来;「in two months」三遍对一遍;节标题上的季度到不了它下面的句子。「截至」一栏-是 0:没写时间的陈述今天拿到的是处理文档的那一刻,不是文档里任何一个日期。+| | dev(第 2 刀之前) | 0064 第 2 刀 |+|---|---|---|+| 句子抽到了(39) | 36 / 36 / 39 | 37 / 38 / 37 |+| 时间说法记成了时间词(29) | 18 / 19 / 20 | 28 / 29 / 27 |+| 起点对:写明的(4) | 4 / 4 / 4 | 3 / 4 / 4 |+| 起点对:相对此刻(15) | 9 / 9 / 9 | 14 / 15 / 13 |+| 起点对:相对有日期的事(3) | 3 / 3 / 3 | 3 / 3 / 3 |+| 起点对:节标题上的时间(6) | 0 / 0 / 0 | 6 / 6 / 6 |+| 没写时间的没被给起点 | 10/10 ×3 | 9/9、9/9、10/10 |+| 「截至」对(10) | 0 / 0 / 0 | 0 / 0 / 0 |+| 每块 token | 6,490 / 5,744 / 7,306 | 6,142 / 7,204 / 8,470 |+| 三遍结果一致的句子 | 34/39 | 34/39 |++- 之前丢的四种:计划类的句子时间词进了宾语(「码表二代 — 发布 → 将在三个月后」);「上周」记下了但+ 解释被当成坏条目丢掉(模型照字报粒度 week,阶梯上没有这一档);汇编里第二份周报的「上周」从第一份的+ 提报日期起算;节标题上的季度到不了它下面的句子。第 2 刀之后剩下的错几乎都是那句话整句没抽到+ (`?`),是抽取本身的波动,不是时间。+- 「截至」一栏第 3 刀才动:没写时间的陈述今天拿到的是处理文档的那一刻。+- 每块 token 多了一成上下:提示词多了两段规则、回复多了 `t`,少了事后读开头的那一次调用。## 读数怎么算diff --git a/scripts/bench/truth/timewords.json b/scripts/bench/truth/timewords.jsonindex 2b59a6b5..4913f1de 100644--- a/scripts/bench/truth/timewords.json+++ b/scripts/bench/truth/timewords.json@@ -5,61 +5,361 @@"filename": "zh-weekly.md","text": "# 码表项目周报\n\n提报日期:2026年9月4日\n\n## 计划\n码表二代将在三个月后发布。\n上周,码表一代在日本市场开售。\n去年,码表一代进入北美市场。\n明年第一季度,码表三代启动立项。\n\n## 回顾\n码表一代于2024年3月在欧洲上市。上市半年后,码表一代销量突破十万台。\n东莞工厂完成验厂后两个月,码表二代开始试产。\n\n## 归属\n码表所属市场为全球。码表所属BU为户外BU。\n","expect": [- { "key": "三个月后发布", "kind": "relative_now", "from": ["2026-12-01", "2026-12-31"] },- { "key": "在日本市场开售", "kind": "relative_now", "from": ["2026-08-24", "2026-09-03"] },- { "key": "进入北美市场", "kind": "relative_now", "from": ["2025-01-01", "2025-12-31"] },- { "key": "三代启动立项", "kind": "relative_now", "from": ["2027-01-01", "2027-03-31"] },- { "key": "在欧洲上市", "kind": "absolute", "from": ["2024-03-01", "2024-03-31"] },- { "key": "销量突破十万台", "kind": "relative_event", "from": ["2024-09-01", "2024-09-30"] },- { "key": "开始试产", "kind": "relative_undated_event", "from": null },- { "key": "所属市场为全球", "kind": "none", "as_of": ["2026-09-04", "2026-09-04"], "as_of_name": "提报日期" },- { "key": "所属BU为户外BU", "kind": "none", "as_of": ["2026-09-04", "2026-09-04"], "as_of_name": "提报日期" }+ {+ "key": "三个月后发布",+ "kind": "relative_now",+ "from": [+ "2026-12-01",+ "2026-12-31"+ ]+ },+ {+ "key": "在日本市场开售",+ "kind": "relative_now",+ "from": [+ "2026-08-24",+ "2026-09-03"+ ]+ },+ {+ "key": "进入北美市场",+ "kind": "relative_now",+ "from": [+ "2025-01-01",+ "2025-12-31"+ ]+ },+ {+ "key": "三代启动立项",+ "kind": "relative_now",+ "from": [+ "2027-01-01",+ "2027-03-31"+ ]+ },+ {+ "key": "在欧洲上市",+ "kind": "absolute",+ "from": [+ "2024-03-01",+ "2024-03-31"+ ]+ },+ {+ "key": "销量突破十万台",+ "kind": "relative_event",+ "from": [+ "2024-09-01",+ "2024-09-30"+ ]+ },+ {+ "key": "开始试产",+ "kind": "relative_undated_event",+ "from": null+ },+ {+ "key": "所属市场为全球",+ "kind": "none",+ "as_of": [+ "2026-09-04",+ "2026-09-04"+ ],+ "as_of_name": "提报日期"+ },+ {+ "key": "所属BU为户外BU",+ "kind": "none",+ "as_of": [+ "2026-09-04",+ "2026-09-04"+ ],+ "as_of_name": "提报日期"+ }]},{"filename": "zh-minutes.md",- "text": "# 码表产品评审会议纪要\n\n会议时间:2026年8月20日\n纪要发出:2026年8月22日\n下次评审:2026年9月15日\n\n## 决议\n会议决定下个月启动码表二代试产。\n码表固件负责人为李雷。\n码表二代采用多模GNSS方案。\n\n## 背景\n两年前,码表一代完成立项。\n",+ "text": "# 码表产品评审会议纪要\n\n会议时间:2026年8月20日\n纪要发出:2026年9月25日\n下次评审:2026年9月15日\n\n## 决议\n会议决定下个月启动码表二代试产。\n码表固件负责人为李雷。\n码表二代采用多模GNSS方案。\n\n## 背景\n两年前,码表一代完成立项。\n","expect": [- { "key": "下个月启动码表二代试产", "kind": "relative_now", "from": ["2026-09-01", "2026-09-30"] },- { "key": "完成立项", "kind": "relative_now", "from": ["2024-01-01", "2024-12-31"] },- { "key": "固件负责人为李雷", "kind": "none", "as_of": ["2026-08-20", "2026-08-20"], "as_of_name": "会议时间" },- { "key": "采用多模GNSS方案", "kind": "none", "as_of": ["2026-08-20", "2026-08-20"], "as_of_name": "会议时间" }+ {+ "key": "下个月启动码表二代试产",+ "kind": "relative_now",+ "from": [+ "2026-09-01",+ "2026-09-30"+ ]+ },+ {+ "key": "完成立项",+ "kind": "relative_now",+ "from": [+ "2024-01-01",+ "2024-12-31"+ ]+ },+ {+ "key": "固件负责人为李雷",+ "kind": "none",+ "as_of": [+ "2026-08-20",+ "2026-08-20"+ ],+ "as_of_name": "会议时间"+ },+ {+ "key": "采用多模GNSS方案",+ "kind": "none",+ "as_of": [+ "2026-08-20",+ "2026-08-20"+ ],+ "as_of_name": "会议时间"+ }]},{"filename": "zh-report.md","text": "# 码表品类调研报告\n\n提报日期:2026年9月4日\n数据统计截止:2026年8月31日\n\n## 2025年第三季度\n码表销量为12万台。码表退货率为百分之二。\n\n## 供应链\n关键物料交期为8至12周。码表由东莞工厂代工。\n2026年第二季度起,码表主板改用国产芯片。\n","expect": [- { "key": "销量为12万台", "kind": "section", "from": ["2025-07-01", "2025-09-30"] },- { "key": "退货率为百分之二", "kind": "section", "from": ["2025-07-01", "2025-09-30"] },- { "key": "主板改用国产芯片", "kind": "absolute", "from": ["2026-04-01", "2026-06-30"] },- { "key": "关键物料交期", "kind": "none", "as_of": ["2026-08-31", "2026-09-04"], "as_of_name": "数据统计截止" },- { "key": "由东莞工厂代工", "kind": "none", "as_of": ["2026-08-31", "2026-09-04"], "as_of_name": "数据统计截止" }+ {+ "key": "销量为12万台",+ "kind": "section",+ "from": [+ "2025-07-01",+ "2025-09-30"+ ]+ },+ {+ "key": "退货率为百分之二",+ "kind": "section",+ "from": [+ "2025-07-01",+ "2025-09-30"+ ]+ },+ {+ "key": "主板改用国产芯片",+ "kind": "absolute",+ "from": [+ "2026-04-01",+ "2026-06-30"+ ]+ },+ {+ "key": "关键物料交期",+ "kind": "none",+ "as_of": [+ "2026-08-31",+ "2026-09-04"+ ],+ "as_of_name": "数据统计截止"+ },+ {+ "key": "由东莞工厂代工",+ "kind": "none",+ "as_of": [+ "2026-08-31",+ "2026-09-04"+ ],+ "as_of_name": "数据统计截止"+ }]},{"filename": "en-release.md","text": "# Acme to acquire Bolt\n\nAUSTIN, March 4, 2011\n\nAcme Corporation today announced the acquisition of Bolt Systems. The deal is expected to close in two months.\n\nBolt Systems was founded in 1998. Last year Acme opened an office in Lyon. Three years after its founding, Bolt Systems released its first compiler.\n\nAcme Corporation is headquartered in Austin. Bolt Systems employs 240 people.\n","expect": [- { "key": "announced the acquisition", "kind": "relative_now", "from": ["2011-03-04", "2011-03-04"] },- { "key": "expected to close in two months", "kind": "relative_now", "from": ["2011-05-01", "2011-05-31"] },- { "key": "was founded in 1998", "kind": "absolute", "from": ["1998-01-01", "1998-12-31"] },- { "key": "opened an office in Lyon", "kind": "relative_now", "from": ["2010-01-01", "2010-12-31"] },- { "key": "released its first compiler", "kind": "relative_event", "from": ["2001-01-01", "2001-12-31"] },- { "key": "is headquartered in Austin", "kind": "none", "as_of": ["2011-03-04", "2011-03-04"], "as_of_name": "dateline" },- { "key": "employs 240 people", "kind": "none", "as_of": ["2011-03-04", "2011-03-04"], "as_of_name": "dateline" }+ {+ "key": "announced the acquisition",+ "kind": "relative_now",+ "from": [+ "2011-03-04",+ "2011-03-04"+ ]+ },+ {+ "key": "expected to close in two months",+ "kind": "relative_now",+ "from": [+ "2011-05-01",+ "2011-05-31"+ ]+ },+ {+ "key": "was founded in 1998",+ "kind": "absolute",+ "from": [+ "1998-01-01",+ "1998-12-31"+ ]+ },+ {+ "key": "opened an office in Lyon",+ "kind": "relative_now",+ "from": [+ "2010-01-01",+ "2010-12-31"+ ]+ },+ {+ "key": "released its first compiler",+ "kind": "relative_event",+ "from": [+ "2001-01-01",+ "2001-12-31"+ ]+ },+ {+ "key": "is headquartered in Austin",+ "kind": "none",+ "as_of": [+ "2011-03-04",+ "2011-03-04"+ ],+ "as_of_name": "dateline"+ },+ {+ "key": "employs 240 people",+ "kind": "none",+ "as_of": [+ "2011-03-04",+ "2011-03-04"+ ],+ "as_of_name": "dateline"+ }]},{"filename": "en-report.md","text": "# Orion programme status\n\nPublished: August 12, 2025\nData as of: June 30, 2025\n\n## Figures\nOrion has 1,200 active users. Orion runs in three regions.\n\n## Plan\nNext quarter the team will launch Orion Mobile. Two weeks ago the team completed the security audit.\n\n## History\nOrion entered beta in January 2024. Six months later Orion reached general availability.\n","expect": [- { "key": "will launch Orion Mobile", "kind": "relative_now", "from": ["2025-10-01", "2025-12-31"] },- { "key": "completed the security audit", "kind": "relative_now", "from": ["2025-07-20", "2025-08-05"] },- { "key": "entered beta in January 2024", "kind": "absolute", "from": ["2024-01-01", "2024-01-31"] },- { "key": "reached general availability", "kind": "relative_event", "from": ["2024-07-01", "2024-07-31"] },- { "key": "1,200 active users", "kind": "none", "as_of": ["2025-06-30", "2025-08-12"], "as_of_name": "Data as of" },- { "key": "runs in three regions", "kind": "none", "as_of": ["2025-06-30", "2025-08-12"], "as_of_name": "Data as of" }+ {+ "key": "will launch Orion Mobile",+ "kind": "relative_now",+ "from": [+ "2025-10-01",+ "2025-12-31"+ ]+ },+ {+ "key": "completed the security audit",+ "kind": "relative_now",+ "from": [+ "2025-07-20",+ "2025-08-05"+ ]+ },+ {+ "key": "entered beta in January 2024",+ "kind": "absolute",+ "from": [+ "2024-01-01",+ "2024-01-31"+ ]+ },+ {+ "key": "reached general availability",+ "kind": "relative_event",+ "from": [+ "2024-07-01",+ "2024-07-31"+ ]+ },+ {+ "key": "1,200 active users",+ "kind": "none",+ "as_of": [+ "2025-06-30",+ "2025-08-12"+ ],+ "as_of_name": "Data as of"+ },+ {+ "key": "runs in three regions",+ "kind": "none",+ "as_of": [+ "2025-06-30",+ "2025-08-12"+ ],+ "as_of_name": "Data as of"+ }+ ]+ },+ {+ "filename": "zh-compiled.md",+ "text": "# 码表项目周报汇编\n\n本汇编收录码表项目连续两周的周报,每一节是一份独立的周报。\n\n## 第35周周报\n\n提报日期:2026年8月28日\n\n码表一代的固件团队在本周完成了三项例行工作:整理了用户反馈,复核了传感器标定流程,并且更新了内部测试用例清单。测试团队对续航、定位精度和防水性能做了回归验证,没有发现新的阻塞问题。供应链团队与两家屏幕供应商开了例会,确认了下一批物料的排产节奏。市场团队整理了各区域渠道的库存数据,准备在下一次周会上汇报。以上工作均按计划推进,没有需要升级的风险项。\n\n上周,码表一代在韩国市场开售。两个月后,码表一代将进入巴西市场。\n\n在质量方面,码表一代的售后数据保持稳定,主要的反馈集中在表带卡扣和充电底座的耐用性上。售后团队已经把这两类问题整理成清单,交给结构团队评估。结构团队表示会在下一轮设计评审里给出改进方案。与此同时,客服团队更新了常见问题的答复口径,并且在帮助中心增加了固件升级的图文指引。这些调整不涉及硬件变更,也不影响当前的出货计划。\n\n## 第36周周报\n\n提报日期:2026年9月4日\n\n码表一代的固件团队在本周完成了四项例行工作:整理了用户反馈,复核了传感器标定流程,并且更新了内部测试用例清单。测试团队对续航、定位精度和防水性能做了回归验证,没有发现新的阻塞问题。供应链团队与两家屏幕供应商开了例会,确认了下一批物料的排产节奏。市场团队整理了各区域渠道的库存数据,准备在下一次周会上汇报。以上工作均按计划推进,没有需要升级的风险项。\n\n上周,码表一代在泰国市场开售。明年,码表二代将进入印度市场。\n\n在质量方面,码表一代的售后数据略有改善,主要的反馈集中在表带卡扣和充电底座的耐用性上。售后团队已经把这两类问题整理成清单,交给结构团队评估。结构团队表示会在下一轮设计评审里给出改进方案。与此同时,客服团队更新了常见问题的答复口径,并且在帮助中心增加了固件升级的图文指引。这些调整不涉及硬件变更,也不影响当前的出货计划。\n",+ "expect": [+ {+ "key": "在韩国市场开售",+ "kind": "relative_now",+ "from": [+ "2026-08-17",+ "2026-08-27"+ ]+ },+ {+ "key": "进入巴西市场",+ "kind": "relative_now",+ "from": [+ "2026-10-01",+ "2026-10-31"+ ]+ },+ {+ "key": "在泰国市场开售",+ "kind": "relative_now",+ "from": [+ "2026-08-24",+ "2026-09-03"+ ]+ },+ {+ "key": "进入印度市场",+ "kind": "relative_now",+ "from": [+ "2027-01-01",+ "2027-12-31"+ ]+ }+ ]+ },+ {+ "filename": "zh-long.md",+ "text": "# 码表品类年度回顾\n\n发布日期:2026年3月28日\n\n码表一代的固件团队在报告期内完成了三项例行工作:整理了用户反馈,复核了传感器标定流程,并且更新了内部测试用例清单。测试团队对续航、定位精度和防水性能做了回归验证,没有发现新的阻塞问题。供应链团队与两家屏幕供应商开了例会,确认了下一批物料的排产节奏。市场团队整理了各区域渠道的库存数据,准备在下一次周会上汇报。以上工作均按计划推进,没有需要升级的风险项。\n\n在质量方面,码表一代的售后数据保持稳定,主要的反馈集中在表带卡扣和充电底座的耐用性上。售后团队已经把这两类问题整理成清单,交给结构团队评估。结构团队表示会在下一轮设计评审里给出改进方案。与此同时,客服团队更新了常见问题的答复口径,并且在帮助中心增加了固件升级的图文指引。这些调整不涉及硬件变更,也不影响当前的出货计划。\n\n## 2025年第三季度\n\n码表一代的固件团队在这一季度完成了三项例行工作:整理了用户反馈,复核了传感器标定流程,并且更新了内部测试用例清单。测试团队对续航、定位精度和防水性能做了回归验证,没有发现新的阻塞问题。供应链团队与两家屏幕供应商开了例会,确认了下一批物料的排产节奏。市场团队整理了各区域渠道的库存数据,准备在下一次周会上汇报。以上工作均按计划推进,没有需要升级的风险项。\n\n码表出货量为30万台。码表平均售价为899元。\n\n## 2025年第四季度\n\n在质量方面,码表一代的售后数据继续改善,主要的反馈集中在表带卡扣和充电底座的耐用性上。售后团队已经把这两类问题整理成清单,交给结构团队评估。结构团队表示会在下一轮设计评审里给出改进方案。与此同时,客服团队更新了常见问题的答复口径,并且在帮助中心增加了固件升级的图文指引。这些调整不涉及硬件变更,也不影响当前的出货计划。\n\n码表出货量为45万台。码表平均售价为849元。\n",+ "expect": [+ {+ "key": "出货量为30万台",+ "kind": "section",+ "from": [+ "2025-07-01",+ "2025-09-30"+ ]+ },+ {+ "key": "平均售价为899元",+ "kind": "section",+ "from": [+ "2025-07-01",+ "2025-09-30"+ ]+ },+ {+ "key": "出货量为45万台",+ "kind": "section",+ "from": [+ "2025-10-01",+ "2025-12-31"+ ]+ },+ {+ "key": "平均售价为849元",+ "kind": "section",+ "from": [+ "2025-10-01",+ "2025-12-31"+ ]+ }]}]