graflo.architecture.evolution.merge¶
Binary merge of two :class:~graflo.architecture.contract.manifest.GraphManifests.
Attributes¶
__all__ = ['AttachedProducer', 'DemotedKey', 'DemotedKeyPlan', 'KeyOwner', 'MergeIdentityError', 'MergeNameConflictError', 'MergeReport', 'OrderCycle', 'PinnedReference', 'SharedKeySpace', 'ambiguous_reference_refusals', 'demoted_key_refusals', 'identifier_refusals', 'key_space_refusals', 'merge_manifests', 'merge_manifests_with_report', 'origin_refusals', 'plan_demoted_key_names']
module-attribute
¶
logger = logging.getLogger(__name__)
module-attribute
¶
Classes¶
AttachedProducer
dataclass
¶
A resource merge turned from creating a merged class into attaching to it.
Its steps producing the class now find it by key, write their
properties onto the node found, and create none.
Source code in graflo/architecture/evolution/merge_report.py
DemotedKey
dataclass
¶
A member's pre-merge key the merge demoted to a lookup-only secondary.
Source code in graflo/architecture/evolution/merge_report.py
Attributes¶
branches = ()
class-attribute
instance-attribute
¶
Funnel branches the member's records can complete, in order, up to the one over its own key. Two or more mean the key no longer deduplicates.
fields
instance-attribute
¶
member
instance-attribute
¶
secondary
instance-attribute
¶
side
instance-attribute
¶
vertex
instance-attribute
¶
Methods:¶
__init__(vertex, side, member, fields, secondary, branches=())
¶
DemotedKeyPlan
dataclass
¶
How one merged class names its members' demoted keys.
names is the secondary identity each demoted member's key answers to,
by (side, member); additions the secondaries to declare for them,
in order; refusals what makes the naming impossible.
Source code in graflo/architecture/evolution/merge_refusals.py
KeyOwner
dataclass
¶
A resource a derived identity names that produces the merged class.
It computes the class's key, so it creates and fuses its nodes.
Source code in graflo/architecture/evolution/merge_report.py
MergeIdentityError
¶
Bases: Refusal
A merged vertex's identity is ambiguous and nothing resolves it.
Two or more cluster members disagree on their (canonical-name) identity
field-set and the VertexEquivalence declares no identity. The
alternative -- silently taking the union of both field-sets as the new
identity -- produces a natural key no record fully carries. Also raised
for a declared identity some member cannot complete, or one whose
funnel's synthetic id a member already declares as a property.
subjects names the merged class and its disagreeing members, as
:func:~graflo.architecture.evolution.equivalence.subject ids; it does not
appear in the message.
Source code in graflo/architecture/evolution/merge_errors.py
Methods:¶
__init__(message, *, check='', subjects=())
¶
Source code in graflo/architecture/evolution/merge_errors.py
MergeNameConflictError
¶
Bases: Refusal
Two names denote one concept under different naming conventions.
Distinct from MergeCanonicalConflictError in canonical.py, which
reports a declared CanonicalMap contradicting the op. This one fires on
the residue neither side declared -- the undeclared path, where merge
would otherwise produce two unrelated types with the data split between
them and nothing raising.
check names the rule that refused and subjects the names it is
about, as :func:~graflo.architecture.evolution.equivalence.subject ids;
see :class:.Refusal.
Source code in graflo/architecture/evolution/merge_errors.py
MergeReport
dataclass
¶
What a merge did to the sources, beyond the manifest it returns.
Source code in graflo/architecture/evolution/merge_report.py
Attributes¶
attached = field(default_factory=list)
class-attribute
instance-attribute
¶
demoted = field(default_factory=list)
class-attribute
instance-attribute
¶
order_cycles = field(default_factory=list)
class-attribute
instance-attribute
¶
owners = field(default_factory=list)
class-attribute
instance-attribute
¶
references = field(default_factory=list)
class-attribute
instance-attribute
¶
shared_key_spaces = field(default_factory=list)
class-attribute
instance-attribute
¶
Methods:¶
__init__(demoted=list(), owners=list(), attached=list(), references=list(), shared_key_spaces=list(), order_cycles=list())
¶
OrderCycle
dataclass
¶
A resource order constraint the union's resource order leaves unmet.
resource depends on before for vertex -- it attaches to or references what before writes -- but runs first, because the constraints formed a cycle and the declared order was kept.
Source code in graflo/architecture/evolution/merge_report.py
PinnedReference
dataclass
¶
A resource that only references a re-keyed member, pointed at its key.
Its edge endpoints for the class now select key.
Source code in graflo/architecture/evolution/merge_report.py
SharedKeySpace
dataclass
¶
Members of one side whose demoted keys are one secondary identity.
Their key values are taken to be one space: an id of one member finds a node of another.
Functions:¶
ambiguous_reference_refusals(resolution, sides, member_properties)
¶
Each resource that would have to find one class by two demoted keys.
The rule :func:_attach_uncovered_producers and
:func:_pin_member_references refuse on, read from the sides before the
union: a resource producing members of one side whose keys are demoted to
different secondaries -- two key spaces, or two field sets -- when it
only references them (every step lookup_only), or when it would be
attached: it writes them, the derived identity names it nowhere, and its
records complete no property branch. sides carry the union's resource
names; member_properties are each member's properties in canonical
names.
Source code in graflo/architecture/evolution/merge_refusals.py
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 | |
demoted_key_refusals(resolution, manifests)
¶
Every demoted key :func:plan_demoted_key_names cannot name.
Read from the sides before the union, so the preview and the merge refuse alike before anything is renamed.
Source code in graflo/architecture/evolution/merge_refusals.py
identifier_refusals(resolution, manifests)
¶
Every demoted-key property name a PostgreSQL target would truncate.
A demoted key field is renamed <key space>__<field>; PostgreSQL keeps
only the first 63 bytes of a column name, so two such names could
become one column. Checked only when the union targets PostgreSQL. Read
from the sides before the union, so the preview and the merge refuse
alike.
Source code in graflo/architecture/evolution/merge_refusals.py
key_space_refusals(resolution, manifests)
¶
Every problem with the key spaces resolution names demoted keys by.
A local_key tag names the key space of a member's own ids, and its
demoted key is named by it. Refused: a member two of its resources tag
differently (its ids would be in two spaces at once), a tag that cannot
name a key space (see :func:~graflo.architecture.evolution.naming_graph.key_space_name_problem),
a tag a member of the cluster already declares as a secondary identity
(the demoted key would take that name), and a key space both sides name
(two sides' ids in one space). An origin colliding with a secondary is
:func:origin_refusals' to report.
Source code in graflo/architecture/evolution/merge_refusals.py
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 | |
merge_manifests(left, right, op, *, bump_version='minor', finish_init=True, strict_references=False, dynamic_edge_feedback=False, canonical_maps=())
¶
Return a new manifest that is the deterministic merge of left and right.
The declared clusters (each a :class:~graflo.architecture.evolution.ops.VertexEquivalence
or :class:~graflo.architecture.evolution.ops.RelationEquivalence, possibly
n-ary) and op.canonical_maps are resolved together into one composite
:class:~graflo.architecture.evolution.ops.CanonicalizeOp per side
(see :func:~graflo.architecture.evolution.canonical.resolve_clusters),
applied to that side in one step, before the two sides are unioned by
name. Does not invent semantic matches: a name both sides carry and no
cluster merges is refused under name_conflict="error" (naming the
equivalences to declare), synthesized into a 1-1 cluster under
union_right so it reconciles exactly as a declared one, and kept apart
under prefix_right.
A vertex equivalence whose identity has a derived or local_key
branch further rewrites the merged union with the fundamental ops that
identity lowers to (see
:func:~graflo.architecture.evolution.alignment.identity_to_ops);
member-keyed sources are resolved against the sides as handed in.
canonical_maps — (side, CanonicalMap) pairs — are folded into
op.canonical_maps; putting the maps on the op itself keeps the whole
recipe in one document.
Source code in graflo/architecture/evolution/merge.py
merge_manifests_with_report(left, right, op, *, bump_version='minor', finish_init=True, strict_references=False, dynamic_edge_feedback=False, canonical_maps=())
¶
:func:merge_manifests, and the :class:MergeReport of what it did.
The report lists the key owners, the resources attached by their own key, the references pinned to a demoted key, the shared key spaces, the demoted keys and any resource order constraint a cycle left unmet.
Source code in graflo/architecture/evolution/merge.py
origin_refusals(op, manifests, resolution)
¶
Every problem with the origins resolution names something by.
Only a side whose origin names something is checked: a demoted key whose
key space is the origin, or a local key the origin tags (see
:attr:~graflo.architecture.evolution.canonical.ClusterResolution.origin_tagged).
Its origin must be a valid key space name (see
:func:~graflo.architecture.evolution.naming_graph.key_space_name_problem;
it is joined to field names with __); two named origins must differ;
and no member of a re-keyed cluster may declare a secondary identity of
that name, which the demoted key takes. Each refusal is about the merged
classes that name something by the origin, or that declare the secondary.
Source code in graflo/architecture/evolution/merge_refusals.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 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 | |
plan_demoted_key_names(into, members, key_spaces, origins, authored)
¶
Name the demoted keys of the merged class into; pure.
members are its demoted members in order, as (side, member, fields,
key): fields in the union's names (after the key-space prefix), key
the canonical fields before it. A member's key space is its entry in
key_spaces, else its side's origin. authored are the secondaries the
members declare, by name, in the union's field names.
A field set authored declares answers to that declaration and its name.
Otherwise the secondary is named by its key space, one per key space; a
key space contributing two field sets names each <space>__<key fields
joined by __>. A field set is shared by the members of one key space
and by members of different sides; the first member to declare it fixes
its column order. Refused: two key spaces of one side on one field set,
authored or not -- their ids would share a lookup column -- and a
<space>__<fields> name an authored secondary takes.
A key space named like an authored secondary is
:func:key_space_refusals' and :func:origin_refusals' to report.
Source code in graflo/architecture/evolution/merge_refusals.py
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 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 | |