ordinary_app_service_registration.bend

bendvy-ecs-core@0.1.0.0 · 131 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.0/ordinary_app_execution_recipe.bend as Exec
3import bendvy-ecs-core@0.1.0.0/ordinary_app_execution_run.bend as ExecuteRun
4import bendvy-ecs-core@0.1.0.0/execution_context.bend as Ctx
5import bendvy-ecs-core@0.1.0.0/trace_facts.bend as Facts
6import bendvy-ecs-core@0.1.0.0/schedule.bend as Sch
7import bendvy-ecs-core@0.1.0.0/captured_schedule_composition.bend as Choice
8import bendvy-ecs-core@0.1.0.0/ordinary_app_composer.bend as Build
9import bendvy-ecs-core@0.1.0.0/ordinary_app_recipe.bend as Tree
10import bendvy-ecs-core@0.1.0.0/ordinary_app_records.bend as Leaf
11import bendvy-ecs-core@0.1.0.0/world.bend as W
12import bendvy-ecs-core@0.1.0.0/system.bend as Sys
13import bendvy-ecs-core@0.1.0.0/schedule_provision.bend as SP
14import bendvy-ecs-core@0.1.0.0/ordinary_service_declaration.bend as D
15import bendvy-ecs-core@0.1.0.0/ordinary_app_registration_fields.bend as Records
16import bendvy-ecs-core@0.1.0.0/ordinary_app_observation_data.bend as DTO
17# Native service declaration remains operational; no query mode is fabricated.
18# Affine registered service owner retaining its actual registry and setup.
19# The service payload itself stays in World resources, not copied into metadata.
20type 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:
21  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>}
22# Detached provided statuses and declaration-derived required service ids.
23type View<S:Data> is Data:
24  View{provided:List<&2,D.Status<S>>,required:List<&2,SP.Requirement<S>>}
25# Advanced owner-returning registration fold deriving ServiceKind metadata from
26# actual registry and declaration; this does not grant query gameplay operations.
27def 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>>:
28  match owner:
29    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{}}])
30# Project this declaration's service requirement for execution preflight.
31def 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>:
32  D.requirement(~S,~R,~Payload,~Rest,~take,~put,~call,declaration)
33def provided_text(~S:Data,value:D.Status<S>) -> String:
34  match value:
35    case D.Status{id,key,ready}:key ++ ":" ++ U32.show(id) ++ ":" ++ Bool.show(ready)
36def requirement_text(~S:Data,value:SP.Requirement<S>) -> String:
37  match value:
38    case SP.Service{id}:"Service:" ++ U32.show(id)
39    case SP.Resource{id}:"Resource:" ++ U32.show(id)
40    case SP.Component{id}:"Component:" ++ U32.show(id)
41def 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>>:
42  match result:
43    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))]})
44# Advanced service observer scanning statuses, returning actual World with View
45# and presentation text. Does not invoke the service; composer debug gating decides
46# whether observation runs.
47def 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>>:
48  observed(~S,~C,~R,~E,~Payload,~Rest,~take,~put,~call,~declaration,~scan,scan(world))
49def 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>:
50  match result:
51    case Sys.Completed{registry,outcome}:(Owner{registry,setup},outcome)
52    case Sys.RegistrationRejected{registry,world,_}:(Owner{registry,setup},Sys.Failed{world,Unit{}})
53# Invoke tracked registration and return Owner plus actual World outcome. This
54# low-level entry does not perform schedule service-availability preflight; the
55# declaration runner is a successful no-op for Missing. No host-effect rollback.
56def 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>:
57  match owner:
58    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{}))
59# Composer App type with this service owner and combined prior/service observations.
60# This type adds service registration metadata, not a fabricated component query.
61def 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:
62  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))>
63def 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:
64  match result:
65    case Sys.RegistrationFailed{world}:failed(Build.Registered{world,owners,recipe,debug})
66    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))
67# Register service onto the composer App. done receives extended actual owners;
68# failed receives the prior App shape and returned World on registration refusal.
69# Does not call the service; callbacks choose a common Output ownership contract.
70def 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:
71  match app:
72    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))
73
74# Advanced owner-returning plan: this registry id at condition slot zero with
75# the declaration's service requirement. Does not invoke P or derive a query grant.
76def 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>:
77  match owner:
78    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)]})
79def 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>:
80  match result:
81    case (owner,outcome):(owner,ExecuteRun.outcome(~W.World<S,C,R,E>,~Unit,~Unit,trace,outcome))
82def 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>:
83  match allowed context:
84    case False{} context:(owner,Sys.Failed{context,Unit{}})
85    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))
86# Advanced dispatch entry: an unmatched id returns Owner/context with Failed(Unit)
87# without calling P. Matched routing invokes tracked run; schedule provisioning
88# performs availability checks separately.
89def 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>:
90  match owner:
91    case Owner{Sys.Registry{namespace,+actual,name,access,cursor},setup}:
92      +selected=id
93      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)
94# Advanced execution-enabled App type composing prior plan/dispatch/provision
95# with this service. Actual owners are retained; errors distinguish prior/service.
96def 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:
97  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))>
98def 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:
99  done(Exec.Registered{app,Exec.Recipe{}})
100def 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:
101  failed(Exec.Registered{app,Exec.Recipe{}})
102# Add service registration to an execution-enabled App, composing its plan and
103# provisioning. done receives the extended App; failed receives the previous App
104# shape on refusal. Does not run the service or make host effects transactional.
105def 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:
106  match value:
107    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)
108# Advanced type projection of prior and actual service registration owners.
109def 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:
110  Owners & Owner<S,C,R,E,Payload,Rest,take,put,call,declaration,scan>
111# Advanced detached row shape pairing prior observations with service View.
112def 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:
113  DTO.Product<Rows,View<S>>
114# Advanced closed observer composition: prior then service statuses, threading World.
115def 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>>>:
116  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))
117# Advanced closed owner fold: prior fields then service metadata, retaining owners.
118def 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>>:
119  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))
120# Advanced closed plan composition retaining actual prior/service owners in order.
121def 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>:
122  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))
123# Advanced closed routing composition; selects prior or service runner by retained
124# registration metadata, preserving both owners and tagging the failure branch.
125def 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>:
126  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))
127# Advanced closed availability composition, prior then service scan; no host call.
128# For an ordinary consumer see failedtxn-motion64/consumer/motion-schedule.bend
129# under test-fixtures/connected-performance.
130def 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>>:
131  Exec.provision_pair(~S,~W.World<S,C,R,E>,~priorProvide,~D.provision(~S,~C,~R,~E,~scan))