1 import Base 2 import ./change_tick.bend as Tick 3 import ./ordinary_app_execution_recipe.bend as Exec 4 import ./ordinary_app_execution_run.bend as ExecuteRun 5 import ./ordinary_app_registration_run.bend as Transport 6 import ./execution_context.bend as Ctx 7 import ./schedule_provision.bend as SP 8 import ./captured_schedule_composition.bend as Choice 9 import ./ordinary_app_composer.bend as Build 10 import ./ordinary_app_registration_fields.bend as Records 11 import ./ordinary_app_records.bend as Leaf 12 import ./ordinary_app_recipe.bend as Tree 13 import ./ordinary_app_observation.bend as Leaves 14 import ./world.bend as W 15 import ./system.bend as Sys 16 import ./transaction.bend as T 17 import ./ordinary_system.bend as System 18 import ./compose.bend as Q 19 import ./inspector.bend as I 20 import ./inspector_query.bend as IQ 21 import ./ordinary_query_observable.bend as O 22 import ./ordinary_app_observation_data.bend as DTO 23 import ./internal/ordinary_component_runner.bend as Generic 24 import ./ordinary_app_component.bend as Legacy 25 import ./recognized_query_declaration.bend as Recognized 26 import ./recognized_system.bend as RecognizedSystem 27 import ./trace_facts.bend as Facts 28 29 # Execution failure reported by this App leaf. CallbackFailure carries the 30 # query access/user error; RegistrationRefused means the stored registration 31 # could not be used. The schedule result still returns its execution context. 32 def ExecutionError(Error:Data) -> Data:Legacy.ExecutionError 33 def callback_failure(~Error:Data,error:Q.Error) -> ExecutionError(Error):Legacy.CallbackFailure{error} 34 # The supplied observable declaration contributes inspection only. Operational 35 # authority, selection and clauses always come from the recognized carrier. 36 def effective_query(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration) -> O.Declaration,Ops(Q.Frame),I.Frame,Value>: 37 O.PreparedDeclaration{_=>Recognized.ordinary(~S,~C,~R,~E,~Ops,recognized),_=>O.inspection(~S,~Q.Frame,~Ops(Q.Frame),~I.Frame,~Value,query),frame=>IQ.each_composed(~I.Frame,~S,~Value,~O.inspect_query(~S,~C,~R,~E,~Q.Frame,~Ops(Q.Frame),~Value,~query),frame)} 38 def observed_result(~S:Data,~C:Type,~R:Type,~E:Data,~Error:Data,~Out:Data,result:Sys.Outcome,Q.Error,List<&2,Out>>) -> Sys.Outcome,Q.Error,List<&2,Out>> & Facts.State: 39 (result,Facts.Off{}) 40 def observed(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),trace:Facts.State,world:W.World,args:Args & Maybe<&2,Tick.Tick>) -> Sys.Outcome,Q.Error,List<&2,Out>> & Facts.State: 41 match trace: 42 case Facts.Off{}:observed_result(~S,~C,~R,~E,~Error,~Out,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)(world,args)) 43 case Facts.On{entries}:System.observable_runner_observed(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~effective_query(~S,~C,~R,~E,~Ops,~Value,~query,~recognized),~body,Facts.On{entries},world,args) 44 def execute_context(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),token:Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,fields:Records.Fields,world:W.World,trace:Facts.State,args:Args) -> Transport.TransportResult>,Args & Maybe<&2,Tick.Tick>,Q.Error,List<&2,Out>,Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>: 45 match fields: 46 case Records.Fields{namespace,id,name,access,+cursor,slot,clauses,kind}:ExecuteRun.returned(~S,~W.World,~(Args & Maybe<&2,Tick.Tick>),~Q.Error,~List<&2,Out>,~Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Transport.run_observed(~S,~C,~R,~E,~(Args & Maybe<&2,Tick.Tick>),~Q.Error,~List<&2,Out>,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~observed(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),token,Records.Fields{namespace,id,name,access,cursor,slot,clauses,kind},trace,world,(args,cursor))) 47 def execute(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),token:Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,fields:Records.Fields,context:Ctx.Context>,args:Args) -> Transport.TransportResult>,Args & Maybe<&2,Tick.Tick>,Q.Error,List<&2,Out>,Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>: 48 match context: 49 case Ctx.Context{world,trace}:execute_context(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body,token,fields,world,trace,args) 50 def extracted(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~render:Value -> String,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,DTO.Product>>>,Tree.observe_pair(~W.World,~Rows,~DTO.Product>>,~observe,~Leaves.component_observe(~S,~C,~R,~E,~Ops,~Value,~query,~render)),Leaf.fold_pair(~S,~Owners,~Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,world:W.World,owners:Owners,debug:Bool,result:Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>> & Records.Fields) -> Output: 51 Generic.extracted(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Error,~Out,~Value,~query,~render,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~Output,done,failed,world,owners,debug,result) 52 53 def defined(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~render:Value -> String,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,DTO.Product>>>,Tree.observe_pair(~W.World,~Rows,~DTO.Product>>,~observe,~Leaves.component_observe(~S,~C,~R,~E,~Ops,~Value,~query,~render)),Leaf.fold_pair(~S,~Owners,~Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,owners:Owners,recipe:Tree.Recipe,Rows,observe>,debug:Bool,result:System.Defined,Sys.Registry,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>) -> Output: 54 Generic.defined(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Error,~Out,~Value,~query,~render,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~Output,done,failed,owners,recipe,debug,result) 55 56 # Advanced setup entry for a registered composer before execution is attached. 57 # Consumes app; done receives the extended composer, while failed receives the 58 # returned previous composer. Recognition supplies operational authority; query 59 # supplies inspection. Ordinary applications should normally use add below. 60 def register(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~render:Value -> String,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,DTO.Product>>>,Tree.observe_pair(~W.World,~Rows,~DTO.Product>>,~observe,~Leaves.component_observe(~S,~C,~R,~E,~Ops,~Value,~query,~render)),Leaf.fold_pair(~S,~Owners,~Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,app:Build.Registered,Owners,Rows,observe,fold>,name:String,slot:String) -> Output: 61 Generic.register(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Error,~Out,~Value,~query,~render,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~Output,done,failed,app,name,slot) 62 63 def execution_returned(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),+args:Args,result:Transport.TransportResult>,Args & Maybe<&2,Tick.Tick>,Q.Error,List<&2,Out>,Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>) -> Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out> & Sys.Outcome>,ExecutionError(Error),Unit>: 64 Generic.execution_returned(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},args,result) 65 66 def execution_allowed(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),allowed:Bool,owner:Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>,world:Ctx.Context>,id:U32) -> Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out> & Sys.Outcome>,ExecutionError(Error),Unit>: 67 Generic.execution_allowed(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},allowed,owner,world,id) 68 69 def execution_run(~S:Data,~C:Type,~R:Type,~E:Data,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),owner:Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>,world:Ctx.Context>,id:U32) -> Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out> & Sys.Outcome>,ExecutionError(Error),Unit>: 70 Generic.execution_run(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},owner,world,id) 71 72 # App type after adding one recognized, noncapturing query system. 73 # It retains earlier owners plus the new invocation token and its row outputs. 74 # Use add to construct it, then the ordinary App attach/schedule/run operations. 75 # Args, Error, Out and inspection Value are Data; component/resource owners may 76 # be affine Type values. The recognized carrier currently covers write, 77 # resource_write and pair; other query shapes use ordinary-app-component. 78 def Application(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> Type: 79 Generic.Application(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 80 81 def execution_added(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String,~Output:Type,args:Args,done:Application(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body,~render) -> Output,result:Build.Registered,Owners & Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,DTO.Product>>>,Tree.observe_pair(~W.World,~Rows,~DTO.Product>>,~observe,~Leaves.component_observe(~S,~C,~R,~E,~Ops,~Value,~query,~render)),Leaf.fold_pair(~S,~Owners,~Leaf.Record,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>>,~fold,~Leaf.observed(~S,~Records.Token,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>))>) -> Output: 82 Generic.execution_added(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render,~Output,args,done,result) 83 84 def execution_rejected(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String,~Output:Type,failed:Exec.Registered,Owners,Rows,observe,fold,PriorError,priorPlan,priorDispatch,priorProvide> -> Output,result:Build.Registered,Owners,Rows,observe,fold>) -> Output: 85 Generic.execution_rejected(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render,~Output,failed,result) 86 87 # Register one recognized query system on an executable App during setup. 88 # Consumes value and calls exactly one continuation: done with the extended App, 89 # or failed with the returned prior App if registration is refused. name and 90 # slot use the normal registry rules. args is retained for repeatable runs. 91 # The recognized declaration owns selection/access authority; the observable 92 # query contributes inspection only, even if its operational clauses differ. 93 # Tracing Off uses compact execution; tracing On uses the ordinary observed path 94 # with that same recognized authority. Query failure rolls back this system's 95 # transactional writes and clears its outputs; prior committed systems remain. 96 # This operation neither runs the schedule nor applies deferred commands. 97 # Complete example: motion-driver.bend:define in test-fixtures/ 98 # connected-performance/sparse-motion64/consumer/s-perf/canonical-api-v1/ 99 # sparse-runtime-v1/; recognized-controls.bend in that fixture's 100 # diagnostics/typed-observation-v1/ exercises both trace modes. 101 def add(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String,~Output:Type,done:Application(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body,~render) -> Output,failed:Exec.Registered,Owners,Rows,observe,fold,PriorError,priorPlan,priorDispatch,priorProvide> -> Output,value:Exec.Registered,Owners,Rows,observe,fold,PriorError,priorPlan,priorDispatch,priorProvide>,args:Args,name:String,slot:String) -> Output: 102 Generic.add(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render,~Output,done,failed,value,args,name,slot) 103 104 # Advanced App-composition type projection: owners after this leaf is appended. 105 # Use with the matching execution_* projections; it does not register a system. 106 def execution_owners(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> Type: 107 Generic.execution_owners(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 108 109 # Advanced App-composition type projection: inspection rows after this leaf. 110 # These rows describe observations, not the callback's per-run output list. 111 def execution_rows(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> Data: 112 Generic.execution_rows(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 113 114 # Advanced App-composition projection of the owner-preserving observer. 115 # It combines earlier observations with this leaf's supplied inspection query. 116 def execution_observe(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> W.World -> W.World & DTO.Observation>>>>: 117 Generic.execution_observe(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 118 119 # Advanced App-composition projection of registration-field collection. 120 # Returns all owners with their metadata; it does not execute gameplay callbacks. 121 def execution_fold(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) & List<&2,Records.Fields>: 122 Generic.execution_fold(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 123 124 # Advanced App-composition projection of the combined registered-ID plan. 125 # Preserves owners and appends this system with condition slot zero and no 126 # requirements, retaining the prior plan order. 127 def execution_plan(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) & SP.Plan: 128 Generic.execution_plan(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 129 130 # Advanced App-composition projection of registered-ID dispatch. 131 # Returns owners and the execution context on success or typed failure; prefer 132 # the App schedule/run entry instead of supplying numeric IDs in gameplay. 133 def execution_dispatch(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) -> Ctx.Context> -> U32 -> (Owners & Exec.Invocation,Q.Error,List<&2,Out>,RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body)>>,Args,Out>) & Sys.Outcome>,Choice.Choice,Unit>: 134 Generic.execution_dispatch(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render) 135 136 # Advanced App-composition projection of the combined provisioning requirements. 137 # It preserves the World and does not grant extra capabilities to the body. 138 def execution_provide(~S:Data,~C:Type,~R:Type,~E:Data,~Owners:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:Owners -> Owners & List<&2,Records.Fields>,~PriorError:Data,~priorPlan:Owners -> Owners & SP.Plan,~priorDispatch:Owners -> Ctx.Context> -> U32 -> Owners & Sys.Outcome>,PriorError,Unit>,~priorProvide:W.World -> W.World & List<&2,SP.Requirement>,~Ops:Type -> Type,~Args:Data,~Error:Data,~Out:Data,~Value:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,Value>,~recognized:Recognized.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~render:Value -> String) -> W.World -> W.World & List<&2,SP.Requirement>: 139 Generic.execution_provide(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~PriorError,~priorPlan,~priorDispatch,~priorProvide,~Ops,~Args,~Error,~Out,~Value,~query,~body,~RecognizedSystem.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~RecognizedSystem.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~recognized,~body),~execute(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body),~ExecutionError(Error),~callback_failure(~Error),~Legacy.RegistrationRefused{},~render)