import Base import ./world.bend as W import ./execution_composer_layout.bend as Layout import ./execution_command_permission.bend as Permission import ./execution_relation_context.bend as Context import ./execution_lifetime_scope_resource_dispatch.bend as Dispatch import ./execution_lifetime_scope_store.bend as Store import ./execution_relation_resource_snapshot.bend as Snapshot import ./execution_relation_world_publication.bend as Publication import ./entity_allocator.bend as Allocator import ./change_tick.bend as Tick def restored(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},frame:Publication.Frame,result:Allocator.Allocator & (Physical & Dispatch.Outcome)) -> W.World & Dispatch.Outcome: match frame result: case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (allocator,(owners,outcome)):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},outcome) def run(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Dispatch.Program(~S,~resources),context:Context.Context,route:Layout.Route,request:Store.Request,world:W.World,tick:Tick.Tick) -> W.World & Dispatch.Outcome: match context world: case Context.Context{expected} W.World{+namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:restored(S,C,R,E,Layout.resources(~S,resources),same,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(expected,namespace,allocator,Layout.checked_owner(R,Layout.resources(~S,resources),same,owners),route,request,tick)) def apply(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection,context:Context.Context,route:Layout.Route,request:Store.Request,world:W.World,tick:Tick.Tick) -> W.World & Dispatch.Outcome: run(~S,~C,~R,~E,~resources,~same,~Permission.scopes_field(S,resources,selection),context,route,request,world,tick) def observed(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},allocator:Allocator.Allocator,frame:Publication.Frame,result:Physical & List<&2,Snapshot.GraphView>) -> W.World & List<&2,Snapshot.GraphView>: match frame result: case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (owners,views):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},views) def gather(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Snapshot.Program(~S,~resources),world:W.World) -> W.World & List<&2,Snapshot.GraphView>: match world: case W.World{namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:observed(S,C,R,E,Layout.resources(~S,resources),same,allocator,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(Layout.checked_owner(R,Layout.resources(~S,resources),same,owners))) def graphs(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection,world:W.World) -> W.World & List<&2,Snapshot.GraphView>: gather(~S,~C,~R,~E,~resources,~same,~Permission.snapshot_field(S,resources,selection),world)