ontocast.onto.ontology_snapshot¶
Prompt-facing ontology snapshot: graph view with provenance, no catalog identity.
Assembled from catalog ontologies (O* → S). Not a versioned catalog subject;
writeback (U → O*) targets real :class:Ontology instances by namespace ownership.
OntologySnapshot
¶
Bases: BasePydanticModel
Ephemeral multi-source ontology context for LLM prompts.
Holds triples + prefix bindings and assembly provenance. Does not carry
catalog iri / ontology_id / lineage — those belong only on
:class:~ontocast.onto.ontology.Ontology.
Source code in ontocast/onto/ontology_snapshot.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
describe_for_prompt()
¶
Human-readable multi-source description for ontology-update prompts.
Source code in ontocast/onto/ontology_snapshot.py
domain_prefix_pairs()
¶
Domain prefix/namespace pairs from graph bindings (prompt hygiene).
Source code in ontocast/onto/ontology_snapshot.py
empty(*, assembly_mode=OntologyAssemblyMode.SELECTED_VECTOR_SEARCH_ENSEMBLE, title=None, description=None)
classmethod
¶
Build an empty snapshot (no triples, no sources).
Source code in ontocast/onto/ontology_snapshot.py
from_graph(graph, *, source_iris, assembly_mode, title=None, description=None, strip_headers=True)
classmethod
¶
Assemble a snapshot from a (possibly multi-source) graph.
Source code in ontocast/onto/ontology_snapshot.py
from_ontology(ontology, *, assembly_mode, title=None, description=None)
classmethod
¶
Assemble a snapshot from a single catalog ontology (graph copy).
Source code in ontocast/onto/ontology_snapshot.py
invalidate_prompt_cache()
¶
Drop memoised prompt text.
Call this after mutating :attr:graph in place. Reassigning graph
needs no call -- the cache key includes the graph's identity.
Source code in ontocast/onto/ontology_snapshot.py
is_empty()
¶
prompt_chapter(profile, *, max_triples=None)
¶
Serialised ontology chapter for prompts, memoised per graph.
Serialising the ontology is the single most expensive step in building a facts prompt, and under a shared document snapshot every unit -- and every render attempt within a unit -- would otherwise redo it on an identical graph, synchronously, on the event loop.
The memo is keyed on the graph's identity, length and the profile's wire
format. It is therefore correct for a snapshot whose graph is replaced,
and assumes the graph is not mutated in place, which is the contract
this class already documents ("ephemeral" context, read-only in the unit
loops). Any code that does mutate it must call
:meth:invalidate_prompt_cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Any
|
Graph format profile supplying the serialisation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The |