import Base import ./change_tick.bend as Tick import ./ordinary_app_execution_recipe.bend as Exec import ./ordinary_app_execution_run.bend as ExecuteRun import ./ordinary_app_registration_run.bend as Transport import ./execution_context.bend as Ctx import ./schedule_provision.bend as SP import ./captured_schedule_composition.bend as Choice import ./ordinary_app_composer.bend as Build import ./ordinary_app_registration_fields.bend as Records import ./ordinary_app_records.bend as Leaf import ./ordinary_app_recipe.bend as Tree import ./ordinary_app_observation.bend as Leaves import ./world.bend as W import ./system.bend as Sys import ./transaction.bend as T import ./ordinary_system.bend as System import ./compose.bend as Q import ./inspector.bend as I import ./inspector_query.bend as IQ import ./ordinary_query_observable.bend as O import ./ordinary_app_observation_data.bend as DTO import ./internal/ordinary_component_runner.bend as Generic import ./ordinary_app_component.bend as Legacy import ./recognized_query_declaration.bend as Recognized import ./recognized_system.bend as RecognizedSystem import ./trace_facts.bend as Facts # Execution failure reported by this App leaf. CallbackFailure carries the # query access/user error; RegistrationRefused means the stored registration # could not be used. The schedule result still returns its execution context. def ExecutionError(Error:Data) -> Data:Legacy.ExecutionError def callback_failure(~Error:Data,error:Q.Error) -> ExecutionError(Error):Legacy.CallbackFailure{error} # The supplied observable declaration contributes inspection only. Operational # authority, selection and clauses always come from the recognized carrier. 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>: 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)} 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: (result,Facts.Off{}) 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: match trace: 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)) 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) 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)>>>: match fields: 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))) 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)>>>: match context: case Ctx.Context{world,trace}:execute_context(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~Value,~query,~recognized,~body,token,fields,world,trace,args) 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: 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) 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: 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) # Advanced setup entry for a registered composer before execution is attached. # Consumes app; done receives the extended composer, while failed receives the # returned previous composer. Recognition supplies operational authority; query # supplies inspection. Ordinary applications should normally use add below. 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: 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) 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>: 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) 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>: 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) 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>: 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) # App type after adding one recognized, noncapturing query system. # It retains earlier owners plus the new invocation token and its row outputs. # Use add to construct it, then the ordinary App attach/schedule/run operations. # Args, Error, Out and inspection Value are Data; component/resource owners may # be affine Type values. The recognized carrier currently covers write, # resource_write and pair; other query shapes use ordinary-app-component. 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: 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) 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: 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) 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: 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) # Register one recognized query system on an executable App during setup. # Consumes value and calls exactly one continuation: done with the extended App, # or failed with the returned prior App if registration is refused. name and # slot use the normal registry rules. args is retained for repeatable runs. # The recognized declaration owns selection/access authority; the observable # query contributes inspection only, even if its operational clauses differ. # Tracing Off uses compact execution; tracing On uses the ordinary observed path # with that same recognized authority. Query failure rolls back this system's # transactional writes and clears its outputs; prior committed systems remain. # This operation neither runs the schedule nor applies deferred commands. # Complete example: motion-driver.bend:define in test-fixtures/ # connected-performance/sparse-motion64/consumer/s-perf/canonical-api-v1/ # sparse-runtime-v1/; recognized-controls.bend in that fixture's # diagnostics/typed-observation-v1/ exercises both trace modes. 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: 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) # Advanced App-composition type projection: owners after this leaf is appended. # Use with the matching execution_* projections; it does not register a system. 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: 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) # Advanced App-composition type projection: inspection rows after this leaf. # These rows describe observations, not the callback's per-run output list. 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: 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) # Advanced App-composition projection of the owner-preserving observer. # It combines earlier observations with this leaf's supplied inspection query. 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>>>>: 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) # Advanced App-composition projection of registration-field collection. # Returns all owners with their metadata; it does not execute gameplay callbacks. 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>: 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) # Advanced App-composition projection of the combined registered-ID plan. # Preserves owners and appends this system with condition slot zero and no # requirements, retaining the prior plan order. 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: 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) # Advanced App-composition projection of registered-ID dispatch. # Returns owners and the execution context on success or typed failure; prefer # the App schedule/run entry instead of supplying numeric IDs in gameplay. 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>: 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) # Advanced App-composition projection of the combined provisioning requirements. # It preserves the World and does not grant extra capabilities to the body. 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>: 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)