query.bend
bendvy-ecs-core@0.1.0.1 · 138 lines · 0 definitions
1import Base
2import bendvy-ecs-core@0.1.0.1/trace_facts.bend as TraceFacts
3import world.bend as W
4import column.bend as Col
5import component.bend as Cmp
6import transaction.bend as T
7import provider.bend as Pv
8import commands.bend as Cmd
9
10# Main membership is required; these modes apply to the independent aux family.
11# Bounded explicit two-family composition is not a general query planner.
12# Auxiliary-family membership in this bounded two-family query. Main
13# membership is always required. Use ordinary/Compose declarations for general
14# heterogeneous query shapes; this helper is not the full query planner.
15type Selection is Data:
16 Required{}
17 Present{}
18 Absent{}
19 Optional{}
20
21def main_found(~V: Data,value: Cmp.Access<V>) -> Bool:
22 match value:
23 case Cmp.Found{_}: True{}
24 case _: False{}
25
26def selection_aux(~V: Data,mode: Selection,value: Cmp.Access<V>) -> Bool:
27 match mode value:
28 case Required{} Cmp.Found{_}: True{}
29 case Present{} Cmp.Found{_}: True{}
30 case Absent{} Cmp.ComponentAbsent{}: True{}
31 case Optional{} Cmp.Found{_}: True{}
32 case Optional{} Cmp.ComponentAbsent{}: True{}
33 case _ _: False{}
34
35def selected_aux(~S: Data,~Store: Type,~R: Type,~E: Data,~V: Data,mode: Selection,main: Bool,observed: T.Tx<W.World<S,Store,R,E>,E> & Cmp.Access<V>) -> T.Tx<W.World<S,Store,R,E>,E> & Bool:
36 (tx,value) = observed
37 (tx,main && selection_aux(~V,mode,value))
38
39def selected_main(~S: Data,~Store: Type,~R: Type,~E: Data,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,mode: Selection,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,+handle: W.Handle<S>,observed: T.Tx<W.World<S,Store,R,E>,E> & Bool) -> T.Tx<W.World<S,Store,R,E>,E> & Bool:
40 match observed:
41 case (tx,False{}): (tx,False{})
42 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))
43
44def main_join(~S: Data,~Store: Type,~R: Type,~E: Data,~V: Data,observed: T.Tx<W.World<S,Store,R,E>,E> & Cmp.Access<V>) -> T.Tx<W.World<S,Store,R,E>,E> & Bool:
45 (tx,value) = observed
46 (tx,main_found(~V,value))
47
48def selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,tx: T.Tx<W.World<S,Store,R,E>,E>,+handle: W.Handle<S>) -> T.Tx<W.World<S,Store,R,E>,E> & Bool:
49 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)))
50
51# Name helpers only carry diagnostic metadata, not capability authority.
52def main_name(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,family: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>) -> String:
53 match family:
54 case Cmp.Family{name}: name
55def aux_name(~S: Data,~Store: Type,~R: Type,~E: Data,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,family: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>) -> String:
56 match family:
57 case Cmp.Family{name}: name
58
59def after_run(~S: Data,~Store: Type,~R: Type,~E: Data,~U: Data,next: T.Tx<W.World<S,Store,R,E>,E> -> T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>,observed: T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>) -> T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>:
60 match observed:
61 case (tx,T.Success{}): next(tx)
62 case (tx,T.Failure{error}): (tx,T.Failure{error})
63
64def run_selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation<S>) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,+mainName: String,+auxName: String,+handle: W.Handle<S>,args: A,next: T.Tx<W.World<S,Store,R,E>,E> -> T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>,observed: T.Tx<W.World<S,Store,R,E>,E> & Bool) -> T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>:
65 match observed:
66 case (tx,False{}): next(tx)
67 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))
68
69def run_handles(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation<S>) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,handles: List<&2,W.Handle<S>>,+mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,+auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,+mode: Selection,+args: A,tx: T.Tx<W.World<S,Store,R,E>,E>) -> T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>:
70 match handles:
71 case []: (tx,T.Success{})
72 case +handle <> rest:
73 run_selected(~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,(tx => 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,rest,mainFamily,auxFamily,mode,args,tx)),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))
74
75def finished(~S: Data,~Store: Type,~R: Type,~E: Data,~U: Data,observed: T.Tx<W.World<S,Store,R,E>,E> & T.Outcome<Pv.Error<U>>) -> T.Returned<W.World<S,Store,R,E>,Pv.Error<U>>:
76 (tx,result) = observed
77 Cmd.tx_finish(~S,~Store,~R,~E,~Pv.Error<U>,tx,result)
78
79def each_reserved(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation<S>) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,args: A,observed: W.World<S,Store,R,E> & List<&2,W.Handle<S>>) -> T.Returned<W.World<S,Store,R,E>,Pv.Error<U>>:
80 (world,handles) = observed
81 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<S,Store,R,E>,~E,world)))
82
83# Traverse a snapshot of live handles with required main and selected aux
84# membership, invoking the declared provider body within one transaction.
85# Failure rolls back that traversal's recorded writes/publications; commands
86# remain deferred until an explicit barrier. Families/lenses are trusted setup.
87# Prefer ordinary declarations for application-derived registration/access.
88def each_rw_read(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> @-resource_set: (H -> R -> H) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> @-spawn: (H -> Payload -> H & W.Reservation<S>) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,world: W.World<S,Store,R,E>,args: A) -> T.Returned<W.World<S,Store,R,E>,Pv.Error<U>>:
89 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))
90
91# Read-only gameplay receives no component/resource setter, event writer or command.
92def read_prepend(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,value: Out,observed: T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>) -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>:
93 (tx,values) = observed
94 (tx,value <> values)
95
96def read_added(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,next: T.Tx<W.World<S,Store,R,E>,E> -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>,observed: T.Tx<W.World<S,Store,R,E>,E> & Out) -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>:
97 (tx,value) = observed
98 read_prepend(~S,~Store,~R,~E,~Out,value,next(tx))
99def read_selected(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> A -> W.Handle<S> -> H -> H & Out,+mainName: String,+auxName: String,+handle: W.Handle<S>,args: A,next: T.Tx<W.World<S,Store,R,E>,E> -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>,observed: T.Tx<W.World<S,Store,R,E>,E> & Bool) -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>:
100 match observed:
101 case (tx,False{}): next(tx)
102 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))
103
104def read_handles(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> A -> W.Handle<S> -> H -> H & Out,handles: List<&2,W.Handle<S>>,+mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,+auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,+mode: Selection,+args: A,tx: T.Tx<W.World<S,Store,R,E>,E>) -> T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>:
105 match handles:
106 case []: (tx,[])
107 case +handle <> rest:
108 read_selected(~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,(tx => 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,rest,mainFamily,auxFamily,mode,args,tx)),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))
109
110def read_world(~S: Data,~Store: Type,~R: Type,~E: Data,~Out: Data,observed: T.Tx<W.World<S,Store,R,E>,E> & List<&2,Out>) -> W.World<S,Store,R,E> & List<&2,Out>:
111 match observed:
112 case (T.Tx{world,_,_,_,_},values): (world,values)
113
114def read_reserved(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> A -> W.Handle<S> -> H -> H & Out,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,args: A,observed: W.World<S,Store,R,E> & List<&2,W.Handle<S>>) -> W.World<S,Store,R,E> & List<&2,Out>:
115 (world,handles) = observed
116 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<S,Store,R,E>,~E,world)))
117
118# Read-only bounded two-family traversal returning World and ordered Data
119# row outputs. Body receives no setter, publisher or structural command grant.
120# Main is required; mode controls auxiliary membership. Canonical projections
121# preserve affine payloads while exposing Data views; callbacks remain trusted.
122def each_read(~S: Data,~Store: Type,~R: Type,~E: Data,~Rest: Type,~C: Type,~V: Data,~Token: Data,~take: Store -> Rest & Col.Column<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~Out: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> A -> W.Handle<S> -> H -> H & Out,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,world: W.World<S,Store,R,E>,args: A) -> W.World<S,Store,R,E> & List<&2,Out>:
123 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))
124
125# Main RW + aux Read + resource Read, with no other user capability grant.
126# Bounded query granting main component read/write, aux component read and
127# resource read, without other gameplay operations. Uses the same transaction
128# and deferred-visibility rules as each_rw_read; raw setup stays trusted.
129def 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<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-resource_get: (H -> H & RV) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,world: W.World<S,Store,R,E>,args: A) -> T.Returned<W.World<S,Store,R,E>,Pv.Error<U>>:
130 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)
131
132# Resource capabilities and spawn are absent from this callback contract.
133# Bounded query granting component operations, declared event publication and
134# deferred despawn, without resource or spawn capabilities. Failure suppresses its
135# staged publications; no deferred command barrier is implied.
136# Broader compositions use ordinary-query-declaration/observable or Compose.
137def 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<S,C>,~put: Rest -> Col.Column<S,C> -> Store,~project: C -> C & V,~AuxRest: Type,~AuxC: Type,~AuxV: Data,~AuxToken: Data,~aux_take: Store -> AuxRest & Col.Column<S,AuxC>,~aux_put: AuxRest -> Col.Column<S,AuxC> -> Store,~aux_project: AuxC -> AuxC & AuxV,~RV: Data,~resource_project: R -> R & RV,~Payload: Type,~populate: W.World<S,Store,R,E> -> W.Handle<S> -> Payload -> W.World<S,Store,R,E>,~clear: Store -> W.Handle<S> -> Store,~A: Data,~U: Data,~body: @-H: Type -> @-get: (H -> H & Cmp.Access<V>) -> @-set: (H -> C -> H) -> @-aux: (H -> H & Cmp.Access<AuxV>) -> @-emit: (H -> E -> H) -> @-despawn: (H -> H) -> A -> W.Handle<S> -> H -> H & T.Outcome<U>,mainFamily: Cmp.Family<S,Store,Rest,C,V,Token,take,put,project>,auxFamily: Cmp.Family<S,Store,AuxRest,AuxC,AuxV,AuxToken,aux_take,aux_put,aux_project>,mode: Selection,world: W.World<S,Store,R,E>,args: A) -> T.Returned<W.World<S,Store,R,E>,Pv.Error<U>>:
138 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)