ontocast.tool.facts_validation.gate¶
Document-level validation for the post-aggregation facts gate.
Merge-signature findings, SHACL conformance summary, non-catalog vocabulary telemetry, dangling references, and the gate metrics record.
FactsValidationReport
¶
Bases: BaseModel
Invariant findings over one aggregated facts graph.
Source code in ontocast/tool/facts_validation/gate.py
error_findings
property
¶
Error-severity findings, whatever their kind.
record_facts_gate_metrics(metrics, *, report, repair_result, ontology_context_empty=False)
¶
Write the validation-gate metrics both entry paths share.
The graph pipeline's VALIDATE_FACTS node and the single-unit gate behind
/process_unit run the same checks minus the un-merge repair, and had
drifted into two hand-maintained copies of these writes — so a metric added
to one path was silently absent from the other, and batch dumps stopped
being comparable across entry paths, which is the one thing they exist for.
Merge-specific counters stay with the graph pipeline: they have no meaning
for a single unit.
Takes a plain mapping rather than AgentState so the tool layer stays
ignorant of the state graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
MutableMapping[str, int | float | str | dict]
|
|
required |
report
|
FactsValidationReport
|
Validation report describing the graph that will be served. |
required |
repair_result
|
ShaclRepairResult
|
Outcome of :func: |
required |
ontology_context_empty
|
bool
|
Whether the facts were validated with no
catalog vocabulary at all. The per-term non-catalog check cannot
see this — with no context there is nothing to compare against — so
it is reported here, where an empty context is known to be
unexpected. Only the document path used to report it, which left
|
False
|
Source code in ontocast/tool/facts_validation/gate.py
summarize_conformance(findings, *, shacl_evaluated=None, repairs=())
¶
Roll findings up into the shape a report or a client can read.
Counting by constraint component is what separates "168 violations" from "two systematic defects": 71 missing-qualifier violations on one shape are one modelling gap, not 71 problems to triage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
findings
|
Sequence[FactsValidationFinding]
|
Residual findings after any repair. |
required |
shacl_evaluated
|
bool | None
|
Whether SHACL actually ran (see
:class: |
None
|
repairs
|
Sequence[GraphRepairRecord]
|
LLM-free repairs the gate applied. |
()
|
Returns:
| Type | Description |
|---|---|
dict
|
|
dict
|
finding kind, by SHACL constraint component and shape, and the applied |
dict
|
repair counts by kind. |
Source code in ontocast/tool/facts_validation/gate.py
validate_aggregated_facts(graph, ontology_graph, *, shapes_graph=None, fact_namespaces=None, suspect_multi_value_severity='error', functional_min_single_support=3, quantity_fallback_vocabulary=None, shacl_inference='rdfs', shacl_advanced=True, shacl_max_triples=0, key_supported_subjects=None)
¶
Check post-merge invariants over the aggregated facts graph.
Deterministic defense-in-depth behind the merge guards: merge-signature violations here are almost always a bad identity merge, and error-severity findings of those kinds on merged subjects drive the un-merge repair. SHACL findings are reported but never drive it: a constraint violation says a node is under-specified, not that two entities were wrongly identified.
Checks
FUNCTIONAL_VIOLATION: >= 2 distinct objects on a predicate the schema constrains to at most one value (owl:FunctionalPropertyor an OWL max-cardinality-1 restriction).SUSPECT_MULTI_VALUE: >= 2 distinct canonical numeric values on one (subject, predicate); >= 2 mutually irreconcilable short string values on a predicate that is string-single-valued for a dominant majority (distinct names collapsed into one node); or >= 2 IRI objects on a predicate that is single-valued for a dominant majority of other subjects. Severity is configurable — legitimate multi-value modeling exists, bad merges are far more common.DEGENERATE_COREFERENCE: one IRI object shared by >= 2 distinct functional-ish predicates of one subject (collapsed range bounds).SHACL: optional, whenpyshaclis installed and shapes exist.NON_CATALOG_VOCABULARY: warning-only telemetry for terms the ontology context never supplied, which mark a retrieval miss the renderer papered over with a documented fallback.MIXED_OBJECT_KINDS: warning-only telemetry for predicates used with both IRI and literal objects across the graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
Aggregated facts graph. |
required |
ontology_graph
|
RDFGraph | None
|
Merged ontology context (functionality harvest). |
required |
shapes_graph
|
RDFGraph | None
|
Optional SHACL shapes graph. |
None
|
fact_namespaces
|
list[str] | None
|
When set, only subjects under these namespaces are reported (ontology entities are not the gate's business). |
None
|
suspect_multi_value_severity
|
str
|
|
'error'
|
functional_min_single_support
|
int
|
Minimum single-valued subjects before a predicate counts as dominantly single-valued. |
3
|
shacl_inference
|
str
|
pyshacl pre-inference mode (see :func: |
'rdfs'
|
shacl_advanced
|
bool
|
Enable SHACL Advanced Features. |
True
|
shacl_max_triples
|
int
|
Skip SHACL above this graph size; 0 disables. |
0
|
key_supported_subjects
|
Sequence[str] | None
|
Final URIs of merge clusters backed by natural-key evidence. Irreconcilable string values on these subjects are reported as warnings, not errors: "Application no. 36760/06" and "Case of Stanev v. Bulgaria" are two names for one key-confirmed case, and an error here would drive the un-merge repair to split a correct merge. |
None
|
Returns:
| Type | Description |
|---|---|
FactsValidationReport
|
Report with all findings, ordered by subject. |
Source code in ontocast/tool/facts_validation/gate.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | |