import Base import ./change_tick.bend as Tick import entity_key_render.bend as KeyText import ./world.bend as W import ./compose.bend as Q import ./ordinary_query_observable.bend as O import ./ordinary_query_declaration.bend as N import ./inspector.bend as I import ./inspector_query.bend as IQ # Detached typed observation rows plus their presentation strings. # Contains no live World or payload owner; rendered text is not a stable save # or wire protocol and may omit information retained in rows. type Observation is Data: Observation{rows:Rows,rendered:List<&2,String>} # Detached heterogeneous pair preserving the left/right observation shape. # Nest for additional row types; it does not duplicate affine payload owners. type Product is Data: Product{left:L,right:R} # Private typed DTO; text presentation is a fixture view, not a wire contract. type Binding is Data: Binding{namespace:U32,id:U32,name:String,access:List<&2,String>,cursor:Maybe<&2,Tick.Tick>,slot:String,clauses:List<&2,N.Clause>} 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>: match result: case (I.Frame{world,_},rows):(world,rows) def render_row(~S:Data,~V:Data,~render:V -> String,row:IQ.ProjectedRow) -> String: match row: case IQ.ProjectedRow{W.Handle{namespace,id},data}:U32.show(namespace) ++ ":" ++ KeyText.show(id) ++ ":" ++ render(data) 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>>>: match result: case (world,+rows):(world,Observation{Product{previous,rows},List.append(&2,String,summaries,[List.show(&2,IQ.ProjectedRow,render_row(~S,~V,~render),rows)])}) 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>>>: match result: 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{}})))