import Base import inspector_metadata.bend as Meta import inspector.bend as I import capabilities.bend as Cap # Trusted schema authoring only, like component.Family's indexed closed lens. # The index binds which projection constructs this grant; it does not prove an # arbitrary caller's numeric token/name/lens assertion is canonical or truthful. type Declaration<-S:Data,-R:Type,-V:Data,-Token:Data,-project:R -> R & V> is Data: Declaration{id:U32,name:String} type BoundRead<-S:Data,-H:Type,-V:Data> is Type: BoundRead{metadata:Meta.Resource,read:Cap.ValueRead} def canonical(~S:Data,~R:Type,~V:Data,~Token:Data,~project:R -> R & V,id:U32,name:String) -> Declaration: Declaration{id,name} def bind(~S:Data,~Store:Type,~R:Type,~E:Data,~V:Data,~Token:Data,~project:R -> R & V,declaration:Declaration) -> BoundRead,V>: match declaration: case Declaration{id,name}:BoundRead{Meta.Resource{id,name},I.read_resource(~S,~Store,~R,~E,~V,~project)} def split(~S:Data,~H:Type,~V:Data,bound:BoundRead) -> Meta.Resource & Cap.ValueRead: match bound: case BoundRead{metadata,read}:(metadata,read)