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.
MintedDuplicate
¶
Bases: BaseModel
One minted term that exactly matches an existing catalog term.
Source code in ontocast/tool/ontology_validation/reconcile.py
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
collect_ontology_unit_findings(*, inserts, deletes, snapshot_graph, merged_graph=None, fact_namespaces=(), policy=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
|
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, terminal_graphs)
¶
Find minted terms whose surface form the full catalog already declares.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
merged_inserts
|
RDFGraph
|
Document-level merged insert delta. |
required |
terminal_graphs
|
dict[str, RDFGraph]
|
Writable IRI -> the freshest full terminal graph (the same graphs the apply step writes onto). |
required |
Returns:
| Type | Description |
|---|---|
list[MintedDuplicate]
|
One record per (minted term, catalog term) unique-surface match with a |
list[MintedDuplicate]
|
compatible role, ordered by minted IRI. Detection only — the caller |
list[MintedDuplicate]
|
decides whether to rewrite. |