1 import Base 2 import ./change_tick.bend as Tick 3 import ./restore_graph_data.bend as GraphData 4 import ./restore_graph_validation.bend as Validation 5 import ./restore_graph_machine.bend as Machine 6 import ./restore_graph_world.bend as Install 7 import ./restore_data.bend as R 8 import ./restore_schema.bend as Schema 9 import ./restore_public.bend as Basic 10 import ./restore_prepare.bend as Prepare 11 import ./restore_apply.bend as Apply 12 import ./relation_commands.bend as Relation 13 import ./relation_types.bend as G 14 import ./relation_failure_reader.bend as Declaration 15 import ./owner_product.bend as Product 16 import ./snapshot_data.bend as Snapshot 17 import ./world.bend as W 18 import ./decode_data.bend as D 19 import ./entity_key.bend as Key 20 import ./restore_graph_public.bend as Public 21 import ./restore_graph_runtime_engine.bend as Engine 22 import ./restore_graph_runtime_state.bend as State 23 import ./event_family_runtime.bend as Family 24 import ./event_family_routing.bend as Route 25 import ./event_notice_runtime.bend as Mixed 26 import ./owned_event_family_catalog.bend as Catalog 27 28 type Outcome is Data: 29 Restored{bindings:List<&2,R.Binding>} 30 Rejected{input:GraphData.Snapshot,error:Public.Error} 31 MissingBinding{saved:Key.Key} 32 type Returned is Type: 33 Returned{runtime:Runtime,owner:Owner,recovery:Recovery,receipt:Maybe<&1,Receipt>,outcome:Outcome} 34 def pack(~S:Data,~Runtime:Type,~Owner:Type,~Recovery:Type,~Receipt:Type,~Custom:Data,runtime:Runtime,owner:Owner,recovery:Recovery,receipt:Maybe<&1,Receipt>,outcome:Outcome) -> Returned:Returned{runtime,owner,recovery,receipt,outcome} 35 36 def joined(~S:Data,~C:Type,~User:Type,~Logs:Type,~Machines:Type,~P:Data,~F:Type,~EventOwners:Type,~Receipt:Type,~State:Type,~Custom:Data,~stage:State -> R.Position -> D.Field -> State & R.Dispatch,~release:State -> State,~clear:Relation.Store -> W.Handle -> Relation.Store & List<&2,R.Change>,~insert:Relation.Store -> Product.Owner,Machines> -> State -> List<&2,R.Binding> -> Tick.Tick -> (Relation.Store & Product.Owner,Machines>) & State,~Recovery:Type,~commit:State -> State,~takeRecovery:State -> State & Recovery,~machineRead:Machines -> Machines & List<&2,D.Field>,~machineCheck:D.Field -> Machine.Dispatch,~machineClear:Machines -> Machines,~machineInstall:Machines -> List<&2,D.Field> -> Machines,~emit:R.Change -> Relation.Notice,~retain:Logs -> List<&2,P> -> Logs & Receipt,~drain:Logs -> Logs & Receipt,~clearStreams:F -> F,~catalog:Catalog.Catalog,~sync:F -> Nat -> List<&2,P> -> F,result:(Mixed.State & Nat) & (Maybe<&1,Receipt> & Public.Returned,Product.Owner,Machines>,Relation.Notice>,Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,Recovery,Custom>)) -> Returned,Product.Owner,Machines>,Relation.Notice,Mixed.State>,Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,Recovery,Receipt,Custom>: 37 match result: 38 case (metadata,(receipt,Public.Restored{world,owner,recovery,bindings})):pack(~S,~Route.Runtime,Product.Owner,Machines>,Relation.Notice,Mixed.State>,~(Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>),~Recovery,~Receipt,~Custom,State.publish(~S,~Relation.Store,~Product.Owner,Machines>,~P,~F,~EventOwners,~sync,world,metadata),owner,recovery,receipt,Restored{bindings}) 39 case (metadata,(receipt,Public.Rejected{world,owner,recovery,input,error})):pack(~S,~Route.Runtime,Product.Owner,Machines>,Relation.Notice,Mixed.State>,~(Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>),~Recovery,~Receipt,~Custom,Mixed.join(~S,~Relation.Store,~Product.Owner,Machines>,~P,~F,~EventOwners,world,metadata),owner,recovery,receipt,Rejected{input,error}) 40 case (metadata,(receipt,Public.MissingBinding{world,owner,recovery,saved})):pack(~S,~Route.Runtime,Product.Owner,Machines>,Relation.Notice,Mixed.State>,~(Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>),~Recovery,~Receipt,~Custom,Mixed.join(~S,~Relation.Store,~Product.Owner,Machines>,~P,~F,~EventOwners,world,metadata),owner,recovery,receipt,MissingBinding{saved}) 41 def detached(~S:Data,~C:Type,~User:Type,~Logs:Type,~Machines:Type,~P:Data,~F:Type,~EventOwners:Type,~Receipt:Type,~State:Type,~Custom:Data,~stage:State -> R.Position -> D.Field -> State & R.Dispatch,~release:State -> State,~clear:Relation.Store -> W.Handle -> Relation.Store & List<&2,R.Change>,~insert:Relation.Store -> Product.Owner,Machines> -> State -> List<&2,R.Binding> -> Tick.Tick -> (Relation.Store & Product.Owner,Machines>) & State,~Recovery:Type,~commit:State -> State,~takeRecovery:State -> State & Recovery,~machineRead:Machines -> Machines & List<&2,D.Field>,~machineCheck:D.Field -> Machine.Dispatch,~machineClear:Machines -> Machines,~machineInstall:Machines -> List<&2,D.Field> -> Machines,~emit:R.Change -> Relation.Notice,~retain:Logs -> List<&2,P> -> Logs & Receipt,~drain:Logs -> Logs & Receipt,~clearStreams:F -> F,~catalog:Catalog.Catalog,~sync:F -> Nat -> List<&2,P> -> F,owner:Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,input:GraphData.Snapshot,result:W.World,Product.Owner,Machines>,Relation.Notice> & (Mixed.State & Nat)) -> Returned,Product.Owner,Machines>,Relation.Notice,Mixed.State>,Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,Recovery,Receipt,Custom>: 42 match result: 43 case (world,metadata):joined(~S,~C,~User,~Logs,~Machines,~P,~F,~EventOwners,~Receipt,~State,~Custom,~stage,~release,~clear,~insert,~Recovery,~commit,~takeRecovery,~machineRead,~machineCheck,~machineClear,~machineInstall,~emit,~retain,~drain,~clearStreams,~catalog,~sync,Engine.run(~S,~C,~Product.Owner,~Machines,~Relation.Notice,~State,~Custom,~stage,~release,~clear,~insert,~Recovery,~commit,~takeRecovery,~machineRead,~machineCheck,~machineClear,~machineInstall,~emit,~(Mixed.State & Nat),~Receipt,~State.admit(~S,~Relation.Store,~User,~Logs,~Machines,~P,~F,~EventOwners,~Receipt,~retain,~drain,~clearStreams,catalog),metadata,owner,world,input)) 44 def run(~S:Data,~C:Type,~User:Type,~Logs:Type,~Machines:Type,~P:Data,~F:Type,~EventOwners:Type,~Receipt:Type,~State:Type,~Custom:Data,~stage:State -> R.Position -> D.Field -> State & R.Dispatch,~release:State -> State,~clear:Relation.Store -> W.Handle -> Relation.Store & List<&2,R.Change>,~insert:Relation.Store -> Product.Owner,Machines> -> State -> List<&2,R.Binding> -> Tick.Tick -> (Relation.Store & Product.Owner,Machines>) & State,~Recovery:Type,~commit:State -> State,~takeRecovery:State -> State & Recovery,~machineRead:Machines -> Machines & List<&2,D.Field>,~machineCheck:D.Field -> Machine.Dispatch,~machineClear:Machines -> Machines,~machineInstall:Machines -> List<&2,D.Field> -> Machines,~emit:R.Change -> Relation.Notice,~retain:Logs -> List<&2,P> -> Logs & Receipt,~drain:Logs -> Logs & Receipt,~clearStreams:F -> F,~catalog:Catalog.Catalog,~sync:F -> Nat -> List<&2,P> -> F,owner:Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,runtime:Route.Runtime,Product.Owner,Machines>,Relation.Notice,Mixed.State>,input:GraphData.Snapshot) -> Returned,Product.Owner,Machines>,Relation.Notice,Mixed.State>,Public.Owner,Machines,Relation.Notice,State,Custom,stage,release,clear,insert,Recovery,commit,takeRecovery,machineRead,machineCheck,machineClear,machineInstall>,Recovery,Receipt,Custom>: 45 detached(~S,~C,~User,~Logs,~Machines,~P,~F,~EventOwners,~Receipt,~State,~Custom,~stage,~release,~clear,~insert,~Recovery,~commit,~takeRecovery,~machineRead,~machineCheck,~machineClear,~machineInstall,~emit,~retain,~drain,~clearStreams,~catalog,~sync,owner,input,Mixed.split(~S,~Relation.Store,~Product.Owner,Machines>,~P,~F,~EventOwners,runtime))