From 3cb51af7a8989af4e57fcbb4e510180308f6fed4 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Thu, 22 Oct 2026 14:09:59 +0200 Subject: [PATCH 1/6] A token reads a base's ontology and a class's instances (#1265) Signed-off-by: Bogdan Szabo Co-authored-by: Claude Opus 5.5 Co-authored-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com> --- .../utopia-server/src/api/ontology_routes.rs | 11 +++++--- .../utopia-server/src/api/token_read_tests.rs | 12 ++++++--- crates/utopia-server/src/auth.rs | 2 +- ...ty-from-the-person-scope-from-the-token.md | 27 +++++++++++-------- docs/design/access-and-audit.md | 6 ++--- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/crates/utopia-server/src/api/ontology_routes.rs b/crates/utopia-server/src/api/ontology_routes.rs index ee944bb0a..795e30c4a 100644 --- a/crates/utopia-server/src/api/ontology_routes.rs +++ b/crates/utopia-server/src/api/ontology_routes.rs @@ -10,6 +10,7 @@ use utopia_core::AppError; use utopia_store::ontology::{Lacking, LinkEnd}; use uuid::Uuid; +use crate::api::documents_routes::require_reader_kb; use crate::auth::{AuthUser, SessionOrToken}; use crate::error::ApiResult; use crate::state::AppState; @@ -23,12 +24,13 @@ async fn require_kb( utopia_store::access::require_kb(&state.pool, user, kb_id, min).await } +/// 令牌也读得到(0014 决定 7):类别 key 要先换成类型 id,才能去查实例 pub async fn get( State(state): State, - AuthUser(user): AuthUser, + reader: SessionOrToken, Path(kb_id): Path, ) -> ApiResult> { - require_kb(&state, &user, kb_id, Role::Viewer).await?; + require_reader_kb(&state, &reader, kb_id).await?; let (entity_types, relation_types) = tokio::try_join!( utopia_store::ontology::entity_type_views(&state.pool, kb_id), utopia_store::ontology::relation_type_views(&state.pool, kb_id), @@ -84,14 +86,15 @@ fn missing_link(q: &InstancesQuery) -> Result, AppError> /// 某个类下的实体实例列表(详情区右侧,分页)。 /// 带 `missing_predicate` 时只列缺那条关系的成员,并回显认作它的属性与短语。 +/// 令牌也读得到(0014 决定 7)。 pub async fn list_entity_instances( State(state): State, - AuthUser(user): AuthUser, + reader: SessionOrToken, Path((kb_id, type_id)): Path<(Uuid, Uuid)>, Query(q): Query, ) -> ApiResult> { let missing = missing_link(&q)?; - require_kb(&state, &user, kb_id, Role::Viewer).await?; + require_reader_kb(&state, &reader, kb_id).await?; let per = q.per.clamp(1, 100); let page = q.page.max(0); let predicate = match missing { diff --git a/crates/utopia-server/src/api/token_read_tests.rs b/crates/utopia-server/src/api/token_read_tests.rs index b9d52d525..289b35100 100644 --- a/crates/utopia-server/src/api/token_read_tests.rs +++ b/crates/utopia-server/src/api/token_read_tests.rs @@ -1,5 +1,5 @@ -//! 个人令牌读图(0014 决定 7):搜实体、实体详情、认知历史、事实证据、图总览、邻域六条读路由 -//! 收任何一枚活着的令牌。角色照旧是上限,`kb_ids` 排除了的库答 404;改实体仍只认会话。 +//! 个人令牌读图(0014 决定 7):搜实体、实体详情、认知历史、事实证据、图总览、邻域、本体、 +//! 某类的实例这些读路由收任何一枚活着的令牌。角色照旧是上限,`kb_ids` 排除了的库答 404;改实体仍只认会话。 use crate::state::AppState; use axum::body::Body; use axum::http::{Request, StatusCode}; @@ -15,6 +15,7 @@ struct Fixture { /// 令牌够不着的另一个库 other_kb: Uuid, reader: Uuid, + person: Uuid, entity: Uuid, fact: Uuid, _dir: tempfile::TempDir, @@ -68,6 +69,7 @@ impl Fixture { kb, other_kb, reader, + person, entity, fact, _dir: dir, @@ -81,8 +83,8 @@ impl Fixture { .1 } - fn read_paths(&self) -> [String; 6] { - let (kb, entity, fact) = (self.kb, self.entity, self.fact); + fn read_paths(&self) -> [String; 8] { + let (kb, person, entity, fact) = (self.kb, self.person, self.entity, self.fact); [ format!("/kbs/{kb}/entities?q=Zhang"), format!("/kbs/{kb}/entities/{entity}"), @@ -90,6 +92,8 @@ impl Fixture { format!("/kbs/{kb}/facts/{fact}/evidence"), format!("/kbs/{kb}/graph/overview"), format!("/kbs/{kb}/graph/neighborhood?entity={entity}"), + format!("/kbs/{kb}/ontology"), + format!("/kbs/{kb}/ontology/entity-types/{person}/entities"), ] } diff --git a/crates/utopia-server/src/auth.rs b/crates/utopia-server/src/auth.rs index f8a9ff910..e45f46416 100644 --- a/crates/utopia-server/src/auth.rs +++ b/crates/utopia-server/src/auth.rs @@ -177,7 +177,7 @@ impl FromRequestParts for AuthUser { /// **不替换 `AuthUser`。** `AuthUser` 把每个 Bearer 都当 JWT 解,令牌在那几百条 /// 路由上一律是 401——那是有意的:哪条路由准令牌进来,要在 0014 里说出理由。 /// 用这个提取器的只有文档原件(0052)、「把一个库搭起来」那几条和读图那几条:搜实体、 -/// 实体详情、认知历史、事实证据、图总览、邻域(决定 7)。 +/// 实体详情、认知历史、事实证据、图总览、邻域、本体、某类的实例(决定 7)。 /// /// 按推送时的 `external_id` 读回一篇文档(#1276)也是文档原件,开给令牌的理由写在决定 7。 /// diff --git a/docs/decisions/0014-identity-from-the-person-scope-from-the-token.md b/docs/decisions/0014-identity-from-the-person-scope-from-the-token.md index f005c3589..747d41e69 100644 --- a/docs/decisions/0014-identity-from-the-person-scope-from-the-token.md +++ b/docs/decisions/0014-identity-from-the-person-scope-from-the-token.md @@ -87,18 +87,22 @@ push documents in. 7. **A token reads the graph** (added 2026-10-16, #1262). A service that mirrors into a base reads the base back to check what landed, and a session JWT is the wrong credential for a backend - (decision 6). Six reads now also take any live token, acting as its owner: searching a base's + (decision 6). Eight reads now also take any live token, acting as its owner: searching a base's entities (`GET /kbs/{id}/entities`), an entity's detail (`GET /kbs/{id}/entities/{eid}`), its record-axis history (`…/history`), a fact's evidence (`GET /kbs/{id}/facts/{fid}/evidence`), - the graph overview (`GET /kbs/{id}/graph/overview`) and an entity's neighbourhood - (`GET /kbs/{id}/graph/neighborhood`). Search finds the entity by name; the detail gives its - facts, names and derivations; the history says when we changed our mind; the evidence ties a - fact to its sentence; the overview gives the most connected entities with the base's totals, - so a client sees the shape of what it pushed; the neighbourhood gives the entities around one, - so it can follow what a statement touches, and one started from another base's entity comes - back empty. Read is the lowest scope, so any token qualifies; the owner's role is still the - ceiling and Viewer suffices; a token whose `kb_ids` exclude the base gets 404, as for document - content (0052). Changing an entity on the same path (`PATCH`) still takes a session. + the graph overview (`GET /kbs/{id}/graph/overview`), an entity's neighbourhood + (`GET /kbs/{id}/graph/neighborhood`), the ontology (`GET /kbs/{id}/ontology`) and a class's + instances (`GET /kbs/{id}/ontology/entity-types/{tid}/entities`). Search finds the entity by + name; the detail gives its facts, names and derivations; the history says when we changed our + mind; the evidence ties a fact to its sentence; the overview gives the most connected entities + with the base's totals, so a client sees the shape of what it pushed; the neighbourhood gives + the entities around one, so it can follow what a statement touches, and one started from + another base's entity comes back empty; the ontology turns a class key into the type id the + instances read takes; the instances list that class's members, or only those lacking a + relation, and a class id from another base gives an empty page. Read is the lowest scope, so + any token qualifies; the owner's role is still the ceiling and Viewer suffices; a token whose + `kb_ids` exclude the base gets 404, as for document content (0052). Changing an entity + (`PATCH`) or the ontology on the same paths still takes a session. Reading a pushed document back by the `external_id` it was pushed under (`GET /kbs/{id}/sources/{sid}/documents/by-external-id`, added 2026-10-19, #1276) takes a @@ -133,7 +137,8 @@ push documents in. token now creates `api` sources too. - 2026-10-16: decision 7 opens four graph reads to any token; decision 6's "only these routes and document content" now also counts them. 2026-10-19: the graph overview and neighbourhood - join them, and so does reading a pushed document back by its `external_id` (#1276). + join them, and so does reading a pushed document back by its `external_id` (#1276). The + ontology and a class's instances follow (#1265). ## Open questions diff --git a/docs/design/access-and-audit.md b/docs/design/access-and-audit.md index 2ad0ab6c2..372ee8be0 100644 --- a/docs/design/access-and-audit.md +++ b/docs/design/access-and-audit.md @@ -19,9 +19,9 @@ writes an audit row `mcp.tool_called`; the tokens page shows the plaintext once snippet [0014]. A `write` token also sets up a base as its owner: creating a base and a `statements` or `api` source, reading the source's push key, importing an ontology and deciding a kind word, with the owner's role unchanged as the ceiling; any token lists a workspace's bases; a token limited by `kb_ids` -creates no base. These routes, document content and six graph reads (entity search, detail, -history, fact evidence, overview, neighbourhood; Viewer suffices, `kb_ids` answers 404) take -`SessionOrToken`; apart from MCP, every other route is session-only [0014 d6, d7]. `ingest_token` on a source is a different kind: plaintext, push-only [0014]. +creates no base. These routes, document content and eight graph reads (entity search, detail, +history, fact evidence, overview, neighbourhood, ontology, a class's instances; Viewer suffices, +`kb_ids` answers 404) take `SessionOrToken`; apart from MCP, every other route is session-only [0014 d6, d7]. `ingest_token` on a source is a different kind: plaintext, push-only [0014]. **A client reads a pushed document back by its `external_id`.** `GET /kbs/{id}/sources/{sid}/documents/by-external-id?external_id=…` finds an `api` or `statements` From c92908303fa9dbbfc9ef11a536cff31673a5cdf7 Mon Sep 17 00:00:00 2001 From: Quintin Botes Date: Thu, 22 Oct 2026 14:15:23 +0200 Subject: [PATCH 2/6] A tool request refused for its reasoning effort is retried with none and the client remembers it, so chat and the second look work on reasoning deployments (#1353) (#1368) Signed-off-by: Quintin Botes Co-authored-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com> --- Cargo.lock | 1 + crates/utopia-llm/Cargo.toml | 1 + crates/utopia-llm/src/lib.rs | 193 +++++++++++++++++++++++++++++++---- 3 files changed, 173 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23de9c05d..069c37471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5477,6 +5477,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tracing", + "wiremock", ] [[package]] diff --git a/crates/utopia-llm/Cargo.toml b/crates/utopia-llm/Cargo.toml index 9b0b0eb98..792e7160a 100644 --- a/crates/utopia-llm/Cargo.toml +++ b/crates/utopia-llm/Cargo.toml @@ -16,3 +16,4 @@ thiserror.workspace = true [dev-dependencies] tokio = { workspace = true, features = ["macros", "rt"] } +wiremock = "0.6.5" diff --git a/crates/utopia-llm/src/lib.rs b/crates/utopia-llm/src/lib.rs index c311f72f4..aa2bfe67a 100644 --- a/crates/utopia-llm/src/lib.rs +++ b/crates/utopia-llm/src/lib.rs @@ -449,6 +449,9 @@ pub struct LlmClient { /// 端点报过的上下文窗口(token),起初是 `u32::MAX`。同一个客户端(含它的克隆)此后 /// 都按它算历史预算,只降不升;对话客户端按工作区留着,所以下一轮也记得(#964) context_window: std::sync::Arc, + /// 端点说过带工具的请求不收推理强度之后置位(#1353):此后带工具的请求体都写 + /// `reasoning_effort: "none"`,别的调用照旧按设置发。同一个客户端(含克隆)只吃一次拒绝 + tools_without_effort: std::sync::Arc, } /// 建连多久算失败。 @@ -580,6 +583,7 @@ impl LlmClient { model: model.to_string(), reasoning_effort: None, context_window: std::sync::Arc::new(std::sync::atomic::AtomicU32::new(u32::MAX)), + tools_without_effort: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)), completion_ceiling: std::sync::Arc::new(std::sync::atomic::AtomicU32::new( MAX_COMPLETION_TOKENS, )), @@ -875,10 +879,56 @@ impl LlmClient { if let Some(choice) = tool_choice { body["tool_choice"] = choice.clone(); } + if self + .tools_without_effort + .load(std::sync::atomic::Ordering::Relaxed) + { + body["reasoning_effort"] = json!("none"); + } } body } + /// 发一个带工具的请求。推理部署上,端点可能整个拒收带工具又带推理强度的请求体 + /// (Azure:`Function tools with reasoning_effort are not supported`),而部署本身的默认 + /// 强度就算数,不发这个字段也一样被拒——于是对话退回一步检索,治理的第二眼跑不了(#1353)。 + /// 吃到这句 400 就记在客户端上,改发 `none` 重试一次;只动带工具的请求,抽取与对齐照旧 + async fn post_tools( + &self, + messages: &[serde_json::Value], + tools: Option<&serde_json::Value>, + tool_choice: Option<&serde_json::Value>, + stream: bool, + ) -> anyhow::Result { + use std::sync::atomic::Ordering; + loop { + let learned = self.tools_without_effort.load(Ordering::Relaxed); + let resp = self + .request("/chat/completions") + .json(&self.tools_body(messages, tools, tool_choice, stream)) + .send() + .await + .map_err(Unreachable)?; + let status = resp.status(); + if status.is_success() { + return Ok(resp); + } + let retry_after = retry_after_of(resp.headers()); + let raw = resp.text().await.map_err(Unreachable)?; + let parsed = serde_json::from_str(&raw).unwrap_or_default(); + if status == reqwest::StatusCode::BAD_REQUEST + && tools.is_some() + && !learned + && says_tools_refuse_effort(&err_detail(&parsed, &raw)) + { + tracing::info!(model = %self.model, "端点不收带工具的推理强度,带工具的请求改发 none 并记住"); + self.tools_without_effort.store(true, Ordering::Relaxed); + continue; + } + return Err(failure("LLM", status, retry_after, &parsed, &raw)); + } + } + /// Exact serialized streaming request size, including model and protocol fields. /// Used by the bounded answer phase before any network I/O. pub fn tool_free_request_bytes(&self, messages: &[serde_json::Value]) -> usize { @@ -894,17 +944,7 @@ impl LlmClient { tools: Option<&serde_json::Value>, tool_choice: Option<&serde_json::Value>, ) -> anyhow::Result { - let resp = self - .request("/chat/completions") - .json(&self.tools_body(messages, tools, tool_choice, false)) - .send() - .await - .map_err(Unreachable)?; - let status = resp.status(); - let retry_after = retry_after_of(resp.headers()); - if !status.is_success() { - return Err(response_failure("LLM", status, retry_after, resp).await?); - } + let resp = self.post_tools(messages, tools, tool_choice, false).await?; let body: serde_json::Value = resp.json().await.map_err(Unreachable)?; let msg = &body["choices"][0]["message"]; if msg.is_null() { @@ -961,17 +1001,7 @@ impl LlmClient { tools: Option<&serde_json::Value>, tool_choice: Option<&serde_json::Value>, ) -> anyhow::Result> + Send + use<>> { - let resp = self - .request("/chat/completions") - .json(&self.tools_body(messages, tools, tool_choice, true)) - .send() - .await - .map_err(Unreachable)?; - if !resp.status().is_success() { - let status = resp.status(); - let retry_after = retry_after_of(resp.headers()); - return Err(response_failure("LLM", status, retry_after, resp).await?); - } + let resp = self.post_tools(messages, tools, tool_choice, true).await?; let mut bytes = resp.bytes_stream(); let stream = async_stream::try_stream! { @@ -1268,6 +1298,13 @@ fn err_detail(body: &serde_json::Value, raw: &str) -> String { .unwrap_or_else(|| "unknown error".to_string()) } +/// 端点说不说「带工具的请求不收推理强度」。只有措辞可认:Azure 给的 code 是笼统的 +/// `invalid_request_error`。两样都得提到——只说工具或只说推理强度的 400 是别的毛病 +fn says_tools_refuse_effort(detail: &str) -> bool { + let d = detail.to_lowercase(); + d.contains("reasoning_effort") && (d.contains("tool") || d.contains("function")) +} + /// 响应体说不说这是余额问题。 /// /// **给 429 用的**:OpenAI 用同一个状态码表示「太快了」和「没钱了」, @@ -1567,6 +1604,118 @@ mod tests { } } + #[test] + fn a_400_about_tools_and_reasoning_effort_is_recognised_and_others_are_not() { + assert!(super::says_tools_refuse_effort( + "Function tools with reasoning_effort are not supported for gpt-x in /v1/chat/completions. Please use /v1/responses instead." + )); + assert!(!super::says_tools_refuse_effort( + "Unsupported value: 'reasoning_effort' does not support 'minimal'" + )); + assert!(!super::says_tools_refuse_effort( + "Invalid 'tools[0].function.name'" + )); + } + + #[tokio::test] + async fn a_tool_request_refused_for_its_reasoning_effort_retries_with_none_and_remembers() { + use wiremock::matchers::{body_partial_json, method}; + use wiremock::{Mock, MockServer, ResponseTemplate}; + let server = MockServer::start().await; + let ok = serde_json::json!({ "choices": [{ "message": { "role": "assistant", "content": "pong" }, "finish_reason": "stop" }] }); + Mock::given(method("POST")) + .and(body_partial_json( + serde_json::json!({ "reasoning_effort": "none" }), + )) + .respond_with(ResponseTemplate::new(200).set_body_json(ok.clone())) + .with_priority(1) + .mount(&server) + .await; + Mock::given(method("POST")) + .and(wiremock::matchers::body_string_contains("\"tools\"")) + .respond_with(ResponseTemplate::new(400).set_body_json(serde_json::json!({ "error": { + "message": "Function tools with reasoning_effort are not supported for gpt-x in /v1/chat/completions.", + "type": "invalid_request_error" } }))) + .with_priority(2) + .mount(&server) + .await; + Mock::given(method("POST")) + .respond_with(ResponseTemplate::new(200).set_body_json(ok)) + .with_priority(3) + .mount(&server) + .await; + let client = + LlmClient::new(&server.uri(), None, "m").with_reasoning_effort(Some("low".into())); + let tool = serde_json::json!([{ "type": "function", "function": { "name": "ping", "parameters": { "type": "object", "properties": {} } } }]); + let ask = [serde_json::json!({ "role": "user", "content": "ping" })]; + assert_eq!( + client + .chat_tools(&ask, &tool) + .await + .unwrap() + .content + .as_deref(), + Some("pong") + ); + assert_eq!( + client + .clone() + .chat_tools(&ask, &tool) + .await + .unwrap() + .content + .as_deref(), + Some("pong") + ); + let plain = [ChatMessage { + role: "user".into(), + content: "hi".into(), + }]; + client.chat(&plain).await.unwrap(); + let sent: Vec = server + .received_requests() + .await + .unwrap() + .iter() + .map(|r| serde_json::from_slice(&r.body).unwrap()) + .collect(); + let efforts: Vec<_> = sent + .iter() + .map(|b| (b.get("tools").is_some(), b["reasoning_effort"].clone())) + .collect(); + assert_eq!( + efforts, + [ + (true, serde_json::json!("low")), // refused once + (true, serde_json::json!("none")), // retried + (true, serde_json::json!("none")), // remembered, also by a clone + (false, serde_json::json!("low")), // a call without tools keeps the setting + ] + ); + } + + #[tokio::test] + async fn another_400_on_a_tool_request_is_not_retried() { + use wiremock::{matchers::method, Mock, MockServer, ResponseTemplate}; + let server = MockServer::start().await; + Mock::given(method("POST")) + .respond_with(ResponseTemplate::new(400).set_body_json( + serde_json::json!({ "error": { "message": "Invalid 'tools[0].function.name'" } }), + )) + .mount(&server) + .await; + let client = LlmClient::new(&server.uri(), None, "m"); + let tool = serde_json::json!([{ "type": "function", "function": { "name": "bad name" } }]); + assert!(client + .chat_tools( + &[serde_json::json!({ "role": "user", "content": "x" })], + &tool + ) + .await + .is_err()); + assert_eq!(server.received_requests().await.unwrap().len(), 1); + } + #[test] fn reasoning_effort_rides_in_every_chat_body_only_when_set() { let plain = LlmClient::new("http://x", None, "m"); From 43fb1589397de93db140cf41799fb7d1cc978178 Mon Sep 17 00:00:00 2001 From: Quintin Botes Date: Thu, 22 Oct 2026 14:21:16 +0200 Subject: [PATCH 3/6] A same verdict that touches an identity entity waits for a person, so a small model cannot merge a source's identities (#1248) (#1364) Signed-off-by: Quintin Botes Co-authored-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com> --- ...71-a-source-may-declare-its-names-identities.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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..e5a2622f5 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,8 +1,8 @@ # 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**: Proposed · 2026-10-19 · [#1293](https://github.com/deeplethe/utopia/issues/1293) · open: all seven decisions - **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 +- **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 and is decided here as decision 7; [#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 > A backend mirrors a repository into a base and pushes `owner/repo:src/a.ts#parseDate`, `owner/repo:src/a.test.ts::adds two`, `owner/repo:specs/x/spec.md#s0003`. Each name is an identity the client already knows to be unique. Every one still goes through write-time resolution. Because they share the `owner/repo:` prefix, their name vectors sit close together, and the duplicates queue fills with pairs that can never be the same thing. @@ -41,6 +41,12 @@ 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. +**7. A `same` verdict that touches an identity entity goes to a person.** + +*Revised 2026-10-22 (#1248):* decision 1 said #1248 decides the merge side with the same flag; this is that decision. An identity entity is one with a name fact that has evidence from an identity source, the same join decision 4 uses. When the adjudicator returns `same` at or above `AUTO_CONF` for a pair where either side is an identity entity, the pair is escalated to human review with the reason `escalate_identity` instead of being merged. This holds on both paths that apply a verdict: `apply_verdict` in `adjudication.rs` with governance off, the second look included (#889), and `apply` in `governance.rs` with governance on. It reuses the execution gate's escalation (0027), so a person sees why the pair is waiting, not "the adjudicator was unsure". A `kept` verdict still closes the pair automatically, which keeps the queue short. A merge a person makes is unchanged. + +Why a person and not a stricter threshold: an identity source has already said what its names are. Decisions 2 to 4 remove the pairs that name vectors and the single-candidate split would raise, so what is left are containment and type-drift pairs and the cross-source duplicate (one thing pushed under two names by two producers). Those are exactly the cases where the model's `same` is a guess about a claim the producer made, and a wrong merge of identities is what #1248 measured: on a small local model, 40 automatic merges with governance off, nearly all wrong (a method into its file, two unrelated types). A person sees few of them because the vectors are off. Raising `AUTO_CONF` for these pairs would still let a confident wrong verdict through, and a per-base switch is a dead end (below). + ## Not doing - **Containment for identity names.** `containment_reviews` still runs for them. #1104's next cut rewrites that predicate, and whether an identity source skips it is a separate decision after that. @@ -50,10 +56,12 @@ One name fact can carry evidence from both an identity source and a prose docume - **Every `statements` push is an identity claim.** Too broad: 0054 sends pushes through the same path on purpose, and human-style names find real variants through their vectors. - **Skip the vector channel after any single exact match.** That is #1296 item 1. Applied to every mention it changes prose resolution, and `the_same_literal_name_is_not_proposed_twice` asserts the opposite. -- **A per-base switch.** One base can mix an identity source with prose sources, and only the producer knows which names are identities. +- **A per-base switch.** One base can mix an identity source with prose sources, and only the producer knows which names are identities. #1248 first asked for `auto_merge: false` per base; decision 7 keeps the merge gate on the same per-source flag instead. +- **Closing a `same` verdict between two identity names as kept.** "Every name identifies one thing" does not say two names never identify the same thing: two producers can push one service under two names. A person decides those. ## Tests the code PR adds - `an_identity_source_adds_no_name_vectors_and_asks_no_neighbours`: a push from an identity source leaves no `name_vector|` rows and runs no `nearest` query. - `a_name_with_identity_evidence_gets_no_vector_even_when_prose_names_it_too` (decision 5). - Turning the flag on deletes the identity names' vectors; turning it off makes them pending again (decision 6). +- `a_same_verdict_on_an_identity_entity_waits_for_a_person`: with governance off and with it on, a `same` verdict at or above `AUTO_CONF` on a pair with one identity side leaves both entities in place and an open review with `escalate_identity`; a `kept` verdict on the same pair still closes it (decision 7). From 9942c0591a3f2a4e4e9ce450e928e13f5b5033e4 Mon Sep 17 00:00:00 2001 From: Quintin Botes Date: Thu, 22 Oct 2026 14:42:52 +0200 Subject: [PATCH 4/6] Three issue trackers share one ticket document and keep their own fetch, so GitLab issues need no third copy of the shape (#1327) (#1367) * Three issue trackers share one ticket document and keep their own fetch, so GitLab issues need no third copy of the shape (#1327) Signed-off-by: Quintin Botes * Write out the ticket fields, the update-time checkpoint and opt-in merge requests in 0013 decision 7 (#1327) Signed-off-by: Quintin Botes --------- Signed-off-by: Quintin Botes Co-authored-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com> --- ...3-a-source-should-hand-over-its-history.md | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/decisions/0013-a-source-should-hand-over-its-history.md b/docs/decisions/0013-a-source-should-hand-over-its-history.md index 0fed62a3b..a8c1631f4 100644 --- a/docs/decisions/0013-a-source-should-hand-over-its-history.md +++ b/docs/decisions/0013-a-source-should-hand-over-its-history.md @@ -1,6 +1,6 @@ # 0013 · A source hands over its history -- **Status**: Implemented for GitHub, Jira and Notion (#134, #135, #213) · open: Feishu, Confluence +- **Status**: Implemented for GitHub, Jira and Notion (#134, #135, #213) · open: Feishu, Confluence, decision 7 (#1327) - **Written**: 2026-08-31 · condensed into English 2026-09-03 - **Related**: the bitemporal ground of [0001](0001-ontology-import-and-governance.md); the same judgment on the corpus side in `scripts/bench/fetch-wiki-history.mjs` (#122); [0012](0012-the-ontology-is-a-contract-not-a-suggestion.md) is the other end of the line — this record is about how things come in, that one about the rules they land by; the grant layer added afterwards (#142, `data_source_grants`) decides who may mount a source: provenance visible, destination governed @@ -83,6 +83,61 @@ Wikipedia; there revisions have to be sampled, an issue tracker hands the events render in UTC (local conversion shows a UTC-5 reader the previous day); `recorded_at` is a real instant and renders in the viewer's timezone. The difference is intentional. +7. **Three trackers share one ticket document, not one fetch.** *Added 2026-10-22 (#1327).* + Decision 1 already made the document the shared part, but each connector carries its own + `render()`, and the shape has drifted in small ways: GitHub opens with "Opened by", Jira with + "Reported by"; #691 changed the timestamps twice, with two comments saying the same thing. A third + copy for GitLab triples that. So a pure `ticket::render(&Ticket)` owns the document: the + heading, the dated sentences, `## Description`, a `## History` sorted by time, `## Comments`. + Each connector maps its payload into `Ticket` and keeps its own fetch: three pulls with `since` + for GitHub, one JQL call for Jira, and for GitLab a list per kind plus, per ticket, its notes and + its `resource_state_events`, `resource_label_events` and `resource_milestone_events`. Still no + provider trait: the fetch strategies are as different as the dead end says, and they stay in + their own modules. + + `Ticket` holds what the two renderers write today, in the order each writes it, and nothing + that would let `render` reword it: + + - `heading`: the title line after `# ` (`#12 Fix it`, `KAFKA-1 Summary`, `!7 Fix it`); + - `sentences`: the dated and plain sentences under the heading, each already worded and in the + connector's own order (GitHub: opened, state, closed, labels, assignees; Jira: reported, + type, state, priority, assignee, resolved, labels); + - `description`: the body under `## Description`, or none; + - `history`: `(time, text)` pairs written as `-