ontocast.onto.model¶
BasePydanticModel
¶
Bases: BaseModel
Shared base for the pipeline's Pydantic models.
Carries no behaviour of its own since the JSON save/load helpers were removed with their only consumer; it is kept as the common ancestor the state and report models already declare.
Source code in ontocast/onto/model.py
ExternalEvidenceCacheEntry
¶
Bases: BaseModel
Node-scoped external evidence planning/fetch outputs.
Source code in ontocast/onto/model.py
ExternalEvidenceHit
¶
Bases: BaseModel
Normalized external evidence hit metadata.
Source code in ontocast/onto/model.py
ExternalEvidencePlan
¶
Bases: BaseModel
Structured plan for optional external evidence retrieval.
Source code in ontocast/onto/model.py
coerce_rationale(v)
classmethod
¶
Mirror the coercion on ExternalEvidenceRequest.rationale.
ExternalEvidenceRequest
¶
Bases: BaseModel
Node-level request for optional web search.
Nodes use this to explicitly signal whether downstream evidence planning/fetching should run for another pass.
Source code in ontocast/onto/model.py
FactsGateRepairKind
¶
Bases: StrEnum
Kinds of machine-applied repair at the post-aggregation gate.
Distinct from :class:FactsUnitFindingKind: these are shape-driven and
apply to the merged graph, where the SHACL report is available.
Source code in ontocast/onto/model.py
FactsRenderReport
¶
Bases: BaseModel
Facts rendering output with optional search decision.
Source code in ontocast/onto/model.py
FactsUnitFinding
¶
Bases: UnitFinding
One deterministic, machine-found issue in a rendered facts graph.
Source code in ontocast/onto/model.py
FactsUnitFindingKind
¶
Bases: StrEnum
Kinds of deterministic per-unit facts findings.
Source code in ontocast/onto/model.py
FactsValidationFinding
¶
Bases: BaseModel
One invariant violation detected in the aggregated facts graph.
Error-severity findings of the merge-signature kinds
(FUNCTIONAL_VIOLATION, SUSPECT_MULTI_VALUE,
DEGENERATE_COREFERENCE) on subjects that resulted from an identity
merge drive the deterministic un-merge repair (full-cluster pair vetoes
plus re-aggregation). SHACL findings never drive it — a constraint
violation says a node is under-specified, not that two entities were
wrongly identified. Warning findings are telemetry only.
Source code in ontocast/onto/model.py
FactsValidationFindingKind
¶
Bases: StrEnum
Kinds of deterministic post-aggregation facts findings.
Source code in ontocast/onto/model.py
GraphRepairRecord
¶
Bases: BaseModel
One machine-applied deterministic rewrite on a facts graph.
LLM-free by construction: every repair either rewrites a term the catalog
already declares or removes a node that asserts nothing. Records what the
repair passes changed (near-miss predicate rewrites, literal rdf:type
coercions, shape-driven retyping/pruning) so downstream consumers can
distinguish machine-altered triples from what the LLM asserted.
Source code in ontocast/onto/model.py
GraphUpdateRenderReport
¶
Bases: BaseModel
Graph update rendering output with optional search decision.
The wire shape is deliberately flat, and deliberately the same shape as
:class:FactsRenderReport: two sibling graph fields, no wrapper object and
no list. The previous shape nested the graph inside
graph_update.triple_operations[], and a singleton list holding one
long JSON-LD document is a shape models close wrongly -- measured at 20/24
malformed above ~4k characters on gpt-5-mini, versus 0/22 whenever the list
happened to hold two or more operations and the },{ boundary reinforced
the array frame. Nothing here may reintroduce a list-of-one around a large
payload.
The internal :class:GraphUpdate keeps its ordered TripleOp list; this
is a wire encoding, not the patch model. See :meth:to_graph_update.
Source code in ontocast/onto/model.py
to_graph_update()
¶
Compile the wire payload into an ordered patch.
Deletes are ordered before inserts, and an empty side contributes no operation. Interleaving the two within a single render is not expressible on this wire: it would only matter for a patch that removes and re-adds the same triple, which nets out to nothing.
Source code in ontocast/onto/model.py
LoopAttempt
¶
Bases: BaseModel
Telemetry record for one attempt inside a per-unit render/critic loop.
Shared by the facts and the ontology loop — the fields are phase-neutral
and a record's home (UnitFactsState.attempt_log vs
UnitOntologyState.attempt_log) says which loop produced it.
n_deterministic_findings / n_mandatory_findings count findings
against the graph as of this record: for llm_repair records that is the
residual after the repair render, so summing the last repair record per
unit yields the true document-level residual.
kind="llm_repair" is a finding-driven render — it costs a provider
call. LLM-free machine rewrites are not attempts and are recorded as
GraphRepairRecord instead.
Source code in ontocast/onto/model.py
OntologyCritiqueReport
¶
Bases: BaseModel
Report from ontology update critique process.
Source code in ontocast/onto/model.py
OntologyRenderReport
¶
Bases: BaseModel
Ontology rendering output with optional search decision.
Source code in ontocast/onto/model.py
OntologySelectorReport
¶
Bases: BasePydanticModel
Base class for ontology selection report.
Note: Use create_ontology_selector_report_model() to create a model with the correct answer_index constraint.
Source code in ontocast/onto/model.py
OntologyUnitFinding
¶
Bases: UnitFinding
One deterministic, machine-found issue in a unit's ontology delta.
Source code in ontocast/onto/model.py
OntologyUnitFindingKind
¶
Bases: StrEnum
Kinds of deterministic per-unit ontology findings.
Computed against the unit's net insert/delete delta, never the whole
working graph — validating snapshot+delta would attribute every
pre-existing catalog defect to this unit, and the facts UNKNOWN_TERM
rule is semantically inverted here (minting new terms is the ontology
renderer's job).
Source code in ontocast/onto/model.py
Suggestions
¶
Bases: BaseModel
Report from knowledge graph critique process.
Attributes:
| Name | Type | Description |
|---|---|---|
systemic_critique_summary |
str
|
A compilation of general improvement suggestions. |
actionable_fixes |
list[TripleFix]
|
An itemized list of concrete suggestions for improvement. |
Source code in ontocast/onto/model.py
from_critique_report(critique)
classmethod
¶
Create Suggestions from any critique report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
critique
|
OntologyCritiqueReport | FactsCritiqueReport
|
Either an OntologyCritiqueReport or FactsCritiqueReport to convert. |
required |
Returns:
| Type | Description |
|---|---|
Suggestions
|
Suggestions object with actionable fixes and systemic critique summary. |
Source code in ontocast/onto/model.py
to_markdown()
¶
Convert actionable fixes and systemic critique summary to a unified markdown block.
Returns:
| Type | Description |
|---|---|
str
|
Markdown formatted string with both actionable fixes and systemic critique summary. |
Source code in ontocast/onto/model.py
TripleFix
¶
Bases: BaseModel
A single actionable correction to an RDF facts or ontology graph.
incorrect_value / correct_value are plain strings; encoding follows
deployment llm_graph_format and GRAPH FORMAT INSTRUCTION.
Source code in ontocast/onto/model.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
coerce_free_text(v)
classmethod
¶
Coerce the two required free-text fields.
Both are required with no default, so a provider answering either with a
bulleted list raised and discarded the whole critique report. Deliberately
not applied to incorrect_value/correct_value: those carry graph
syntax, where joining a list would corrupt the payload rather than
recover it.
Source code in ontocast/onto/model.py
normalize_severity(v)
classmethod
¶
Normalize severity values to accepted literals.
Maps 'major' to 'important' for backward compatibility with prompts that use 'major' terminology. This allows the LLM to use either term.
Source code in ontocast/onto/model.py
to_markdown()
¶
Convert this TripleFix to markdown format.
Returns:
| Type | Description |
|---|---|
str
|
Markdown formatted string representing this fix. |
Source code in ontocast/onto/model.py
UnitFailure
¶
Bases: BaseModel
One content unit that produced no usable output.
Carried to the document level so a caller can tell "nothing to extract"
from "every unit failed" -- previously both produced an empty result with
status: success.
Source code in ontocast/onto/model.py
UnitFinding
¶
Bases: BaseModel
One deterministic, machine-found issue in a rendered unit graph.
Base shape shared by the facts and ontology validators; the subclasses
pin kind to their own enum. Mandatory findings are violations the
renderer must fix; non-mandatory findings list candidates the renderer
adjudicates item by item.
Source code in ontocast/onto/model.py
create_ontology_selector_report_model(num_ontologies)
¶
Create a dynamic OntologySelectorReport model with answer_index constraint.
The answer_index field is constrained to be between 1 and num_ontologies + 1, where: - 1 to num_ontologies: corresponds to the ontology at that index (1-based) - num_ontologies + 1: represents "None" (no suitable ontology)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_ontologies
|
int
|
The number of ontologies in the selection list. |
required |
Returns:
| Type | Description |
|---|---|
type[BasePydanticModel]
|
A dynamically created Pydantic model class with the appropriate constraint. |
Source code in ontocast/onto/model.py
format_findings_for_prompt(findings, *, advisory_heading='## Verify numeric coverage')
¶
Render findings as MANDATORY-fixes + advisory blocks for a prompt.
The default advisory heading is the facts loop's (its only advisory kind is numeric coverage) and is part of prompts already in the LLM cache — callers with different advisory content pass their own heading rather than changing the default.