From c859c86cc4d1c5969b30bdbbcc08ae53129f23db Mon Sep 17 00:00:00 2001 From: Bogdan Szabo Date: Tue, 20 Oct 2026 11:21:10 +0200 Subject: [PATCH 1/2] A statements source that declares its names identities attaches them by exact name and computes no name vectors for them Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Bogdan Szabo --- crates/utopia-core/src/models.rs | 26 ++++ crates/utopia-server/src/extraction.rs | 39 ++++-- crates/utopia-server/src/extraction_open.rs | 13 +- .../extraction_open_identity_names_tests.rs | 126 ++++++++++++++++++ crates/utopia-store/src/resolution.rs | 58 +++++++- ...dentity_name_attaches_by_its_exact_name.rs | 123 +++++++++++++++++ crates/utopia-store/tests/store/main.rs | 1 + ...source-may-declare-its-names-identities.md | 3 +- docs/decisions/README.md | 2 +- web/src/docs/ingest.md | 2 + 10 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 crates/utopia-server/src/extraction_open_identity_names_tests.rs create mode 100644 crates/utopia-store/tests/store/an_identity_name_attaches_by_its_exact_name.rs diff --git a/crates/utopia-core/src/models.rs b/crates/utopia-core/src/models.rs index a32be0210..13e0bcaaf 100644 --- a/crates/utopia-core/src/models.rs +++ b/crates/utopia-core/src/models.rs @@ -181,6 +181,13 @@ impl Source { .and_then(serde_json::Value::as_bool) .unwrap_or(true) } + + /// statements 来源的 config 写了 `{"names": "identity"}`:它推来的每个名字各指一个 + /// 确定的东西(0071),按字面归并、不算名字向量。其余来源照旧。 + pub fn names_are_identities(&self) -> bool { + self.kind == "statements" + && self.config.get("names").and_then(serde_json::Value::as_str) == Some("identity") + } } #[cfg(test)] @@ -217,6 +224,25 @@ mod source_extracts_tests { assert!(with(serde_json::json!({ "extract": 0 })).extracts()); assert!(!with(serde_json::json!({ "extract": false })).extracts()); } + + fn of_kind(kind: &str, config: serde_json::Value) -> Source { + Source { + kind: kind.into(), + ..with(config) + } + } + + #[test] + fn only_a_statements_source_with_the_string_identity_has_identity_names() { + let identity = serde_json::json!({ "names": "identity" }); + assert!(of_kind("statements", identity.clone()).names_are_identities()); + assert!(!of_kind("api", identity).names_are_identities()); + assert!(!of_kind("statements", serde_json::json!({})).names_are_identities()); + assert!(!of_kind("statements", serde_json::json!({ "names": true })).names_are_identities()); + assert!( + !of_kind("statements", serde_json::json!({ "names": "prose" })).names_are_identities() + ); + } } /// 来源配置里**用来鉴权**的那几个键。凭据只进不出:列表与创建 / 更新的响应都剔掉, diff --git a/crates/utopia-server/src/extraction.rs b/crates/utopia-server/src/extraction.rs index 6b7ae44fb..993655e63 100644 --- a/crates/utopia-server/src/extraction.rs +++ b/crates/utopia-server/src/extraction.rs @@ -209,12 +209,23 @@ async fn resolve_uncached( name_vec: Option<&[f32]>, text: Option<&str>, exclude: &[Uuid], + identity: bool, needs_adjudication: &mut bool, ) -> anyhow::Result { - let r = utopia_store::resolution::resolve_mention( - pool, kb_id, type_id, name, ctx, name_vec, text, exclude, - ) - .await?; + let r = match identity { + true => { + utopia_store::resolution::resolve_identity_name( + pool, kb_id, type_id, name, ctx, text, exclude, + ) + .await? + } + false => { + utopia_store::resolution::resolve_mention( + pool, kb_id, type_id, name, ctx, name_vec, text, exclude, + ) + .await? + } + }; // 疑似重复对(画像灰区 / 类型漂移 / 同名并列)入审核队列。多数走批量裁决器, // 同名并列(`ReviewStage::Human`)分不出谁是谁,只能等人裁——它自己带着 stage。 for review in &r.reviews { @@ -268,6 +279,7 @@ pub(crate) async fn resolve_handle( ctx: Option<&[f32]>, name_vec: Option<&[f32]>, text: Option<&str>, + identity: bool, response_claims: &mut HashMap>, handled_by_name: &mut HashMap>, ambiguous_bare_cache: &mut HashMap, @@ -309,6 +321,7 @@ pub(crate) async fn resolve_handle( name_vec, text, &excluded, + identity, needs_adjudication, ) .await?; @@ -343,10 +356,14 @@ async fn run(state: &AppState, document_id: Uuid, proposer: Proposer) -> anyhow: } let kb = utopia_store::kbs::get(&state.pool, doc.kb_id).await?; // 推送来的陈述(0054):块就是契约,抽取按契约解析、不问模型,没配对话模型也照抽 - let pushed = crate::pipeline::source_kind(state, doc.source_id) - .await? - .as_deref() - == Some("statements"); + let source = match doc.source_id { + Some(id) => Some(utopia_store::sources::get(&state.pool, id).await?), + None => None, + }; + let pushed = source.as_ref().is_some_and(|s| s.kind == "statements"); + let identity = source + .as_ref() + .is_some_and(utopia_core::models::Source::names_are_identities); // settings 有就传:推送路径不问对话模型,但名字向量的嵌入模型(#877)仍从它来 let settings = utopia_store::settings::get(&state.pool, kb.workspace_id).await?; let client = if pushed { @@ -376,6 +393,7 @@ async fn run(state: &AppState, document_id: Uuid, proposer: Proposer) -> anyhow: proposer, await_nod, pushed, + identity, ) .await } @@ -496,6 +514,7 @@ mod tests { None, None, None, + false, &mut response_claims, &mut document_claims, &mut bare_cache, @@ -510,6 +529,7 @@ mod tests { None, None, None, + false, &mut response_claims, &mut document_claims, &mut bare_cache, @@ -588,6 +608,7 @@ mod tests { None, None, None, + false, &mut later_response_claims, &mut document_claims, &mut bare_cache, @@ -616,6 +637,7 @@ mod tests { None, None, None, + false, &mut another_response_claims, &mut document_claims, &mut bare_cache, @@ -743,6 +765,7 @@ mod tests { Some(&ctx), None, None, + false, &mut response_claims, &mut document_claims, &mut bare_cache, diff --git a/crates/utopia-server/src/extraction_open.rs b/crates/utopia-server/src/extraction_open.rs index bac9f8ea1..56a1f9534 100644 --- a/crates/utopia-server/src/extraction_open.rs +++ b/crates/utopia-server/src/extraction_open.rs @@ -251,6 +251,7 @@ async fn apply_open_extraction( attested_at: Option>, bound_types: &HashMap, pushed: bool, + identity: bool, await_nod: bool, proposer: Proposer, pending_count: &mut usize, @@ -291,6 +292,7 @@ async fn apply_open_extraction( ctx, name_vecs.get(&key).map(Vec::as_slice), Some(&chunk.text), + identity, &mut response_claims, handled_by_name, ambiguous_bare_cache, @@ -971,6 +973,8 @@ pub(crate) async fn run_open( proposer: Proposer, await_nod: bool, pushed: bool, + // 0071: the source's names are identities, so they get no name vectors + identity: bool, ) -> anyhow::Result<()> { let pool = &state.pool; let document_id = doc.id; @@ -1005,7 +1009,9 @@ pub(crate) async fn run_open( // 名字向量的嵌入客户端(0041 决定 3 通道 2)。没配嵌入模型就是 None:召回退回 // 字面相等,抽取照常 - let embed = settings.and_then(crate::llm_util::embed_client); + let embed = settings + .and_then(crate::llm_util::embed_client) + .filter(|_| !identity); // 文档自己说到的日期(0064 决定 1):每一块报上来的,连它所在的标题路径。块与块之间 // 不传——一条日期管到哪,看的是它自己那一块正文里的标题,块并行抽的时候照样成立(#588) let mut time_entries: Vec = Vec::new(); @@ -1101,6 +1107,7 @@ pub(crate) async fn run_open( attested_at, &bound_types, pushed, + identity, await_nod, proposer, &mut pending_count, @@ -1243,6 +1250,10 @@ pub(crate) async fn run_open( #[path = "extraction_open_known_flow_tests.rs"] mod known_flow_tests; +#[cfg(test)] +#[path = "extraction_open_identity_names_tests.rs"] +mod identity_names_tests; + #[cfg(test)] #[path = "extraction_open_out_of_credit_tests.rs"] mod out_of_credit_tests; diff --git a/crates/utopia-server/src/extraction_open_identity_names_tests.rs b/crates/utopia-server/src/extraction_open_identity_names_tests.rs new file mode 100644 index 000000000..352f0853f --- /dev/null +++ b/crates/utopia-server/src/extraction_open_identity_names_tests.rs @@ -0,0 +1,126 @@ +//! A statements source with `{"names": "identity"}` (0071) gets no embedding call and no +//! `name_vector|` pair. The fake endpoint returns one vector for every name. +use super::*; +use axum::{routing::post, Json, Router}; +use serde_json::{json, Value}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Arc; + +/// Push `PUSHED` into a base holding `KNOWN` (with a name vector); answers (embedding calls, review reasons). +async fn push(config: Value) -> anyhow::Result)>> { + let Some(url) = utopia_store::test_db::url() else { + return Ok(None); + }; + let pool = sqlx::PgPool::connect(&url).await?; + utopia_store::db::migrate(&pool).await?; + let [org, ws, kb, source, doc, chunk, known_id]: [Uuid; 7] = + std::array::from_fn(|_| Uuid::now_v7()); + let text = serde_json::to_string(&json!({ + "external_id": "commit:identity", + "e": [[PUSHED, "SourceFile", true]], + "s": [[null, PUSHED, "path", null, "src/x.ts", null, null, null]], + "n": [] + }))?; + sqlx::raw_sql(&format!( + "INSERT INTO organizations(id,name) VALUES ('{org}','identity-names'); + INSERT INTO workspaces(id,org_id,name) VALUES ('{ws}','{org}','identity-names'); + INSERT INTO knowledge_bases(id,workspace_id,name) VALUES ('{kb}','{ws}','identity-names'); + INSERT INTO sources(id,kb_id,kind,name,config) VALUES + ('{source}','{kb}','statements','lore',$${config}$$::jsonb); + INSERT INTO documents(id,kb_id,filename,sha256,source_id) VALUES + ('{doc}','{kb}','commit.json','x{doc}','{source}'); + INSERT INTO chunks(id,kb_id,document_id,seq,text) VALUES + ('{chunk}','{kb}','{doc}',0,$${text}$$);" + )) + .execute(&pool) + .await?; + sqlx::query("INSERT INTO entities(id,kb_id,canonical_name) VALUES ($1,$2,$3)") + .bind(known_id) + .bind(kb) + .bind(KNOWN) + .execute(&pool) + .await?; + let fact = utopia_store::names::record(&pool, kb, known_id, KNOWN, None, None) + .await? + .expect("a named entity gets a name fact"); + utopia_store::name_vectors::set(&pool, kb, &[(fact, known_id, vec![1.0, 0.0, 0.0, 0.0])]) + .await?; + + let calls = Arc::new(AtomicUsize::new(0)); + let counted = calls.clone(); + let router = Router::new().route( + "/embeddings", + post(move |Json(body): Json| async move { + counted.fetch_add(1, Ordering::SeqCst); + let inputs = body["input"].as_array().map_or(0, Vec::len); + Json(json!({"data": vec![json!({"embedding": [1.0, 0.0, 0.0, 0.0]}); inputs]})) + }), + ); + let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await?; + let base = format!("http://{}", listener.local_addr()?); + let server = tokio::spawn(async move { axum::serve(listener, router).await.unwrap() }); + utopia_store::settings::upsert( + &pool, + ws, + None, + None, + None, + Some(&base), + None, + Some("fake-embed"), + Some(4), + ) + .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()); + crate::extraction::extract_document(&state, doc, utopia_core::models::Proposer::default()) + .await?; + + let reasons: Vec = sqlx::query_scalar( + "SELECT reason FROM resolution_reviews WHERE kb_id = $1 ORDER BY reason", + ) + .bind(kb) + .fetch_all(&pool) + .await?; + + server.abort(); + sqlx::query("DELETE FROM jobs WHERE payload->>'kb_id' = $1") + .bind(kb.to_string()) + .execute(&pool) + .await?; + sqlx::query("DELETE FROM organizations WHERE id = $1") + .bind(org) + .execute(&pool) + .await?; + Ok(Some((calls.load(Ordering::SeqCst), reasons))) +} + +const KNOWN: &str = "re-cinq/lore:src/a.ts"; +const PUSHED: &str = "re-cinq/lore:src/b.ts"; + +#[tokio::test] +async fn an_identity_source_adds_no_name_vectors_and_asks_no_neighbours() -> anyhow::Result<()> { + let Some(outcome) = push(json!({"names": "identity"})).await? else { + return Ok(()); + }; + assert_eq!(outcome, (0, Vec::::new())); + Ok(()) +} + +#[tokio::test] +async fn a_statements_source_without_the_flag_still_proposes_by_name_vector() -> anyhow::Result<()> +{ + let Some((calls, reasons)) = push(json!({})).await? else { + return Ok(()); + }; + assert!(calls > 0 && reasons.iter().any(|r| r.starts_with("name_vector|"))); + Ok(()) +} diff --git a/crates/utopia-store/src/resolution.rs b/crates/utopia-store/src/resolution.rs index b50571b50..5c4888221 100644 --- a/crates/utopia-store/src/resolution.rs +++ b/crates/utopia-store/src/resolution.rs @@ -362,6 +362,57 @@ async fn kept_apart_from(pool: &PgPool, kb_id: Uuid, entity_id: Uuid) -> AppResu Ok(rows.into_iter().map(|(id,)| id).collect()) } +/// 0071 决定 2、3:恰有一个活着的同名持有者(类为声明的类或无类)时,不看画像,直接归并; +/// 没有就新建,哪怕该名字在别的类下已有(类型漂移审核照留);两个及以上走原来的画像路径。 +/// 持有者按本名或名字事实认(合并会把输家的名字作为 known_as 移给存活者)。 +pub async fn resolve_identity_name( + pool: &PgPool, + kb_id: Uuid, + type_id: Option, + raw_name: &str, + context: Option<&[f32]>, + text: Option<&str>, + exclude: &[Uuid], +) -> AppResult { + let normalized = normalize_name(raw_name); + let name = fold_markdown_markers(&normalized); + let spellings = vec![normalized.to_lowercase(), name.to_lowercase()]; + let holders: Vec = sqlx::query_as(&format!( + "SELECT e.id, e.canonical_name, e.profile_embedding, e.profile_n + FROM entities e + WHERE e.kb_id = $1 AND e.merged_into IS NULL AND e.description IS NULL + AND (e.type_id IS NULL OR e.type_id = $2) + AND (lower(e.canonical_name) = ANY($3) OR {named})", + named = crate::names::has_name_in("e", 1, 3), + )) + .bind(kb_id) + .bind(type_id) + .bind(&spellings) + .fetch_all(pool) + .await? + .into_iter() + .filter(|holder: &Candidate| !exclude.contains(&holder.id)) + .collect(); + match holders.as_slice() { + [holder] => { + match context { + Some(ctx) => update_profile(pool, holder.id, holder.profile_n, ctx).await?, + None => touch_entity(pool, holder.id).await?, + } + Ok(Resolution { + entity_id: holder.id, + created: false, + reviews: Vec::new(), + }) + } + [] => { + let keys = recall_keys(&normalized); + resolve_type_drift(pool, kb_id, type_id, name, &keys, context, exclude, false).await + } + _ => resolve_by_name(pool, kb_id, type_id, raw_name, context, text, exclude).await, + } +} + /// 通道 2:mention 名字向量的近邻,各排一对(规矩见 [`resolve_mention`]) async fn propose_by_name_vector( pool: &PgPool, @@ -484,7 +535,7 @@ async fn resolve_by_name( if candidates.is_empty() { // 同类型无候选 ≠ 新名字:类型标签会漂(同一团队被抽成 organization/project/ // concept),先查其它类型下的同名实体,按类型对的互斥强度分流。 - return resolve_type_drift(pool, kb_id, type_id, name, &keys, context, exclude).await; + return resolve_type_drift(pool, kb_id, type_id, name, &keys, context, exclude, true).await; } let Some(ctx) = context else { @@ -1033,6 +1084,7 @@ fn confusable_reviews( /// concept 兜底型候选跑既有画像分层:高相似直接 ATTACH(漂移的召回修复,concept /// 侧类型升格为具体类型),灰区/无从判别 → 宁分勿合新建 + 审核对;易混具体类型 /// 一律新建 + 审核对(同名 + 类型摇摆本身就是信号,不设相似度门槛);硬互斥忽略。 +#[allow(clippy::too_many_arguments)] async fn resolve_type_drift( pool: &PgPool, kb_id: Uuid, @@ -1042,6 +1094,8 @@ async fn resolve_type_drift( keys: &[String], context: Option<&[f32]>, exclude: &[Uuid], + // false = never attach to a concept fallback (identity mentions create in their own class) + may_attach: bool, ) -> AppResult { // 这一侧也可能还没判出类型(0009),那时没有 key 可查 let mention_key: Option = match type_id { @@ -1098,7 +1152,7 @@ async fn resolve_type_drift( } } - if let Some(ctx) = context { + if let Some(ctx) = context.filter(|_| may_attach) { let best = recall_cands .iter() .filter_map(|c| { diff --git a/crates/utopia-store/tests/store/an_identity_name_attaches_by_its_exact_name.rs b/crates/utopia-store/tests/store/an_identity_name_attaches_by_its_exact_name.rs new file mode 100644 index 000000000..647606416 --- /dev/null +++ b/crates/utopia-store/tests/store/an_identity_name_attaches_by_its_exact_name.rs @@ -0,0 +1,123 @@ +//! 0071 decisions 2 and 3: an identity mention attaches to the exact-name holder whatever the +//! profile says, and is created otherwise. Skipped without `UTOPIA_DATABASE_URL`. + +use sqlx::PgPool; +use utopia_store::resolution::resolve_identity_name; +use uuid::Uuid; + +/// Orthogonal to every holder's profile, so the profile never supports an attach. +const UNRELATED: [f32; 3] = [0.0, 1.0, 0.0]; + +/// A kb with a project and an organization class, a body to run in it, then teardown. +async fn in_kb(body: F) -> anyhow::Result<()> +where + F: FnOnce(PgPool, Uuid, Uuid, Uuid) -> Fut, + Fut: std::future::Future>, +{ + let Some(url) = utopia_store::test_db::url() else { + return Ok(()); + }; + let pool = PgPool::connect(&url).await?; + let ids: [Uuid; 5] = std::array::from_fn(|_| Uuid::now_v7()); + let [org, ws, kb, project, organization] = ids; + sqlx::raw_sql(&format!( + "INSERT INTO organizations (id, name) VALUES ('{org}', 'identity'); + INSERT INTO workspaces (id, org_id, name) VALUES ('{ws}', '{org}', 'identity'); + INSERT INTO knowledge_bases (id, workspace_id, name) VALUES ('{kb}', '{ws}', 'identity'); + INSERT INTO entity_types (id, kb_id, key, label) VALUES + ('{project}', '{kb}', 'project', 'Project'), + ('{organization}', '{kb}', 'organization', 'Organization');" + )) + .execute(&pool) + .await?; + let run = body(pool.clone(), kb, project, organization).await; + sqlx::query("DELETE FROM organizations WHERE id = $1") + .bind(org) + .execute(&pool) + .await?; + run +} + +/// A live entity whose profile points along the first axis. +async fn holder( + pool: &PgPool, + kb: Uuid, + type_id: Option, + name: &str, +) -> anyhow::Result { + let id = Uuid::now_v7(); + sqlx::query( + "INSERT INTO entities (id, kb_id, type_id, canonical_name, profile_embedding, profile_n) + VALUES ($1, $2, $3, $4, '[1,0,0]'::vector, 1)", + ) + .bind(id) + .bind(kb) + .bind(type_id) + .bind(name) + .execute(pool) + .await?; + utopia_store::names::record(pool, kb, id, name, None, None).await?; + Ok(id) +} + +#[tokio::test] +async fn one_exact_holder_is_attached_and_otherwise_the_name_is_created() -> anyhow::Result<()> { + in_kb(|pool, kb, project, _| async move { + let only = holder(&pool, kb, Some(project), "acme/a.ts").await?; + let (twin, twin_too) = ( + holder(&pool, kb, Some(project), "acme/b.ts").await?, + holder(&pool, kb, Some(project), "acme/b.ts").await?, + ); + let resolve = |name: &'static str| { + resolve_identity_name(&pool, kb, Some(project), name, Some(&UNRELATED), None, &[]) + }; + let attached = resolve("ACME/a.ts").await?; + assert_eq!((attached.entity_id, attached.created), (only, false)); + assert!(resolve("acme/c.ts").await?.created); + let split = resolve("acme/b.ts").await?; + assert!(split.created && ![twin, twin_too].contains(&split.entity_id)); + // known only by a known_as fact, as after a merge + let renamed = holder(&pool, kb, Some(project), "acme/old.ts").await?; + utopia_store::names::record(&pool, kb, renamed, "acme/e.ts", None, None).await?; + assert_eq!(resolve("acme/e.ts").await?.entity_id, renamed); + // untyped mention, same profile as a typed holder: still no concept-fallback attach + let typed = holder(&pool, kb, Some(project), "acme/d.ts").await?; + let same = [1.0, 0.0, 0.0]; + let untyped = + resolve_identity_name(&pool, kb, None, "acme/d.ts", Some(&same), None, &[]).await?; + assert!(untyped.created && untyped.entity_id != typed); + Ok(()) + }) + .await +} + +#[tokio::test] +async fn a_name_under_another_class_is_created_with_a_drift_review_unless_disjoint( +) -> anyhow::Result<()> { + in_kb(|pool, kb, project, organization| async move { + holder(&pool, kb, Some(organization), "acme/a.ts").await?; + holder(&pool, kb, Some(organization), "acme/b.ts").await?; + let reviews = |name: &'static str| async { + let r = resolve_identity_name(&pool, kb, Some(project), name, None, None, &[]).await?; + anyhow::Ok(( + r.created, + r.reviews.into_iter().map(|v| v.reason).collect::>(), + )) + }; + assert_eq!( + reviews("acme/a.ts").await?, + (true, vec!["type_drift|project vs organization".to_string()]) + ); + for (a, b) in [(project, organization), (organization, project)] { + sqlx::query("INSERT INTO entity_type_disjoint (kb_id, a_id, b_id) VALUES ($1, $2, $3)") + .bind(kb) + .bind(a) + .bind(b) + .execute(&pool) + .await?; + } + assert_eq!(reviews("acme/b.ts").await?, (true, vec![])); + Ok(()) + }) + .await +} diff --git a/crates/utopia-store/tests/store/main.rs b/crates/utopia-store/tests/store/main.rs index 8bcfe2c09..935bf3bfa 100644 --- a/crates/utopia-store/tests/store/main.rs +++ b/crates/utopia-store/tests/store/main.rs @@ -119,6 +119,7 @@ mod an_end_date_closes_the_open_span; mod an_event_holds_at_the_moment_it_names; mod an_exploration_says_what_it_covered; mod an_export_carries_the_whole_ledger; +mod an_identity_name_attaches_by_its_exact_name; mod an_instance_list_names_what_a_type_lacks; mod an_open_statement_keeps_the_documents_words; mod an_sso_login_finds_or_opens_its_account; diff --git a/docs/decisions/0071-a-source-may-declare-its-names-identities.md b/docs/decisions/0071-a-source-may-declare-its-names-identities.md index da59eb112..86d51ceaa 100644 --- a/docs/decisions/0071-a-source-may-declare-its-names-identities.md +++ b/docs/decisions/0071-a-source-may-declare-its-names-identities.md @@ -1,6 +1,6 @@ # 0071 · A source may declare its names identities -- **Status**: Proposed · 2026-10-19 · [#1293](https://github.com/deeplethe/utopia/issues/1293) · open: all six decisions +- **Status**: In progress · 2026-10-19 · [#1293](https://github.com/deeplethe/utopia/issues/1293) · open: decisions 5 and 6, and the `name_vectors::pending` skip of decision 4 - **Written**: 2026-10-19 (conventions in the [README](README.md)) - **Related**: [0054](0054-a-source-may-push-statements-in-the-open-contract.md) decision 3 sends pushed statements down the same resolution path as prose, and this record narrows that for one kind of source; [0041](0041-a-name-is-a-claim-about-an-entity.md) owns name facts and name-vector recall; [#1248](https://github.com/deeplethe/utopia/issues/1248) meets the same problem from the merge side; [#1296](https://github.com/deeplethe/utopia/issues/1296) measured what the recall costs; [#1308](https://github.com/deeplethe/utopia/pull/1308) is the disjointness fix that stands on its own @@ -40,6 +40,7 @@ One name fact can carry evidence from both an identity source and a prose docume - **On:** the update that sets the flag also deletes the stored vectors of name facts that now have identity evidence, in the same transaction. Leaving them in place and skipping them would put an evidence join into every `nearest` query, which is the per-mention cost #1296 measured. - **Off:** nothing is deleted. Those name facts become pending again, and the next extraction in the base backfills their vectors through `pending`, as it does for any name whose vector is missing. Recall for them returns from then on. Pairs that were never proposed while the flag was on are not proposed in retrospect. +**A NULL-typed holder keeps its class for now.** A typed mention that attaches to a holder with `type_id IS NULL` does not upgrade the holder's class, as the type-drift path does. PR 2 decides that. ## Not doing diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 727d60be0..c92bbbcf2 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -55,7 +55,7 @@ By domain; the domains are the files of [../design/](../design/README.md). **Sta | | Record | Status | Overtaken | |---|---|---|---| | 0041 | [A name is a claim about an entity](0041-a-name-is-a-claim-about-an-entity.md) | In progress | | -| 0071 | [A source may declare its names identities](0071-a-source-may-declare-its-names-identities.md) | Proposed | | +| 0071 | [A source may declare its names identities](0071-a-source-may-declare-its-names-identities.md) | In progress | | ### [time](../design/time.md) diff --git a/web/src/docs/ingest.md b/web/src/docs/ingest.md index e2611fade..35bc59479 100644 --- a/web/src/docs/ingest.md +++ b/web/src/docs/ingest.md @@ -153,6 +153,8 @@ Content-Type: application/json Any other key is refused with `422`, so a mistaken `predicate` or `class` field cannot pass as a typed fact: the contract has no slot for one. A `subject`, or the entity of an `n` row, that is not listed in `e` is refused the same way, rather than dropped later in silence. A body over 64 KiB or with more than 200 statements is refused too. +If every name your system pushes is already unique, such as `owner/repo:src/a.ts#parseDate`, set `{"names": "identity"}` in the source's config. A name from that source attaches to the entity with the same name (ignoring case, in the same class or none) and is created when there is none, whatever the surrounding text. It gets no name vector, so it queues no near-name pairs. A name that exists only under another class is created in this source's class, and still queues the type-drift review unless the two classes are declared disjoint. + Two things to know before wiring a system to it: - **Send events, not state.** A row that *is* the current state of a system belongs on a mounted database, read at query time. Pushing it here copies state into the ledger and the two drift. From c1656164387a4c423eadbadecaf619a4122013a5 Mon Sep 17 00:00:00 2001 From: Bogdan Szabo Date: Thu, 22 Oct 2026 14:05:11 +0200 Subject: [PATCH 2/2] The identity record separates the class note from decision 6, and the may_attach comment is in Chinese Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Bogdan Szabo --- crates/utopia-store/src/resolution.rs | 2 +- .../decisions/0071-a-source-may-declare-its-names-identities.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/utopia-store/src/resolution.rs b/crates/utopia-store/src/resolution.rs index 5c4888221..f02cf5ed3 100644 --- a/crates/utopia-store/src/resolution.rs +++ b/crates/utopia-store/src/resolution.rs @@ -1094,7 +1094,7 @@ async fn resolve_type_drift( keys: &[String], context: Option<&[f32]>, exclude: &[Uuid], - // false = never attach to a concept fallback (identity mentions create in their own class) + // false = 不归并到概念兜底:身份名按自己声明的类新建,不能被兜底吞掉 may_attach: bool, ) -> AppResult { // 这一侧也可能还没判出类型(0009),那时没有 key 可查 diff --git a/docs/decisions/0071-a-source-may-declare-its-names-identities.md b/docs/decisions/0071-a-source-may-declare-its-names-identities.md index 86d51ceaa..271ecb064 100644 --- a/docs/decisions/0071-a-source-may-declare-its-names-identities.md +++ b/docs/decisions/0071-a-source-may-declare-its-names-identities.md @@ -40,6 +40,7 @@ One name fact can carry evidence from both an identity source and a prose docume - **On:** the update that sets the flag also deletes the stored vectors of name facts that now have identity evidence, in the same transaction. Leaving them in place and skipping them would put an evidence join into every `nearest` query, which is the per-mention cost #1296 measured. - **Off:** nothing is deleted. Those name facts become pending again, and the next extraction in the base backfills their vectors through `pending`, as it does for any name whose vector is missing. Recall for them returns from then on. Pairs that were never proposed while the flag was on are not proposed in retrospect. + **A NULL-typed holder keeps its class for now.** A typed mention that attaches to a holder with `type_id IS NULL` does not upgrade the holder's class, as the type-drift path does. PR 2 decides that. ## Not doing