ontocast.tool.ontology_validation¶
Deterministic validation of ontology deltas.
Two lanes with different authorities: unit_findings validates a unit's
delta against its own (possibly partial) prompt snapshot inside the loop;
reconcile checks the merged document delta against the FULL catalog
terminals at reduce time, where duplicates invisible to a retrieved snapshot
become detectable.
Modules:
| Name | Description |
|---|---|
axiom_hygiene |
Deterministic clean-up of a document's ontology delta before it is written. |
catalog_terms |
The catalog's terms as the ontology prompts list them. |
consolidate |
Compile term actions into a graph patch, deterministically. |
label_repair |
LLM-free labels for newly minted ontology terms. |
plan |
The document ontology plan: model-free checks and the reduce-time split. |
reconcile |
Reduce-time reconciliation of minted terms against the whole catalog. |
shape |
Model-free measures of an ontology's shape, and a whole-catalog name index. |
unit_findings |
Deterministic per-unit findings on a unit's ontology delta. |
Attributes¶
__all__ = ['CatalogSurfaceIndex', 'MintedDuplicate', 'apply_minted_duplicate_rewrites', 'build_catalog_surface_index', 'collect_ontology_unit_findings', 'count_fixes_targeting_snapshot', 'detect_minted_duplicates']
module-attribute
¶
Classes¶
CatalogSurfaceIndex
¶
Bases: BaseModel
Names of every catalog term, case-insensitive, by label and local name.
Source code in ontocast/tool/ontology_validation/shape.py
Attributes¶
by_label = Field(default_factory=dict)
class-attribute
instance-attribute
¶
by_local = Field(default_factory=dict)
class-attribute
instance-attribute
¶
classes = Field(default_factory=set)
class-attribute
instance-attribute
¶
properties = Field(default_factory=set)
class-attribute
instance-attribute
¶
terms = Field(default_factory=set)
class-attribute
instance-attribute
¶
Methods:¶
MintedDuplicate
¶
Bases: BaseModel
One minted term that names an existing catalog term.
Source code in ontocast/tool/ontology_validation/reconcile.py
Functions:¶
apply_minted_duplicate_rewrites(merged_inserts, duplicates)
¶
Rewrite minted IRIs to their catalog IRIs, in place.
Substitutes in subject and object position — a second minted term referencing the duplicate must end up pointing at the catalog term, or the rewrite would strand it. Predicate position is included for completeness (a minted property duplicate used as a predicate elsewhere in the delta).
Returns:
| Type | Description |
|---|---|
int
|
Number of triples rewritten. |
Source code in ontocast/tool/ontology_validation/reconcile.py
build_catalog_surface_index(graphs)
¶
Index the labels, notations and local names of every subject.
Source code in ontocast/tool/ontology_validation/shape.py
collect_ontology_unit_findings(*, inserts, deletes, snapshot_graph, merged_graph=None, fact_namespaces=(), policy=None, max_class_depth=6, catalog_index=None, home_namespace=None)
¶
Assemble all deterministic findings for one unit's ontology delta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inserts
|
RDFGraph
|
Net new triples this unit adds ( |
required |
deletes
|
RDFGraph
|
Snapshot triples this unit removes. |
required |
snapshot_graph
|
RDFGraph | None
|
The prompt ontology context; |
required |
merged_graph
|
RDFGraph | None
|
|
None
|
fact_namespaces
|
Sequence[str]
|
Facts/document namespaces; ontology terms minted there are mandatory findings. |
()
|
policy
|
ValidationPolicy | None
|
Deployment namespace exemptions; |
None
|
max_class_depth
|
int
|
Deepest named-superclass chain a minted class may sit on. |
6
|
catalog_index
|
CatalogSurfaceIndex | None
|
Names of every catalog term, for the duplicate check;
|
None
|
home_namespace
|
str | None
|
The document's home namespace: where every new term
belongs. |
None
|
Returns:
| Type | Description |
|---|---|
list[OntologyUnitFinding]
|
Findings, mandatory first is not guaranteed — order follows the |
list[OntologyUnitFinding]
|
check sequence; callers filter on |
Source code in ontocast/tool/ontology_validation/unit_findings.py
count_fixes_targeting_snapshot(fixes, snapshot_graph, insert_subjects)
¶
Critic fixes aimed at catalog content this unit's delta never touched.
The ontology critic is shown snapshot + delta and can reject a unit
for pre-existing catalog defects the renderer cannot own. This counts the
proposed fixes whose incorrect_value names a snapshot-declared subject
absent from the unit's inserts — by full-IRI or prefixed-name substring
match, so it is a lower bound, recorded as telemetry rather than used for
control flow.
Source code in ontocast/tool/ontology_validation/unit_findings.py
detect_minted_duplicates(merged_inserts, catalog_index)
¶
Find minted terms that name an existing catalog term.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
merged_inserts
|
RDFGraph
|
Document-level merged insert delta. |
required |
catalog_index
|
CatalogSurfaceIndex
|
Names of every catalog term. |
required |
Returns:
| Type | Description |
|---|---|
list[MintedDuplicate]
|
One record per minted term with a unique, role-compatible match, |
list[MintedDuplicate]
|
ordered by minted IRI. Detection only — the caller decides whether to |
list[MintedDuplicate]
|
rewrite. |