def each
import bendvy-ecs-core@0.1.0.4/compose.bend as Composeimport Base
import world.bend as W
import transaction.bend as T
257# Snapshot live handles in allocator-visible order; deferred commands stay invisible.
258# Snapshot allocator-visible live handles, then select and execute rows in that
259# order within ONE enclosing transaction, with no prior cursor. Later reads observe
260# earlier immediate writes; stop after the first selected-row failure, rollback
261# recorded writes and suppress all outputs/staged publications/commands on failure.
262# Success returns ordered Data outputs and enqueues commands without applying a
263# barrier. User bodies receive only Ops(H), not raw World storage. Arbitrary trusted
264# selectors/projectors or external effects are outside universal rollback claims.
265# See examples/query-composition/declarations.bend and gameplay.bend.
266def each(~S: Data,~Store: Type,~R: Type,~E: Data,~Ops: Type -> Type,~A: Data,~U: Data,~Out: Data,~plan: Plan<S,Store,R,E,Ops>,~body: @-H: Type -> @-caps: Ops(H) -> A -> H -> H & (T.Outcome<U> & Out),args: A,world: W.World<S,Store,R,E>) -> Executed<W.World<S,Store,R,E>,Error<U>,Out>:
267 reserved(~S,~Store,~R,~E,~Ops,~A,~U,~Out,~plan,~body,args,None{},W.handles(~S,~Store,~R,~E,world))