@reventlessdev/reventless-spec 3.0.0-alpha.67 → 3.0.0-alpha.68
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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/components/DcbTag.res +68 -0
- package/src/components/DcbTag.res.mjs +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.68 (2026-07-07)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **reventless-aws:** thread inferred DCB scope into the deployed command handler ([4d8327f](https://github.com/ReventlessDev/reventless-core/commit/4d8327fad8659a1cde8c36098c72392737437af1))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
# 3.0.0-alpha.67 (2026-07-06)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @reventlessdev/reventless-spec
|
package/package.json
CHANGED
|
@@ -989,6 +989,74 @@ let sliceShapeFromSchemas = (
|
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
|
|
992
|
+
/** One slice's sury schemas — the input to `deriveEffectiveScope`. */
|
|
993
|
+
type sliceSchemas = {
|
|
994
|
+
name: string,
|
|
995
|
+
commandSchema: S.t<unknown>,
|
|
996
|
+
consumedEventSchema: S.t<unknown>,
|
|
997
|
+
eventSchema: S.t<unknown>,
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
The DCB decision-read scope threaded into every StateChangeSlice callback:
|
|
1002
|
+
- `crossPartitionTagKeys` — keys whose scalar command tag must be fanned into its
|
|
1003
|
+
own single-tag clause (a cross-entity reference read), and
|
|
1004
|
+
- `tagKeysByEventType` — each produced event type's *indexed* tag keys, so a
|
|
1005
|
+
decision query drops vacuous (type, tag) clause combinations.
|
|
1006
|
+
*/
|
|
1007
|
+
type effectiveScope = {
|
|
1008
|
+
crossPartitionTagKeys: array<string>,
|
|
1009
|
+
tagKeysByEventType: dict<array<string>>,
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
Derives the effective DCB decision-read scope for one consistency boundary from
|
|
1014
|
+
its slices' schemas.
|
|
1015
|
+
|
|
1016
|
+
Prefers the slice-graph inference (`DcbScopeInference.infer`) and falls back to
|
|
1017
|
+
the `@crossPartition` / tag *annotations* only when a slice's partition is
|
|
1018
|
+
ambiguous — all-or-nothing, matching `Dcb_Builder`. This is the **single source of
|
|
1019
|
+
truth** shared by the deploy-time builder (`Dcb_Builder.res`) and the deployed
|
|
1020
|
+
command-handler entry point (`DcbCommandTopicEntryPoint.mjs`): both call this so
|
|
1021
|
+
the runtime decision query cannot diverge from the storage/GSI scope. Before this
|
|
1022
|
+
existed the entry point re-derived scope from annotations alone, silently dropping
|
|
1023
|
+
inferred cross-partition reference reads — see
|
|
1024
|
+
`docs/analysis/dcb-runtime-scope-annotation-drift.md`.
|
|
1025
|
+
*/
|
|
1026
|
+
let deriveEffectiveScope = (slices: array<sliceSchemas>): effectiveScope => {
|
|
1027
|
+
let producedSchemas = slices->Array.map(s => s.eventSchema)
|
|
1028
|
+
let annotatedCross = {
|
|
1029
|
+
let seen = Set.make()
|
|
1030
|
+
producedSchemas
|
|
1031
|
+
->Array.flatMap(extractCrossPartitionTagKeys)
|
|
1032
|
+
->Array.filter(k =>
|
|
1033
|
+
if seen->Set.has(k) {
|
|
1034
|
+
false
|
|
1035
|
+
} else {
|
|
1036
|
+
seen->Set.add(k)
|
|
1037
|
+
true
|
|
1038
|
+
}
|
|
1039
|
+
)
|
|
1040
|
+
}
|
|
1041
|
+
let annotatedTagKeys =
|
|
1042
|
+
producedSchemas->Array.map(extractTagKeysByEventType)->mergeTagKeysByEventType
|
|
1043
|
+
let shapes =
|
|
1044
|
+
slices->Array.map(s =>
|
|
1045
|
+
sliceShapeFromSchemas(
|
|
1046
|
+
~name=s.name,
|
|
1047
|
+
~commandSchema=s.commandSchema,
|
|
1048
|
+
~consumedEventSchema=s.consumedEventSchema,
|
|
1049
|
+
~eventSchema=s.eventSchema,
|
|
1050
|
+
)
|
|
1051
|
+
)
|
|
1052
|
+
let inferred = DcbScopeInference.infer(shapes)
|
|
1053
|
+
let useInferred = inferred.ambiguities->Array.length == 0
|
|
1054
|
+
{
|
|
1055
|
+
crossPartitionTagKeys: useInferred ? inferred.crossPartitionTagKeys : annotatedCross,
|
|
1056
|
+
tagKeysByEventType: useInferred ? inferred.tagKeysByEventType : annotatedTagKeys,
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
992
1060
|
/**
|
|
993
1061
|
Checks whether any single variant in a schema has multiple tagged fields.
|
|
994
1062
|
If so, a partition tag annotation is needed to disambiguate.
|
|
@@ -8,6 +8,7 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
|
8
8
|
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
9
9
|
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
10
10
|
import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
|
|
11
|
+
import * as DcbScopeInference$Reventless from "./DcbScopeInference.res.mjs";
|
|
11
12
|
|
|
12
13
|
let tagSchema = S.schema(s => ({
|
|
13
14
|
key: s.m(S.string),
|
|
@@ -618,6 +619,27 @@ function sliceShapeFromSchemas(name, commandSchema, consumedEventSchema, eventSc
|
|
|
618
619
|
};
|
|
619
620
|
}
|
|
620
621
|
|
|
622
|
+
function deriveEffectiveScope(slices) {
|
|
623
|
+
let producedSchemas = slices.map(s => s.eventSchema);
|
|
624
|
+
let seen = new Set();
|
|
625
|
+
let annotatedCross = producedSchemas.flatMap(extractCrossPartitionTagKeys).filter(k => {
|
|
626
|
+
if (seen.has(k)) {
|
|
627
|
+
return false;
|
|
628
|
+
} else {
|
|
629
|
+
seen.add(k);
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
let annotatedTagKeys = mergeTagKeysByEventType(producedSchemas.map(extractTagKeysByEventType));
|
|
634
|
+
let shapes = slices.map(s => sliceShapeFromSchemas(s.name, s.commandSchema, s.consumedEventSchema, s.eventSchema));
|
|
635
|
+
let inferred = DcbScopeInference$Reventless.infer(shapes);
|
|
636
|
+
let useInferred = inferred.ambiguities.length === 0;
|
|
637
|
+
return {
|
|
638
|
+
crossPartitionTagKeys: useInferred ? inferred.crossPartitionTagKeys : annotatedCross,
|
|
639
|
+
tagKeysByEventType: useInferred ? inferred.tagKeysByEventType : annotatedTagKeys
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
621
643
|
function hasMultiTagVariant(schema) {
|
|
622
644
|
switch (schema.type) {
|
|
623
645
|
case "object" :
|
|
@@ -866,6 +888,7 @@ export {
|
|
|
866
888
|
eventShapesOfSchema,
|
|
867
889
|
extractPartitionTagFields,
|
|
868
890
|
sliceShapeFromSchemas,
|
|
891
|
+
deriveEffectiveScope,
|
|
869
892
|
hasMultiTagVariant,
|
|
870
893
|
findMultiTagVariantNames,
|
|
871
894
|
extractCompositePartitionFieldsFromProperties,
|