graflo.architecture.evolution.ops.canonical¶
Canonical vocabulary maps and the op that applies one.
Classes¶
CanonicalMap
¶
Bases: ConfigBaseModel
Declared translation of a source vocabulary into canonical names.
A partial function on names, identity where unmapped: vertices maps
source class names to canonical class names, relations does the same
for relation names, and properties maps, per source class name,
source attribute names to canonical attribute names — including for
classes whose name does not change. Two sources sharing a target is a
merge and must be acknowledged with allow_merges.
It is a vocabulary, so it is idempotent: a canonical name is a fixed
point that no entry maps away from. A chain ({X: Z, Z: Q}) or a swap
is refused at construction — that shape is a relabel, which
:class:CanonicalizeOp expresses directly. The rule is what lets two
maps, or a map and an equivalence, be checked for agreement without
asking in which order they were written.
Used on its own through :func:~graflo.architecture.evolution.canonical.canonical_map_to_ops,
and on :attr:MergeManifestsOp.canonical_maps where it names the
merged classes and is checked against the declared equivalences.
Source code in graflo/architecture/evolution/ops/canonical.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 | |
Attributes¶
allow_dangling_entries = PydanticField(default=False, description='Accept entries that name nothing in the manifest the map is applied to, dropping and logging each one. A shared vocabulary map is legitimately broader than any single manifest. Off by default, because a misspelt class has exactly the same shape, and dropping it silently narrows the rename to less than the author asked for.')
class-attribute
instance-attribute
¶
allow_merges = PydanticField(default=False, description='Accept a non-injective ``vertices`` / ``relations`` map. Two sources sharing a canonical target is a *merge*, not a rename; it must be a stated intent because merging fuses entities and can create self-relations.')
class-attribute
instance-attribute
¶
allow_observation_fusion = PydanticField(default=False, description='Accept a merge this map makes whose sources are produced in one accumulator slot, fusing those observations into one node.')
class-attribute
instance-attribute
¶
allow_self_relations = PydanticField(default=False, description='Accept a merge this map makes whose sources are connected by an edge that becomes a self-relation.')
class-attribute
instance-attribute
¶
properties = PydanticField(default_factory=dict, description='Per-source-class attribute rename map: ``{source_class: {source_attr: canonical_attr}}``.')
class-attribute
instance-attribute
¶
relation_targets
property
¶
Canonical relation names this map establishes.
relations = PydanticField(default_factory=dict, description='Relation rename map: ``{source_relation: canonical_relation}``.')
class-attribute
instance-attribute
¶
vertex_targets
property
¶
Canonical class names this map establishes (targets of a real rename).
vertices = PydanticField(default_factory=dict, description='Class rename map: ``{source_class: canonical_class}``.')
class-attribute
instance-attribute
¶
Methods:¶
canonical_class(source_class)
¶
canonical_property_names(canonical_class)
¶
Canonical attribute names the map establishes on canonical_class.
Source code in graflo/architecture/evolution/ops/canonical.py
canonical_relation(source_relation)
¶
Canonical name of source_relation (itself when unmapped).
CanonicalizeOp
¶
Bases: ConfigBaseModel
Relabel classes, attributes and relations by one vocabulary map, in one step.
The map is a partial function on names — identity where unmapped — applied
simultaneously over the original schema, so a chain ({X: Z, Z: Q}) and
a swap resolve without an intermediate state, and the fibers of the map
are exactly the groups that merge. A target that already exists and does
not move must be declared a member of its own group with a self entry
(Company: Company); otherwise the op refuses rather than merging into
it silently. properties is keyed by the source class name and is
applied before the class relabel.
This is the single lowering of a
:class:~graflo.architecture.evolution.canonical.CanonicalMap, and the
per-side step of
:func:~graflo.architecture.evolution.merge.merge_manifests.
Source code in graflo/architecture/evolution/ops/canonical.py
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 | |
Attributes¶
allow_merges = PydanticField(default=False, description='Accept a group of more than one class or relation collapsing onto one target. A merge fuses entities and can create self-relations, so it is acknowledged here rather than inferred from the map.')
class-attribute
instance-attribute
¶
allow_observation_fusion = PydanticField(default=False, description='Accept a merge whose sources are produced in one accumulator slot (the same pipeline level and the same ``role``, or both bare), fusing those observations into one node.')
class-attribute
instance-attribute
¶
allow_self_relations = PydanticField(default=False, description='Accept a merge whose sources are connected by an edge that becomes a self-relation once both endpoints land on the same class.')
class-attribute
instance-attribute
¶
merges
property
¶
Whether any class or relation group has more than one member.
op = 'canonicalize'
class-attribute
instance-attribute
¶
properties = PydanticField(default_factory=dict, description='Per-source-class attribute map: ``{source_class: {source_attr: canonical_attr}}``.')
class-attribute
instance-attribute
¶
relation_groups
property
¶
{target: [members]} over relations, self entries included.
relations = PydanticField(default_factory=dict, description='Relation map: ``{source_relation: canonical_relation}``.')
class-attribute
instance-attribute
¶
vertex_groups
property
¶
{target: [members]} over vertices, self entries included.