~/bend-docscommunity

ordinary_app_service_registration.bend source

ordinary_app_service_registration.bend on the hub · documented module

import Baseimport ./ordinary_app_execution_recipe.bend as Execimport ./ordinary_app_execution_run.bend as ExecuteRunimport ./execution_context.bend as Ctximport ./trace_facts.bend as Factsimport ./schedule.bend as Schimport ./captured_schedule_composition.bend as Choiceimport ./ordinary_app_composer.bend as Buildimport ./ordinary_app_recipe.bend as Treeimport ./ordinary_app_records.bend as Leafimport ./world.bend as Wimport ./system.bend as Sysimport ./schedule_provision.bend as SPimport ./ordinary_service_declaration.bend as Dimport ./ordinary_app_registration_fields.bend as Recordsimport ./ordinary_app_observation_data.bend as DTO# Native service declaration remains operational; no query mode is fabricated.# Affine registered service owner retaining its actual registry and setup.# The service payload itself stays in World resources, not copied into metadata.type Owner<S:Data,C:Type,R:Type,E:Data,Payload:Type,Rest:Type,-take:R -> Rest & D.Slot<Payload>,-put:Rest -> D.Slot<Payload> -> R,-call:Payload -> Payload,-declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,-scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>> is Type:  Owner{registry:Sys.Registry<S,C,R,E,Unit,Unit,Unit,D.runner(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration)>,setup:D.Setup<S,C,R,E,scan>}# Detached provided statuses and declaration-derived required service ids.type View<S:Data> is Data:  View{provided:List<&2,D.Status<S>>,required:List<&2,SP.Requirement<S>>}# Advanced owner-returning registration fold deriving ServiceKind metadata from# actual registry and declaration; this does not grant query gameplay operations.def fields(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,owner:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & List<&2,Records.Fields<S>>:  match owner:    case Owner{Sys.Registry{+namespace,+id,+name,+access,+cursor},setup}:(Owner{Sys.Registry{namespace,id,name,access,cursor},setup},[Records.Fields{namespace,id,name,access,cursor,D.key(~S,~R,~Payload,~Rest,~take,~put,~call,declaration),[],Records.ServiceKind{}}])# Project this declaration's service requirement for execution preflight.def required(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>) -> SP.Requirement<S>:  D.requirement(~S,~R,~Payload,~Rest,~take,~put,~call,declaration)def provided_text(~S:Data,value:D.Status<S>) -> String:  match value:    case D.Status{id,key,ready}:key ++ ":" ++ U32.show(id) ++ ":" ++ Bool.show(ready)def requirement_text(~S:Data,value:SP.Requirement<S>) -> String:  match value:    case SP.Service{id}:"Service:" ++ U32.show(id)    case SP.Resource{id}:"Resource:" ++ U32.show(id)    case SP.Component{id}:"Component:" ++ U32.show(id)def observed(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,result:W.World<S,C,R,E> & List<&2,D.Status<S>>) -> W.World<S,C,R,E> & DTO.Observation<View<S>>:  match result:    case (world,+provided):(world,DTO.Observation{View{provided,[required(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)]},["services=" ++ List.show(&2,D.Status<S>,provided_text(~S),provided),"requires=" ++ requirement_text(~S,required(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))]})# Advanced service observer scanning statuses, returning actual World with View# and presentation text. Does not invoke the service; composer debug gating decides# whether observation runs.def observe(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,world:W.World<S,C,R,E>) -> W.World<S,C,R,E> & DTO.Observation<View<S>>:  observed(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,scan(world))def dispatched(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,setup:D.Setup<S,C,R,E,scan>,result:Sys.RunResult<S,C,R,E,Unit,Unit,Unit,D.runner(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration)>) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<W.World<S,C,R,E>,Unit,Unit>:  match result:    case Sys.Completed{registry,outcome}:(Owner{registry,setup},outcome)    case Sys.RegistrationRejected{registry,world,_}:(Owner{registry,setup},Sys.Failed{world,Unit{}})# Invoke tracked registration and return Owner plus actual World outcome. This# low-level entry does not perform schedule service-availability preflight; the# declaration runner is a successful no-op for Missing. No host-effect rollback.def run(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,owner:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,world:W.World<S,C,R,E>) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<W.World<S,C,R,E>,Unit,Unit>:  match owner:    case Owner{registry,setup}:dispatched(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,setup,Sys.run(~S,~C,~R,~E,~Unit,~Unit,~Unit,~D.runner(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration),registry,world,Unit{}))# Composer App type with this service owner and combined prior/service observations.# This type adds service registration metadata, not a fabricated component query.def Application(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>) -> Type:  Build.Registered<S,W.World<S,C,R,E>,Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,DTO.Product<Rows,View<S>>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~View<S>,~prior,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Leaf.fold_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~fold,~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))>def defined(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,~Output:Type,done:Build.Registered<S,W.World<S,C,R,E>,Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,DTO.Product<Rows,View<S>>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~View<S>,~prior,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Leaf.fold_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~fold,~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))> -> Output,failed:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold> -> Output,setup:D.Setup<S,C,R,E,scan>,owners:Owners,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,prior>,debug:Bool,result:Sys.RegistrationResult<S,C,R,E,Unit,Unit,Unit,D.runner(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration)>) -> Output:  match result:    case Sys.RegistrationFailed{world}:failed(Build.Registered{world,owners,recipe,debug})    case Sys.Registered{world,registry}:done(Build.appended(~S,~W.World<S,C,R,E>,~Owners,~Rows,~prior,~fold,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~View<S>,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan),~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan),world,owners,Owner{registry,setup},debug))# Register service onto the composer App. done receives extended actual owners;# failed receives the prior App shape and returned World on registration refusal.# Does not call the service; callbacks choose a common Output ownership contract.def install(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:Owners -> Owners & List<&2,Records.Fields<S>>,~Output:Type,done:Build.Registered<S,W.World<S,C,R,E>,Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,DTO.Product<Rows,View<S>>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~View<S>,~prior,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Leaf.fold_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~fold,~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))> -> Output,failed:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold> -> Output,setup:D.Setup<S,C,R,E,scan>,name:String,app:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold>) -> Output:  match app:    case Build.Registered{world,owners,recipe,debug}:defined(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~Output,done,failed,setup,owners,recipe,debug,D.define(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,world,name))# Advanced owner-returning plan: this registry id at condition slot zero with# the declaration's service requirement. Does not invoke P or derive a query grant.def execution_plan(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,owner:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & SP.Plan<S>:  match owner:    case Owner{Sys.Registry{+namespace,+id,+name,+access,+cursor},setup}:(Owner{Sys.Registry{namespace,id,name,access,cursor},setup},SP.Entry{Sch.System{id,0},[required(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)]})def execution_returned(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,trace:Facts.State,result:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<W.World<S,C,R,E>,Unit,Unit>) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<Ctx.Context<W.World<S,C,R,E>>,Unit,Unit>:  match result:    case (owner,outcome):(owner,ExecuteRun.outcome(~W.World<S,C,R,E>,~Unit,~Unit,trace,outcome))def execution_allowed(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,allowed:Bool,owner:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,context:Ctx.Context<W.World<S,C,R,E>>,id:U32) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<Ctx.Context<W.World<S,C,R,E>>,Unit,Unit>:  match allowed context:    case False{} context:(owner,Sys.Failed{context,Unit{}})    case True{} Ctx.Context{world,trace}:execution_returned(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,trace,run(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,owner,world))# Advanced dispatch entry: an unmatched id returns Owner/context with Failed(Unit)# without calling P. Matched routing invokes tracked run; schedule provisioning# performs availability checks separately.def execution_run(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,owner:Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,context:Ctx.Context<W.World<S,C,R,E>>,id:U32) -> Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan> & Sys.Outcome<Ctx.Context<W.World<S,C,R,E>>,Unit,Unit>:  match owner:    case Owner{Sys.Registry{namespace,+actual,name,access,cursor},setup}:      +selected=id      execution_allowed(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,U32.is_eq(selected,actual),Owner{Sys.Registry{namespace,actual,name,access,cursor},setup},context,selected)# Advanced execution-enabled App type composing prior plan/dispatch/provision# with this service. Actual owners are retained; errors distinguish prior/service.def Executable(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> Type:  Exec.Registered<S,W.World<S,C,R,E>,Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,DTO.Product<Rows,View<S>>,Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~View<S>,~prior,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Leaf.fold_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~fold,~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Choice.Choice<PriorError,Unit>,Exec.plan_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~priorPlan,~execution_plan(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Exec.dispatch_pair(~S,~W.World<S,C,R,E>,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~PriorError,~Unit,~fold,~priorDispatch,~execution_run(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan)),Exec.provision_pair(~S,~W.World<S,C,R,E>,~priorProvide,~D.provision(~S,~C,~R,~E,~scan))>def execution_added(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>,~Output:Type,done:Executable(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide) -> Output,app:Application(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold)) -> Output:  done(Exec.Registered{app,Exec.Recipe{}})def execution_rejected(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>,~Output:Type,failed:Exec.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold,PriorError,priorPlan,priorDispatch,priorProvide> -> Output,app:Build.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold>) -> Output:  failed(Exec.Registered{app,Exec.Recipe{}})# Add service registration to an execution-enabled App, composing its plan and# provisioning. done receives the extended App; failed receives the previous App# shape on refusal. Does not run the service or make host effects transactional.def add(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>,~Output:Type,done:Executable(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide) -> Output,failed:Exec.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold,PriorError,priorPlan,priorDispatch,priorProvide> -> Output,setup:D.Setup<S,C,R,E,scan>,name:String,value:Exec.Registered<S,W.World<S,C,R,E>,Owners,Rows,prior,fold,PriorError,priorPlan,priorDispatch,priorProvide>) -> Output:  match value:    case Exec.Registered{app,_}:install(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~Output,execution_added(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Output,done),execution_rejected(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,~Owners,~Rows,~prior,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Output,failed),setup,name,app)# Advanced type projection of prior and actual service registration owners.def execution_owners(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> Type:  Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan># Advanced detached row shape pairing prior observations with service View.def execution_rows(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> Data:  DTO.Product<Rows,View<S>># Advanced closed observer composition: prior then service statuses, threading World.def execution_observe(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<DTO.Product<Rows,View<S>>>:  Tree.observe_pair(~W.World<S,C,R,E>,~Rows,~View<S>,~prior,~observe(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))# Advanced closed owner fold: prior fields then service metadata, retaining owners.def execution_fold(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) & List<&2,Records.Fields<S>>:  Leaf.fold_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~fold,~fields(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))# Advanced closed plan composition retaining actual prior/service owners in order.def composed_plan(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) & SP.Plan<S>:  Exec.plan_pair(~S,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~priorPlan,~execution_plan(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))# Advanced closed routing composition; selects prior or service runner by retained# registration metadata, preserving both owners and tagging the failure branch.def execution_dispatch(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) -> Ctx.Context<W.World<S,C,R,E>> -> U32 -> (Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>) & Sys.Outcome<Ctx.Context<W.World<S,C,R,E>>,Choice.Choice<PriorError,Unit>,Unit>:  Exec.dispatch_pair(~S,~W.World<S,C,R,E>,~Owners,~Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>,~PriorError,~Unit,~fold,~priorDispatch,~execution_run(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan))# Advanced closed availability composition, prior then service scan; no host call.# For an ordinary consumer see failedtxn-motion64/consumer/motion-schedule.bend# under test-fixtures/connected-performance.def execution_provide(~S:Data,~C:Type,~R:Type,~E:Data,~Payload:Type,~Rest:Type,~take:R -> Rest & D.Slot<Payload>,~put:Rest -> D.Slot<Payload> -> R,~call:Payload -> Payload,~declaration:D.Declaration<S,R,Payload,Rest,take,put,call>,~scan:W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,D.Status<S>>,~Owners:Type,~Rows:Data,~prior: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>>) -> W.World<S,C,R,E> -> W.World<S,C,R,E> & List<&2,SP.Requirement<S>>:  Exec.provision_pair(~S,~W.World<S,C,R,E>,~priorProvide,~D.provision(~S,~C,~R,~E,~scan))