graflo.architecture.schema.semantics¶
Optional grounding of schema elements in external vocabularies.
Purely additive and never consulted at execution time: identity, storage naming and ingestion behave identically whether or not these blocks are present. Their audience is the reader — human or agent — deciding what a type means before deciding what to ask about it.
Serialized through the gf: meta-ontology, reusing skos:exactMatch and
skos:altLabel rather than minting GraFlo-specific equivalents.
Classes¶
FieldSemantics
¶
Bases: Semantics
Anchors for a property, which additionally may carry a unit.
Separate from :class:Semantics on purpose: a unit on a vertex or an edge is
meaningless, and because these models forbid extra keys, the split makes
unit: on a vertex a validation error without any custom validator.
Source code in graflo/architecture/schema/semantics.py
Semantics
¶
Bases: ConfigBaseModel
External-vocabulary anchors for a vertex, edge, or whole schema.
Source code in graflo/architecture/schema/semantics.py
Attributes¶
exact_match = PydanticField(default_factory=list, description='IRIs asserted equivalent to this element (``skos:exactMatch``).')
class-attribute
instance-attribute
¶
iri = PydanticField(default=None, description='IRI of the concept this element denotes, e.g. ``https://schema.org/Person``.')
class-attribute
instance-attribute
¶
synonyms = PydanticField(default_factory=list, description='Alternative labels an agent may encounter (``skos:altLabel``).')
class-attribute
instance-attribute
¶
Functions:¶
merge_field_semantics(left, right, *, owner, field)
¶
Merge two property grounding blocks, refusing a unit clash.
The anchors fold exactly as :func:merge_semantics folds them. unit does
not: unlike a disputed iri, which costs the reader a claim about meaning,
two units mean the merged property would hold numerically incomparable
values -- the one place in this module where a disagreement is a defect in
the data rather than in its description.
Source code in graflo/architecture/schema/semantics.py
merge_semantics(left, right)
¶
Merge two semantic anchor blocks, unioning their anchors.
exact_match and synonyms are sets of claims and simply union.
iri is single-valued and cannot: a type composed from one denoting
schema.org/Person and one denoting foaf:Agent denotes neither
exactly, so a disagreement clears it rather than silently electing the left
side's concept as the merged type's meaning.
Source code in graflo/architecture/schema/semantics.py
union_anchors(values)
¶
Order-preserving de-duplication, for the list-valued anchor fields.