1 import Base 2 import ./world.bend as W 3 import ./ordinary_schema.bend as Schema 4 import ./schema_fragments.bend as Fragment 5 import ./ordinary_app_composer.bend as Build 6 import ./ordinary_app_registration_fields.bend as Records 7 import ./ordinary_app_observation_data.bend as DTO 8 # Retain the ordinary schema itself, never an extra debug declaration. 9 # Schema-scoped App retaining the ordinary schema and registered owner 10 # collection. Construct via attached; raw fields remain trusted setup and 11 # cannot replace runtime namespace/registration validation. 12 type Application -> W.World & DTO.Observation,-fold:Owners -> Owners & List<&2,Records.Fields>> is Type: 13 Application{schema:Schema.Schema,app:Build.Registered,Owners,Rows,observe,fold>} 14 # Detached ordinary schema entries and registered application observations. 15 # This enabled-debug view contains no live owners and is not a restorable 16 # runtime checkpoint or a replacement for typed registration authority. 17 type Description is Data: 18 Description{schema:List<&2,Fragment.Entry>,registered:DTO.Product>,DTO.Observation>} 19 # Pair a matching schema with registered World/system owners. Does not 20 # validate raw metadata/storage consistency, execute systems or build a schedule. 21 def attached(~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>,schema:Schema.Schema,app:Build.Registered,Owners,Rows,observe,fold>) -> Application: 22 Application{schema,app} 23 # Toggle declaration-derived debug observation, returning the retained App. 24 # Does not immediately invoke folds or World projections. 25 def enabled(~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>,value:Application,flag:Bool) -> Application: 26 match value: 27 case Application{schema,app}:Application{schema,Build.enabled(~S,~W.World,~Owners,~Rows,~observe,~fold,app,flag)} 28 def observed(~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>,+schema:Schema.Schema,result:Build.Registered,Owners,Rows,observe,fold> & Maybe<&2,DTO.Product>,DTO.Observation>>) -> Application & Maybe<&2,Description>: 29 match result: 30 case (app,None{}):(Application{schema,app},None{}) 31 case (app,Some{view}):(Application{schema,app},Some{Description{Schema.entries(~S,~C,~R,schema),view}}) 32 # Return App and Some schema/registration observation when enabled, or 33 # None when disabled. Uses existing owner-threading folds/projections; does not 34 # run systems or consume their reader cursors. Not a restorable World save. 35 def snapshot(~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>,value:Application) -> Application & Maybe<&2,Description>: 36 match value: 37 case Application{schema,app}:observed(~S,~C,~R,~E,~Owners,~Rows,~observe,~fold,schema,Build.snapshot(~S,~W.World,~Owners,~Rows,~observe,~fold,app)) 38 # Schema is part of ordinary typed setup; World factory/refusal contracts unchanged. 39 # Trusted factory-based World creation returning schema and Creation. 40 # Actual empty storage comes from the supplied callback; refusal retains the 41 # caller resource owner. Prefer world-io.create for independent IO namespaces. 42 def create(~S:Data,~C:Type,~R:Type,~E:Data,~empty:Unit -> C,schema:Schema.Schema,factory:W.Factory,resource:R) -> Schema.Schema & W.Creation: 43 (schema,W.create(~S,~C,~R,~E,~empty,factory,resource))