import Base import inspector.bend as I import inspector_metadata.bend as Meta import world.bend as W # Unchecked extraction draft. Descriptor is trusted closed schema setup; # arbitrary runtime owner is threaded once, never captured by the callback. type State<-S:Data,-Store:Type,-R:Type,-E:Data,-Ops:Type -> Type,-descriptor:Meta.Definition>,-Owner:Type> is Type: State{owner:Owner} def metadata_field(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,definition:Meta.Definition>) -> Meta.Metadata: match definition: case Meta.Definition{metadata,_}:metadata def metadata(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>) -> Meta.Metadata: metadata_field(~S,~Store,~R,~E,~Ops,descriptor) def plan(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>) -> I.Plan: Meta.into_plan(~S,~I.Plan,descriptor) def attach(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,owner:Owner) -> State: State{owner} def read(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,state:State) -> State & Meta.Metadata: (state,metadata(~S,~Store,~R,~E,~Ops,~descriptor)) def invoke(~S:Data,~Store:Type,~R:Type,~E:Data,~Ops:Type -> Type,~descriptor:Meta.Definition>,~Owner:Type,~A:Data,~U:Data,~Out:Data,~body:@-H:Type -> @-caps:Ops(H) -> A -> H -> H & Result<&2,&2,U,Out>,state:State,instance:I.Instance,args:A,world:W.World) -> State & I.Observed: (state,I.run(~S,~Store,~R,~E,~Ops,~A,~U,~Out,~plan(~S,~Store,~R,~E,~Ops,~descriptor),~body,instance,args,world))