1 import Base 2 import ./entity_allocator.bend as A 3 import ./relation_types.bend as T 4 import ./execution_relation_operation.bend as O 5 import ./execution_relation_store.bend as Store 6 import ./execution_composer_layout.bend as Layout 7 import ./lifecycle.bend as Life 8 import ./change_tick.bend as Tick 9 10 # The shared barrier validates full route, origin, descriptor policy and grant 11 # before taking this exact canonical slot. No caller chooses a replacement graph. 12 def refreshed(~S:Data,~descriptor:T.Descriptor,~key:String,~origin:Layout.Layout,allocator:A.Allocator,stamp:Life.Stamp,operation:O.Operation,result:Store.Store & Store.View) -> A.Allocator & (Layout.ResourceSlot,Store.View>,key,origin> & Store.Receipt): 13 match result: 14 case (store,view):(allocator,(Layout.ResourceSlot{Layout.Viewed{store,view},stamp},Store.Applied{operation})) 15 def refusal_refreshed(~S:Data,~descriptor:T.Descriptor,~key:String,~origin:Layout.Layout,allocator:A.Allocator,stamp:Life.Stamp,operation:O.Operation,reason:Store.Reason,result:Store.Store & Store.View) -> A.Allocator & (Layout.ResourceSlot,Store.View>,key,origin> & Store.Receipt): 16 match result: 17 case (store,view):(allocator,(Layout.ResourceSlot{Layout.Viewed{store,view},stamp},Store.Refused{operation,reason})) 18 def returned(~S:Data,~descriptor:T.Descriptor,~key:String,~origin:Layout.Layout,tick:Tick.Tick,stamp:Life.Stamp,priorView:Store.View,result:A.Allocator & (Store.Store & Store.Receipt)) -> A.Allocator & (Layout.ResourceSlot,Store.View>,key,origin> & Store.Receipt): 19 match result: 20 case (allocator,(store,Store.Applied{operation})):refreshed(~S,~descriptor,~key,~origin,allocator,Life.after_write(True{},True{},stamp,tick),operation,Store.project(~S,~descriptor,store)) 21 case (allocator,(store,Store.Refused{operation,reason})):refusal_refreshed(~S,~descriptor,~key,~origin,allocator,stamp,operation,reason,Store.project(~S,~descriptor,store)) 22 def apply(~S:Data,~descriptor:T.Descriptor,~key:String,~origin:Layout.Layout,namespace:U32,allocator:A.Allocator,slot:Layout.ResourceSlot,Store.View>,key,origin>,operation:O.Operation,tick:Tick.Tick) -> A.Allocator & (Layout.ResourceSlot,Store.View>,key,origin> & Store.Receipt): 23 match slot: 24 case Layout.ResourceSlot{Layout.Viewed{store,view},stamp}:returned(~S,~descriptor,~key,~origin,tick,stamp,view,Store.apply(~S,~descriptor,namespace,allocator,store,operation))