ordinary_app_registration_fields.bend

bendvy-ecs-core@0.1.0.0 · 69 lines · 0 definitions

1import Base
2import bendvy-ecs-core@0.1.0.0/change_tick.bend as Tick
3import bendvy-ecs-core@0.1.0.0/world.bend as W
4import bendvy-ecs-core@0.1.0.0/system.bend as Sys
5import bendvy-ecs-core@0.1.0.0/ordinary_system.bend as System
6import bendvy-ecs-core@0.1.0.0/ordinary_resource_system.bend as Resource
7import bendvy-ecs-core@0.1.0.0/ordinary_query_declaration.bend as Query
8# Sole ordinary registration fields; no detached debug Binding or cached description.
9# The private trusted token holds the actual registration's erased runner authority.
10# Mixed readers retain each operational source rather than inferring modes from access strings.
11# Detached classification of declared component, resource or event usage.
12type UseCategory is Data:
13  ComponentUse{}
14  ResourceUse{}
15  EventUse{}
16# Detached origin of a read declaration, including distinct notice streams.
17type ReaderSource is Data:
18  QuerySource{}
19  MessageSource{}
20  RemovalSource{}
21  RelationFailureSource{}
22# Detached key/mode and source of one declared access; not runtime authority.
23type DeclaredUse is Data:
24  DeclaredUse{category:UseCategory,source:ReaderSource,key:String,mode:Query.Mode}
25# Detached registration category; mixed registrations retain each declared use.
26type RegistrationKind is Data:
27  ComponentKind{}
28  ResourceKind{mode:Query.Mode}
29  FieldKind{}
30  ServiceKind{}
31  EventKind{}
32  MixedKind{uses:List<&2,DeclaredUse>}
33# Detached advanced registration description: namespace/ID/name/access,
34# cursor, authored slot/query clauses and operation kind. This Data record
35# is observation metadata; it does not independently prove a live registration
36# or authorize execution without its matching typed token and World checks.
37type Fields<S:Data> is Data:
38  Fields{namespace:U32,id:U32,name:String,access:List<&2,String>,cursor:Maybe<&2,Tick.Tick>,slot:String,clauses:List<&2,Query.Clause<S>>,kind:RegistrationKind}
39type Token<-Registry:Type> is Type:
40  Token{}
41def component_registry(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,slot:String,clauses:List<&2,Query.Clause<S>>,registry:Sys.Registry<S,C,R,E,Args,Error,Out,runner>) -> Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Fields<S>:
42  match registry:
43    case Sys.Registry{namespace,id,name,access,cursor}:(Token{},Fields{namespace,id,name,access,cursor,slot,clauses,ComponentKind{}})
44def component(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,owner:System.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>>) -> Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Fields<S>:
45  match owner:
46    case System.Owner{registry,slot,clauses}:component_registry(~S,~C,~R,~E,~Args,~Error,~Out,~runner,slot,clauses,registry)
47def restored_registry(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,fields:Fields<S>) -> System.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>>:
48  match fields:
49    case Fields{namespace,id,name,access,cursor,slot,clauses,_}:System.Owner{Sys.Registry{namespace,id,name,access,cursor},slot,clauses}
50def restore_component(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,token:Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>,fields:Fields<S>) -> System.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>>:
51  match token:
52    case Token{}:restored_registry(~S,~C,~R,~E,~Args,~Error,~Out,~runner,fields)
53def resource_registry(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~mode:Query.Mode,slot:String,registry:Sys.Registry<S,C,R,E,Args,Error,Out,runner>) -> Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Fields<S>:
54  match registry:
55    case Sys.Registry{namespace,id,name,access,cursor}:(Token{},Fields{namespace,id,name,access,cursor,slot,[],ResourceKind{mode}})
56def resource(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~mode:Query.Mode,owner:Resource.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>,mode>) -> Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Fields<S>:
57  match owner:
58    case Resource.Owner{registry,slot}:resource_registry(~S,~C,~R,~E,~Args,~Error,~Out,~runner,~mode,slot,registry)
59def restored_resource(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~mode:Query.Mode,fields:Fields<S>) -> Resource.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>,mode>:
60  match fields:
61    case Fields{namespace,id,name,access,cursor,slot,_,_}:Resource.Owner{Sys.Registry{namespace,id,name,access,cursor},slot}
62def restore_resource(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,~mode:Query.Mode,token:Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>>,fields:Fields<S>) -> Resource.Owner<S,Sys.Registry<S,C,R,E,Args,Error,Out,runner>,mode>:
63  match token:
64    case Token{}:restored_resource(~S,~C,~R,~E,~Args,~Error,~Out,~runner,~mode,fields)
65
66# Field declarations retain each canonical clause, including mixed read/write packs.
67def field_registry(~S:Data,~C:Type,~R:Type,~E:Data,~Args:Type,~Error:Data,~Out:Type,~runner:W.World<S,C,R,E> -> Args -> Sys.Outcome<W.World<S,C,R,E>,Error,Out>,slot:String,clauses:List<&2,Query.Clause<S>>,registry:Sys.Registry<S,C,R,E,Args,Error,Out,runner>) -> Token<Sys.Registry<S,C,R,E,Args,Error,Out,runner>> & Fields<S>:
68  match registry:
69    case Sys.Registry{namespace,id,name,access,cursor}:(Token{},Fields{namespace,id,name,access,cursor,slot,clauses,FieldKind{}})