ontocast.stategraph.facts_gate¶
The post-aggregation facts invariant gate, shared by both entry paths.
Two callers reach this gate with the same contract and different capabilities:
- the document graph, at
VALIDATE_FACTS-- many units, so the un-merge repair is meaningful; - the single-unit path (
/process_unitand the CLI--use-unit-pipelinebatch), which does not run the graph and calls in after aggregation.
Un-merging re-aggregates retained units against each other, which has no
meaning for one unit, so the single-unit caller passes merge_repair=False.
Everything else -- validation arguments, SHACL autofix, conformance summary and
the emitted metrics -- is identical, and used to be written out twice; a new
validate_aggregated_facts argument added to one copy silently skipped the
other entry path.
run_facts_gate(state, ontology_graph, tools, *, merge_repair, document_metadata=None)
¶
Validate the aggregated facts and apply the two LLM-free repair stages.
When merge_repair is set, merge-signature error findings whose subject
resulted from an identity merge turn the offending cluster into pair vetoes
and the retained facts units are re-aggregated, up to
FACTS_MERGE_REPAIR_PASSES times. Then, on both paths, SHACL autofix
(FACTS_SHACL_AUTOFIX) repairs constraint violations in code. Residual
findings stay on the state as telemetry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
Document state carrying |
required |
ontology_graph
|
RDFGraph
|
Ontology context the facts are validated against. |
required |
tools
|
ToolBox
|
Dependency container; only the aggregator is used, and only when
|
required |
merge_repair
|
bool
|
Whether to run the un-merge repair loop. False for the single-unit path, where re-aggregating one unit is a no-op. |
required |
document_metadata
|
dict | None
|
Provenance metadata for re-aggregation. Required
when |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ontocast/stategraph/facts_gate.py
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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
vetoes_from_findings(findings, clusters)
¶
Full-cluster pair vetoes for merge-signature error findings.
Both the finding's subject and its IRI-valued objects are candidate merge
victims. DEGENERATE_COREFERENCE reports the pointing node as subject and
the over-merged endpoint in values (range1 hasLowerBound v1 ;
hasUpperBound v1 -- v1 is the collapsed cluster, range1 usually
is not merged at all), so a subject-only lookup could never repair it.
The same holds for the IRI-object branch of SUSPECT_MULTI_VALUE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
findings
|
list[FactsValidationFinding]
|
Error findings from the validation report. |
required |
clusters
|
dict[str, list[str]]
|
Identity-merge clusters keyed by representative IRI. |
required |
Returns:
| Type | Description |
|---|---|
set[frozenset[URIRef]]
|
Pairs of IRIs that must not be merged on a re-aggregation pass. |