ordinary_app_dump.bend source
ordinary_app_dump.bend on the hub · documented module
import Baseimport ./clock_state.bend as Clockimport ./deferred_command.bend as Deferredimport entity_key.bend as Keyimport entity_allocator.bend as Allocimport ./world.bend as Wimport ./ordinary_schema.bend as Schemaimport ./schema_fragments.bend as Fragmentimport ./ordinary_app_schema.bend as SchemaAppimport ./ordinary_app_composer.bend as Buildimport ./ordinary_app_registration_fields.bend as Recordsimport ./ordinary_app_observation_data.bend as DTOimport ./ordinary_app_recipe.bend as Treeimport ./ordinary_schema_dump.bend as Provisionimport ./ordinary_dump_filter.bend as Filterimport ./ordinary_dump_eligibility.bend as Eligibleimport ./ordinary_dump_render.bend as Render# Ordinary provisioning generates the erased presence/presentation operations.# The schema is retained once; forged raw index bridges remain trusted setup.# Schema-backed dump wrapper retaining the registered App and all affine owners.# count/components/resources are advanced erased presence/presentation adapters# generated by ordinary provisioning. Raw forged bridges and opaque presenters# remain trusted; their signatures alone do not prove owner identity or purity.type Application<S:Data,C:Type,R:Type,E:Data,H:Type,Rows:Data,-observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,-fold:H -> H & List<&2,Records.Fields<S>>,-count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,-components:C -> U32 -> C & List<&2,Maybe<&2,String>>,-resources:R -> R & List<&2,Maybe<&2,String>>> is Type: Application{schema:Schema.Schema<S,C,R>,app:Build.Registered<S,W.World<S,C,R,E>,H,Rows,observe,fold>}# Detached presentation result: alive counts all currently live handles before# filtering; rows contains selected entities and resources is a separate view.# Strings are descriptions, not payload owners or a restorable save/checkpoint.type Dump<S:Data> is Data: Dump{alive:U32,rows:List<&2,Filter.Row<S>>,resources:List<&2,Filter.Value>}# Advanced attachment of a retained schema and registered App to its generated# dump operations. Does not register systems, enable debug or inspect payloads.def attached(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,schema:Schema.Schema<S,C,R>,app:Build.Registered<S,W.World<S,C,R,E>,H,Rows,observe,fold>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources>: Application{schema,app}# Set the underlying App debug flag, returning schema, World and registration# owners. This changes observation enablement, not gameplay execution authority.def enabled(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,value:Application<S,C,R,E,H,Rows,observe,fold,count,components,resources>,flag:Bool) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources>: match value: case Application{schema,Build.Registered{world,owners,recipe,_}}:Application{schema,Build.Registered{world,owners,recipe,flag}}# Delegate World creation through the retained schema and factory, returning# the schema with the actual Creation result. Refusal retains its owned creation# inputs under SchemaApp.create; this does not attach a registered dump App.def create(~S:Data,~C:Type,~R:Type,~E:Data,~empty:Unit -> C,schema:Schema.Schema<S,C,R>,factory:W.Factory,resource:R) -> Schema.Schema<S,C,R> & W.Creation<S,C,R,E>: SchemaApp.create(~S,~C,~R,~E,~empty,schema,factory,resource)def resource_returned(~S:Data,~C:Type,~R:Type,~E:Data,namespace:U32,allocator:Alloc.Allocator,store:C,events:List<&2,E>,pending:List<Deferred.Command<W.World<S,C,R,E>>>,registrations:List<&2,W.RegistrationMeta>,nextSystemId:U32,clock:Clock.State,result:R & List<&2,Maybe<&2,String>>) -> W.World<S,C,R,E> & List<&2,Maybe<&2,String>>: match result: case (resource,slots):(W.World{namespace,allocator,store,resource,events,pending,registrations,nextSystemId,clock},slots)def resource_world(~S:Data,~C:Type,~R:Type,~E:Data,~read:R -> R & List<&2,Maybe<&2,String>>,world:W.World<S,C,R,E>) -> W.World<S,C,R,E> & List<&2,Maybe<&2,String>>: match world: case W.World{namespace,allocator,store,resource,events,pending,registrations,nextSystemId,clock}:resource_returned(~S,~C,~R,~E,namespace,allocator,store,events,pending,registrations,nextSystemId,clock,read(resource))def finished(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,+schema:Schema.Schema<S,C,R>,owners:H,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,alive:U32,rows:List<&2,Filter.Row<S>>,result:W.World<S,C,R,E> & List<&2,Maybe<&2,String>>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match result: case (world,slots):(Application{schema,Build.Registered{world,owners,recipe,True{}}},Some{Dump{alive,rows,Render.resources(~S,List.zip(&2,Fragment.Entry<S>,&2,Maybe<&2,String>,Fragment.bare_entries(~S,Schema.entries(~S,~C,~R,schema)),slots))}})def rendered(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,schema:Schema.Schema<S,C,R>,owners:H,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,alive:U32,result:W.World<S,C,R,E> & List<&2,Filter.Row<S>>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match result: case (world,rows):finished(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,schema,owners,recipe,alive,rows,resource_world(~S,~C,~R,~E,~resources,world))def selected(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,+schema:Schema.Schema<S,C,R>,owners:H,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,alive:U32,result:W.World<S,C,R,E> & List<&2,W.Handle<S>>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match result: case (world,handles):rendered(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,schema,owners,recipe,alive,W.with_store(~S,~C,~R,~E,~List<&2,Filter.Row<S>>,store => Render.rows(~S,~C,~components,handles,Schema.entries(~S,~C,~R,schema),store),world))def handled(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,+schema:Schema.Schema<S,C,R>,owners:H,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,ids:Maybe<&2,List<&2,Key.Key>>,required:List<&2,Filter.Component<S>>,limit:Maybe<&2,Nat>,result:W.World<S,C,R,E> & List<&2,W.Handle<S>>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match result: case (world,+handles):selected(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,schema,owners,recipe,U32.from_nat(List.length(&2,W.Handle<S>,handles)),W.with_store(~S,~C,~R,~E,~List<&2,W.Handle<S>>,store => Eligible.scan(~S,~C,~count,handles,Schema.entries(~S,~C,~R,schema),ids,required,limit,store),world))def scanned(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,+schema:Schema.Schema<S,C,R>,owners:H,recipe:Tree.Recipe<W.World<S,C,R,E>,Rows,observe>,criteria:Filter.Filter<S>,result:W.World<S,C,R,E> & List<&2,W.Handle<S>>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match criteria: case Filter.Filter{ids,required,limit}:handled(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,schema,owners,recipe,ids,required,limit,result)# Return the App and optional filtered dump. Disabled returns None before handle# scanning or presentation. Enabled scans live handles in their existing order;# entity keys and required component tokens are conjunctive, and the Nat limit# counts accepted rows before component rendering. Resources are rendered apart# from entity filters, including when the entity limit is zero.# All projections return their actual storage/resource owners. This does not run# systems, advance readers, flush commands or apply a structural barrier. Opaque# presenter behavior remains trusted rather than universally proven noninterfering.# See docs/parity/debug.md, ordinary filtered dump acceptance and retained consumer.def snapshot(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,criteria:Filter.Filter<S>,value:Application<S,C,R,E,H,Rows,observe,fold,count,components,resources>) -> Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>: match value: case Application{schema,Build.Registered{world,owners,recipe,False{}}}:(Application{schema,Build.Registered{world,owners,recipe,False{}}},None{}) case Application{schema,Build.Registered{world,owners,recipe,True{}}}:scanned(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,schema,owners,recipe,criteria,W.handles(~S,~C,~R,~E,world))def schema_returned(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,result:Application<S,C,R,E,H,Rows,observe,fold,count,components,resources> & Maybe<&2,Dump<S>>) -> SchemaApp.Application<S,C,R,E,H,Rows,observe,fold> & Maybe<&2,Dump<S>>: match result: case (Application{schema,app},view):(SchemaApp.Application{schema,app},view)# Schema-App adapter for snapshot with the same generated operations and filter# semantics, returning the SchemaApp wrapper and optional detached dump. Preserve# the generated provisioning functions; no second handwritten key list is needed.def schema_snapshot(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World<S,C,R,E> -> W.World<S,C,R,E> & DTO.Observation<Rows>,~fold:H -> H & List<&2,Records.Fields<S>>,~count:C -> List<&2,W.Handle<S>> -> C & List<&2,Maybe<&2,U32>>,~components:C -> U32 -> C & List<&2,Maybe<&2,String>>,~resources:R -> R & List<&2,Maybe<&2,String>>,criteria:Filter.Filter<S>,value:SchemaApp.Application<S,C,R,E,H,Rows,observe,fold>) -> SchemaApp.Application<S,C,R,E,H,Rows,observe,fold> & Maybe<&2,Dump<S>>: match value: case SchemaApp.Application{schema,app}:schema_returned(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,snapshot(~S,~C,~R,~E,~H,~Rows,~observe,~fold,~count,~components,~resources,criteria,Application{schema,app}))