def add

bendvy-ecs-core@0.1.0.4 · ordinary_app_capture_query.bend:65

import bendvy-ecs-core@0.1.0.4/ordinary_app_capture_query.bend as OrdinaryAppCaptureQuery
import Base
import bendvy-ecs-core@0.1.0.4/ordinary_app_execution_recipe.bend as Exec
import bendvy-ecs-core@0.1.0.4/execution_context.bend as Ctx
import bendvy-ecs-core@0.1.0.4/schedule_provision.bend as SP
import bendvy-ecs-core@0.1.0.4/ordinary_app_registration_fields.bend as Records
import bendvy-ecs-core@0.1.0.4/world.bend as W
import bendvy-ecs-core@0.1.0.4/system.bend as Sys
import bendvy-ecs-core@0.1.0.4/transaction.bend as T
import bendvy-ecs-core@0.1.0.4/compose.bend as Q
import bendvy-ecs-core@0.1.0.4/ordinary_query_declaration.bend as Decl
import bendvy-ecs-core@0.1.0.4/ordinary_app_capture_query_fields.bend as Fields
import bendvy-ecs-core@0.1.0.4/ordinary_app_observation_data.bend as DTO

65# Register a captured query during App setup, consuming value and capture.
66# On success done receives the extended App. On refusal failed receives the
67# returned prior App AND capture, so the caller can recover or explicitly drop
68# those affine owners. args is retained for future invocations; name follows
69# the ordinary registry rules. No callback runs during this registration.
70# During execution, failure rolls back transactional writes and clears row
71# outputs, but retains the callback-returned capture: capture mutation is not
72# ECS rollback. Failure/refusal do not advance the query reader cursor; success does.
73# Deferred structural commands still need the ordinary explicit barrier.
74# Runnable example: bash examples/captured-query/run.sh js (or native).
75# Its app.bend:add_second shows add; body.bend returns all owners on failure.
76def add(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan<S>,~priorDispatch:Owners -> Ctx.Context<W.World<S,C,R,E>> -> U32 -> Owners & Sys.Outcome<Ctx.Context<W.World<S,C,R,E>>,PriorError,Unit>,~priorProvide:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,SP.Requirement<S>>,~L:Type,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~query:Decl.Declaration<S,Q.Frame<S,C,R,E>,Ops(Q.Frame<S,C,R,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome<Error> & Out)),~Output:Type,done:Application(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~L,~Ops,~Args,~Error,~Out,~query,~body) -> Output,failed:Exec.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold,PriorError,priorPlan,priorDispatch,priorProvide> -> L -> Output,value:Exec.Registered<S,W.World<S,C,R,E>,Owners,Rows,observe,fold,PriorError,priorPlan,priorDispatch,priorProvide>,args:Args,name:String,capture:L) -> Output:
77  match value:
78    case Exec.Registered{app,_}:added(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~L,~Ops,~Args,~Error,~Out,~query,~body,~Output,args,done,failed,Fields.register(~S,~C,~R,~E,~L,~Ops,~Args,~Error,~Out,~query,~body,~Owners,~Rows,~observe,~fold,app,name,capture))

Uses (19)

Used by (0)

No other definition uses this definition.