import Base import ./trace_facts.bend as TraceFacts import world.bend as W import column.bend as Col import component.bend as Cmp import transaction.bend as T import provider.bend as Pv import commands.bend as Cmd # Main membership is required; these modes apply to the independent aux family. # Bounded explicit two-family composition is not a general query planner. # Auxiliary-family membership in this bounded two-family query. Main # membership is always required. Use ordinary/Compose declarations for general # heterogeneous query shapes; this helper is not the full query planner. type Selection is Data: Required{} Present{} Absent{} Optional{} def main_found(~V: Data,value: Cmp.Access) -> Bool: match value: case Cmp.Found{_}: True{} case _: False{} def selection_aux(~V: Data,mode: Selection,value: Cmp.Access) -> Bool: match mode value: case Required{} Cmp.Found{_}: True{} case Present{} Cmp.Found{_}: True{} case Absent{} Cmp.ComponentAbsent{}: True{} case Optional{} Cmp.Found{_}: True{} case Optional{} Cmp.ComponentAbsent{}: True{} case _ _: False{} def selected_aux(~S: Data,~Store: Type,~R: Type,~E: Data,~V: Data,mode: Selection,main: Bool,observed: T.Tx,E> & Cmp.Access) -> T.Tx,E> & Bool: (tx,value) = observed (tx,main && selection_aux(~V,mode,value)) def selected_main(~S: Data,~Store: Type,~R: Type,~E: Data,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,mode: Selection,auxFamily: Cmp.Family,+handle: W.Handle,observed: T.Tx,E> & Bool) -> T.Tx,E> & Bool: match observed: case (tx,False{}): (tx,False{}) case (tx,True{}): selected_aux(~S,~Store,~R,~E,~AuxV,mode,True{},Cmp.tx_get(~S,~Store,~R,~E,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,auxFamily,tx,handle)) def main_join(~S: Data,~Store: Type,~R: Type,~E: Data,~V: Data,observed: T.Tx,E> & Cmp.Access) -> T.Tx,E> & Bool: (tx,value) = observed (tx,main_found(~V,value)) def selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,tx: T.Tx,E>,+handle: W.Handle) -> T.Tx,E> & Bool: selected_main(~S,~Store,~R,~E,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,mode,auxFamily,handle,main_join(~S,~Store,~R,~E,~V,Cmp.tx_get(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,mainFamily,tx,handle))) # Name helpers only carry diagnostic metadata, not capability authority. def main_name(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,family: Cmp.Family) -> String: match family: case Cmp.Family{name}: name def aux_name(~S: Data,~Store: Type,~R: Type,~E: Data,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,family: Cmp.Family) -> String: match family: case Cmp.Family{name}: name def after_run(~S: Data,~Store: Type,~R: Type,~E: Data,~U: Data,next: T.Tx,E> -> T.Tx,E> & T.Outcome>,observed: T.Tx,E> & T.Outcome>) -> T.Tx,E> & T.Outcome>: match observed: case (tx,T.Success{}): next(tx) case (tx,T.Failure{error}): (tx,T.Failure{error}) def run_selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,+mainName: String,+auxName: String,+handle: W.Handle,args: A,next: T.Tx,E> -> T.Tx,E> & T.Outcome>,observed: T.Tx,E> & Bool) -> T.Tx,E> & T.Outcome>: match observed: case (tx,False{}): next(tx) case (tx,True{}): after_run(~S,~Store,~R,~E,~U,next,Pv.run(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,mainName,auxName,tx,handle,args)) def run_selected_row(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,+mainName: String,+auxName: String,+handle: W.Handle,args: A,observed: T.Tx,E> & Bool) -> T.Tx,E> & T.Outcome>: match observed: case (tx,False{}): (tx,T.Success{}) case (tx,True{}): Pv.run(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,mainName,auxName,tx,handle,args) def run_handles_acc(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,handles: List<&2,W.Handle>,+mainFamily: Cmp.Family,+auxFamily: Cmp.Family,+mode: Selection,+args: A,observed: T.Tx,E> & T.Outcome>) -> T.Tx,E> & T.Outcome>: match handles observed: case _ Tuple{tx,T.Failure{error}}: (tx,T.Failure{error}) case Nil{} Tuple{tx,T.Success{}}: (tx,T.Success{}) case Con{+handle,rest} Tuple{tx,T.Success{}}: run_handles_acc(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,rest,mainFamily,auxFamily,mode,args,run_selected_row(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,main_name(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,mainFamily),aux_name(~S,~Store,~R,~E,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,auxFamily),handle,args,selected(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,mainFamily,auxFamily,mode,tx,handle))) def run_handles(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,handles: List<&2,W.Handle>,+mainFamily: Cmp.Family,+auxFamily: Cmp.Family,+mode: Selection,+args: A,tx: T.Tx,E>) -> T.Tx,E> & T.Outcome>: run_handles_acc(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,handles,mainFamily,auxFamily,mode,args,(tx,T.Success{})) def finished(~S: Data,~Store: Type,~R: Type,~E: Data,~U: Data,observed: T.Tx,E> & T.Outcome>) -> T.Returned,Pv.Error>: (tx,result) = observed Cmd.tx_finish(~S,~Store,~R,~E,~Pv.Error,tx,result) def each_reserved(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,args: A,observed: W.World & List<&2,W.Handle>) -> T.Returned,Pv.Error>: (world,handles) = observed finished(~S,~Store,~R,~E,~U,run_handles(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,handles,mainFamily,auxFamily,mode,args,T.begin(~W.World,~E,world))) # Traverse a snapshot of live handles with required main and selected aux # membership, invoking the declared provider body within one transaction. # Failure rolls back that traversal's recorded writes/publications; commands # remain deferred until an explicit barrier. Families/lenses are trusted setup. # Prefer ordinary declarations for application-derived registration/access. def each_rw_read(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation) -> A -> W.Handle -> H -> H & T.Outcome,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,world: W.World,args: A) -> T.Returned,Pv.Error>: each_reserved(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~body,mainFamily,auxFamily,mode,args,W.handles(~S,~Store,~R,~E,world)) # Read-only gameplay receives no component/resource setter, event writer or command. def read_prepend(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,value: Out,observed: T.Tx,E> & List<&2,Out>) -> T.Tx,E> & List<&2,Out>: (tx,values) = observed (tx,value <> values) def read_added(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,next: T.Tx,E> -> T.Tx,E> & List<&2,Out>,observed: T.Tx,E> & Out) -> T.Tx,E> & List<&2,Out>: (tx,value) = observed read_prepend(~S,~Store,~R,~E,~Out,value,next(tx)) def read_selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,+mainName: String,+auxName: String,+handle: W.Handle,args: A,next: T.Tx,E> -> T.Tx,E> & List<&2,Out>,observed: T.Tx,E> & Bool) -> T.Tx,E> & List<&2,Out>: match observed: case (tx,False{}): next(tx) case (tx,True{}): read_added(~S,~Store,~R,~E,~Out,next,Pv.read(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,mainName,auxName,tx,handle,args)) def read_row_returned(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,observed: T.Tx,E> & Out) -> T.Tx,E> & Maybe<&2,Out>: match observed: case (tx,value): (tx,Some{value}) def read_selected_row(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,+mainName: String,+auxName: String,+handle: W.Handle,args: A,observed: T.Tx,E> & Bool) -> T.Tx,E> & Maybe<&2,Out>: match observed: case (tx,False{}): (tx,None{}) case (tx,True{}): read_row_returned(~S,~Store,~R,~E,~Out,Pv.read(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,mainName,auxName,tx,handle,args)) def read_handles_acc(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,handles: List<&2,W.Handle>,+mainFamily: Cmp.Family,+auxFamily: Cmp.Family,+mode: Selection,+args: A,values: List<&2,Out>,observed: T.Tx,E> & Maybe<&2,Out>) -> T.Tx,E> & List<&2,Out>: match handles observed: case Nil{} Tuple{tx,None{}}: (tx,List.reverse(&2,Out,values)) case Nil{} Tuple{tx,Some{value}}: (tx,List.reverse(&2,Out,value <> values)) case Con{+handle,rest} Tuple{tx,None{}}: read_handles_acc(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,rest,mainFamily,auxFamily,mode,args,values,read_selected_row(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,main_name(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,mainFamily),aux_name(~S,~Store,~R,~E,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,auxFamily),handle,args,selected(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,mainFamily,auxFamily,mode,tx,handle))) case Con{+handle,rest} Tuple{tx,Some{value}}: read_handles_acc(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,rest,mainFamily,auxFamily,mode,args,value <> values,read_selected_row(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,main_name(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,mainFamily),aux_name(~S,~Store,~R,~E,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,auxFamily),handle,args,selected(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,mainFamily,auxFamily,mode,tx,handle))) def read_handles(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,handles: List<&2,W.Handle>,+mainFamily: Cmp.Family,+auxFamily: Cmp.Family,+mode: Selection,+args: A,tx: T.Tx,E>) -> T.Tx,E> & List<&2,Out>: read_handles_acc(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,handles,mainFamily,auxFamily,mode,args,[],(tx,None{})) def read_world(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,observed: T.Tx,E> & List<&2,Out>) -> W.World & List<&2,Out>: match observed: case (T.Tx{world,_,_,_,_},values): (world,values) def read_reserved(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,args: A,observed: W.World & List<&2,W.Handle>) -> W.World & List<&2,Out>: (world,handles) = observed read_world(~S,~Store,~R,~E,~Out,read_handles(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,handles,mainFamily,auxFamily,mode,args,T.begin(~W.World,~E,world))) # Read-only bounded two-family traversal returning World and ordered Data # row outputs. Body receives no setter, publisher or structural command grant. # Main is required; mode controls auxiliary membership. Canonical projections # preserve affine payloads while exposing Data views; callbacks remain trusted. def each_read(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & Out,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,world: W.World,args: A) -> W.World & List<&2,Out>: read_reserved(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~Out,~body,mainFamily,auxFamily,mode,args,W.handles(~S,~Store,~R,~E,world)) # Main RW + aux Read + resource Read, with no other user capability grant. # Bounded query granting main component read/write, aux component read and # resource read, without other gameplay operations. Uses the same transaction # and deferred-visibility rules as each_rw_read; raw setup stays trusted. def each_rw_read_resource(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-resource_get: (H -> H & RV) -> A -> W.Handle -> H -> H & T.Outcome,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,world: W.World,args: A) -> T.Returned,Pv.Error>: each_rw_read(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~Pv.component_body(~S,~C,~V,~AuxV,~RV,~R,~E,~Payload,~A,~U,~body),mainFamily,auxFamily,mode,world,args) # Resource capabilities and spawn are absent from this callback contract. # Bounded query granting component operations, declared event publication and # deferred despawn, without resource or spawn capabilities. Failure suppresses its # staged publications; no deferred command barrier is implied. # Broader compositions use ordinary-query-declaration/observable or Compose. def each_rw_read_events(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column,~put: Rest -> Col.Column -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column,~aux_put: AuxRest -> Col.Column -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World -> W.Handle -> Payload -> W.World,~clear: Store -> W.Handle -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> A -> W.Handle -> H -> H & T.Outcome,mainFamily: Cmp.Family,auxFamily: Cmp.Family,mode: Selection,world: W.World,args: A) -> T.Returned,Pv.Error>: each_rw_read(~S,~Store,~R,~E,~Rest,~C,~V,~Token,~take,~put,~project,~AuxRest,~AuxC,~AuxV,~AuxToken,~aux_take,~aux_put,~aux_project,~RV,~resource_project,~Payload,~populate,~clear,~A,~U,~Pv.event_body(~S,~C,~V,~AuxV,~RV,~R,~E,~Payload,~A,~U,~body),mainFamily,auxFamily,mode,world,args)