graflo.architecture.profile.context¶
What a profile check reads, and the vocabularies it recognises.
Two things live here. :class:CheckContext is the bundle every assertion is
handed -- the parsed manifest and the document the author actually wrote,
which are not interchangeable (see below). The rest is the vocabulary tables,
kept in one module so the IRIs a check recognises can be audited in one place
rather than found by grepping the assertion bodies.
Why the authored document is carried alongside the model. Two assertions
ask what the author declared, and the model has already lost that by the time
it exists: VertexConfig fills an unset Vertex.identity from every
property when identity_from_all_properties is set, and Edge.directed
defaults to True. So "identity was not declared" and "identity was declared
as every property" are the same model, and so are "directed was declared" and
"directed was defaulted". Every real caller has the authored mapping in hand --
a CLI reads the YAML, a pack holds its manifests as plain dicts, a registry
stores the config it was pushed -- so the check takes it rather than guessing.
Attributes¶
AGENT_TYPE_IRIS = frozenset({'http://www.w3.org/ns/prov#Agent', 'http://www.w3.org/ns/prov#SoftwareAgent', 'http://www.w3.org/ns/sosa/Sensor', 'http://xmlns.com/foaf/0.1/Agent'})
module-attribute
¶
KNOWN_NAMESPACES = ('http://www.w3.org/ns/prov#', 'http://www.w3.org/ns/sosa/', 'http://www.w3.org/ns/ssn/', 'http://www.w3.org/2006/time#', 'http://qudt.org/schema/qudt/', 'http://qudt.org/vocab/unit/', 'http://www.w3.org/2004/02/skos/core#', 'http://purl.org/dc/terms/', 'https://schema.org/', 'http://schema.org/', 'http://xmlns.com/foaf/0.1/', 'http://www.w3.org/2002/07/owl#', 'http://www.w3.org/2000/01/rdf-schema#')
module-attribute
¶
PROVENANCE_EDGE_IRIS = frozenset({'http://www.w3.org/ns/prov#wasDerivedFrom', 'http://www.w3.org/ns/prov#wasAttributedTo', 'http://www.w3.org/ns/prov#wasGeneratedBy', 'http://www.w3.org/ns/prov#used', 'http://www.w3.org/ns/sosa/madeBySensor'})
module-attribute
¶
TEMPORAL_PROPERTY_IRIS = frozenset({'http://www.w3.org/ns/prov#generatedAtTime', 'http://www.w3.org/ns/prov#invalidatedAtTime', 'http://www.w3.org/ns/prov#startedAtTime', 'http://www.w3.org/ns/prov#endedAtTime', 'http://www.w3.org/ns/sosa/resultTime', 'http://www.w3.org/ns/sosa/phenomenonTime'})
module-attribute
¶
UNIT_PROPERTY_IRIS = frozenset({'http://qudt.org/schema/qudt/hasUnit', 'http://qudt.org/schema/qudt/ucumCode', 'http://qudt.org/schema/qudt/unit', 'http://qudt.org/schema/qudt/hasQuantityKind'})
module-attribute
¶
VocabularyStatus = Literal['live', 'unknown', 'malformed']
module-attribute
¶
__all__ = ['AGENT_TYPE_IRIS', 'KNOWN_NAMESPACES', 'PROVENANCE_EDGE_IRIS', 'TEMPORAL_PROPERTY_IRIS', 'UNIT_PROPERTY_IRIS', 'CheckContext', 'PrefixAllowListResolver', 'VocabularyResolver', 'VocabularyStatus']
module-attribute
¶
Classes¶
CheckContext
dataclass
¶
Everything an assertion may read.
Attributes:
| Name | Type | Description |
|---|---|---|
manifest |
GraphManifest
|
The parsed, |
authored |
Mapping[str, Any] | None
|
The document the author wrote, when the caller has it.
|
waivers |
ProfileWaivers | None
|
Operator waivers to apply, if any. |
resolver |
VocabularyResolver
|
Vocabulary liveness backend. |
Source code in graflo/architecture/profile/context.py
Attributes¶
authored = None
class-attribute
instance-attribute
¶
has_authored
property
¶
Whether declaration-sensitive assertions can be decided at all.
manifest
instance-attribute
¶
resolver = field(default_factory=PrefixAllowListResolver)
class-attribute
instance-attribute
¶
waivers = None
class-attribute
instance-attribute
¶
Methods:¶
__init__(manifest, authored=None, waivers=None, resolver=PrefixAllowListResolver())
¶
authored_edges()
¶
Authored edge blocks; empty when the document is absent.
authored_vertices()
¶
Authored vertex blocks by name; empty when the document is absent.
Source code in graflo/architecture/profile/context.py
PrefixAllowListResolver
dataclass
¶
Recognises :data:KNOWN_NAMESPACES; everything else is unknown.
The honest v0.1 answer to "does this resolve to a live vocabulary": it
checks the shape and the namespace and says so, rather than dereferencing
anything. unknown is reported as a warning, never as a failure.
Source code in graflo/architecture/profile/context.py
Attributes¶
namespaces = KNOWN_NAMESPACES
class-attribute
instance-attribute
¶
Methods:¶
__init__(namespaces=KNOWN_NAMESPACES)
¶
resolve(iri)
¶
Source code in graflo/architecture/profile/context.py
VocabularyResolver
¶
Bases: Protocol
Decides whether an IRI resolves to a vocabulary worth grounding in.
A protocol rather than a class so the bundled prefix check can be replaced by a real registry lookup without touching the report model or any of the surfaces that render it.