Elffuss BraidHub

kikocis/utopia public

dev · 7.1 KiBSourceRawPermalink

0009 · An undecided type stays empty

The problem

A new KB used to seed nine entity classes: person organization project metric dimension product event concept location. None carried a signature (0008), and once schema.org is installed Person / Organization / Product / Event / Project are claimed by key, so the builtin set was a placeholder. location was worse: schema.org calls it Place, the keys differ, so City / AdministrativeArea hung under a separately created place — a name of our own cut the geographic subtree in two.

concept was different: it was control flow. extraction.rs required it ("Ontology missing the 'concept' type") as the landing place for entities whose type is not in the whitelist — a state that exists under any ontology — and as the candidate pool for type resolution (entities_for_type_resolution(kb, DUMPING_GROUND, …)). A "not decided yet" sat in the ontology as a class, as if someone had decided it.

Decisions

  1. Remove all nine classes; a KB without packs is truly empty. Extracted entities get type_id NULL, facts and evidence land as usual; install a pack later, rerun type resolution, and they are assigned — entities_for_type_resolution now takes type_id IS NULL. "Build the KB first, model later" is a supported path; schema.org is pre-checked in the create dialog. Landing added entities.type_source (extracted / human / inferred) to separate "not decided" from "a human decided there is none".
  2. entities.type_id becomes nullable, no sentinel row. The Rust compiler lists every consumer of the new Option. SQL does not: NULL <> uuid evaluates to NULL, so AND type_id <> $2 selects no rows and raises nothing. Hit twice on the main path — adopt_proposed_types and retype_entities, whose inputs are almost all type_id IS NULL — running silently empty with green tests. The fix is IS DISTINCT FROM (measured: <> selects 0 rows, IS DISTINCT FROM 1). The real cost was rereading every comparison in 26 SQL strings; the change touched 14 files, +316 / -369.
  3. Untyped same-name entities may coexist. The unique index (kb_id, type_id, lower(canonical_name)) WHERE merged_into IS NULL does not stop two untyped "张三", because NULL ≠ NULL. Intended: the index allows same name across types (0001 P0: two 张伟 must be storable apart), and untyped we know even less, so there is even less reason to merge. Recorded so nobody files it as a bug.
  4. Drawing it. The node query switched from JOIN entity_types to LEFT JOIN — an inner join makes an untyped entity vanish from the graph while its facts stay, the hardest data loss to notice. key and label stay NULL; color and shape get defaults (gray dot: the canvas must receive something). Review items likewise.
  5. First typing is a completion. Type resolution treats "chosen class outside the current subtree" as reclassification and sends it to a human; an untyped entity has no extraction judgment to overturn, and judging it cross-axis would put every entity in front of a person. entity_retypes.from_type_id is nullable accordingly — the commonest retype is none → some, and that table is the only basis for undo.
  6. CONFUSABLE_TYPE_KEYS stays (["organization","project","product"]): the keys still exist after schema.org, from import rather than seeding; without packs the tier never hits and every cross-type same-name pair is Disjoint — stricter, no wrong merges. The proper fix is to read disjointWith from the ontology.

Dead ends

Revisions

Open questions