1 import Base 2 import ./ordinary_schema_dump.bend as Presentation 3 import ./ordinary_app_dump.bend as Dump 4 import ./ordinary_app_population.bend as Population 5 import ./ordinary_dump_filter.bend as Filter 6 import ./world.bend as W 7 import ./event_runtime.bend as Ev 8 import ./ordinary_schema.bend as Schema 9 import ./ordinary_app_schema.bend as SchemaApp 10 import ./ordinary_app_composer.bend as Build 11 import ./ordinary_app_registration_fields.bend as Records 12 import ./ordinary_app_recipe.bend as Tree 13 import ./ordinary_app_observation_data.bend as DTO 14 import ./ordinary_app_access.bend as Access 15 import ./system.bend as Sys 16 import ./ordinary_event_declaration.bend as Event 17 import ./ordinary_app_event.bend as EventOwner 18 # Sole World is inside Runtime; schema/operational owners/phantom recipe remain retained. 19 # Schema App retaining one actual event Runtime, ordinary registration owners and 20 # event-owner product. Events are detached Data here; affine payload logs require 21 # the separate owned-event family APIs. Raw folds/adapters remain trusted setup. 22 type Application -> W.World & DTO.Observation,-fold:H -> H & List<&2,Records.Fields>,Events:Type,-eventFold:Events -> Events & List<&2,Access.Entry>> is Type: 23 Application{schema:Schema.Schema,runtime:Ev.Runtime,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,debug:Bool} 24 # Advanced Unit event-owner fold with an empty access inventory. 25 def empty_events(unit:Unit) -> Unit & List<&2,Access.Entry>:(unit,[]) 26 # Wrap the schema App World in an event Runtime with the supplied retention 27 # capacity and no event owners. Preserve schema/owners/recipe/debug; no reader 28 # or writer is automatically registered. 29 def start(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,capacity:Nat,value:SchemaApp.Application) -> Application: 30 match value: 31 case SchemaApp.Application{schema,Build.Registered{world,owners,recipe,debug}}:Application{schema,Ev.start(~S,~C,~R,~E,world,capacity),owners,recipe,Unit{},debug} 32 # Set App observation enablement without dispatch or retention/cursor changes. 33 def enabled(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,app:Application,flag:Bool) -> Application: 34 match app: 35 case Application{schema,runtime,owners,recipe,events,_}:Application{schema,runtime,owners,recipe,events,flag} 36 def indexed(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,schema:Schema.Schema,runtime:Ev.Runtime,recipe:Tree.Recipe,Rows,observe>,prior:H & List<&2,Records.Fields>,eventResult:Events & List<&2,Access.Entry>) -> Application & Maybe<&2,List<&2,Access.Entry>>: 37 match prior eventResult: 38 case (owners,records),(events,entries):(Application{schema,runtime,owners,recipe,events,True{}},Some{Access.grouped(List.append(&2,Access.Entry,Access.fields(~S,records),entries),[])}) 39 # Return App and optional grouped registration/event access inventory. Disabled 40 # bypasses both folds; enabled threads actual owners through generated folds. 41 # Inventory metadata is not a gameplay grant or an event acknowledgement. 42 def index(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,app:Application) -> Application & Maybe<&2,List<&2,Access.Entry>>: 43 match app: 44 case Application{schema,runtime,owners,recipe,events,False{}}:(Application{schema,runtime,owners,recipe,events,False{}},None{}) 45 case Application{schema,runtime,owners,recipe,events,True{}}:indexed(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,schema,runtime,recipe,fold(owners),eventFold(events)) 46 def pair_second(~L:Type,~R:Type,left:L,before:List<&2,Access.Entry>,right:R & List<&2,Access.Entry>) -> (L & R) & List<&2,Access.Entry>: 47 match right: 48 case (right,after):((left,right),List.append(&2,Access.Entry,before,after)) 49 def pair_first(~L:Type,~R:Type,~rightFold:R -> R & List<&2,Access.Entry>,right:R,left:L & List<&2,Access.Entry>) -> (L & R) & List<&2,Access.Entry>: 50 match left: 51 case (left,before):pair_second(~L,~R,left,before,rightFold(right)) 52 # Advanced left-before-right event-owner fold composition retaining both actual 53 # owners and concatenating detached access entries in order. 54 def pair(~L:Type,~R:Type,~leftFold:L -> L & List<&2,Access.Entry>,~rightFold:R -> R & List<&2,Access.Entry>,events:L & R) -> (L & R) & List<&2,Access.Entry>: 55 match events: 56 case (left,right):pair_first(~L,~R,~rightFold,right,leftFold(left)) 57 # Actual event reader token paired with its declaration/registry owner. Reader id 58 # and system registry id are distinct identities; neither is copied to run a reader. 59 type ReaderLeaf is Type: 60 ReaderLeaf{reader:Ev.Reader,owner:EventOwner.Owner} 61 def writer_entry_returned(~S:Data,~C:Type,~R:Type,~E:Data,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>,result:EventOwner.Owner> & Maybe<&2,Access.Entry>) -> EventOwner.Owner> & List<&2,Access.Entry>: 62 match result: 63 case (owner,None{}):(owner,[]) 64 case (owner,Some{entry}):(owner,[entry]) 65 # Advanced owner-returning event-writer access description using its declaration 66 # and actual registry. The owner's debug flag controls whether an entry is emitted. 67 def writer_entry(~S:Data,~C:Type,~R:Type,~E:Data,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>,leaf:EventOwner.Owner>) -> EventOwner.Owner> & List<&2,Access.Entry>: 68 match leaf: 69 case EventOwner.Owner{declaration,registry,debug}:writer_entry_returned(~S,~C,~R,~E,~A,~Error,~O,~runner,EventOwner.described(~S,~C,~R,~E,~A,~Error,~O,~runner,declaration,registry,debug)) 70 def reader_entry_returned(~S:Data,~C:Type,~R:Type,~E:Data,~A:Type,~Error:Data,~O:Type,~runner:W.World -> Ev.Input -> Sys.Outcome,Error,O>,reader:Ev.Reader,result:EventOwner.Owner,Error,O,runner>> & Maybe<&2,Access.Entry>) -> ReaderLeaf,Error,O,runner>> & List<&2,Access.Entry>: 71 match result: 72 case (owner,None{}):(ReaderLeaf{reader,owner},[]) 73 case (owner,Some{entry}):(ReaderLeaf{reader,owner},[entry]) 74 # Advanced event-reader access description retaining the actual reader and registry. 75 # Does not consume unread messages or advance stream positions. 76 def reader_entry(~S:Data,~C:Type,~R:Type,~E:Data,~A:Type,~Error:Data,~O:Type,~runner:W.World -> Ev.Input -> Sys.Outcome,Error,O>,leaf:ReaderLeaf,Error,O,runner>>) -> ReaderLeaf,Error,O,runner>> & List<&2,Access.Entry>: 77 match leaf: 78 case ReaderLeaf{reader,EventOwner.Owner{declaration,registry,debug}}:reader_entry_returned(~S,~C,~R,~E,~A,~Error,~O,~runner,reader,EventOwner.described(~S,~C,~R,~E,~Ev.Input,~Error,~O,~runner,declaration,registry,debug)) 79 def writer_registered_world(~S:Data,~C:Type,~R:Type,~E:Data,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>,result:EventOwner.WriterRegistered) -> W.World & Maybe>>: 80 match result: 81 case EventOwner.WriterFailed{world}:(world,None{}) 82 case EventOwner.WriterRegistered{world,owner}:(world,Some{owner}) 83 def writer_appended(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>,~Result:Type,done:Application>,pair(~Events,~EventOwner.Owner>,~eventFold,~writer_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> -> Result,failed:Application -> Result,schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,debug:Bool,result:Ev.Runtime & Maybe>>) -> Result: 84 match result: 85 case (runtime,None{}):failed(Application{schema,runtime,owners,recipe,events,debug}) 86 case (runtime,Some{owner}):done(Application{schema,runtime,owners,recipe,(events,owner),debug}) 87 # Register a declared writer and append its actual owner on success. failed gets 88 # the prior App shape with returned Runtime; done gets extended event owners. 89 # No writer body runs. World registration adapter synchronizes through Ev.with_world. 90 def register_writer(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>,~Result:Type,done:Application>,pair(~Events,~EventOwner.Owner>,~eventFold,~writer_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> -> Result,failed:Application -> Result,app:Application,declaration:Event.Declaration,name:String) -> Result: 91 match app: 92 case Application{schema,runtime,owners,recipe,events,debug}:writer_appended(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~A,~Error,~O,~runner,~Result,done,failed,schema,owners,recipe,events,debug,Ev.with_world(~S,~C,~R,~E,~Maybe>>,world => writer_registered_world(~S,~C,~R,~E,~A,~Error,~O,~runner,EventOwner.register_writer(~S,~C,~R,~E,~A,~Error,~O,~runner,world,declaration,name)),runtime)) 93 def reader_appended(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> Ev.Input -> Sys.Outcome,Error,O>,~Result:Type,done:Application,Error,O,runner>>,pair(~Events,~ReaderLeaf,Error,O,runner>>,~eventFold,~reader_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> -> Result,failed:Application -> Result,schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,debug:Bool,result:EventOwner.ReaderRegistered) -> Result: 94 match result: 95 case EventOwner.ReaderFailed{runtime}:failed(Application{schema,runtime,owners,recipe,events,debug}) 96 case EventOwner.ReaderRegistered{runtime,reader,owner}:done(Application{schema,runtime,owners,recipe,(events,ReaderLeaf{reader,owner}),debug}) 97 # Register a declared reader with its actual stream/registry ownership. done gets 98 # the extended App; failed gets the prior App shape with returned Runtime. Does 99 # not invoke the body or equate Reader id with Registry id. 100 def register_reader(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> Ev.Input -> Sys.Outcome,Error,O>,~Result:Type,done:Application,Error,O,runner>>,pair(~Events,~ReaderLeaf,Error,O,runner>>,~eventFold,~reader_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> -> Result,failed:Application -> Result,app:Application,declaration:Event.Declaration,name:String) -> Result: 101 match app: 102 case Application{schema,runtime,owners,recipe,events,debug}:reader_appended(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~A,~Error,~O,~runner,~Result,done,failed,schema,owners,recipe,events,debug,EventOwner.register_reader(~S,~C,~R,~E,~A,~Error,~O,~runner,runtime,declaration,name)) 103 104 # Internal owner-returning action transport, not an additional public App owner. 105 type Previous -> W.World & DTO.Observation,Out:Type> is Type: 106 Previous{schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,debug:Bool,output:Out} 107 def previous_finished(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Out:Type,result:SchemaApp.Application & Out) -> W.World & Previous: 108 match result: 109 case (SchemaApp.Application{schema,Build.Registered{world,owners,recipe,debug}},output):(world,Previous{schema,owners,recipe,debug,output}) 110 def previous_returned(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~Out:Type,events:Events,result:Ev.Runtime & Previous) -> Application & Out: 111 match result: 112 case (runtime,Previous{schema,owners,recipe,debug,output}):(Application{schema,runtime,owners,recipe,events,debug},output) 113 # Advanced schema-App action bridge retaining event owners and threading Runtime 114 # through Ev.with_world synchronization/tick semantics. Arbitrary action effects 115 # are trusted; this is not the observation-only bypass used by population/dump. 116 def with_previous(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~Out:Type,action:SchemaApp.Application -> SchemaApp.Application & Out,app:Application) -> Application & Out: 117 match app: 118 case Application{schema,runtime,owners,recipe,events,debug}:previous_returned(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~Out,events,Ev.with_world(~S,~C,~R,~E,~Previous,world => previous_finished(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Out,action(SchemaApp.Application{schema,Build.Registered{world,owners,recipe,debug}})),runtime)) 119 # Advanced type projection of the App after appending one actual writer owner. 120 def AfterWriter(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> A -> Sys.Outcome,Error,O>) -> Type:Application>,pair(~Events,~EventOwner.Owner>,~eventFold,~writer_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> 121 # Advanced type projection after appending a ReaderLeaf with actual reader/owner. 122 def AfterReader(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~A:Type,~Error:Data,~O:Type,~runner:W.World -> Ev.Input -> Sys.Outcome,Error,O>) -> Type:Application,Error,O,runner>>,pair(~Events,~ReaderLeaf,Error,O,runner>>,~eventFold,~reader_entry(~S,~C,~R,~E,~A,~Error,~O,~runner))> 123 124 # Trusted internal action bridge: its arbitrary callback type does not imply read-only behavior. 125 # Ordinary population/dump use only the concrete qualified generated observations. 126 def internal_observation_returned(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~Out:Type,namespace:U32,batches:List<&2,Ev.Batch>,positions:List<&2,Ev.Position>,nextReader:U32,tick:Nat,frameStart:Nat,boundary:Nat,capacity:Nat,dropped:Nat,events:Events,result:SchemaApp.Application & Out) -> Application & Out: 127 match result: 128 case (SchemaApp.Application{schema,Build.Registered{world,owners,recipe,debug}},output):(Application{schema,Ev.Runtime{world,namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped},owners,recipe,events,debug},output) 129 def internal_observation_runtime(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~Out:Type,schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,debug:Bool,action:SchemaApp.Application -> SchemaApp.Application & Out,runtime:Ev.Runtime) -> Application & Out: 130 match runtime: 131 case Ev.Runtime{world,namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped}:internal_observation_returned(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~Out,namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped,events,action(SchemaApp.Application{schema,Build.Registered{world,owners,recipe,debug}})) 132 def internal_observation(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~Out:Type,action:SchemaApp.Application -> SchemaApp.Application & Out,app:Application) -> Application & Out: 133 match app: 134 case Application{schema,runtime,owners,recipe,events,debug}:internal_observation_runtime(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~Out,schema,owners,recipe,events,debug,action,runtime) 135 # Observe generated ordinary component counts while preserving actual Runtime 136 # fields, event owners and pending work. Disabled population bypasses counting. 137 # No event synchronization/tick/frame/reader update is added by this observation. 138 def population(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~count:C -> List<&2,W.Handle> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,presentation:Presentation.Recipe,app:Application) -> Application & Maybe<&2,Population.Population>: 139 match presentation: 140 case Presentation.Recipe{}:internal_observation(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~Maybe<&2,Population.Population>,value => Population.schema_population(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,value),app) 141 # Observe the generated filtered ordinary dump without advancing event Runtime. 142 # Retain all actual owners; debug/filter/presenter behavior is that of App Dump, 143 # with opaque presentation adapters trusted. Does not acknowledge event readers. 144 def dump(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,~count:C -> List<&2,W.Handle> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,presentation:Presentation.Recipe,criteria:Filter.Filter,app:Application) -> Application & Maybe<&2,Dump.Dump>: 145 match presentation: 146 case Presentation.Recipe{}:internal_observation(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,~Maybe<&2,Dump.Dump>,value => Dump.schema_snapshot(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,criteria,value),app) 147 148 # Descriptive values only. Position.id is the actual Reader ID, not a Registry ID. 149 # Detached debug view of Data batches, actual reader positions and World event 150 # log. Reader position ids are not registry ids; this is not a restorable checkpoint. 151 type RuntimeView is Data: 152 RuntimeView{namespace:U32,batches:List<&2,Ev.Batch>,positions:List<&2,Ev.Position>,nextReader:U32,tick:Nat,frameStart:Nat,boundary:Nat,capacity:Nat,droppedThrough:Nat,log:List<&2,E>} 153 def runtime_view_returned(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,+namespace:U32,+batches:List<&2,Ev.Batch>,+positions:List<&2,Ev.Position>,+nextReader:U32,+tick:Nat,+frameStart:Nat,+boundary:Nat,+capacity:Nat,+dropped:Nat,result:W.World & List<&2,E>) -> Application & Maybe<&2,RuntimeView>: 154 match result: 155 case (world,log):(Application{schema,Ev.Runtime{world,namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped},owners,recipe,events,True{}},Some{RuntimeView{namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped,log}}) 156 def runtime_view_enabled(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,schema:Schema.Schema,owners:H,recipe:Tree.Recipe,Rows,observe>,events:Events,runtime:Ev.Runtime) -> Application & Maybe<&2,RuntimeView>: 157 match runtime: 158 case Ev.Runtime{world,+namespace,+batches,+positions,+nextReader,+tick,+frameStart,+boundary,+capacity,+dropped}:runtime_view_returned(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,schema,owners,recipe,events,namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped,W.events_view(~S,~C,~R,~E,world)) 159 # Return App and optional copied RuntimeView. Disabled bypasses log observation; 160 # enabled preserves Runtime fields and owners, without sync/trim/frame or dispatch. 161 def runtime_view(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Records.Fields>,~Events:Type,~eventFold:Events -> Events & List<&2,Access.Entry>,app:Application) -> Application & Maybe<&2,RuntimeView>: 162 match app: 163 case Application{schema,runtime,owners,recipe,events,False{}}:(Application{schema,runtime,owners,recipe,events,False{}},None{}) 164 case Application{schema,runtime,owners,recipe,events,True{}}:runtime_view_enabled(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~Events,~eventFold,schema,owners,recipe,events,runtime) 165 def runtime_batch_u32(batch:Ev.Batch) -> String: 166 match batch: 167 case Ev.Batch{tick,values}:Nat.show(tick) ++ ":" ++ List.show(~&2,~U32,~U32.show,values) 168 def runtime_position(position:Ev.Position) -> String: 169 match position: 170 case Ev.Position{id,cursor,registeredAt}:"Reader" ++ U32.show(id) ++ ":" ++ Nat.show(cursor) ++ ":" ++ Nat.show(registeredAt) 171 # Format a detached U32 RuntimeView only; no runtime access, cursor movement or IO. 172 def runtime_text_u32(view:Maybe<&2,RuntimeView>) -> String: 173 match view: 174 case None{}:"runtime=None" 175 case Some{RuntimeView{namespace,batches,positions,nextReader,tick,frameStart,boundary,capacity,dropped,log}}:"runtime=namespace:" ++ U32.show(namespace) ++ ";batches:" ++ List.show(~&2,~Ev.Batch,~runtime_batch_u32,batches) ++ ";readers:" ++ List.show(~&2,~Ev.Position,~runtime_position,positions) ++ ";nextReader:" ++ U32.show(nextReader) ++ ";tick:" ++ Nat.show(tick) ++ ";frameStart:" ++ Nat.show(frameStart) ++ ";boundary:" ++ Nat.show(boundary) ++ ";capacity:" ++ Nat.show(capacity) ++ ";droppedThrough:" ++ Nat.show(dropped) ++ ";log:" ++ List.show(~&2,~U32,~U32.show,log)