parallax-evolution 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,243 @@
1
+ from __future__ import annotations
2
+
3
+ from parallax.evolution.model_evolution import (
4
+ ABSENT,
5
+ AS_OF_AXIS_DELTA_ORDER,
6
+ ATTRIBUTE_DELTA_ORDER,
7
+ BEHAVIORAL_IMPACT_ORDER,
8
+ COORDINATION_REASON_ORDER,
9
+ ENTITY_DELTA_ORDER,
10
+ INDEX_DELTA_ORDER,
11
+ LOCKING_FALLBACK,
12
+ RELATIONSHIP_DELTA_ORDER,
13
+ VALUE_OBJECT_ATTRIBUTE_DELTA_ORDER,
14
+ VALUE_OBJECT_OCCURRENCE_DELTA_ORDER,
15
+ WRITES_DISABLED,
16
+ Absent,
17
+ AsOfAxisAdded,
18
+ AsOfAxisAltered,
19
+ AsOfAxisDelta,
20
+ AsOfAxisRemoved,
21
+ AttributeAdded,
22
+ AttributeAltered,
23
+ AttributeDelta,
24
+ AttributeRemoved,
25
+ AttributeWriteCapability,
26
+ BehavioralImpact,
27
+ CardinalityChanged,
28
+ ComponentsChanged,
29
+ ConcreteSubtypeAdded,
30
+ ConcreteSubtypeRemoved,
31
+ ConcurrencyControl,
32
+ ConcurrencyControlChanged,
33
+ CoordinatedEvolution,
34
+ CoordinationReason,
35
+ CoordinationRequirement,
36
+ DeclarationCollection,
37
+ DeclarationFormChanged,
38
+ DeclarationIdentity,
39
+ DeclarationOrderChanged,
40
+ DeletePropagation,
41
+ DeletePropagationChanged,
42
+ DependencyChanged,
43
+ EndAttributeChanged,
44
+ EntityAdded,
45
+ EntityAltered,
46
+ EntityDelta,
47
+ EntityRemoved,
48
+ EntitySelectionFacts,
49
+ EntityWriteCapability,
50
+ EntityWriteShape,
51
+ Evolution,
52
+ EvolutionOperation,
53
+ IndexAdded,
54
+ IndexAltered,
55
+ IndexDelta,
56
+ IndexRemoved,
57
+ InheritanceChanged,
58
+ JoinChanged,
59
+ LockingFallback,
60
+ MaximumLengthChanged,
61
+ MultiplicityChanged,
62
+ NullabilityChanged,
63
+ OccurrenceAdmissibility,
64
+ OptimisticLockingChanged,
65
+ OrderingChanged,
66
+ PersistenceChanged,
67
+ PrimaryKeyChanged,
68
+ QueryResultMembershipChanged,
69
+ QueryResultOrderingChanged,
70
+ ReadOnlyChanged,
71
+ RelationshipAdded,
72
+ RelationshipAltered,
73
+ RelationshipDelta,
74
+ RelationshipRemoved,
75
+ RelationshipSelectionFacts,
76
+ ReverseOfChanged,
77
+ ScalarAdmissibility,
78
+ SelectionFacts,
79
+ SelectionScope,
80
+ StartAttributeChanged,
81
+ StorageChanged,
82
+ StorageContainerChanged,
83
+ StorageLayoutChanged,
84
+ TemporalAxisFacts,
85
+ TransactionTimeGated,
86
+ TypeChanged,
87
+ UnilateralEvolution,
88
+ UniquenessChanged,
89
+ UniquenessEnforcementChanged,
90
+ UniqueTuple,
91
+ ValueAdmissibility,
92
+ ValueAdmissibilityChanged,
93
+ ValueObjectAttributeAdded,
94
+ ValueObjectAttributeAltered,
95
+ ValueObjectAttributeDelta,
96
+ ValueObjectAttributeRemoved,
97
+ ValueObjectOccurrenceAdded,
98
+ ValueObjectOccurrenceAltered,
99
+ ValueObjectOccurrenceDelta,
100
+ ValueObjectOccurrenceRemoved,
101
+ ValuePath,
102
+ VersionGated,
103
+ WriteCapabilityChanged,
104
+ WriteCapabilityFacts,
105
+ WriteScope,
106
+ WritesDisabled,
107
+ WritesEnabled,
108
+ canonical_operation_key,
109
+ evolve,
110
+ )
111
+ from parallax.evolution.schema_delta import (
112
+ CollidingIndex,
113
+ CollidingTemporalConstraint,
114
+ CollisionGroup,
115
+ CreatedIndex,
116
+ IndexPresence,
117
+ PhysicalIndexNameCollisionError,
118
+ PhysicalLocation,
119
+ SchemaDelta,
120
+ UnsupportedSchemaEvolutionError,
121
+ UnsupportedSchemaOperation,
122
+ schema_delta,
123
+ )
124
+
125
+ __all__ = [
126
+ "ABSENT",
127
+ "AS_OF_AXIS_DELTA_ORDER",
128
+ "ATTRIBUTE_DELTA_ORDER",
129
+ "BEHAVIORAL_IMPACT_ORDER",
130
+ "COORDINATION_REASON_ORDER",
131
+ "ENTITY_DELTA_ORDER",
132
+ "INDEX_DELTA_ORDER",
133
+ "LOCKING_FALLBACK",
134
+ "RELATIONSHIP_DELTA_ORDER",
135
+ "VALUE_OBJECT_ATTRIBUTE_DELTA_ORDER",
136
+ "VALUE_OBJECT_OCCURRENCE_DELTA_ORDER",
137
+ "WRITES_DISABLED",
138
+ "Absent",
139
+ "AsOfAxisAdded",
140
+ "AsOfAxisAltered",
141
+ "AsOfAxisDelta",
142
+ "AsOfAxisRemoved",
143
+ "AttributeAdded",
144
+ "AttributeAltered",
145
+ "AttributeDelta",
146
+ "AttributeRemoved",
147
+ "AttributeWriteCapability",
148
+ "BehavioralImpact",
149
+ "CardinalityChanged",
150
+ "CollidingIndex",
151
+ "CollidingTemporalConstraint",
152
+ "CollisionGroup",
153
+ "ComponentsChanged",
154
+ "ConcreteSubtypeAdded",
155
+ "ConcreteSubtypeRemoved",
156
+ "ConcurrencyControl",
157
+ "ConcurrencyControlChanged",
158
+ "CoordinatedEvolution",
159
+ "CoordinationReason",
160
+ "CoordinationRequirement",
161
+ "CreatedIndex",
162
+ "DeclarationCollection",
163
+ "DeclarationFormChanged",
164
+ "DeclarationIdentity",
165
+ "DeclarationOrderChanged",
166
+ "DeletePropagation",
167
+ "DeletePropagationChanged",
168
+ "DependencyChanged",
169
+ "EndAttributeChanged",
170
+ "EntityAdded",
171
+ "EntityAltered",
172
+ "EntityDelta",
173
+ "EntityRemoved",
174
+ "EntitySelectionFacts",
175
+ "EntityWriteCapability",
176
+ "EntityWriteShape",
177
+ "Evolution",
178
+ "EvolutionOperation",
179
+ "IndexAdded",
180
+ "IndexAltered",
181
+ "IndexDelta",
182
+ "IndexPresence",
183
+ "IndexRemoved",
184
+ "InheritanceChanged",
185
+ "JoinChanged",
186
+ "LockingFallback",
187
+ "MaximumLengthChanged",
188
+ "MultiplicityChanged",
189
+ "NullabilityChanged",
190
+ "OccurrenceAdmissibility",
191
+ "OptimisticLockingChanged",
192
+ "OrderingChanged",
193
+ "PersistenceChanged",
194
+ "PhysicalIndexNameCollisionError",
195
+ "PhysicalLocation",
196
+ "PrimaryKeyChanged",
197
+ "QueryResultMembershipChanged",
198
+ "QueryResultOrderingChanged",
199
+ "ReadOnlyChanged",
200
+ "RelationshipAdded",
201
+ "RelationshipAltered",
202
+ "RelationshipDelta",
203
+ "RelationshipRemoved",
204
+ "RelationshipSelectionFacts",
205
+ "ReverseOfChanged",
206
+ "ScalarAdmissibility",
207
+ "SchemaDelta",
208
+ "SelectionFacts",
209
+ "SelectionScope",
210
+ "StartAttributeChanged",
211
+ "StorageChanged",
212
+ "StorageContainerChanged",
213
+ "StorageLayoutChanged",
214
+ "TemporalAxisFacts",
215
+ "TransactionTimeGated",
216
+ "TypeChanged",
217
+ "UnilateralEvolution",
218
+ "UniqueTuple",
219
+ "UniquenessChanged",
220
+ "UniquenessEnforcementChanged",
221
+ "UnsupportedSchemaEvolutionError",
222
+ "UnsupportedSchemaOperation",
223
+ "ValueAdmissibility",
224
+ "ValueAdmissibilityChanged",
225
+ "ValueObjectAttributeAdded",
226
+ "ValueObjectAttributeAltered",
227
+ "ValueObjectAttributeDelta",
228
+ "ValueObjectAttributeRemoved",
229
+ "ValueObjectOccurrenceAdded",
230
+ "ValueObjectOccurrenceAltered",
231
+ "ValueObjectOccurrenceDelta",
232
+ "ValueObjectOccurrenceRemoved",
233
+ "ValuePath",
234
+ "VersionGated",
235
+ "WriteCapabilityChanged",
236
+ "WriteCapabilityFacts",
237
+ "WriteScope",
238
+ "WritesDisabled",
239
+ "WritesEnabled",
240
+ "canonical_operation_key",
241
+ "evolve",
242
+ "schema_delta",
243
+ ]
@@ -0,0 +1,301 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import overload
4
+
5
+ from parallax.core.metamodel import Metamodel
6
+ from parallax.evolution.model_evolution._classify import classify
7
+ from parallax.evolution.model_evolution._diff import diff
8
+ from parallax.evolution.model_evolution._impacts import impacts
9
+ from parallax.evolution.model_evolution._matching import Matching, match
10
+ from parallax.evolution.model_evolution._values import (
11
+ ABSENT,
12
+ AS_OF_AXIS_DELTA_ORDER,
13
+ ATTRIBUTE_DELTA_ORDER,
14
+ BEHAVIORAL_IMPACT_ORDER,
15
+ COORDINATION_REASON_ORDER,
16
+ ENTITY_DELTA_ORDER,
17
+ INDEX_DELTA_ORDER,
18
+ LOCKING_FALLBACK,
19
+ RELATIONSHIP_DELTA_ORDER,
20
+ VALUE_OBJECT_ATTRIBUTE_DELTA_ORDER,
21
+ VALUE_OBJECT_OCCURRENCE_DELTA_ORDER,
22
+ WRITES_DISABLED,
23
+ Absent,
24
+ AsOfAxisAdded,
25
+ AsOfAxisAltered,
26
+ AsOfAxisDelta,
27
+ AsOfAxisRemoved,
28
+ AttributeAdded,
29
+ AttributeAltered,
30
+ AttributeDelta,
31
+ AttributeRemoved,
32
+ AttributeWriteCapability,
33
+ BehavioralImpact,
34
+ CardinalityChanged,
35
+ ComponentsChanged,
36
+ ConcreteSubtypeAdded,
37
+ ConcreteSubtypeRemoved,
38
+ ConcurrencyControl,
39
+ ConcurrencyControlChanged,
40
+ CoordinatedEvolution,
41
+ CoordinationReason,
42
+ CoordinationRequirement,
43
+ DeclarationCollection,
44
+ DeclarationFormChanged,
45
+ DeclarationIdentity,
46
+ DeclarationOrderChanged,
47
+ DeletePropagation,
48
+ DeletePropagationChanged,
49
+ DependencyChanged,
50
+ EndAttributeChanged,
51
+ EntityAdded,
52
+ EntityAltered,
53
+ EntityDelta,
54
+ EntityRemoved,
55
+ EntitySelectionFacts,
56
+ EntityWriteCapability,
57
+ EntityWriteShape,
58
+ Evolution,
59
+ EvolutionOperation,
60
+ IndexAdded,
61
+ IndexAltered,
62
+ IndexDelta,
63
+ IndexRemoved,
64
+ InheritanceChanged,
65
+ JoinChanged,
66
+ LockingFallback,
67
+ MaximumLengthChanged,
68
+ MultiplicityChanged,
69
+ NullabilityChanged,
70
+ OccurrenceAdmissibility,
71
+ OptimisticLockingChanged,
72
+ OrderingChanged,
73
+ PersistenceChanged,
74
+ PrimaryKeyChanged,
75
+ QueryResultMembershipChanged,
76
+ QueryResultOrderingChanged,
77
+ ReadOnlyChanged,
78
+ RelationshipAdded,
79
+ RelationshipAltered,
80
+ RelationshipDelta,
81
+ RelationshipRemoved,
82
+ RelationshipSelectionFacts,
83
+ ReverseOfChanged,
84
+ ScalarAdmissibility,
85
+ SelectionFacts,
86
+ SelectionScope,
87
+ StartAttributeChanged,
88
+ StorageChanged,
89
+ StorageContainerChanged,
90
+ StorageLayoutChanged,
91
+ TemporalAxisFacts,
92
+ TransactionTimeGated,
93
+ TypeChanged,
94
+ UnilateralEvolution,
95
+ UniquenessChanged,
96
+ UniquenessEnforcementChanged,
97
+ UniqueTuple,
98
+ ValueAdmissibility,
99
+ ValueAdmissibilityChanged,
100
+ ValueObjectAttributeAdded,
101
+ ValueObjectAttributeAltered,
102
+ ValueObjectAttributeDelta,
103
+ ValueObjectAttributeRemoved,
104
+ ValueObjectOccurrenceAdded,
105
+ ValueObjectOccurrenceAltered,
106
+ ValueObjectOccurrenceDelta,
107
+ ValueObjectOccurrenceRemoved,
108
+ ValuePath,
109
+ VersionGated,
110
+ WriteCapabilityChanged,
111
+ WriteCapabilityFacts,
112
+ WriteScope,
113
+ WritesDisabled,
114
+ WritesEnabled,
115
+ canonical_operation_key,
116
+ )
117
+
118
+ __all__ = [
119
+ "ABSENT",
120
+ "AS_OF_AXIS_DELTA_ORDER",
121
+ "ATTRIBUTE_DELTA_ORDER",
122
+ "BEHAVIORAL_IMPACT_ORDER",
123
+ "COORDINATION_REASON_ORDER",
124
+ "ENTITY_DELTA_ORDER",
125
+ "INDEX_DELTA_ORDER",
126
+ "LOCKING_FALLBACK",
127
+ "RELATIONSHIP_DELTA_ORDER",
128
+ "VALUE_OBJECT_ATTRIBUTE_DELTA_ORDER",
129
+ "VALUE_OBJECT_OCCURRENCE_DELTA_ORDER",
130
+ "WRITES_DISABLED",
131
+ "Absent",
132
+ "AsOfAxisAdded",
133
+ "AsOfAxisAltered",
134
+ "AsOfAxisDelta",
135
+ "AsOfAxisRemoved",
136
+ "AttributeAdded",
137
+ "AttributeAltered",
138
+ "AttributeDelta",
139
+ "AttributeRemoved",
140
+ "AttributeWriteCapability",
141
+ "BehavioralImpact",
142
+ "CardinalityChanged",
143
+ "ComponentsChanged",
144
+ "ConcreteSubtypeAdded",
145
+ "ConcreteSubtypeRemoved",
146
+ "ConcurrencyControl",
147
+ "ConcurrencyControlChanged",
148
+ "CoordinatedEvolution",
149
+ "CoordinationReason",
150
+ "CoordinationRequirement",
151
+ "DeclarationCollection",
152
+ "DeclarationFormChanged",
153
+ "DeclarationIdentity",
154
+ "DeclarationOrderChanged",
155
+ "DeletePropagation",
156
+ "DeletePropagationChanged",
157
+ "DependencyChanged",
158
+ "EndAttributeChanged",
159
+ "EntityAdded",
160
+ "EntityAltered",
161
+ "EntityDelta",
162
+ "EntityRemoved",
163
+ "EntitySelectionFacts",
164
+ "EntityWriteCapability",
165
+ "EntityWriteShape",
166
+ "Evolution",
167
+ "EvolutionOperation",
168
+ "IndexAdded",
169
+ "IndexAltered",
170
+ "IndexDelta",
171
+ "IndexRemoved",
172
+ "InheritanceChanged",
173
+ "JoinChanged",
174
+ "LockingFallback",
175
+ "MaximumLengthChanged",
176
+ "MultiplicityChanged",
177
+ "NullabilityChanged",
178
+ "OccurrenceAdmissibility",
179
+ "OptimisticLockingChanged",
180
+ "OrderingChanged",
181
+ "PersistenceChanged",
182
+ "PrimaryKeyChanged",
183
+ "QueryResultMembershipChanged",
184
+ "QueryResultOrderingChanged",
185
+ "ReadOnlyChanged",
186
+ "RelationshipAdded",
187
+ "RelationshipAltered",
188
+ "RelationshipDelta",
189
+ "RelationshipRemoved",
190
+ "RelationshipSelectionFacts",
191
+ "ReverseOfChanged",
192
+ "ScalarAdmissibility",
193
+ "SelectionFacts",
194
+ "SelectionScope",
195
+ "StartAttributeChanged",
196
+ "StorageChanged",
197
+ "StorageContainerChanged",
198
+ "StorageLayoutChanged",
199
+ "TemporalAxisFacts",
200
+ "TransactionTimeGated",
201
+ "TypeChanged",
202
+ "UnilateralEvolution",
203
+ "UniqueTuple",
204
+ "UniquenessChanged",
205
+ "UniquenessEnforcementChanged",
206
+ "ValueAdmissibility",
207
+ "ValueAdmissibilityChanged",
208
+ "ValueObjectAttributeAdded",
209
+ "ValueObjectAttributeAltered",
210
+ "ValueObjectAttributeDelta",
211
+ "ValueObjectAttributeRemoved",
212
+ "ValueObjectOccurrenceAdded",
213
+ "ValueObjectOccurrenceAltered",
214
+ "ValueObjectOccurrenceDelta",
215
+ "ValueObjectOccurrenceRemoved",
216
+ "ValuePath",
217
+ "VersionGated",
218
+ "WriteCapabilityChanged",
219
+ "WriteCapabilityFacts",
220
+ "WriteScope",
221
+ "WritesDisabled",
222
+ "WritesEnabled",
223
+ "canonical_operation_key",
224
+ "evolve",
225
+ ]
226
+
227
+
228
+ @overload
229
+ def evolve(earlier: Absent, later: Metamodel) -> UnilateralEvolution: ...
230
+
231
+
232
+ @overload
233
+ def evolve(earlier: Metamodel, later: Metamodel) -> Evolution: ...
234
+
235
+
236
+ def evolve(earlier: Metamodel | Absent, later: Metamodel) -> Evolution:
237
+ """Describe every difference between two accepted Metamodels.
238
+
239
+ Provisioning is unilateral by TYPE: passing :data:`ABSENT` narrows the
240
+ result, so a consumer that only accepts a Unilateral Evolution — the schema
241
+ generator above all — needs no runtime check on that path.
242
+
243
+ ``earlier`` is :data:`ABSENT` for fresh provisioning — an explicit sentinel,
244
+ never inferred from an empty accepted model or from inspecting a physical
245
+ schema. Provisioning is always unilateral: one entity-level addition per
246
+ target Entity, which suppresses that Entity's members, and no Behavioral
247
+ Impact or Overlap-Visible Operation, because no earlier scope survives.
248
+
249
+ Equal endpoints return an empty :class:`UnilateralEvolution` retaining both
250
+ models, so the result is total without a third no-evolution kind.
251
+ """
252
+ matching = match(earlier, later)
253
+ operations = diff(matching)
254
+ if matching.earlier is None:
255
+ return UnilateralEvolution(
256
+ earlier=None,
257
+ later=later,
258
+ operations=operations,
259
+ behavioral_impacts=(),
260
+ overlap_visible_operations=(),
261
+ )
262
+ return _assemble(matching.earlier, matching, operations)
263
+
264
+
265
+ def _assemble(
266
+ earlier: Metamodel,
267
+ matching: Matching,
268
+ operations: tuple[EvolutionOperation, ...],
269
+ ) -> Evolution:
270
+ """Fold per-operation classification and the impacts into one result.
271
+
272
+ Any nonempty reason set makes the whole evolution coordinated, carrying one
273
+ requirement per coordinated operation in canonical operation order;
274
+ otherwise the overlap-visible operations are collected in the same order.
275
+ """
276
+ classifications = classify(matching, operations)
277
+ behavioral_impacts = impacts(earlier, matching, operations)
278
+ requirements = tuple(
279
+ CoordinationRequirement(operation=operation, reasons=classification.reasons)
280
+ for operation, classification in zip(operations, classifications, strict=True)
281
+ if classification.reasons
282
+ )
283
+ if requirements:
284
+ return CoordinatedEvolution(
285
+ earlier=earlier,
286
+ later=matching.later,
287
+ operations=operations,
288
+ behavioral_impacts=behavioral_impacts,
289
+ coordination_requirements=requirements,
290
+ )
291
+ return UnilateralEvolution(
292
+ earlier=earlier,
293
+ later=matching.later,
294
+ operations=operations,
295
+ behavioral_impacts=behavioral_impacts,
296
+ overlap_visible_operations=tuple(
297
+ operation
298
+ for operation, classification in zip(operations, classifications, strict=True)
299
+ if classification.overlap_visible
300
+ ),
301
+ )