@@ -426,6 +426,72 @@ defmodule ColouredFlow.Runner.Enactment.WorkitemCalibrationTest do
426426 assert expected_state === calibration . state
427427 assert [ aj_workitem_2 ] === calibration . to_withdraw
428428 end
429+
430+ # ```mermaid
431+ # flowchart LR
432+ # %% colset int() :: integer()
433+ # %% place_1 ~MS[1], place_2 ~MS[1]
434+ # p1((place_1))
435+ # p2((place_2))
436+ # o1((output_1))
437+ # o2((output_2))
438+ # pt1[pass_through_1]
439+ # pt2[pass_through_2]
440+ # p1 --{1,x}--> pt1 --> o1
441+ # p2 --{1,x}--> pt2 --> o2
442+ # ```
443+ test "keeps enabled workitems whose input places are disjoint from the started workitem's input places" do
444+ enactment_id = Ecto.UUID . generate ( )
445+
446+ pt1_workitem = % Enactment.Workitem {
447+ id: Ecto.UUID . generate ( ) ,
448+ state: :enabled ,
449+ binding_element: % BindingElement {
450+ transition: "pass_through_1" ,
451+ binding: [ x: 1 ] ,
452+ to_consume: [ % Marking { place: "place_1" , tokens: ~MS[ 1] } ]
453+ }
454+ }
455+
456+ pt2_workitem = % Enactment.Workitem {
457+ id: Ecto.UUID . generate ( ) ,
458+ state: :enabled ,
459+ binding_element: % BindingElement {
460+ transition: "pass_through_2" ,
461+ binding: [ x: 1 ] ,
462+ to_consume: [ % Marking { place: "place_2" , tokens: ~MS[ 1] } ]
463+ }
464+ }
465+
466+ state = % Enactment {
467+ enactment_id: enactment_id ,
468+ version: 0 ,
469+ markings:
470+ to_map ( [
471+ % Marking { place: "place_1" , tokens: ~MS[ 1] } ,
472+ % Marking { place: "place_2" , tokens: ~MS[ 1] }
473+ ] ) ,
474+ workitems:
475+ to_map ( [
476+ % Enactment.Workitem { pt1_workitem | state: :started } ,
477+ pt2_workitem
478+ ] )
479+ }
480+
481+ expected_state = % Enactment {
482+ state
483+ | workitems:
484+ to_map ( [
485+ % Enactment.Workitem { pt1_workitem | state: :started } ,
486+ pt2_workitem
487+ ] )
488+ }
489+
490+ calibration = WorkitemCalibration . calibrate ( state , :start , workitems: [ pt1_workitem ] )
491+
492+ assert expected_state === calibration . state
493+ assert [ ] === calibration . to_withdraw
494+ end
429495 end
430496
431497 describe "calibrate after completed" do
0 commit comments