graflo.architecture.evolution.autogenerate¶
Derive a contract change set from two manifests.
Before this, nothing produced :data:~graflo.architecture.evolution.ops.ManifestOp
values: every op in the codebase was hand-built. SchemaDiff (migrate)
produces description records on a different plane — it reports what changed
but emits nothing that can be applied — and it only ever looks at Schema,
never at ingestion_model or bindings.
:func:diff_manifests closes that gap for the mechanically derivable ops, and
is explicit about the rest. Its contract is the replay invariant::
ops, warnings = diff_manifests(base, target)
manifest_hash(apply_evolution(base, ops)) == manifest_hash(target)
Where that does not hold, :func:diff_manifests_verified reports the residual
rather than claiming success. Silence about an incomplete diff is the one
failure mode a change-set generator must not have — it produces a revision that
looks applied and is not.
Renames are ambiguous by construction: a dropped mail plus an added
email is indistinguishable from a rename. Pass :class:RenameHints when the
intent is known; otherwise the pair is emitted as a drop and an add.
Attributes¶
__all__ = ['RenameHints', 'diff_manifests', 'diff_manifests_verified']
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
RenameHints
¶
Bases: ConfigBaseModel
Renames the differ cannot infer, supplied by the caller.
A drop plus an add is structurally identical to a rename. Guessing would turn a data-preserving rename into a destructive drop (or the reverse), so the differ never guesses.
Source code in graflo/architecture/evolution/autogenerate.py
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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
Attributes¶
edge_properties = PydanticField(default_factory=dict, description='``{relation: {old_field: new_field}}``.')
class-attribute
instance-attribute
¶
relations = PydanticField(default_factory=dict, description='``{old_relation: new_relation}``.')
class-attribute
instance-attribute
¶
resources = PydanticField(default_factory=dict, description='``{old_resource: new_resource}``.')
class-attribute
instance-attribute
¶
vertex_properties = PydanticField(default_factory=dict, description='``{vertex_name: {old_field: new_field}}``.')
class-attribute
instance-attribute
¶
vertices = PydanticField(default_factory=dict, description='``{old_vertex_name: new_vertex_name}``.')
class-attribute
instance-attribute
¶
Methods:¶
from_ops(ops, *, base)
classmethod
¶
The renames ops perform on base, as hints for diffing it.
Renames chain (A → B then B → C is A → C), and a property
rename follows its owner's later renames. A name base does not have is
left out: renaming an element the ops themselves added is part of that
addition, not a rename of anything in base.
Source code in graflo/architecture/evolution/autogenerate.py
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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
to_ops()
¶
The rename ops these hints stand for, in the order a diff emits them.
Source code in graflo/architecture/evolution/autogenerate.py
Functions:¶
diff_manifests(base, target, *, hints=None)
¶
Ops turning base into target, plus warnings for what was not expressed.
Ops are ordered so each one's preconditions hold when it runs: renames first (so later ops address the new names), then additions, then property and identity changes, then removals last. Edge property changes precede edge additions: they address a whole relation, and must not reach a sibling edge the diff adds with properties of its own.
Source code in graflo/architecture/evolution/autogenerate.py
diff_manifests_verified(base, target, *, hints=None)
¶
:func:diff_manifests, with the replay invariant actually checked.
Applies the derived ops to a copy of base and compares the result's hash to target's. A mismatch appends a warning naming the residual difference instead of letting an incomplete change set pass as complete.