1 import Base 2 import ./ordinary_app_composer.bend as Build 3 import ./ordinary_app_registration_fields.bend as Records 4 import ./ordinary_app_records.bend as Leaf 5 import ./ordinary_app_recipe.bend as Tree 6 import ./ordinary_app_observation.bend as Leaves 7 import ./world.bend as W 8 import ./system.bend as Sys 9 import ./transaction.bend as T 10 import ./ordinary_resource_system.bend as P 11 import ./ordinary_app_resource_declaration.bend as D 12 import ./ordinary_app_observation_data.bend as DTO 13 # The same ordinary resource declaration drives registration, observation and metadata. 14 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:Type,~Error:Data,~Out:Type,~Value:Data,~declaration:D.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record>>,DTO.Product,Tree.observe_pair(~W.World,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record>>,~fold,~Leaf.observed(~S,~Records.Token>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,world:W.World,owners:Owners,debug:Bool,result:Records.Token> & Records.Fields) -> Output: 15 match result: 16 case (token,fields):done(Build.appended(~S,~W.World,~Owners,~Rows,~observe,~fold,~Leaf.Record>>,~Value,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration),~Leaf.observed(~S,~Records.Token>),world,owners,Leaf.Record{token,fields},debug)) 17 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:Type,~Error:Data,~Out:Type,~Value:Data,~declaration:D.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record>>,DTO.Product,Tree.observe_pair(~W.World,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record>>,~fold,~Leaf.observed(~S,~Records.Token>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,owners:Owners,recipe:Tree.Recipe,Rows,observe>,debug:Bool,result:P.Defined,Sys.Registry,P.mode(~S,~R,~T.Tx,E>,~Ops(T.Tx,E>),D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration))>) -> Output: 18 match result: 19 case P.Rejected{world}:failed(Build.Registered{world,owners,recipe,debug}) 20 case P.Defined{world,owner}:extracted(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Error,~Out,~Value,~declaration,~body,~Output,done,failed,world,owners,debug,Records.resource(~S,~C,~R,~E,~Args,~Error,~Out,~P.runner(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration),~body),~P.mode(~S,~R,~T.Tx,E>,~Ops(T.Tx,E>),D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration)),owner)) 21 # Add a whole-resource system using the same operational declaration for 22 # grants, observation and metadata. done receives extended registered owners; 23 # failed receives the original App shape with its World/prior owners retained. 24 # Registration does not execute body or inspect resource values. This advanced 25 # registration-only adapter differs from declaration-derived App execution. 26 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:Type,~Error:Data,~Out:Type,~Value:Data,~declaration:D.Declaration,~body:@-H:Type -> @-caps:Ops(H) -> Args -> H -> H & (T.Outcome & Out),~Output:Type,done:Build.Registered,Owners & Leaf.Record>>,DTO.Product,Tree.observe_pair(~W.World,~Rows,~Value,~observe,~Leaves.resource_observe(~S,~C,~R,~E,~Ops,~Value,~declaration)),Leaf.fold_pair(~S,~Owners,~Leaf.Record>>,~fold,~Leaf.observed(~S,~Records.Token>))> -> Output,failed:Build.Registered,Owners,Rows,observe,fold> -> Output,app:Build.Registered,Owners,Rows,observe,fold>,name:String,slot:String) -> Output: 27 match app: 28 case Build.Registered{world,owners,recipe,debug}:defined(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,~Ops,~Args,~Error,~Out,~Value,~declaration,~body,~Output,done,failed,owners,recipe,debug,P.define(~S,~C,~R,~E,~Ops,~Args,~Error,~Out,~D.ordinary(~S,~C,~R,~E,~Ops,~Value,declaration),~body,world,name,slot))