@reventlessdev/reventless-core 3.0.0-alpha.339 → 3.0.0-alpha.341

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 CHANGED
@@ -3,6 +3,23 @@
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.341 (2026-11-16)
7
+
8
+ **Note:** Version bump only for package @reventlessdev/reventless-core
9
+
10
+
11
+
12
+
13
+
14
+ # 3.0.0-alpha.340 (2026-11-16)
15
+
16
+ ### Bug Fixes
17
+
18
+ * **aws:** a new plugin stack's preview no longer waits for the DCB command Lambda ([175f61b](https://github.com/ReventlessDev/reventless-core/commit/175f61b6b5a5f9c81de28de1c238ed5231a95a80))
19
+ * **dcb:** a partition is a key every event the slice writes carries ([5dae458](https://github.com/ReventlessDev/reventless-core/commit/5dae458443e9dafc119a941962194e315b3c051e))
20
+ * **dcb:** no composite-read warning for a query that fans out ([67b38e5](https://github.com/ReventlessDev/reventless-core/commit/67b38e51c8d6156f52ab5f969987bf2393c573d6))
21
+
22
+
6
23
  # 3.0.0-alpha.339 (2026-11-15)
7
24
 
8
25
  **Note:** Version bump only for package @reventlessdev/reventless-core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-core",
3
- "version": "3.0.0-alpha.339",
3
+ "version": "3.0.0-alpha.341",
4
4
  "description": "Core package for Reventless framework",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -29,21 +29,21 @@
29
29
  "sury": "11.1.0",
30
30
  "uuid": "^13.0.0",
31
31
  "@reventlessdev/rescript-effect": "1.0.0-alpha.3",
32
- "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.26",
33
32
  "@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
33
+ "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.26",
34
34
  "@reventlessdev/rescript-jest": "1.0.0-alpha.13",
35
35
  "@reventlessdev/rescript-node": "2.0.0-alpha.26",
36
36
  "@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
37
- "@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
38
- "@reventlessdev/reventless-infra": "3.0.0-alpha.232",
39
37
  "@reventlessdev/rescript-ssh2": "2.0.0-alpha.27",
40
- "@reventlessdev/reventless-interop": "3.0.0-alpha.43",
41
- "@reventlessdev/reventless-spec": "3.0.0-alpha.201"
38
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.234",
39
+ "@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
40
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.203",
41
+ "@reventlessdev/reventless-interop": "3.0.0-alpha.43"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rescript": "12.3.1",
45
45
  "sury-ppx": "11.1.0",
46
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.113"
46
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.114"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "rescript": "^12.3.1"
@@ -364,76 +364,84 @@ module Make = (
364
364
  }
365
365
  let _resolvers = adminSchemaPushed->Pulumi.Output.apply(() => allQueryDbs->createResolvers)
366
366
 
367
- let extensionPointsOutputs =
367
+ let callbackInputs =
368
368
  (
369
369
  aggregateResources->Pulumi.Output.allDict,
370
370
  publishToAggregates->Pulumi.Output.allDict,
371
371
  queryEngine,
372
372
  scheduler,
373
- )
374
- ->Pulumi.Output.all4
375
- ->Pulumi.Output.apply(((aggregateResources, publishToAggregates, queryEngine, scheduler)) => {
376
- let _aggregatesOutputs = addEventMappers(allEventTopics, queryEngine)
377
-
378
- let (
379
- extensionPointsOutputs,
380
- extensionPointsOutgoingJsonEventsHandlers,
381
- _extensionPointRegistryInfos,
382
- ) =
383
- extensionPoints->createExtensionPoints(
384
- ~aggregateResources,
385
- ~publishToAggregates,
386
- ~scheduler,
387
- ~queryEngine,
388
- ~resourceNaming,
389
- ~componentRuntime=Dict.make(),
390
- ~opts,
391
- )
373
+ )->Pulumi.Output.all4
374
+ Config.hooks.onDcbRuntimeSetupGate->Option.forEach(hook =>
375
+ hook(callbackInputs->Pulumi.Output.apply(_ => ()))
376
+ )
392
377
 
393
- let aggregateNames =
394
- extensionPointsOutputs
395
- ->Array.map(extensionPointOutputs =>
396
- extensionPointOutputs.aggregateNames->Belt.Set.String.fromArray
397
- )
398
- ->Array.reduce(Belt.Set.String.empty, (acc, names) => acc->Belt.Set.String.union(names))
399
-
400
- let aggregatesOutputs = addEventMappers(allEventTopics, queryEngine)
401
- // The admin EventCollector subscribes only to the aggregate event topics
402
- // filtered by its extension-point aggregate names. It is NOT a reader of the
403
- // admin DcbEventLog stream: ApiFragmentRegistry is now a singleton aggregate
404
- // (its reactive push is the ApiSchemaPush SideEffect on the aggregate event
405
- // topic), and the remaining DcbEventLog slice (UiFragmentRegistry) is consumed
406
- // by the AllStateViewSlices projection, not here.
407
- let eventTopics = aggregatesOutputs->Aggregate.filterEventTopics(aggregateNames)
408
-
409
- module EventCollectorHelper = MakeEventCollectorHelper(
410
- RuntimeEnvironment,
411
- EventCollectorChannel,
412
- PlatformRuntimeBuilder,
413
- )
414
- let (eventCollector, _eventCollectorOutputs) = EventCollectorHelper.make(
415
- ~name,
416
- ~eventTopics,
378
+ let extensionPointsOutputs = callbackInputs->Pulumi.Output.apply(((
379
+ aggregateResources,
380
+ publishToAggregates,
381
+ queryEngine,
382
+ scheduler,
383
+ )) => {
384
+ let _aggregatesOutputs = addEventMappers(allEventTopics, queryEngine)
385
+
386
+ let (
387
+ extensionPointsOutputs,
388
+ extensionPointsOutgoingJsonEventsHandlers,
389
+ _extensionPointRegistryInfos,
390
+ ) =
391
+ extensionPoints->createExtensionPoints(
392
+ ~aggregateResources,
393
+ ~publishToAggregates,
394
+ ~scheduler,
395
+ ~queryEngine,
396
+ ~resourceNaming,
397
+ ~componentRuntime=Dict.make(),
417
398
  ~opts,
418
399
  )
419
400
 
420
- let _ =
421
- extensionPointsOutgoingJsonEventsHandlers
422
- ->Pulumi.Output.all
423
- ->Pulumi.Output.flatMap(extensionPointsOutgoingJsonEventsHandlers =>
424
- EventCollectorHelper.connect(
425
- ~eventCollector,
426
- ~eventTopics,
427
- ~extensionPointsOutputs,
428
- ~extensionPointsOutgoingJsonEventsHandlers,
429
- )
401
+ let aggregateNames =
402
+ extensionPointsOutputs
403
+ ->Array.map(extensionPointOutputs =>
404
+ extensionPointOutputs.aggregateNames->Belt.Set.String.fromArray
405
+ )
406
+ ->Array.reduce(Belt.Set.String.empty, (acc, names) => acc->Belt.Set.String.union(names))
407
+
408
+ let aggregatesOutputs = addEventMappers(allEventTopics, queryEngine)
409
+ // The admin EventCollector subscribes only to the aggregate event topics
410
+ // filtered by its extension-point aggregate names. It is NOT a reader of the
411
+ // admin DcbEventLog stream: ApiFragmentRegistry is now a singleton aggregate
412
+ // (its reactive push is the ApiSchemaPush SideEffect on the aggregate event
413
+ // topic), and the remaining DcbEventLog slice (UiFragmentRegistry) is consumed
414
+ // by the AllStateViewSlices projection, not here.
415
+ let eventTopics = aggregatesOutputs->Aggregate.filterEventTopics(aggregateNames)
416
+
417
+ module EventCollectorHelper = MakeEventCollectorHelper(
418
+ RuntimeEnvironment,
419
+ EventCollectorChannel,
420
+ PlatformRuntimeBuilder,
421
+ )
422
+ let (eventCollector, _eventCollectorOutputs) = EventCollectorHelper.make(
423
+ ~name,
424
+ ~eventTopics,
425
+ ~opts,
426
+ )
427
+
428
+ let _ =
429
+ extensionPointsOutgoingJsonEventsHandlers
430
+ ->Pulumi.Output.all
431
+ ->Pulumi.Output.flatMap(extensionPointsOutgoingJsonEventsHandlers =>
432
+ EventCollectorHelper.connect(
433
+ ~eventCollector,
434
+ ~eventTopics,
435
+ ~extensionPointsOutputs,
436
+ ~extensionPointsOutgoingJsonEventsHandlers,
430
437
  )
438
+ )
431
439
 
432
- // Connect DCB command topic to its runtime (if DCB is configured)
433
- dcbResult.dcbRuntimeSetup->Option.forEach(dcbRuntimeSetup => dcbRuntimeSetup())
440
+ // Connect DCB command topic to its runtime (if DCB is configured)
441
+ dcbResult.dcbRuntimeSetup->Option.forEach(dcbRuntimeSetup => dcbRuntimeSetup())
434
442
 
435
- extensionPointsOutputs
436
- })
443
+ extensionPointsOutputs
444
+ })
437
445
 
438
446
  // Cloner (opt-in)
439
447
  if Config.cloner {
@@ -153,12 +153,14 @@ function Make(RuntimeEnvironment) {
153
153
  let push = Config.hooks.preAdminResolversSchemaHook;
154
154
  let adminSchemaPushed = push !== undefined ? push(adminBarrier) : Pulumi.output();
155
155
  adminSchemaPushed.apply(() => Builder_Helpers$ReventlessCore.createResolvers(allQueryDbs));
156
- let extensionPointsOutputs = Pulumi.all([
156
+ let callbackInputs = Pulumi.all([
157
157
  Pulumi.all(Builder_Helpers$ReventlessCore.aggregateResources),
158
158
  Pulumi.all(Builder_Helpers$ReventlessCore.publishToAggregates),
159
159
  queryEngine,
160
160
  scheduler
161
- ]).apply(param => {
161
+ ]);
162
+ Stdlib_Option.forEach(Config.hooks.onDcbRuntimeSetupGate, hook => hook(callbackInputs.apply(param => {})));
163
+ let extensionPointsOutputs = callbackInputs.apply(param => {
162
164
  let queryEngine = param[2];
163
165
  Builder_Helpers$ReventlessCore.addEventMappers(aggregateEventTopics, queryEngine);
164
166
  let match = Builder_Helpers$ReventlessCore.createExtensionPoints(extensionPoints, param[0], param[1], param[3], queryEngine, resourceNaming, {}, opts);
@@ -396,6 +396,7 @@ module Make = (
396
396
  Sc.Spec.consumedEventSchema->S.castToUnknown,
397
397
  )),
398
398
  ~producedTagKeys=tagKeysByEventType,
399
+ ~crossPartitionTagKeys=effectiveCrossPartitionTagKeys,
399
400
  ~payloadTagKeysBySlice=sliceSchemas
400
401
  ->Array.map(slice => (
401
402
  slice.name,
@@ -239,7 +239,7 @@ function Make(DcbEventLogStorage) {
239
239
  ]), tagKeysByEventType, Object.fromEntries(sliceSchemas.map(slice => [
240
240
  slice.name,
241
241
  DcbTag$Reventless.commandPayloadTagKeys(DcbTag$Reventless.sliceShape(slice), DcbTag$Reventless.slicePartitionTag(boundaryPartition, slice.name), effectiveCrossPartitionTagKeys)
242
- ]))).forEach(w => log.warn("Dcb_Builder", undefined, `DCB composite-read warning (` + w.sliceName + `): ` + w.message));
242
+ ])), effectiveCrossPartitionTagKeys).forEach(w => log.warn("Dcb_Builder", undefined, `DCB composite-read warning (` + w.sliceName + `): ` + w.message));
243
243
  if (effective.droppedCrossPartitionTagKeys.length !== 0) {
244
244
  log.error("Dcb_Builder", undefined, `DCB scope degraded (` + name + `): cross-partition reads of [` + effective.droppedCrossPartitionTagKeys.join(", ") + `] were derived but dropped — an ambiguous slice forced the boundary onto @crossPartition annotations that do not carry them. Slices referencing another entity by these keys will decide against an empty history and reject valid commands. Resolve: ` + effective.ambiguities.map(param => param[0] + ` (` + param[1] + `)`).join(" | "));
245
245
  }
@@ -679,14 +679,19 @@ module Make = (
679
679
  toPayload(s, ~schema=Reventless.Plugin.pluginStructureSchema, ~store="pluginStructures")
680
680
  )
681
681
 
682
- (
683
- (interstackAdminExtensionPoints, localAdminResolvedEP, schemaPushed)->Pulumi.Output.all3,
684
- aggregateResources->Pulumi.Output.allDict,
685
- publishToAggregates->Pulumi.Output.allDict,
686
- scheduler,
687
- queryEngine,
682
+ let callbackInputs =
683
+ (
684
+ (interstackAdminExtensionPoints, localAdminResolvedEP, schemaPushed)->Pulumi.Output.all3,
685
+ aggregateResources->Pulumi.Output.allDict,
686
+ publishToAggregates->Pulumi.Output.allDict,
687
+ scheduler,
688
+ queryEngine,
689
+ )->Pulumi.Output.all5
690
+ Spec.hooks.onDcbRuntimeSetupGate->Option.forEach(hook =>
691
+ hook(callbackInputs->Pulumi.Output.apply(_ => ()))
688
692
  )
689
- ->Pulumi.Output.all5
693
+
694
+ callbackInputs
690
695
  // `applyAttributed`, not `apply`: this callback provisions real resources —
691
696
  // extension points, tasks, the heartbeat, resolvers — and it runs after
692
697
  // this construct has returned, when the ambient attribution context is
@@ -437,7 +437,7 @@ function Make(Spec) {
437
437
  let schemaPushed = pushSchema !== undefined ? pushSchema(extra$1, version, apiSchemaFragment) : Pulumi.output();
438
438
  let apiSchemaFragmentPayload = Plugin_Helpers$ReventlessCore.offloadPayload(apiSchemaFragment, Plugin$Reventless.apiSchemaFragmentSchema, "pluginApiFragments");
439
439
  let structurePayload = Stdlib_Option.map(pluginStructure, s => Plugin_Helpers$ReventlessCore.offloadPayload(s, Plugin$Reventless.pluginStructureSchema, "pluginStructures"));
440
- let builderOutputs = ResourceAttribution_Deploytime$ReventlessCore.applyAttributed(Pulumi.all([
440
+ let callbackInputs = Pulumi.all([
441
441
  Pulumi.all([
442
442
  interstackAdminExtensionPoints,
443
443
  localAdminResolvedEP,
@@ -447,7 +447,9 @@ function Make(Spec) {
447
447
  Pulumi.all(Plugin_Helpers$ReventlessCore.publishToAggregates),
448
448
  scheduler,
449
449
  queryEngine
450
- ]), param => {
450
+ ]);
451
+ Stdlib_Option.forEach(Spec.hooks.onDcbRuntimeSetupGate, hook => hook(callbackInputs.apply(param => {})));
452
+ let builderOutputs = ResourceAttribution_Deploytime$ReventlessCore.applyAttributed(callbackInputs, param => {
451
453
  let queryEngine = param[4];
452
454
  let scheduler = param[3];
453
455
  let publishToAggregates = param[2];
@@ -1026,6 +1026,10 @@ type platformHooks = {
1026
1026
  onDcbEventLogCreated?: unknown => unit,
1027
1027
  onDcbCommandTopicCreated?: unknown => unit,
1028
1028
  onDcbSlicesCreated?: unknown => unit,
1029
+ // The outputs the callback that runs `dcbRuntimeSetup` waits for, handed over
1030
+ // before it is applied. A preview skips that callback where they are unknown, so
1031
+ // anything waiting for the DCB command Lambdas waits on these instead.
1032
+ onDcbRuntimeSetupGate?: Pulumi.Output.t<unit> => unit,
1029
1033
  // heartbeatInterval carries the plugin's heartbeat cadence so the AWS bundled
1030
1034
  // heartbeat Lambda emits Heartbeat(interval) matching its EventBridge schedule
1031
1035
  // rate. Both derive from the same heartbeatInterval; threading it here prevents
@@ -602,6 +602,72 @@ describe("DcbScopeInference:", () => {
602
602
  expect(issues.contradictions->names)->toEqual(["ShipOrder"])
603
603
  },
604
604
  )
605
+
606
+ // A question's answer is kept per message. `AnswerMarked` names the reply, but
607
+ // `QuestionReopened` does not, so the reply cannot be the partition — though
608
+ // `ReplyPosted` comes from a slice partitioned by it, which once gave it back.
609
+ let postMessage = slice(
610
+ "PostMessage",
611
+ ~chapter="Messages",
612
+ ~produced=[ev("MessagePosted", [scal("messageId"), scal("channelId")])],
613
+ ~partitionHint="messageId",
614
+ )
615
+ let postReply = slice(
616
+ "PostReply",
617
+ ~chapter="Messages",
618
+ ~consumed=[ev("MessagePosted", [scal("messageId"), scal("channelId")])],
619
+ ~produced=[ev("ReplyPosted", [scal("replyId"), scal("messageId"), scal("channelId")])],
620
+ )
621
+ let questionState = slice(
622
+ "QuestionState",
623
+ ~chapter="Questions",
624
+ ~partitionHint="messageId",
625
+ ~consumed=[
626
+ ev("AnswerMarked", [scal("messageId"), scal("replyId"), scal("channelId")]),
627
+ ev("QuestionReopened", [scal("messageId"), scal("channelId")]),
628
+ ev("MessagePosted", [scal("messageId"), scal("channelId")]),
629
+ ev("ReplyPosted", [scal("replyId"), scal("messageId"), scal("channelId")]),
630
+ ],
631
+ ~produced=[
632
+ ev("AnswerMarked", [scal("messageId"), scal("replyId"), scal("channelId")]),
633
+ ev("QuestionReopened", [scal("messageId"), scal("channelId")]),
634
+ ],
635
+ )
636
+ let questions = [postMessage, postReply, questionState]
637
+
638
+ testSync(
639
+ "inference never picks a key one of the slice's own events lacks",
640
+ () => {
641
+ let unhinted = {...questionState, partitionHint: None}
642
+ let r = DSI.resolvePartitions([postMessage, postReply, unhinted])
643
+ expect(r.partitionBySlice->Dict.get("QuestionState"))->toEqual(None)
644
+ expect(r.candidatesBySlice->Dict.get("QuestionState"))->toEqual(Some([]))
645
+ },
646
+ )
647
+
648
+ testSync(
649
+ "a hint deciding a slice inference leaves unresolved is accepted",
650
+ () => {
651
+ let issues = check(questions)
652
+ expect(issues.contradictions)->toEqual([])
653
+ expect(issues.redundancies)->toEqual([])
654
+ expect(
655
+ DSI.resolvePartitions(questions).partitionBySlice->Dict.get("QuestionState"),
656
+ )->toEqual(Some("messageId"))
657
+ },
658
+ )
659
+
660
+ testSync(
661
+ "a hint naming a key one of the slice's events lacks is still a contradiction",
662
+ () => {
663
+ let issues = check([
664
+ postMessage,
665
+ postReply,
666
+ {...questionState, partitionHint: Some("replyId")},
667
+ ])
668
+ expect(issues.contradictions->names)->toEqual(["QuestionState"])
669
+ },
670
+ )
605
671
  })
606
672
 
607
673
  describe("ambiguity surfacing", () => {
@@ -965,6 +965,172 @@ globalThis.describe("DcbScopeInference:", () => {
965
965
  globalThis.expect(issues.overrides.map(e => e.sliceName)).toEqual([]);
966
966
  globalThis.expect(issues.contradictions.map(e => e.sliceName)).toEqual(["ShipOrder"]);
967
967
  });
968
+ let postMessage = slice("PostMessage", undefined, undefined, [{
969
+ eventType: "MessagePosted",
970
+ idFields: [
971
+ {
972
+ name: "messageId",
973
+ isList: false
974
+ },
975
+ {
976
+ name: "channelId",
977
+ isList: false
978
+ }
979
+ ]
980
+ }], "messageId", "Messages");
981
+ let postReply = slice("PostReply", undefined, [{
982
+ eventType: "MessagePosted",
983
+ idFields: [
984
+ {
985
+ name: "messageId",
986
+ isList: false
987
+ },
988
+ {
989
+ name: "channelId",
990
+ isList: false
991
+ }
992
+ ]
993
+ }], [{
994
+ eventType: "ReplyPosted",
995
+ idFields: [
996
+ {
997
+ name: "replyId",
998
+ isList: false
999
+ },
1000
+ {
1001
+ name: "messageId",
1002
+ isList: false
1003
+ },
1004
+ {
1005
+ name: "channelId",
1006
+ isList: false
1007
+ }
1008
+ ]
1009
+ }], undefined, "Messages");
1010
+ let questionState = slice("QuestionState", undefined, [
1011
+ {
1012
+ eventType: "AnswerMarked",
1013
+ idFields: [
1014
+ {
1015
+ name: "messageId",
1016
+ isList: false
1017
+ },
1018
+ {
1019
+ name: "replyId",
1020
+ isList: false
1021
+ },
1022
+ {
1023
+ name: "channelId",
1024
+ isList: false
1025
+ }
1026
+ ]
1027
+ },
1028
+ {
1029
+ eventType: "QuestionReopened",
1030
+ idFields: [
1031
+ {
1032
+ name: "messageId",
1033
+ isList: false
1034
+ },
1035
+ {
1036
+ name: "channelId",
1037
+ isList: false
1038
+ }
1039
+ ]
1040
+ },
1041
+ {
1042
+ eventType: "MessagePosted",
1043
+ idFields: [
1044
+ {
1045
+ name: "messageId",
1046
+ isList: false
1047
+ },
1048
+ {
1049
+ name: "channelId",
1050
+ isList: false
1051
+ }
1052
+ ]
1053
+ },
1054
+ {
1055
+ eventType: "ReplyPosted",
1056
+ idFields: [
1057
+ {
1058
+ name: "replyId",
1059
+ isList: false
1060
+ },
1061
+ {
1062
+ name: "messageId",
1063
+ isList: false
1064
+ },
1065
+ {
1066
+ name: "channelId",
1067
+ isList: false
1068
+ }
1069
+ ]
1070
+ }
1071
+ ], [
1072
+ {
1073
+ eventType: "AnswerMarked",
1074
+ idFields: [
1075
+ {
1076
+ name: "messageId",
1077
+ isList: false
1078
+ },
1079
+ {
1080
+ name: "replyId",
1081
+ isList: false
1082
+ },
1083
+ {
1084
+ name: "channelId",
1085
+ isList: false
1086
+ }
1087
+ ]
1088
+ },
1089
+ {
1090
+ eventType: "QuestionReopened",
1091
+ idFields: [
1092
+ {
1093
+ name: "messageId",
1094
+ isList: false
1095
+ },
1096
+ {
1097
+ name: "channelId",
1098
+ isList: false
1099
+ }
1100
+ ]
1101
+ }
1102
+ ], "messageId", "Questions");
1103
+ let questions = [
1104
+ postMessage,
1105
+ postReply,
1106
+ questionState
1107
+ ];
1108
+ globalThis.test("inference never picks a key one of the slice's own events lacks", () => {
1109
+ let newrecord = {...questionState};
1110
+ newrecord.partitionHint = undefined;
1111
+ let r = DcbScopeInference$Reventless.resolvePartitions([
1112
+ postMessage,
1113
+ postReply,
1114
+ newrecord
1115
+ ]);
1116
+ globalThis.expect(r.partitionBySlice["QuestionState"]).toEqual(undefined);
1117
+ globalThis.expect(r.candidatesBySlice["QuestionState"]).toEqual([]);
1118
+ });
1119
+ globalThis.test("a hint deciding a slice inference leaves unresolved is accepted", () => {
1120
+ let issues = DcbValidation$Reventless.validatePartitionHintsVsInference(questions);
1121
+ globalThis.expect(issues.contradictions).toEqual([]);
1122
+ globalThis.expect(issues.redundancies).toEqual([]);
1123
+ globalThis.expect(DcbScopeInference$Reventless.resolvePartitions(questions).partitionBySlice["QuestionState"]).toEqual("messageId");
1124
+ });
1125
+ globalThis.test("a hint naming a key one of the slice's events lacks is still a contradiction", () => {
1126
+ let newrecord = {...questionState};
1127
+ let issues = DcbValidation$Reventless.validatePartitionHintsVsInference([
1128
+ postMessage,
1129
+ postReply,
1130
+ (newrecord.partitionHint = "replyId", newrecord)
1131
+ ]);
1132
+ globalThis.expect(issues.contradictions.map(e => e.sliceName)).toEqual(["QuestionState"]);
1133
+ });
968
1134
  });
969
1135
  globalThis.describe("ambiguity surfacing", () => {
970
1136
  let aOwner = slice("A", undefined, undefined, [{
@@ -371,6 +371,27 @@ describe("DcbValidation:", () => {
371
371
  },
372
372
  )
373
373
 
374
+ testSync(
375
+ "ignores a command with a cross-partition key (single-tag clauses, not composite)",
376
+ () => {
377
+ let slices = [("RecordDemand", recordDemandCommandSchema->u, demandConsumedSchema->u)]
378
+ let fanned = Reventless.DcbValidation.validateCompositeReads(
379
+ ~slices,
380
+ ~producedTagKeys,
381
+ ~crossPartitionTagKeys=["orderId"],
382
+ )
383
+ expect(fanned)->toEqual([])
384
+ // and the query the check now trusts is indeed single-tag clauses
385
+ let query = Reventless.DcbTag.buildQueryFromCommand(
386
+ ~eventTypes=["ProductDemandRevoked"],
387
+ ~schema=recordDemandCommandSchema,
388
+ ~value=RecordDemand({productId: "p1", orderId: "o1"}),
389
+ ~crossPartitionTagKeys=["orderId"],
390
+ )
391
+ expect(query->Array.every(qi => qi.tags->Option.mapOr(0, Array.length) == 1))->toBe(true)
392
+ },
393
+ )
394
+
374
395
  testSync(
375
396
  "no warnings when nothing reads compositely",
376
397
  () => {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as Sury from "sury";
4
4
  import * as JestGlobals from "@reventlessdev/rescript-jest/src/JestGlobals.res.mjs";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
6
  import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
6
7
  import * as DcbValidation$Reventless from "@reventlessdev/reventless-spec/src/components/DcbValidation.res.mjs";
7
8
 
@@ -367,12 +368,13 @@ globalThis.describe("DcbValidation:", () => {
367
368
  });
368
369
  });
369
370
  globalThis.describe("validateCompositeReads (Issue 5)", () => {
371
+ let check = slices => DcbValidation$Reventless.validateCompositeReads(slices, producedTagKeys, undefined, undefined);
370
372
  globalThis.test("warns when a composite read's consumed type carries an extra tag", () => {
371
- let warnings = DcbValidation$Reventless.validateCompositeReads([[
373
+ let warnings = check([[
372
374
  "RecordDemand",
373
375
  recordDemandCommandSchema,
374
376
  demandConsumedSchema
375
- ]], producedTagKeys, undefined);
377
+ ]]);
376
378
  globalThis.expect(warnings.length).toBe(1);
377
379
  let w = warnings[0];
378
380
  globalThis.expect(w.sliceName).toBe("RecordDemand");
@@ -380,31 +382,46 @@ globalThis.describe("DcbValidation:", () => {
380
382
  globalThis.expect(w.message.includes("customerId")).toBe(true);
381
383
  });
382
384
  globalThis.test("does not warn for an exact-match consumed type", () => {
383
- let warnings = DcbValidation$Reventless.validateCompositeReads([[
385
+ let warnings = check([[
384
386
  "RecordDemand",
385
387
  recordDemandCommandSchema,
386
388
  demandConsumedSchema
387
- ]], producedTagKeys, undefined);
389
+ ]]);
388
390
  globalThis.expect(warnings.some(w => w.message.includes("ProductDemandRecorded"))).toBe(false);
389
391
  });
390
392
  globalThis.test("ignores single-tag commands (partition read, not composite)", () => {
391
- let warnings = DcbValidation$Reventless.validateCompositeReads([[
393
+ let warnings = check([[
392
394
  "TouchDemand",
393
395
  touchDemandCommandSchema,
394
396
  demandConsumedSchema
395
- ]], producedTagKeys, undefined);
397
+ ]]);
396
398
  globalThis.expect(warnings).toEqual([]);
397
399
  });
398
400
  globalThis.test("ignores tagged-array commands (per-element OR, not composite)", () => {
399
- let warnings = DcbValidation$Reventless.validateCompositeReads([[
401
+ let warnings = check([[
400
402
  "PlaceOrder",
401
403
  placeOrderCommandSchema,
402
404
  demandConsumedSchema
403
- ]], producedTagKeys, undefined);
405
+ ]]);
404
406
  globalThis.expect(warnings).toEqual([]);
405
407
  });
408
+ globalThis.test("ignores a command with a cross-partition key (single-tag clauses, not composite)", () => {
409
+ let slices = [[
410
+ "RecordDemand",
411
+ recordDemandCommandSchema,
412
+ demandConsumedSchema
413
+ ]];
414
+ let fanned = DcbValidation$Reventless.validateCompositeReads(slices, producedTagKeys, undefined, ["orderId"]);
415
+ globalThis.expect(fanned).toEqual([]);
416
+ let query = DcbTag$Reventless.buildQueryFromCommand(["ProductDemandRevoked"], recordDemandCommandSchema, {
417
+ TAG: "RecordDemand",
418
+ productId: "p1",
419
+ orderId: "o1"
420
+ }, undefined, ["orderId"], undefined);
421
+ globalThis.expect(query.every(qi => Stdlib_Option.mapOr(qi.tags, 0, prim => prim.length) === 1)).toBe(true);
422
+ });
406
423
  globalThis.test("no warnings when nothing reads compositely", () => {
407
- globalThis.expect(DcbValidation$Reventless.validateCompositeReads([], producedTagKeys, undefined)).toEqual([]);
424
+ globalThis.expect(check([])).toEqual([]);
408
425
  });
409
426
  });
410
427
  globalThis.describe("validateCrossPartitionScope (Issue 13)", () => {