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