Elffuss BraidHub

kikocis/utopia public

A contradiction is visible where it sits (B2b) (#243)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Changeset42856b1d5fd1a921d71d25e561fc746c1b91b3e39d01bccb4ff3f41ba0d905bd
AuthorWaylandYang <145302500+WaylandYang@users.noreply.github.com> · 2026-09-03 12:14 +08:00
CommitterGitHub <noreply@github.com> · 2026-09-03 12:14 +08:00
Parents492772ddf244

Browse the files at this changeset

16 files changed

modified crates/utopia-core/src/models.rs +35 −0
@@ -513,6 +513,13 @@
513513 pub valid_from: Option<DateTime<Utc>>,
514514 pub valid_to: Option<DateTime<Utc>>,
515515 pub confidence: f32,
516+ /// 有争议(0017 §3):有一条 open 的公理违规或时态冲突指着它。整条边画成
517+ /// 警戒色——环在节点上、边还是灰的,余光分不出来
518+ pub contested: bool,
519+ /// 幽灵边(0017 §3):一条**没有落地**的派生——推出来了却撞上断言。`id` 是那条
520+ /// `derived_contradiction` 违规的 id,不是任何事实;`derived` 同时为 true,
521+ /// 所以它跟着派生开关走
522+ pub blocked: bool,
516523 }
517524
518525 /// 实体详情页的事实行(时间线)。
@@ -549,6 +556,10 @@
549556 pub corrected: bool,
550557 /// 证据集合里最新的文档时间——开放事实的"最后确认时间"(时效性透明化)
551558 pub last_evidence_time: Option<DateTime<Utc>>,
559+ /// 有争议(0017 §3):`{ kind, ref_id, derived? }`——哪一种(违规的 kind,或
560+ /// `temporal_conflict`)、Review 里那一项的 id、派生撞断言时推出来的那句话。
561+ /// 一条只报最新的一处;行**不压暗**,断言仍然活着
562+ pub contested: Option<serde_json::Value>,
552563 }
553564
554565 /// 实体的一次认知变更(记录时间轴上的事件,与 EntityFact 的有效时间轴正交)。
@@ -933,6 +944,30 @@
933944 pub premises: Vec<String>,
934945 }
935946
947+/// 一条**没有落地**的派生(0017 §3):推出来了,撞上一条断言,拦在图外。
948+///
949+/// 它没有 id——落库的才有。这里用那条 `derived_contradiction` 违规的 id 指它,
950+/// 面板上的「没落地的」一档与图上的幽灵边都靠这个 id 对上 Review 里的卡片。
951+#[derive(Debug, Clone, Serialize, sqlx::FromRow)]
952+pub struct BlockedDerivation {
953+ pub violation_id: Uuid,
954+ pub subject_id: Uuid,
955+ pub subject: String,
956+ pub object_id: Uuid,
957+ pub object: String,
958+ pub predicate: String,
959+ pub rule: String,
960+ /// 声明所在的谓词
961+ pub via_label: String,
962+ pub valid_from: Option<DateTime<Utc>>,
963+ pub valid_to: Option<DateTime<Utc>>,
964+ /// 挡住它的那条断言,与它的三元组文本
965+ pub against_fact: Uuid,
966+ pub against_text: String,
967+ /// 前提事实 id,按推导顺序——证明链从这里展开
968+ pub premises: Vec<Uuid>,
969+}
970+
936971 /// 证明的一步:一条断言前提,连同它的证据(0002 R2)。
937972 ///
938973 /// 前提一律是断言(`fact_derivations` 不记派生),所以证明是一条链而不是一棵树:
modified crates/utopia-server/src/api/graph_routes.rs +16 −1
@@ -145,9 +145,12 @@
145145 // 只有先改一次名才够得着——而两个张伟并存是「宁分勿合」的正当产物,不是
146146 // 改名改出来的。合并入口该长在能看见同名的地方。
147147 let same_name = utopia_store::graph::same_name_peers(&state.pool, kb_id, entity_id).await?;
148+ // 没落地的派生(0017 §3)也单独一个键:它们连 `derived_facts` 都不在
149+ let blocked =
150+ utopia_store::reasoning::blocked_for_entity(&state.pool, kb_id, entity_id).await?;
148151 Ok(Json(json!({
149152 "entity": entity, "facts": facts,
150- "derived": derived, "same_name": same_name,
153+ "derived": derived, "blocked": blocked, "same_name": same_name,
151154 })))
152155 }
153156
@@ -240,6 +243,18 @@
240243 Ok(Json(json!({ "proof": proof })))
241244 }
242245
246+/// 没落地的派生的证明链(0017 §3):前提在那条 `derived_contradiction` 违规的
247+/// `path` 里,展开方式与落了地的一样。违规不存在时 `steps` 为 null
248+pub async fn blocked_proof(
249+ State(state): State<AppState>,
250+ AuthUser(user): AuthUser,
251+ Path((kb_id, violation_id)): Path<(Uuid, Uuid)>,
252+) -> ApiResult<Json<serde_json::Value>> {
253+ require_kb(&state, &user, kb_id, Role::Viewer).await?;
254+ let steps = utopia_store::reasoning::blocked_proof(&state.pool, kb_id, violation_id).await?;
255+ Ok(Json(json!({ "steps": steps })))
256+}
257+
243258 /// 手动触发抽取(failed 重试 / 补配模型后补抽)。
244259 pub async fn extract(
245260 State(state): State<AppState>,
modified crates/utopia-server/src/api/mod.rs +5 −0
@@ -295,6 +295,11 @@
295295 "/kbs/{id}/derived/{derived_id}/proof",
296296 get(graph_routes::derived_proof),
297297 )
298+ // 没落地的派生的证明(0017 §3):前提在违规的 path 里
299+ .route(
300+ "/kbs/{id}/violations/{violation_id}/proof",
301+ get(graph_routes::blocked_proof),
302+ )
298303 .route("/kbs/{id}/events", get(events_routes::kb_events))
299304 .route(
300305 "/kbs/{id}/sources",
modified crates/utopia-store/src/graph.rs +59 −4
@@ -418,13 +418,29 @@
418418 //
419419 // 图要它们,因为「这条边是推出来的」正是用户该看见的信息之一;`derived`
420420 // 那一位让界面画得出区别,也让人整体过滤掉。
421+ //
422+ // 第三段是**幽灵边**(0017 §3):推出来却没落地的派生,住在 `axiom_violations`
423+ // 的 `detail` 里。它的 id 是违规的 id;`derived` 与 `blocked` 同时为 true,
424+ // 界面据此让它跟着派生开关走、画成争议色往背景混的那一档。
425+ //
426+ // 断言那一段多算一位 `contested`:有 open 的违规或时态冲突指着它。派生撞断言
427+ // 时被撞的是 left;right 只是最后一条前提,它本身没有争议
421428 let edges: Vec<GraphEdge> = sqlx::query_as(
422429 "SELECT f.id, f.subject_id AS source, f.object_id AS target,
423430 COALESCE(r.key, fact_surface_predicate(f.id)) AS predicate,
424431 COALESCE(r.label, fact_surface_predicate(f.id)) AS label,
425432 r.id IS NULL AS inferred, FALSE AS derived, NULL::text AS rule,
426433 ARRAY[]::uuid[] AS premises,
427- f.valid_from, f.valid_to, f.confidence
434+ f.valid_from, f.valid_to, f.confidence,
435+ (EXISTS (SELECT 1 FROM axiom_violations v
436+ WHERE v.status = 'open'
437+ AND (v.left_fact = f.id
438+ OR (v.right_fact = f.id AND v.kind <> 'derived_contradiction')))
439+ OR EXISTS (SELECT 1 FROM fact_conflicts c
440+ WHERE c.status = 'open'
441+ AND (c.old_fact_id = f.id OR c.new_fact_id = f.id))
442+ ) AS contested,
443+ FALSE AS blocked
428444 FROM facts f LEFT JOIN relation_types r ON r.id = f.predicate_id
429445 WHERE f.kb_id = $1 AND f.invalidated_at IS NULL AND f.object_id IS NOT NULL
430446 AND f.subject_id = ANY($2) AND f.object_id = ANY($2)
@@ -437,14 +453,35 @@
437453 FALSE AS inferred, TRUE AS derived, ru.kind AS rule,
438454 ARRAY(SELECT fd.premise_fact_id FROM fact_derivations fd
439455 WHERE fd.derived_fact_id = d.id ORDER BY fd.seq) AS premises,
440- d.valid_from, d.valid_to, d.confidence
456+ d.valid_from, d.valid_to, d.confidence,
457+ FALSE AS contested, FALSE AS blocked
441458 FROM derived_facts d JOIN relation_types r ON r.id = d.predicate_id
442459 JOIN rules ru ON ru.id = d.rule_id
443460 WHERE d.kb_id = $1 AND d.invalidated_at IS NULL
444461 AND d.subject_id = ANY($2) AND d.object_id = ANY($2)
445462 AND ($3::timestamptz IS NULL
446463 OR ((d.valid_from IS NULL OR d.valid_from <= $3)
447- AND (d.valid_to IS NULL OR d.valid_to > $3)))",
464+ AND (d.valid_to IS NULL OR d.valid_to > $3)))
465+ UNION ALL
466+ SELECT v.id,
467+ (v.detail->>'subject_id')::uuid AS source,
468+ (v.detail->>'object_id')::uuid AS target,
469+ v.detail->>'predicate' AS predicate, v.detail->>'predicate' AS label,
470+ FALSE AS inferred, TRUE AS derived, v.detail->>'rule' AS rule,
471+ v.path AS premises,
472+ (v.detail->>'valid_from')::timestamptz AS valid_from,
473+ (v.detail->>'valid_to')::timestamptz AS valid_to,
474+ 0::real AS confidence,
475+ TRUE AS contested, TRUE AS blocked
476+ FROM axiom_violations v
477+ WHERE v.kb_id = $1 AND v.kind = 'derived_contradiction' AND v.status = 'open'
478+ AND (v.detail->>'subject_id')::uuid = ANY($2)
479+ AND (v.detail->>'object_id')::uuid = ANY($2)
480+ AND ($3::timestamptz IS NULL
481+ OR (((v.detail->>'valid_from')::timestamptz IS NULL
482+ OR (v.detail->>'valid_from')::timestamptz <= $3)
483+ AND ((v.detail->>'valid_to')::timestamptz IS NULL
484+ OR (v.detail->>'valid_to')::timestamptz > $3)))",
448485 )
449486 .bind(kb_id)
450487 .bind(ids)
@@ -568,7 +605,25 @@
568605 (f.supersedes IS NOT NULL) AS corrected,
569606 (SELECT MAX(COALESCE(d.doc_time, d.created_at))
570607 FROM fact_evidence fe JOIN documents d ON d.id = fe.document_id
571- WHERE fe.fact_id = f.id) AS last_evidence_time
608+ WHERE fe.fact_id = f.id) AS last_evidence_time,
609+ COALESCE(
610+ (SELECT jsonb_build_object(
611+ 'kind', v.kind, 'ref_id', v.id,
612+ 'derived', CASE WHEN v.kind = 'derived_contradiction'
613+ THEN (v.detail->>'subject') || ' · '
614+ || (v.detail->>'predicate') || ' · '
615+ || (v.detail->>'object') END)
616+ FROM axiom_violations v
617+ WHERE v.status = 'open'
618+ AND (v.left_fact = f.id
619+ OR (v.right_fact = f.id AND v.kind <> 'derived_contradiction'))
620+ ORDER BY v.detected_at DESC LIMIT 1),
621+ (SELECT jsonb_build_object('kind', 'temporal_conflict', 'ref_id', c.id)
622+ FROM fact_conflicts c
623+ WHERE c.status = 'open'
624+ AND (c.old_fact_id = f.id OR c.new_fact_id = f.id)
625+ ORDER BY c.created_at DESC LIMIT 1)
626+ ) AS contested
572627 FROM facts f
573628 LEFT JOIN relation_types r ON r.id = f.predicate_id
574629 LEFT JOIN entities o
modified crates/utopia-store/src/reasoning.rs +84 −9
@@ -1178,9 +1178,27 @@
11781178 let Some(derived) = derived_one(pool, kb_id, derived_id).await? else {
11791179 return Ok(None);
11801180 };
1181+ let premises: Vec<Uuid> = sqlx::query_scalar(
1182+ "SELECT premise_fact_id FROM fact_derivations WHERE derived_fact_id = $1 ORDER BY seq",
1183+ )
1184+ .bind(derived_id)
1185+ .fetch_all(pool)
1186+ .await?;
1187+ let steps = steps_for(pool, &premises).await?;
1188+ Ok(Some(utopia_core::models::Proof { derived, steps }))
1189+}
1190+
1191+/// 一串前提展开成证明的步:三元组、区间、撤没撤、证据。
1192+///
1193+/// 落了地的派生(`fact_derivations`)与没落地的(`axiom_violations.path`)都从这里
1194+/// 走——前提是同一种东西,证明链没有理由长两个样
1195+async fn steps_for(
1196+ pool: &PgPool,
1197+ premises: &[Uuid],
1198+) -> AppResult<Vec<utopia_core::models::ProofStep>> {
11811199 #[allow(clippy::type_complexity)]
11821200 let rows: Vec<(
1183- i32,
1201+ i64,
11841202 Uuid,
11851203 Uuid,
11861204 String,
@@ -1193,19 +1211,18 @@
11931211 f32,
11941212 bool,
11951213 )> = sqlx::query_as(
1196- "SELECT fd.seq, f.id, f.subject_id, s.canonical_name,
1214+ "SELECT x.ord - 1, f.id, f.subject_id, s.canonical_name,
11971215 f.predicate_id, r.label, f.object_id, o.canonical_name,
11981216 f.valid_from, f.valid_to, f.confidence,
11991217 f.invalidated_at IS NOT NULL
1200- FROM fact_derivations fd
1201- JOIN facts f ON f.id = fd.premise_fact_id
1218+ FROM unnest($1::uuid[]) WITH ORDINALITY AS x(id, ord)
1219+ JOIN facts f ON f.id = x.id
12021220 JOIN entities s ON s.id = f.subject_id
12031221 LEFT JOIN relation_types r ON r.id = f.predicate_id
12041222 LEFT JOIN entities o ON o.id = f.object_id
1205- WHERE fd.derived_fact_id = $1
1206- ORDER BY fd.seq",
1223+ ORDER BY x.ord",
12071224 )
1208- .bind(derived_id)
1225+ .bind(premises)
12091226 .fetch_all(pool)
12101227 .await?;
12111228 let mut steps = Vec::with_capacity(rows.len());
@@ -1227,7 +1244,7 @@
12271244 // 一条链最多 MAX_DEPTH 步,逐条取证据是可数的几次往返
12281245 let evidence = crate::graph::fact_evidence(pool, fact_id).await?;
12291246 steps.push(utopia_core::models::ProofStep {
1230- seq,
1247+ seq: seq as i32,
12311248 fact_id,
12321249 subject_id,
12331250 subject,
@@ -1242,7 +1259,65 @@
12421259 evidence,
12431260 });
12441261 }
1245- Ok(Some(utopia_core::models::Proof { derived, steps }))
1262+ Ok(steps)
1263+}
1264+
1265+/// 没落地的派生里,与这个实体有关的那些(0017 §3)——面板「推出来的」一档的
1266+/// 「没落地的」小节。
1267+pub async fn blocked_for_entity(
1268+ pool: &PgPool,
1269+ kb_id: Uuid,
1270+ entity_id: Uuid,
1271+) -> AppResult<Vec<utopia_core::models::BlockedDerivation>> {
1272+ Ok(sqlx::query_as(
1273+ "SELECT v.id AS violation_id,
1274+ (v.detail->>'subject_id')::uuid AS subject_id,
1275+ COALESCE(v.detail->>'subject', '?') AS subject,
1276+ (v.detail->>'object_id')::uuid AS object_id,
1277+ COALESCE(v.detail->>'object', '?') AS object,
1278+ COALESCE(v.detail->>'predicate', '?') AS predicate,
1279+ COALESCE(v.detail->>'rule', '?') AS rule,
1280+ COALESCE(v.detail->>'via_label', '?') AS via_label,
1281+ (v.detail->>'valid_from')::timestamptz AS valid_from,
1282+ (v.detail->>'valid_to')::timestamptz AS valid_to,
1283+ v.left_fact AS against_fact,
1284+ s.canonical_name || ' · '
1285+ || COALESCE(r.label, fact_surface_predicate(f.id), '?') || ' · '
1286+ || COALESCE(o.canonical_name, '?') AS against_text,
1287+ v.path AS premises
1288+ FROM axiom_violations v
1289+ JOIN facts f ON f.id = v.left_fact
1290+ JOIN entities s ON s.id = f.subject_id
1291+ LEFT JOIN relation_types r ON r.id = f.predicate_id
1292+ LEFT JOIN entities o ON o.id = f.object_id
1293+ WHERE v.kb_id = $1 AND v.kind = 'derived_contradiction' AND v.status = 'open'
1294+ AND (v.detail->>'subject_id' = $2::text OR v.detail->>'object_id' = $2::text)
1295+ ORDER BY v.detected_at DESC",
1296+ )
1297+ .bind(kb_id)
1298+ .bind(entity_id)
1299+ .fetch_all(pool)
1300+ .await?)
1301+}
1302+
1303+/// 没落地的派生的证明链:它的前提就在违规的 `path` 里。找不到那条违规时 `None`
1304+pub async fn blocked_proof(
1305+ pool: &PgPool,
1306+ kb_id: Uuid,
1307+ violation_id: Uuid,
1308+) -> AppResult<Option<Vec<utopia_core::models::ProofStep>>> {
1309+ let path: Option<(Vec<Uuid>,)> = sqlx::query_as(
1310+ "SELECT path FROM axiom_violations
1311+ WHERE id = $1 AND kb_id = $2 AND kind = 'derived_contradiction'",
1312+ )
1313+ .bind(violation_id)
1314+ .bind(kb_id)
1315+ .fetch_optional(pool)
1316+ .await?;
1317+ match path {
1318+ None => Ok(None),
1319+ Some((p,)) => Ok(Some(steps_for(pool, &p).await?)),
1320+ }
12461321 }
12471322
12481323 /// 按 id 取一条派生(失效的也取:证明要能回看)。
modified crates/utopia-store/tests/a_contradiction_points_upstream.rs +43 −0
@@ -225,6 +225,49 @@
225225 assert_eq!(card.hint.as_deref(), Some("stale"));
226226 assert_eq!(card.detail["subject"], "Mira");
227227
228+ // 争议在它坐的地方可见(0017 §3):面板行挂 contested,图上有一条幽灵边,
229+ // 「没落地的」一档有一行,它的证明链读得出前提
230+ let (_, facts) = utopia_store::graph::entity_detail(&pool, f.kb, f.mira).await?;
231+ let hit = facts
232+ .iter()
233+ .find(|x| x.id == old)
234+ .expect("the assertion is on the panel");
235+ let c = hit
236+ .contested
237+ .as_ref()
238+ .expect("the hit assertion is contested");
239+ assert_eq!(c["kind"], "derived_contradiction");
240+ assert_eq!(c["ref_id"], serde_json::json!(vid));
241+ assert!(
242+ facts
243+ .iter()
244+ .find(|x| x.id == ceo)
245+ .unwrap()
246+ .contested
247+ .is_none(),
248+ "the premise is not the disputed one"
249+ );
250+ let (_, edges) = utopia_store::graph::neighborhood(&pool, f.kb, f.mira, 1, None).await?;
251+ let ghost = edges
252+ .iter()
253+ .find(|e| e.blocked)
254+ .expect("a ghost edge for the blocked derivation");
255+ assert_eq!(ghost.id, *vid);
256+ assert!(ghost.derived && ghost.contested);
257+ assert_eq!((ghost.source, ghost.target), (f.mira, f.acme));
258+ assert!(edges.iter().find(|e| e.id == old).unwrap().contested);
259+ assert!(!edges.iter().find(|e| e.id == ceo).unwrap().contested);
260+ let blocked = reasoning::blocked_for_entity(&pool, f.kb, f.acme).await?;
261+ assert_eq!(blocked.len(), 1);
262+ assert_eq!(blocked[0].violation_id, *vid);
263+ assert_eq!(blocked[0].against_fact, old);
264+ assert_eq!(blocked[0].premises, vec![ceo]);
265+ let steps = reasoning::blocked_proof(&pool, f.kb, *vid)
266+ .await?
267+ .expect("the ghost has a proof");
268+ assert_eq!(steps.len(), 1);
269+ assert_eq!(steps[0].fact_id, ceo);
270+
228271 // 重跑幂等:还是那一行
229272 reasoning::run(&pool, f.kb).await?;
230273 assert_eq!(open_contradictions(&pool, &f).await?.len(), 1);
modified docs/decisions/0016-close-the-open-seams-before-cutting-new-ones.md +3 −3
@@ -1,6 +1,6 @@
11 # 0016 · Close the open seams before cutting new ones
22
3-- **Status**: in progress · the first schedule after v0.1.0 · A1, A2, A3 done · B1 done (#227) · B2a done (#238, [0017](0017-a-contradiction-points-upstream.md)), B2b planned · B3: the signature half done (#190 / #196), cross-pack signatures and range-aware direction done (#233), `disjointWith` into resolution still open · D2's blank-base problem worked around with builtin `metric` / `dimension` classes (#231), the pack itself still planned · the lakehouse engines landed ahead of D4 (#239, [0018](0018-the-lakehouse-is-one-protocol-away.md))
3+- **Status**: in progress · the first schedule after v0.1.0 · A1, A2, A3 done · B1 done (#227) · B2 done (#238 / #243, [0017](0017-a-contradiction-points-upstream.md)) · B3: the signature half done (#190 / #196), cross-pack signatures and range-aware direction done (#233), `disjointWith` into resolution still open · D2's blank-base problem worked around with builtin `metric` / `dimension` classes (#231), the pack itself still planned · the lakehouse engines landed ahead of D4 (#239, [0018](0018-the-lakehouse-is-one-protocol-away.md))
44 - **Written**: 2026-09-02 · condensed into English 2026-09-03
55 - **Related**: written after checking [0001](0001-ontology-import-and-governance.md) through [0015](0015-recording-a-sentence-is-not-asserting-a-fact.md) against the code; every item below has its source in those fifteen records, whose 2026-09-02 revision notes are the check's product. This record only orders them and says why this order.
66
@@ -44,8 +44,8 @@
4444
4545 **B · Finish the reasoning engine**, after A, parallel with C. B1 the R2 proof chain (done,
4646 #227; a chain, not a tree — see [0002](0002-reasoning-engine.md)). B2 the derived-vs-asserted
47-contradiction signal, `axiom_violations` kind `derived_contradiction` (B2a done; B2b, visibility
48-on graph and panel, planned — 0017). B3 `classify_type_drift` reads `entity_type_disjoint`
47+contradiction signal, `axiom_violations` kind `derived_contradiction` (done: B2a engine and
48+queue #238, B2b visibility on graph and panel #243 — 0017). B3 `classify_type_drift` reads `entity_type_disjoint`
4949 instead of the hard-coded list, today's behavior when nothing is declared (class kinship from the
5050 hierarchy landed first, #226). B4 R3 incremental
5151 maintenance, deferred until a full re-derivation of `ai-timeline-ends` exceeds a threshold
modified docs/decisions/0017-a-contradiction-points-upstream.md +1 −1
@@ -1,6 +1,6 @@
11 # 0017 · A contradiction points at an error upstream
22
3-- **Status**: B2a implemented (engine and queue: `derive::contradictions`, migration 0020, the Review card with clues and repairs) · B2b (visibility in the graph and the entity panel) still planned · B2 of 0016, wider than the one line written there: contradictions become visible everywhere, not only as a new kind in the queue
3+- **Status**: implemented · B2a (#238): engine and queue — `derive::contradictions`, migration 0020, the Review card with clues and repairs · B2b: contested edges in the alert colour and ghost edges for blocked derivations on the graph, the disputed chip on panel rows, the "did not land" section of the Derived tab with its proof chain · B2 of 0016, wider than the one line written there: contradictions become visible everywhere, not only as a new kind in the queue
44 - **Written**: 2026-09-03 (conventions in [README](README.md))
55 - **Related**: the two unbuilt rows of the "derived vs asserted" table in [0002](0002-reasoning-engine.md) §2; [0016](0016-close-the-open-seams-before-cutting-new-ones.md) B2; the proof chain (B1, #227) supplies the "premises expand to the sentence" half of the card below
66
modified docs/decisions/README.md +2 −2
@@ -39,8 +39,8 @@
3939 | 0013 | [A source hands over its history](0013-a-source-should-hand-over-its-history.md) | Implemented for GitHub, Jira and Notion (#134 / #135 / #213) · Feishu and Confluence not started · `instant` precision not triggered |
4040 | 0014 | [Identity from the person, scope from the token](0014-identity-from-the-person-scope-from-the-token.md) | Implemented (#180) · five read-only MCP tools over Streamable HTTP · tokens page at `/account/tokens` · `can_write` still hard-coded false |
4141 | 0015 | [A recorded sentence waits for a nod](0015-recording-a-sentence-is-not-asserting-a-fact.md) | Implemented · memory facts wait in `pending_facts`, nod queue and chat card, `remember` reopened · MCP write is the next cut |
42-| 0016 | [Close the open seams before cutting new ones](0016-close-the-open-seams-before-cutting-new-ones.md) | In progress · A done · B1 and B2a done, B2b and `disjointWith` open · C untouched · D2 worked around (#231); the lakehouse landed ahead of D4 (#239) |
43-| 0017 | [A contradiction points at an error upstream](0017-a-contradiction-points-upstream.md) | B2a implemented: engine and queue, per-item cap, aggregation by rule pair, cards with clues and repairs (#238) · B2b planned: disputes visible on the graph and in the panel |
42+| 0016 | [Close the open seams before cutting new ones](0016-close-the-open-seams-before-cutting-new-ones.md) | In progress · A done · B1 and B2 done, `disjointWith` open · C untouched · D2 worked around (#231); the lakehouse landed ahead of D4 (#239) |
43+| 0017 | [A contradiction points at an error upstream](0017-a-contradiction-points-upstream.md) | Implemented · B2a: engine and queue, per-item cap, aggregation by rule pair, cards with clues and repairs (#238) · B2b: contested edges in the alert colour, ghost edges for blocked derivations, the disputed chip and the "did not land" section in the panel (#243) |
4444 | 0018 | [The lakehouse is one protocol away](0018-the-lakehouse-is-one-protocol-away.md) | Implemented: Trino (Iceberg / Delta / Hive), Databricks and Snowflake behind the same trait, scheme picks the engine (#239) · replay tests only, real clusters wanted (#240–#242) · MaxCompute waits |
4545
4646 ## Not a decision record
modified web/src/api.ts +37 −0
@@ -324,6 +324,24 @@
324324 premises: string[];
325325 }
326326
327+/** 一条**没有落地**的派生(0017 §3):推出来了,撞上一条断言,拦在图外。
328+ * 没有自己的 id,用那条违规的 id 指它——面板、幽灵边、Review 卡片三处靠它对上 */
329+export interface BlockedDerivation {
330+ violation_id: string;
331+ subject_id: string;
332+ subject: string;
333+ object_id: string;
334+ object: string;
335+ predicate: string;
336+ rule: string;
337+ via_label: string;
338+ valid_from: string | null;
339+ valid_to: string | null;
340+ against_fact: string;
341+ against_text: string;
342+ premises: string[];
343+}
344+
327345 /** 证明的一步:一条断言前提,带它的证据。前提一律是断言,所以证明是链不是树 */
328346 export interface ProofStep {
329347 seq: number;
@@ -646,6 +664,11 @@
646664 valid_from: string | null;
647665 valid_to: string | null;
648666 confidence: number;
667+ /** 有争议(0017 §3):有一条 open 的公理违规或时态冲突指着它。整条边画成警戒色 */
668+ contested: boolean;
669+ /** 幽灵边(0017 §3):没落地的派生。`id` 是那条 `derived_contradiction` 违规的 id;
670+ * `derived` 同时为 true,跟着派生开关走。点它打开主语的面板 */
671+ blocked: boolean;
649672 }
650673
651674 export interface EntityFact {
@@ -673,6 +696,13 @@
673696 stale: boolean;
674697 /** 修正行:区间闭合来自引擎对账/人工裁决而非抽取原文 */
675698 corrected: boolean;
699+ /** 有争议(0017 §3):哪一种、Review 里那一项的 id、派生撞断言时推出来的那句话。
700+ * 行不压暗——断言仍然活着 */
701+ contested: {
702+ kind: string;
703+ ref_id: string;
704+ derived?: string | null;
705+ } | null;
676706 /** 证据集合里最新的文档时间(开放事实的"最后确认时间") */
677707 last_evidence_time: string | null;
678708 }
@@ -1361,6 +1391,8 @@
13611391 /** 推出来的那些**单独一个键**,不掺进 facts:混在同一个列表里,
13621392 * 用户看不出「文档里写的」和「引擎推的」的区别 */
13631393 derived: DerivedFact[];
1394+ /** 没落地的派生(0017 §3):连 `derived_facts` 都不在,所以也单独一个键 */
1395+ blocked: BlockedDerivation[];
13641396 /** 同名的其他实体。**打开面板就给**——合并入口要长在能看见同名的地方,
13651397 * 而不是藏在「改一次名」之后 */
13661398 same_name: GraphNode[];
@@ -1391,6 +1423,11 @@
13911423 request<{ proof: Proof | null }>(
13921424 `/api/v1/kbs/${kbId}/derived/${derivedId}/proof`,
13931425 ),
1426+ /** 没落地的派生的证明链(0017 §3):前提在违规的 path 里 */
1427+ blockedProof: (kbId: string, violationId: string) =>
1428+ request<{ steps: ProofStep[] | null }>(
1429+ `/api/v1/kbs/${kbId}/violations/${violationId}/proof`,
1430+ ),
13941431 documentDetail: (id: string) =>
13951432 request<{ document: Doc; chunks: ChunkFull[] }>(`/api/v1/documents/${id}`),
13961433 extractDocument: (id: string) =>
modified web/src/i18n/en.ts +13 −0
@@ -732,6 +732,19 @@
732732 derivedHint:
733733 "Edges no one asserted — the engine worked them out from axioms your ontology declares. Each one shows the premises it came from.",
734734 derivedNoProof: "The premises are gone.",
735+ /* 争议(0017 §3) */
736+ contestedChip: "disputed",
737+ contestedHint: (kind: string, derived: string | null) =>
738+ kind === "derived_contradiction"
739+ ? `A derivation contradicts this assertion${derived ? `: ${derived}` : ""}. Open it under Review.`
740+ : kind === "temporal_conflict"
741+ ? "A newer assertion conflicts with this one in time. Open it under Review."
742+ : "This assertion breaks an axiom the ontology declares. Open it under Review.",
743+ blockedTitle: "Did not land",
744+ blockedHint:
745+ "The engine could draw these edges; an assertion stood in the way. They show on the graph as ghost edges.",
746+ blockedBy: (t: string) => `blocked by ${t}`,
747+ blockedReview: "Review",
735748 /** 证明链(0002 R2):每一步是一条断言前提,展开到原句 */
736749 proofStep: (n: number) => `Step ${n}`,
737750 proofRetracted: "since retracted",
modified web/src/i18n/zh.ts +11 −0
@@ -674,6 +674,17 @@
674674 derivedHint:
675675 "没有人断言过的边——引擎按本体声明的公理推出来的。每一条都附着它用到的前提。",
676676 derivedNoProof: "前提已经不在了。",
677+ contestedChip: "有争议",
678+ contestedHint: (kind: string, derived: string | null) =>
679+ kind === "derived_contradiction"
680+ ? `有一条推出来的事实与它抵触${derived ? `:${derived}` : ""}。去 Review 看。`
681+ : kind === "temporal_conflict"
682+ ? "有一条更新的断言在时间上与它冲突。去 Review 看。"
683+ : "这条断言违反了本体声明的公理。去 Review 看。",
684+ blockedTitle: "没落地的",
685+ blockedHint: "引擎本可以画出这些边,被一条断言挡住了。图上画成幽灵边。",
686+ blockedBy: (t: string) => `挡住它的:${t}`,
687+ blockedReview: "去 Review",
677688 proofStep: (n: number) => `第 ${n} 步`,
678689 proofRetracted: "后来撤了",
679690 proofLoading: "正在展开证明…",
modified web/src/pages/Graph.tsx +299 −64
@@ -1,4 +1,11 @@
1-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
1+import {
2+ useCallback,
3+ useEffect,
4+ useMemo,
5+ useRef,
6+ useState,
7+ type MutableRefObject,
8+} from "react";
29 import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
310 import { Link, useNavigate, useSearch } from "@tanstack/react-router";
411 import Graphology from "graphology";
@@ -34,6 +41,8 @@
3441 type Evidence,
3542 type GraphEdge,
3643 type GraphNode,
44+ type BlockedDerivation,
45+ type ProofStep,
3746 } from "../api";
3847 import { S } from "../i18n";
3948 import { usePopoverFlip } from "../ui/popoverFlip";
@@ -69,6 +78,10 @@
6978 // 用户要在余光里就分得出「文档里写的」和「推出来的」
7079 const EDGE_COLOR_DERIVED = "rgba(231,197,124,0.42)";
7180 const EDGE_COLOR_DERIVED_DIM = "rgba(231,197,124,0.14)";
81+/* 争议(0017 §3):珊瑚橙 `--u-contest`。金是派生、琥珀是警告、粉是危险,
82+ 它得跟三个都拉开。**整条边换色**——环在节点上、边还是灰的,余光分不出来 */
83+const EDGE_COLOR_CONTEST = "rgba(255,106,61,0.55)";
84+const EDGE_FOCUS_CONTEST = "rgba(255,106,61,1)";
7285
7386 /** 相邻两条弧之间的曲率差。太小仍然糊,太大在长边上会甩得离节点很远 */
7487 const EDGE_CURVATURE_STEP = 0.18;
@@ -187,6 +200,10 @@
187200 // 注意:sigma 边着色器在预乘混合(ONE, ONE_MINUS_SRC_ALPHA)下不预乘 RGB,
188201 // alpha 无法压暗边——暗度必须编码进 RGB(不透明近背景色)
189202 const EDGE_DIM = "#141414";
203+/* 幽灵边:没落地的派生。同一个色相往 EDGE_DIM 混(预乘混合下 alpha 压不暗边),
204+ 更细。sigma 默认的边程序画不了虚线,也不为此另写一个 */
205+const EDGE_GHOST = lerpColor("rgba(255,106,61,1)", EDGE_DIM, 0.55);
206+const EDGE_GHOST_FOCUS = lerpColor("rgba(255,106,61,1)", EDGE_DIM, 0.2);
190207 const EDGE_FOCUS = "rgba(255,255,255,0.55)";
191208 // 选中/悬停时的派生边。**不能跟着走白**:选中恰恰是看得最仔细的时候,
192209 // 而这时候「这条边是推出来的、没人写过」比任何时候都该说清楚。
@@ -439,6 +456,8 @@
439456 先留在原地演完退场,再真的移除。用 selectedRef 取当前值而不是把
440457 setState 写成带副作用的 updater:那种写法在 StrictMode 下会跑两遍 */
441458 const [exiting, setExiting] = useState<string | null>(null);
459+ // 打开面板时想停在哪一档、展开哪一行——幽灵边点进来时用
460+ const panelIntentRef = useRef<{ view: "derived"; open: string } | null>(null);
442461 const deselect = useCallback(() => {
443462 const cur = selectedRef.current;
444463 if (!cur) return;
@@ -843,13 +862,20 @@
843862 );
844863 for (const { edge: e, curvature, alsoLabels } of placed.edges) {
845864 g.addEdgeWithKey(e.id, e.source, e.target, {
846- label: e.label?.toUpperCase() ?? "",
847- size: 1,
848- color: e.derived
849- ? EDGE_COLOR_DERIVED
850- : e.inferred
851- ? EDGE_COLOR_INFERRED
852- : EDGE_COLOR,
865+ // 争议的边标签前置 ⚠:颜色之外再给一个不靠色觉的记号
866+ label: (e.contested ? "⚠ " : "") + (e.label?.toUpperCase() ?? ""),
867+ size: e.blocked ? 0.7 : 1,
868+ color: e.blocked
869+ ? EDGE_GHOST
870+ : e.contested
871+ ? EDGE_COLOR_CONTEST
872+ : e.derived
873+ ? EDGE_COLOR_DERIVED
874+ : e.inferred
875+ ? EDGE_COLOR_INFERRED
876+ : EDGE_COLOR,
877+ contested: e.contested,
878+ blocked: e.blocked,
853879 // 独一条就走直线:曲线是为了把重叠分开,没有重叠就不必弯
854880 type: curvature === 0 ? "line" : "curved",
855881 curvature,
@@ -1170,16 +1196,24 @@
11701196 : null;
11711197 const hovNow = hoverRef.current;
11721198 const focused = selNow ?? hovNow;
1199+ const ghost = attrs.blocked === true;
11731200 const from = !focused
1174- ? EDGE_COLOR_DERIVED
1201+ ? ghost
1202+ ? EDGE_GHOST
1203+ : EDGE_COLOR_DERIVED
11751204 : s === focused || t === focused
1176- ? EDGE_FOCUS_DERIVED
1205+ ? ghost
1206+ ? EDGE_GHOST_FOCUS
1207+ : EDGE_FOCUS_DERIVED
11771208 : EDGE_DIM;
11781209 res.color = lerpColor(from, EDGE_DIM, k);
11791210 res.label = "";
11801211 return res;
11811212 }
1182- const pulse = lerpColor(
1213+ // 幽灵边不呼吸:它不是知识,是一条没走通的路
1214+ const pulse = attrs.blocked === true
1215+ ? EDGE_GHOST
1216+ : lerpColor(
11831217 EDGE_COLOR_DERIVED_DIM,
11841218 EDGE_COLOR_DERIVED,
11851219 // 三角波而不是正弦:两端各停一瞬,看起来是「呼吸」不是「闪」
@@ -1199,7 +1233,14 @@
11991233 ? selectedRef.current
12001234 : null;
12011235 const boost = () => {
1202- res.color = isDerived ? EDGE_FOCUS_DERIVED : EDGE_FOCUS;
1236+ res.color =
1237+ attrs.blocked === true
1238+ ? EDGE_GHOST_FOCUS
1239+ : attrs.contested === true
1240+ ? EDGE_FOCUS_CONTEST
1241+ : isDerived
1242+ ? EDGE_FOCUS_DERIVED
1243+ : EDGE_FOCUS;
12031244 res.size = Math.max((attrs.size as number) * 1.42, 1.85);
12041245 res.zIndex = 5;
12051246 };
@@ -1245,6 +1286,13 @@
12451286 },
12461287 });
12471288 sigma.on("clickNode", ({ node }) => setSelected(node));
1289+ // 幽灵边点一下:打开它主语的面板,停在「推出来的」那一档、展开那一行(0017 §3)
1290+ sigma.on("clickEdge", ({ edge }) => {
1291+ if (g.getEdgeAttribute(edge, "blocked") !== true) return;
1292+ const [s] = g.extremities(edge);
1293+ panelIntentRef.current = { view: "derived", open: edge };
1294+ setSelected(s);
1295+ });
12481296 sigma.on("doubleClickNode", ({ node, event }) => {
12491297 event.preventSigmaDefault();
12501298 setFocusEntity(node);
@@ -1840,6 +1888,7 @@
18401888 kbId={kb.id}
18411889 entityId={(selected ?? exiting)!}
18421890 exiting={!selected}
1891+ intent={panelIntentRef}
18431892 onClose={deselect}
18441893 onNavigate={(id) => {
18451894 // 跳转目标可能不在当前画布:同时把图 refocus 到它的邻域(与搜索选择一致)
@@ -2515,56 +2564,7 @@
25152564 {proof.isPending && (
25162565 <p className="text-[11px] text-neutral-600">{S.graph.proofLoading}</p>
25172566 )}
2518- {steps && (
2519- <ol className="space-y-2">
2520- {steps.map((st) => (
2521- <li key={st.fact_id} className="text-[11px]">
2522- <div className="flex items-baseline gap-1.5 flex-wrap">
2523- <span className="u-num text-[10px] text-neutral-600 shrink-0">
2524- {S.graph.proofStep(st.seq + 1)}
2525- </span>
2526- <span className={st.retracted ? "text-neutral-600 line-through" : "text-neutral-300"}>
2527- {st.subject}
2528- <span className="text-neutral-500"> — {st.predicate ?? "?"} → </span>
2529- {st.object ?? "?"}
2530- </span>
2531- {st.retracted && (
2532- <span className="u-chip u-chip-warn text-[10px]">{S.graph.proofRetracted}</span>
2533- )}
2534- </div>
2535- <div className="mt-0.5 space-y-1 pl-2">
2536- {st.evidence.map((ev) => (
2537- <Link
2538- key={ev.chunk_id}
2539- to="/kb/$kbId/doc/$docId"
2540- params={{ kbId, docId: ev.document_id }}
2541- search={{ chunk: ev.chunk_id }}
2542- className="block text-neutral-500 hover:text-neutral-300"
2543- >
2544- <div className="line-clamp-2 italic">
2545- {ev.quote ? `“${ev.quote}”` : S.graph.noQuote}
2546- </div>
2547- <div className="mt-0.5 text-neutral-400">
2548- {S.graph.sectionRef(ev.filename, ev.seq + 1)}
2549- {ev.stale && (
2550- <span
2551- className="ml-1.5 u-num text-[10px] text-neutral-600"
2552- title={S.graph.staleEvidenceHint}
2553- >
2554- {S.graph.fromVersion(ev.doc_version)}
2555- </span>
2556- )}
2557- </div>
2558- </Link>
2559- ))}
2560- {st.evidence.length === 0 && (
2561- <p className="text-neutral-600">{S.graph.noEvidence}</p>
2562- )}
2563- </div>
2564- </li>
2565- ))}
2566- </ol>
2567- )}
2567+ {steps && <ProofSteps kbId={kbId} steps={steps} />}
25682568 {/* 派生已失效、证明取不到:退回列表里带来的那几行文本 */}
25692569 {!proof.isPending && !steps && (
25702570 <ol className="space-y-0.5">
@@ -2582,10 +2582,200 @@
25822582 );
25832583 }
25842584
2585+/** 证明的步,落了地的与没落地的派生共用:前提是同一种东西 */
2586+function ProofSteps({ kbId, steps }: { kbId: string; steps: ProofStep[] }) {
2587+ return (
2588+ <ol className="space-y-2">
2589+ {steps.map((st) => (
2590+ <li key={st.fact_id} className="text-[11px]">
2591+ <div className="flex items-baseline gap-1.5 flex-wrap">
2592+ <span className="u-num text-[10px] text-neutral-600 shrink-0">
2593+ {S.graph.proofStep(st.seq + 1)}
2594+ </span>
2595+ <span className={st.retracted ? "text-neutral-600 line-through" : "text-neutral-300"}>
2596+ {st.subject}
2597+ <span className="text-neutral-500"> — {st.predicate ?? "?"} → </span>
2598+ {st.object ?? "?"}
2599+ </span>
2600+ {st.retracted && (
2601+ <span className="u-chip u-chip-warn text-[10px]">{S.graph.proofRetracted}</span>
2602+ )}
2603+ </div>
2604+ <div className="mt-0.5 space-y-1 pl-2">
2605+ {st.evidence.map((ev) => (
2606+ <Link
2607+ key={ev.chunk_id}
2608+ to="/kb/$kbId/doc/$docId"
2609+ params={{ kbId, docId: ev.document_id }}
2610+ search={{ chunk: ev.chunk_id }}
2611+ className="block text-neutral-500 hover:text-neutral-300"
2612+ >
2613+ <div className="line-clamp-2 italic">
2614+ {ev.quote ? `“${ev.quote}”` : S.graph.noQuote}
2615+ </div>
2616+ <div className="mt-0.5 text-neutral-400">
2617+ {S.graph.sectionRef(ev.filename, ev.seq + 1)}
2618+ {ev.stale && (
2619+ <span
2620+ className="ml-1.5 u-num text-[10px] text-neutral-600"
2621+ title={S.graph.staleEvidenceHint}
2622+ >
2623+ {S.graph.fromVersion(ev.doc_version)}
2624+ </span>
2625+ )}
2626+ </div>
2627+ </Link>
2628+ ))}
2629+ {st.evidence.length === 0 && (
2630+ <p className="text-neutral-600">{S.graph.noEvidence}</p>
2631+ )}
2632+ </div>
2633+ </li>
2634+ ))}
2635+ </ol>
2636+ );
2637+}
2638+
2639+/** 没落地的派生(0017 §3):像 DerivedRow 一样的一行,多一句「挡住它的是谁」,
2640+ * 展开是它的证明链——人在这里看到「引擎本可以画这条边,是什么拦住了它」 */
2641+function BlockedRow({
2642+ kbId,
2643+ b,
2644+ entityId,
2645+ open,
2646+ onToggle,
2647+ onNavigate,
2648+}: {
2649+ kbId: string;
2650+ b: BlockedDerivation;
2651+ entityId: string;
2652+ open: boolean;
2653+ onToggle: () => void;
2654+ onNavigate: (entityId: string) => void;
2655+}) {
2656+ const navigate = useNavigate();
2657+ const out = b.subject_id === entityId;
2658+ const otherId = out ? b.object_id : b.subject_id;
2659+ const otherName = out ? b.object : b.subject;
2660+ const proof = useQuery({
2661+ queryKey: ["blocked-proof", b.violation_id],
2662+ queryFn: () => api.blockedProof(kbId, b.violation_id),
2663+ enabled: open,
2664+ });
2665+ return (
2666+ <div
2667+ className={`rounded-lg transition-colors ${open ? "bg-white/[0.05]" : "hover:bg-white/[0.04]"}`}
2668+ >
2669+ <button
2670+ onClick={onToggle}
2671+ className="w-full text-left px-2 py-1.5 flex items-center gap-1.5"
2672+ >
2673+ <ChevronRight
2674+ size={11}
2675+ className={`shrink-0 text-neutral-600 transition-transform ${open ? "rotate-90" : ""}`}
2676+ />
2677+ {out ? <ArrowRight size={10} className="shrink-0 text-neutral-600" /> : <ArrowLeft size={10} className="shrink-0 text-neutral-600" />}
2678+ <span className="shrink-0 text-[11px] text-neutral-500">{b.predicate}</span>
2679+ <span
2680+ role="link"
2681+ tabIndex={0}
2682+ onClick={(ev) => {
2683+ ev.stopPropagation();
2684+ onNavigate(otherId);
2685+ }}
2686+ onKeyDown={(ev) => {
2687+ if (ev.key === "Enter") {
2688+ ev.stopPropagation();
2689+ onNavigate(otherId);
2690+ }
2691+ }}
2692+ className="truncate text-[13px] text-neutral-200 hover:text-white hover:underline underline-offset-2 decoration-white/30"
2693+ >
2694+ {otherName}
2695+ </span>
2696+ <span className="ml-auto shrink-0 pl-2 text-[10.5px] text-neutral-600">
2697+ {S.graph.ruleNames[b.rule] ?? b.rule}
2698+ </span>
2699+ </button>
2700+ <div className="flex items-center gap-1.5 px-2 pb-1.5 pl-[26px] text-[11px]">
2701+ <span className="truncate text-[var(--u-contest)]">
2702+ {S.graph.blockedBy(b.against_text)}
2703+ </span>
2704+ <span
2705+ role="link"
2706+ tabIndex={0}
2707+ onClick={() =>
2708+ navigate({
2709+ to: "/kb/$kbId/review",
2710+ params: { kbId },
2711+ search: { queue: "violations", item: b.violation_id },
2712+ })
2713+ }
2714+ className="ml-auto shrink-0 text-neutral-500 hover:text-neutral-300 hover:underline underline-offset-2"
2715+ >
2716+ {S.graph.blockedReview} →
2717+ </span>
2718+ </div>
2719+ {open && (
2720+ <div className="mx-2 mb-2 mt-0.5 border-l border-white/15 pl-2.5">
2721+ {proof.isPending && (
2722+ <p className="text-[11px] text-neutral-600">{S.graph.proofLoading}</p>
2723+ )}
2724+ {proof.data?.steps && (
2725+ <ProofSteps kbId={kbId} steps={proof.data.steps} />
2726+ )}
2727+ </div>
2728+ )}
2729+ </div>
2730+ );
2731+}
2732+
2733+/** 争议 chip(0017 §3):有一条 open 的违规或冲突指着这条断言。行不压暗——
2734+ * 它仍然活着。点它去 Review 对应那一档,并把那张卡点亮 */
2735+function ContestedChip({
2736+ kbId,
2737+ c,
2738+}: {
2739+ kbId: string;
2740+ c: NonNullable<EntityFact["contested"]>;
2741+}) {
2742+ const navigate = useNavigate();
2743+ const queue = c.kind === "temporal_conflict" ? "conflicts" : "violations";
2744+ return (
2745+ <span
2746+ role="link"
2747+ tabIndex={0}
2748+ onClick={(ev) => {
2749+ ev.stopPropagation();
2750+ navigate({
2751+ to: "/kb/$kbId/review",
2752+ params: { kbId },
2753+ search: { queue, item: c.ref_id },
2754+ });
2755+ }}
2756+ onKeyDown={(ev) => {
2757+ if (ev.key === "Enter") {
2758+ ev.stopPropagation();
2759+ navigate({
2760+ to: "/kb/$kbId/review",
2761+ params: { kbId },
2762+ search: { queue, item: c.ref_id },
2763+ });
2764+ }
2765+ }}
2766+ className="u-chip u-chip-contest shrink-0 !text-[10px] !px-1.5 cursor-pointer"
2767+ title={S.graph.contestedHint(c.kind, c.derived ?? null)}
2768+ >
2769+ {S.graph.contestedChip}
2770+ </span>
2771+ );
2772+}
2773+
25852774 function EntityPanel({
25862775 kbId,
25872776 entityId,
25882777 exiting,
2778+ intent,
25892779 onClose,
25902780 onNavigate,
25912781 }: {
@@ -2593,6 +2783,8 @@
25932783 entityId: string;
25942784 /** 正在演退场:还挂在 DOM 上,但已经不接受点击 */
25952785 exiting: boolean;
2786+ /** 打开时停在哪一档、展开哪一行;读一次就清掉 */
2787+ intent?: MutableRefObject<{ view: "derived"; open: string } | null>;
25962788 onClose: () => void;
25972789 onNavigate: (entityId: string) => void;
25982790 }) {
@@ -2604,6 +2796,8 @@
26042796 // 推出来的那些。**单独一个键,不掺进 facts**——混在一个列表里,用户看不出
26052797 // 「文档里写的」和「引擎推的」的区别
26062798 const derived = detail.data?.derived ?? [];
2799+ // 没落地的(0017 §3):推出来了,撞上一条断言
2800+ const blocked = detail.data?.blocked ?? [];
26072801 /* 按「方向 + 谓词 + 规则」分组,骨架与 Relations 的 groups 一致。
26082802 规则挂在组上而不是每一行:它对整组都成立,逐行重复既冗余,
26092803 那个琥珀色小字还会跟派生边抢色相 */
@@ -2635,6 +2829,13 @@
26352829 const [view, setView] = useState<
26362830 "relations" | "timeline" | "history" | "derived"
26372831 >("relations");
2832+ useEffect(() => {
2833+ const it = intent?.current;
2834+ if (!it) return;
2835+ intent.current = null;
2836+ setView(it.view);
2837+ setOpenFact(it.open);
2838+ }, [entityId, intent]);
26382839
26392840 const e: GraphNode | undefined = detail.data?.entity;
26402841
@@ -2919,8 +3120,10 @@
29193120 <div className="flex rounded-lg overflow-hidden border border-white/10 w-fit">
29203121 {(["relations", "timeline", "history", "derived"] as const)
29213122 // 推出来的那一档:**没有派生就不出现**。一个没开推理的库不该看到
2922- // 一个永远是空的标签页
2923- .filter((v) => v !== "derived" || derived.length > 0)
3123+ // 一个永远是空的标签页。没落地的也算——那正是这一档要说的事
3124+ .filter(
3125+ (v) => v !== "derived" || derived.length > 0 || blocked.length > 0,
3126+ )
29243127 .map((v) => (
29253128 <button
29263129 key={v}
@@ -3051,6 +3254,34 @@
30513254 </div>
30523255 </div>
30533256 ))}
3257+ {blocked.length > 0 && (
3258+ <div className="mb-3 last:mb-1">
3259+ <div className="flex items-center gap-1.5 px-2 pb-1 pt-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-[var(--u-contest)]">
3260+ <span>{S.graph.blockedTitle}</span>
3261+ <span className="ml-auto text-neutral-600">
3262+ {blocked.length}
3263+ </span>
3264+ </div>
3265+ <p className="px-2 pb-1.5 text-[11px] leading-relaxed text-neutral-500">
3266+ {S.graph.blockedHint}
3267+ </p>
3268+ {blocked.map((b) => (
3269+ <BlockedRow
3270+ key={b.violation_id}
3271+ kbId={kbId}
3272+ b={b}
3273+ entityId={entityId}
3274+ open={openFact === b.violation_id}
3275+ onToggle={() =>
3276+ setOpenFact(
3277+ openFact === b.violation_id ? null : b.violation_id,
3278+ )
3279+ }
3280+ onNavigate={onNavigate}
3281+ />
3282+ ))}
3283+ </div>
3284+ )}
30543285 </>
30553286 )}
30563287 {view !== "history" &&
@@ -3212,6 +3443,9 @@
32123443 {S.graph.staleFactChip}
32133444 </span>
32143445 )}
3446+ {fact.contested && (
3447+ <ContestedChip kbId={kbId} c={fact.contested} />
3448+ )}
32153449 </div>
32163450 </button>
32173451 {open && <EvidenceList kbId={kbId} fact={fact} />}
@@ -3296,6 +3530,7 @@
32963530 {S.graph.staleFactChip}
32973531 </span>
32983532 )}
3533+ {fact.contested && <ContestedChip kbId={kbId} c={fact.contested} />}
32993534 {interval && (
33003535 <span className="ml-auto shrink-0 pl-2 u-num text-[10.5px] text-neutral-500">
33013536 {interval}
modified web/src/pages/Review.tsx +15 −3
@@ -1,6 +1,6 @@
11 import { useEffect, useState } from "react";
22 import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3-import { useNavigate } from "@tanstack/react-router";
3+import { useNavigate, useSearch } from "@tanstack/react-router";
44 import { ArrowUpRight } from "lucide-react";
55 import {
66 api,
@@ -830,7 +830,11 @@
830830 const { kb } = useKb();
831831 const queryClient = useQueryClient();
832832 const navigate = useNavigate();
833- const [sel, setSel] = useState<Sel | null>(null);
833+ // 面板的争议 chip 带着 queue / item 跳过来:先落到那一档,再把那张卡点亮
834+ const search = useSearch({ from: "/app/kb/$kbId/review" });
835+ const [sel, setSel] = useState<Sel | null>(
836+ QUEUE_ORDER.includes(search.queue as Sel) ? (search.queue as Sel) : null,
837+ );
834838 const [page, setPage] = useState(0);
835839
836840 // 队列变化经 SSE 事件流推送(useKbEvents 挂在 Shell),无需轮询。
@@ -1301,8 +1305,15 @@
13011305 </div>
13021306 )}
13031307 {asViolations().map((v) => (
1304- <ViolationRow
1308+ <div
13051309 key={v.id}
1310+ className={
1311+ v.id === search.item
1312+ ? "rounded-xl ring-1 ring-[var(--u-contest)]"
1313+ : undefined
1314+ }
1315+ >
1316+ <ViolationRow
13061317 violation={v}
13071318 busy={
13081319 violationAction.isPending &&
@@ -1314,6 +1325,7 @@
13141325 onDuplicates={() => select("duplicates")}
13151326 onOntology={() => navigate({ to: "/ontology" })}
13161327 />
1328+ </div>
13171329 ))}
13181330 </div>
13191331 )}
modified web/src/router.tsx +7 −0
@@ -143,6 +143,13 @@
143143 const reviewRoute = createRoute({
144144 getParentRoute: () => kbRoute,
145145 path: "review",
146+ // 从实体面板的争议 chip 跳过来:落到对应那一档,并点亮那一张卡(0017 §3)
147+ validateSearch: (
148+ search: Record<string, unknown>,
149+ ): { queue?: string; item?: string } => ({
150+ queue: typeof search.queue === "string" ? search.queue : undefined,
151+ item: typeof search.item === "string" ? search.item : undefined,
152+ }),
146153 component: Review,
147154 });
148155
modified web/src/styles.css +5 −0
@@ -413,6 +413,11 @@
413413 background: rgba(242, 182, 109, 0.12);
414414 color: var(--u-warn);
415415 }
416+/* 争议(0017 §3):与图上的争议边同一个色相 */
417+.u-chip-contest {
418+ background: rgba(255, 106, 61, 0.14);
419+ color: var(--u-contest);
420+}
416421 .u-chip-danger {
417422 background: rgba(255, 157, 175, 0.12);
418423 color: var(--u-danger);