1 import Base 2 import ./change_tick.bend as Tick 3 import entity_key_render.bend as KeyText 4 import ./world.bend as W 5 import ./compose.bend as Q 6 import ./ordinary_query_observable.bend as O 7 import ./ordinary_query_declaration.bend as N 8 import ./inspector.bend as I 9 import ./inspector_query.bend as IQ 10 # Detached typed observation rows plus their presentation strings. 11 # Contains no live World or payload owner; rendered text is not a stable save 12 # or wire protocol and may omit information retained in rows. 13 type Observation is Data: 14 Observation{rows:Rows,rendered:List<&2,String>} 15 # Detached heterogeneous pair preserving the left/right observation shape. 16 # Nest for additional row types; it does not duplicate affine payload owners. 17 type Product is Data: 18 Product{left:L,right:R} 19 # Private typed DTO; text presentation is a fixture view, not a wire contract. 20 type Binding is Data: 21 Binding{namespace:U32,id:U32,name:String,access:List<&2,String>,cursor:Maybe<&2,Tick.Tick>,slot:String,clauses:List<&2,N.Clause>} 22 def lowered(~S:Data,~C:Type,~R:Type,~E:Data,~V:Data,result:I.Frame & List<&2,IQ.ProjectedRow>) -> W.World & List<&2,IQ.ProjectedRow>: 23 match result: 24 case (I.Frame{world,_},rows):(world,rows) 25 def render_row(~S:Data,~V:Data,~render:V -> String,row:IQ.ProjectedRow) -> String: 26 match row: 27 case IQ.ProjectedRow{W.Handle{namespace,id},data}:U32.show(namespace) ++ ":" ++ KeyText.show(id) ++ ":" ++ render(data) 28 def appended(~S:Data,~C:Type,~R:Type,~E:Data,~Rows:Data,~V:Data,~render:V -> String,previous:Rows,summaries:List<&2,String>,result:W.World & List<&2,IQ.ProjectedRow>) -> W.World & Observation>>>: 29 match result: 30 case (world,+rows):(world,Observation{Product{previous,rows},List.append(&2,String,summaries,[List.show(&2,IQ.ProjectedRow,render_row(~S,~V,~render),rows)])}) 31 def append_previous(~S:Data,~C:Type,~R:Type,~E:Data,~Rows:Data,~Ops:Type -> Type,~V:Data,~query:O.Declaration,Ops(Q.Frame),I.Frame,V>,~render:V -> String,result:W.World & Observation) -> W.World & Observation>>>: 32 match result: 33 case (world,Observation{previous,summaries}):appended(~S,~C,~R,~E,~Rows,~V,~render,previous,summaries,lowered(~S,~C,~R,~E,~V,IQ.each_composed(~I.Frame,~S,~V,~O.inspect_query(~S,~C,~R,~E,~Q.Frame,~Ops(Q.Frame),~V,~query),I.Frame{world,None{}})))