import Base import ./ordinary_declaration.bend as Identity import ./component.bend as C import ./column.bend as Col # Static trusted schema lenses; this Data binding owns no payload or closure. type Binding<-S:Data,-Store:Type,-Rest:Type,-P:Type,-V:Data,-Token:Data,-take:Store -> Rest & Col.Column,-put:Rest -> Col.Column -> Store,-view:P -> P & V> is Data: Binding{identity:Identity.Declaration,family:C.Family} # Trusted schema setup: connect a component identity to its column take/put # lenses and owner-preserving Data projection. The resulting Data binding owns # no payload. Callers must supply mutually consistent lenses; this constructor # does not prove their laws or establish runtime world identity. # Example: examples/scheduled-health/registration.bend component bindings. def bind(~S:Data,~Store:Type,~Rest:Type,~P:Type,~V:Data,~Token:Data,~take:Store -> Rest & Col.Column,~put:Rest -> Col.Column -> Store,~view:P -> P & V,+identity:Identity.Declaration) -> Binding: Binding{identity,C.Family{Identity.key(~S,~P,identity)}} # Return the schema-scoped component identity from a trusted binding. # This detached declaration does not identify an entity or grant world access. def identity(~S:Data,~Store:Type,~Rest:Type,~P:Type,~V:Data,~Token:Data,~take:Store -> Rest & Col.Column,~put:Rest -> Col.Column -> Store,~view:P -> P & V,binding:Binding) -> Identity.Declaration: match binding: case Binding{identity,_}:identity # Return the typed component family used by lower-level component operations. # Retains the binding's schema, storage and projection indices; does not access # a world. Raw family construction is trusted provisioning, not gameplay access. def family(~S:Data,~Store:Type,~Rest:Type,~P:Type,~V:Data,~Token:Data,~take:Store -> Rest & Col.Column,~put:Rest -> Col.Column -> Store,~view:P -> P & V,binding:Binding) -> C.Family: match binding: case Binding{_,family}:family