import Base import ./ordinary_app_execution_recipe.bend as Exec import ./ordinary_app_execution_run.bend as ExecuteRun import ./execution_context.bend as Ctx import ./trace_facts.bend as Facts import ./system.bend as Sys import ./schedule.bend as Sch import ./schedule_provision.bend as SP import ./captured_schedule_composition.bend as Choice import ./ordinary_app_composer.bend as Build import ./ordinary_app_records.bend as Pair import ./ordinary_app_recipe.bend as Tree import ./ordinary_app_observation_data.bend as DTO import ./local.bend as Local import ./world.bend as W import ./ordinary_app_registration_fields.bend as Fields import ./ordinary_query_declaration.bend as Query import ./ordinary_resource_system.bend as P import ./transaction.bend as T import ./commands.bend as Cmd import ./capabilities.bend as Cap # One ordinary declaration indexes the runner and registration owner. Local is # returned separately from body Out on both transaction success and failure. def returned(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Error:Data,~Out:Type,local:L,output:Out,result:T.Returned,Error>) -> Local.Outcome,L,Error,Out>: match result: case T.Returned{world,T.Success{}}:Local.Succeeded{world,local,output} case T.Returned{world,T.Failure{error}}:Local.Failed{world,local,error} def finished(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Error:Data,~Out:Type,result:T.Tx,E> & (L & (T.Outcome & Out))) -> Local.Outcome,L,Error,Out>: match result: case (tx,(local,(outcome,output))):returned(~S,~C,~R,~E,~L,~Error,~Out,local,output,Cmd.tx_finish(~S,~C,~R,~E,~Error,tx,outcome)) # Execute one resource declaration/body with opaque Tx capabilities and actual L. # Finish the ECS transaction using the returned outcome. Body-returned Local # persists on success AND failure; failed Out is discarded, not returned as recovery. # Args is consumed by the callback. This is Local execution, not captured-query # state rollback, and arbitrary external callback effects are not transactional. def runner(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),world:W.World,local:L,args:Args) -> Local.Outcome,L,Error,Out>: finished(~S,~C,~R,~E,~L,~Error,~Out,body(T.Tx,E>,P.grant(~S,~R,~T.Tx,E>,~Ops(T.Tx,E>),declaration),local,args,T.begin(~W.World,~E,world))) # Affine owner of the actual Local.Instance, indexed by declaration and body. # No copied Local payload is retained in registration metadata. type Owner<-S:Data,-C:Type,-R:Type,-E:Data,-L:Type,-Args:Type,-Error:Data,-Out:Type,-Ops:Type -> Type,-declaration:P.Declaration,E>,Ops(T.Tx,E>)>,-body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out))> is Type: Owner{instance:Local.Instance} # Registration success retains Local in owner; refusal returns actual World and # incoming L separately, without running the callback. type Registration<-World:Type,-Owned:Type,-L:Type> is Type: Registered{world:World,owner:Owned} Rejected{world:World,local:L} def registered(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),result:Local.Registered) -> Registration,Owner,L>: match result: case Local.Registered{world,instance}:Registered{world,Owner{instance}} case Local.RegistrationRejected{world,local}:Rejected{world,local} # Register the Local runner using access derived from the same resource declaration. # Returns Registration with actual owners; does not execute the body or fabricate # a query reader. Closed declarations/projections remain trusted provisioning. def define(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),world:W.World,name:String,local:L) -> Registration,Owner,L>: registered(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,Local.register(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body),world,name,P.access(~S,P.clause(~S,~R,~T.Tx,E>,~Ops(T.Tx,E>),declaration)),local)) # Run the retained Local instance after actual registration/World validation. # Completed returns the updated instance and Done(Out) or Fail(Error); callback # failure still retains its returned Local. Refused returns World, instance and # unconsumed Args. No implicit barrier, skip processing or disposal is performed. def run(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Owner,world:W.World,args:Args) -> Local.Run: match value: case Owner{instance}:Local.run(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body),instance,world,args) def field_values(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),instance:Local.Instance,clause:Query.Clause) -> Owner & Fields.Fields: match instance clause: case Local.Instance{+namespace,+id,+name,+access,local} Query.Clause{+slot,+mode}:(Owner{Local.Instance{namespace,id,name,access,local}},Fields.Fields{namespace,id,name,access,None{},slot,[Query.Clause{slot,mode}],Fields.ResourceKind{mode}}) # Local has no retained query reader cursor; None marks this nonreader metadata. # Project registration fields while returning Owner. Resource slot/mode/access # come from the operational declaration; Local payload remains opaque. The absent cursor # is metadata, not a live lifecycle/event reader position. def fields(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Owner) -> Owner & Fields.Fields: match value: case Owner{instance}:field_values(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,instance,P.clause(~S,~R,~T.Tx,E>,~Ops(T.Tx,E>),declaration)) def fields_list_returned(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),result:Owner & Fields.Fields) -> Owner & List<&2,Fields.Fields>: match result: case (value,field):(value,[field]) # Advanced singleton registration fold retaining Owner and its actual Local. # Produces metadata only, not an additional resource grant or gameplay invocation. def fold(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Owner) -> Owner & List<&2,Fields.Fields>: fields_list_returned(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,fields(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,value)) # Registration into an App either returns the extended App or the prior App shape # with actual incoming Local. No automatic destructor runs on AppendRejected. type Appended<-Before:Type,-After:Type,-L:Type> is Type: Appended{app:After} AppendRejected{app:Before,local:L} # Ordinary registration composes the derived fold itself; application authors # provide only operational declaration/body and Local, never metadata adapters. def appended(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,previous:Previous,recipe:Tree.Recipe,Rows,observe>,debug:Bool,result:Registration,Owner,L>) -> Appended,Previous,Rows,observe,previousFold>,Build.Registered,Previous & Owner,Rows,observe,Pair.fold_pair(~S,~Previous,~Owner,~previousFold,~fold(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body))>,L>: match result: case Rejected{world,local}:AppendRejected{Build.Registered{world,previous,recipe,debug},local} case Registered{world,owner}:Appended{Build.Registered{world,(previous,owner),recipe,debug}} # Register into a composer App, deriving the metadata fold and retaining prior # owners/observer/debug. On refusal return prior App shape and Local; does not run # body. See test-fixtures/public-schedules/named-app-v1/matched-feature-v1/fixture.bend. def register(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Type,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,app:Build.Registered,Previous,Rows,observe,previousFold>,name:String,local:L) -> Appended,Previous,Rows,observe,previousFold>,Build.Registered,Previous & Owner,Rows,observe,Pair.fold_pair(~S,~Previous,~Owner,~previousFold,~fold(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body))>,L>: match app: case Build.Registered{world,previous,recipe,debug}:appended(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,~Previous,~Rows,~observe,~previousFold,previous,recipe,debug,define(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,world,name,local)) # Schedule-facing distinction between callback transaction failure and refused # registration/routing. Neither branch implies Local was rolled back. type ExecutionError is Data: CallbackFailure{error:Error} RegistrationRefused{} # Executable invocation retaining actual Local owner and reusable Data Args. # It stores no Out: schedule execution discards successful Out after completion. type Invocation<-S:Data,-C:Type,-R:Type,-E:Data,-L:Type,-Args:Data,-Error:Data,-Out:Type,-Ops:Type -> Type,-declaration:P.Declaration,E>,Ops(T.Tx,E>)>,-body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out))> is Type: Invocation{owner:Owner,args:Args} def execution_folded(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),args:Args,result:Owner & List<&2,Fields.Fields>) -> Invocation & List<&2,Fields.Fields>: match result: case (owner,fields):(Invocation{owner,args},fields) # Advanced owner-returning fold of invocation metadata, retaining stored Args. def execution_fields(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Invocation) -> Invocation & List<&2,Fields.Fields>: match value: case Invocation{owner,args}:execution_folded(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,args,fold(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,owner)) def execution_planned(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),args:Args,result:Owner & Fields.Fields) -> Invocation & SP.Plan: match result: case (owner,Fields.Fields{_,id,_,_,_,_,_,_}):(Invocation{owner,args},SP.Entry{Sch.System{id,0},[]}) # Advanced owner-returning single-id plan at condition slot zero with no explicit # requirements. Does not derive requirements from field metadata or run Local. def execution_plan(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Invocation) -> Invocation & SP.Plan: match value: case Invocation{owner,args}:execution_planned(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,args,fields(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,owner)) def execution_returned(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),args:Args,trace:Facts.State,result:Local.Run) -> Invocation & Sys.Outcome>,ExecutionError,Unit>: match result: case Local.Completed{world,instance,Done{_},_}:(Invocation{Owner{instance},args},Sys.Succeeded{Ctx.Context{world,trace},Unit{}}) case Local.Completed{world,instance,Fail{error},_}:(Invocation{Owner{instance},args},Sys.Failed{Ctx.Context{world,trace},CallbackFailure{error}}) case Local.Refused{world,instance,_}:(Invocation{Owner{instance},args},Sys.Failed{Ctx.Context{world,trace},RegistrationRefused{}}) def execution_allowed(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),valid:Bool,owner:Owner,args:Args,context:Ctx.Context>) -> Invocation & Sys.Outcome>,ExecutionError,Unit>: match valid context: case False{} context:(Invocation{owner,args},Sys.Failed{context,RegistrationRefused{}}) case True{} Ctx.Context{world,trace}: +actual=args execution_returned(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,actual,trace,run(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,owner,world,actual)) def execution_selected(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),args:Args,context:Ctx.Context>,id:U32,result:Owner & Fields.Fields) -> Invocation & Sys.Outcome>,ExecutionError,Unit>: match result: case (owner,fields):execution_allowed(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,U32.is_eq(id,Exec.registration_id(~S,fields)),owner,args,context) # Advanced id-routed dispatch. Mismatched id returns invocation/context unchanged # with RegistrationRefused. Matched execution preserves reusable Data Args and # retains the returned Local instance; callback failure maps to CallbackFailure, # while successful Out is discarded. Trace context is carried separately. # This adapter installs no skip/cursor-advance or Local disposal callback. def execution_run(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),value:Invocation,context:Ctx.Context>,id:U32) -> Invocation & Sys.Outcome>,ExecutionError,Unit>: match value: case Invocation{owner,args}:execution_selected(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,args,context,id,fields(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,owner)) # Advanced execution-enabled App type with prior owners plus Local invocation. # Uses prior observation unchanged and adds registration fields/plan/dispatch; # this does not expose Local to unrelated systems or reset it on failed execution. def Executable(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> Type: Exec.Registered,Previous & Invocation,Rows,observe,Pair.fold_pair(~S,~Previous,~Invocation,~previousFold,~execution_fields(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)),Choice.Choice>,Exec.plan_pair(~S,~Previous,~Invocation,~priorPlan,~execution_plan(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)),Exec.dispatch_pair(~S,~W.World,~Previous,~Invocation,~PriorError,~ExecutionError,~previousFold,~priorDispatch,~execution_run(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)),Exec.provision_pair(~S,~W.World,~priorProvide,~Exec.empty_provide(~S,~W.World))> def execution_added(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,args:Args,previous:Previous,recipe:Tree.Recipe,Rows,observe>,debug:Bool,result:Registration,Owner,L>) -> Appended,Previous,Rows,observe,previousFold,PriorError,priorPlan,priorDispatch,priorProvide>,Executable(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,~Previous,~Rows,~observe,~previousFold,~PriorError,~priorPlan,~priorDispatch,~priorProvide),L>: match result: case Rejected{world,local}:AppendRejected{Exec.Registered{Build.Registered{world,previous,recipe,debug},Exec.Recipe{}},local} case Registered{world,owner}:Appended{Exec.Registered{Build.Registered{world,(previous,Invocation{owner,args}),recipe,debug},Exec.Recipe{}}} # Register Local and Data Args into an execution-enabled App, deriving composition # from the declaration. Refusal returns prior App and actual L; success retains # L and Args for later dispatch. No run, condition skip or disposal happens here. # Explicit lifecycle cleanup remains in local.bend rather than an implicit finalizer. def add(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,value:Exec.Registered,Previous,Rows,observe,previousFold,PriorError,priorPlan,priorDispatch,priorProvide>,name:String,local:L,args:Args) -> Appended,Previous,Rows,observe,previousFold,PriorError,priorPlan,priorDispatch,priorProvide>,Executable(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,~Previous,~Rows,~observe,~previousFold,~PriorError,~priorPlan,~priorDispatch,~priorProvide),L>: match value: case Exec.Registered{Build.Registered{world,previous,recipe,debug},_}:execution_added(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,~Previous,~Rows,~observe,~previousFold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,args,previous,recipe,debug,define(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body,world,name,local)) # Advanced type projection of prior owners paired with actual Local invocation. def execution_owners(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> Type: Previous & Invocation # Advanced detached row projection: Local adds metadata, not observation rows. def execution_rows(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> Data: Rows # Advanced observer projection retaining the prior observer exactly; Local is # not automatically rendered or inspected by this adapter. def execution_observe(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> W.World -> W.World & DTO.Observation: observe # Advanced closed fold of prior fields followed by Local invocation metadata. def execution_fold(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> (Previous & Invocation) -> (Previous & Invocation) & List<&2,Fields.Fields>: Pair.fold_pair(~S,~Previous,~Invocation,~previousFold,~execution_fields(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)) # Advanced closed plan composition: prior plan then Local id, retaining owners. def composed_plan(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> (Previous & Invocation) -> (Previous & Invocation) & SP.Plan: Exec.plan_pair(~S,~Previous,~Invocation,~priorPlan,~execution_plan(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)) # Advanced closed routing to prior or Local invocation with tagged error branches. # Dispatch preserves actual owners; it is not a shared Local or capture transaction. def execution_dispatch(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> (Previous & Invocation) -> Ctx.Context> -> U32 -> (Previous & Invocation) & Sys.Outcome>,Choice.Choice>,Unit>: Exec.dispatch_pair(~S,~W.World,~Previous,~Invocation,~PriorError,~ExecutionError,~previousFold,~priorDispatch,~execution_run(~S,~C,~R,~E,~L,~Args,~Error,~Out,~Ops,~declaration,~body)) # Advanced provisioning composition: preserve prior provisioning and add no # extra requirements for this Local registration. def execution_provide(~S:Data,~C:Type,~R:Type,~E:Data,~L:Type,~Args:Data,~Error:Data,~Out:Type,~Ops:Type -> Type,~declaration:P.Declaration,E>,Ops(T.Tx,E>)>,~body:@-H:Type -> @-caps:Ops(H) -> L -> Args -> H -> H & (L & (T.Outcome & Out)),~Previous:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~previousFold:Previous -> Previous & List<&2,Fields.Fields>,~PriorError:Data,~priorPlan:Previous -> Previous & SP.Plan,~priorDispatch:Previous -> Ctx.Context> -> U32 -> Previous & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>) -> W.World -> W.World & List<&2,SP.Requirement>: Exec.provision_pair(~S,~W.World,~priorProvide,~Exec.empty_provide(~S,~W.World))