Skip to content

World's first open-source enterprise world model.

An attribute whose range is xsd:hexBinary is imported as text (#1008)

Maya Kidc7ac51a72038
diff --git a/crates/utopia-ingest/src/ontology_rdf.rs b/crates/utopia-ingest/src/ontology_rdf.rs
index f3f89cb0..00090a0c 100644
--- a/crates/utopia-ingest/src/ontology_rdf.rs
+++ b/crates/utopia-ingest/src/ontology_rdf.rs
@@ -937,13 +937,16 @@ fn resolve_range(ranges: &[String], union: bool, vocab: &VocabDatatypes) -> Rang
/// `09:00`,而一张 base64 平面图不会出现在散文里;就算文档里真有一段 base64,
/// 把它当成事实抽出来也是错的。
///
+/// `hexBinary` 不在此列:名字里有 binary,写出来却是一串十六进制数字,散文里带的是
+/// 哈希、内存地址、标志位这类值(「该文件的 SHA-256 为 9f86d0…」),抽成事实是对的。
+/// UCO 有 12 个属性是它(#1001 的评审)。
+///
/// **其余一律降级成 text**——一个抽得出来的值,宁可类型糙一点也别让它没处可去。
fn unusable(iri: &str) -> bool {
if let Some(local) = iri.strip_prefix(XSD) {
return matches!(
local,
"base64Binary"
- | "hexBinary"
| "QName"
| "NOTATION"
| "ID"
@@ -971,11 +974,12 @@ fn datatype_of(iri: &str) -> Option<&'static str> {
// 我们的日期格式本就是 YYYY[-MM[-DD]],逐级可省,所以 gYear / gYearMonth 装得下
"date" | "dateTime" | "dateTimeStamp" | "gYear" | "gYearMonth" => Some("date"),
"boolean" => Some("bool"),
+ // hexBinary 的写法就是十六进制数字:哈希、地址、标志位,照原样存成文本不丢东西
"string" | "normalizedString" | "token" | "language" | "Name" | "NCName"
- | "NMTOKEN" | "anyURI" => Some("text"),
+ | "NMTOKEN" | "anyURI" | "hexBinary" => Some("text"),
// time / gMonth / gDay / gMonthDay 缺年,duration 系列是时长不是时点 ——
// 落到 None,再由 unusable() 分流:它们是可读字面量,降级成 text;
- // 二进制与 XML 内部标识才是真的不收
+ // base64 块与 XML 内部标识才是真的不收
_ => None,
};
}
@@ -1062,15 +1066,25 @@ mod tests {
map_range(&[format!("{XSD}duration")]),
RangeMapping::Degraded(_)
));
- // 取值本就不该进图谱:二进制块与 XML 片段,这才是真的跳过
- assert!(matches!(
- map_range(&[format!("{XSD}base64Binary")]),
- RangeMapping::Unusable(_)
- ));
- assert!(matches!(
- map_range(&[format!("{RDF_NS}XMLLiteral")]),
- RangeMapping::Unusable(_)
- ));
+ // 十六进制写出来的值:哈希、地址、标志位。它是一个值,照原样存成文本
+ assert_eq!(
+ map_range(&[format!("{XSD}hexBinary")]),
+ RangeMapping::Datatype("text")
+ );
+ // 取值本就不该进图谱:base64 块、XML 片段与 XML 内部标识,这才是真的跳过
+ for unusable in [
+ format!("{XSD}base64Binary"),
+ format!("{RDF_NS}XMLLiteral"),
+ format!("{XSD}QName"),
+ ] {
+ assert!(
+ matches!(
+ map_range(std::slice::from_ref(&unusable)),
+ RangeMapping::Unusable(_)
+ ),
+ "{unusable}"
+ );
+ }
}
/// 多条 range 在 RDFS 里是**交集**("必须同时是两者"),不是并集。
diff --git a/docs/decisions/0001-ontology-import-and-governance.md b/docs/decisions/0001-ontology-import-and-governance.md
index 20a2d110..985b5bf5 100644
--- a/docs/decisions/0001-ontology-import-and-governance.md
+++ b/docs/decisions/0001-ontology-import-and-governance.md
@@ -124,9 +124,10 @@ since moved to `scripts/bench/` (0012); these numbers are real but no longer com
20. **Attributes** (`create_attribute_with_iri`): `rdfs:range` → `datatype` three ways. A mappable XSD
type gets its datatype; no range → `text`, listed in the preview; a type we cannot express
(`time`, `gMonth`, `duration`, several ranges, unknown IRIs) → `text` and reported; a type the
- extractor could never read out of prose (`base64Binary`, `hexBinary`, `XMLLiteral`, `QName`,
- `ID`, `IDREF`, `ENTITY`) is skipped and reported. The dividing line is "can this value appear in a
- sentence": skipping protects the prompt, where every attribute is a line paid per chunk. A domain
+ extractor could never read out of prose (`base64Binary`, `XMLLiteral`, `QName`, `ID`, `IDREF`,
+ `ENTITY`) is skipped and reported. The dividing line is "can this value appear in a sentence":
+ skipping protects the prompt, where every attribute is a line paid per chunk. `hexBinary` → `text`:
+ it is written as hex digits, and what it carries in prose is a hash, an address or a flag. A domain
pointing at a class that was not imported is skipped and counted.
21. **Multiple inheritance is real.** FOAF's `Person` is both `foaf:Agent` and `geo:SpatialThing`;
keeping one parent makes attributes on the other branch fail their domain check.
@@ -250,6 +251,9 @@ since moved to `scripts/bench/` (0012); these numbers are real but no longer com
state their constraints as SHACL shapes (UCO, #923) declare almost none, so every attribute
without a domain was skipped at import; decision 13 now reads the shapes where a property
declares neither.
+- 2026-09-29: counted `hexBinary` among the values that never appear in prose. It is written as hex
+ digits, and forensic reports state hashes, addresses and flags in sentences (UCO has 12 such
+ properties, #1001); decision 20 now maps it to `text`. `base64Binary` stays skipped.
## Open questions