mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-12 04:01:35 +00:00
* fix(explorer): resolve ontology ownership on the backend Which registered ontology owns an entity was decided twice: the backend applies nested-namespace boundaries, while the Ontology Editor did a bare prefix match. The two had already drifted, so a deep link to an entity in an unregistered nested namespace selected the parent ontology whose /graph response excludes that entity, and the selection silently failed. /api/ontology/entity now returns owning_ontology, resolved with the same rule the graph endpoint filters by, and the editor prefers it. The frontend namespace guess stays as the fallback for a missing verdict, documented as non-authoritative. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(explorer): keep the backend's no-owner verdict authoritative Review follow-up: loadOntologyEntityOwner collapsed the backend's explicit owning_ontology: null into undefined, re-activating the namespace prefix guess for exactly the unregistered-nested-namespace case this PR exists to fix. The owner verdict is now three-state (owner / authoritative none / unavailable) and resolveEditorOntology in the model suppresses inference on an authoritative none; only an unavailable verdict may fall back. Model tests pin all three states. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * refactor(explorer): trust the backend to send owning_ontology The Explorer bundle ships in the same wheel as the route that emits this field, so the legacy-response branch could never run. Dropping it lets the type say what the wire actually carries, leaving undefined to mean only what it should: the request failed. Note why the endpoint derives its ontology-URI set inline rather than calling _known_ontology_uris, so the next reader does not consolidate a graph scan back in. Co-Authored-By: Claude Code <noreply@anthropic.com> * fix(explorer): stop the registry default overriding a no-owner verdict resolveEditorOntology returned string | undefined, so the caller wrote `resolved || entries[0]?.uri` and an authoritative "nothing owns this entity" fell straight through to an arbitrary registry entry. When that entry happened to be the parent, the deep link opened the parent whose graph excludes the entity — the bug the verdict exists to prevent. Only the ordering of the registry in the earlier test hid it. It now returns a union: unowned and unresolved both mean "no ontology to open" but the editor treats them oppositely, so collapsing them with || is a type error rather than a silent regression. An unowned entity is reported on the canvas instead of quietly opening the wrong ontology. Also: - /entity resolves ownership through _known_ontology_uris, the same helper /graph uses, instead of deriving it from a get_nodes scan capped at 999,999. Past that cap the set was silently truncated and the two endpoints could disagree about who owns a node. - _resolve_owning_ontology does one pass over the candidates rather than one pass per candidate, each rescanning the whole set: 516us -> 9us at 50 ontologies, 125ms -> 138us at 800, same answers throughout. A test pins it against _node_belongs_to_ontology so the hand-rolled version cannot drift from the membership rule it has to mirror. - An explicit scheme_uri is honoured even when the registry does not list it, on both sides. Discarding it and guessing by namespace answered a question nobody asked; an unregistered owner now surfaces as an explicit error from /graph instead. - A missing owning_ontology field reads as "no verdict", not as the authoritative "nothing owns this". That claim now suppresses selection outright, so it must not be inferred from an absent field. Co-Authored-By: Claude Code <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Sameer Kadam <sskadam6305@gmail.com> Co-authored-by: Sameer Kadam <sameerkadam@Mac.lan>