1 import Base 2 import ./world.bend as W 3 import ./ordinary_app_schedule.bend as Schedule 4 import ./ordinary_app_schema.bend as SchemaApp 5 import ./ordinary_app_composer.bend as Build 6 import ./ordinary_schema.bend as Schema 7 import ./ordinary_app_recipe.bend as Tree 8 import ./ordinary_app_observation_data.bend as DTO 9 import ./ordinary_app_registration_fields.bend as Fields 10 import ./ordinary_app_access.bend as Access 11 import ./schedule.bend as Sch 12 import ./schedule_provision.bend as SP 13 # Retained operational Plan selects actual registry identity; no parallel catalog. 14 # Detached grouped declared accesses for the retained schedule's actual 15 # namespace/name. This is a diagnostic index, not a runtime grant or payload view. 16 type Index is Data: 17 Index{namespace:U32,name:String,entries:List<&2,Access.Entry>} 18 def selected(~S:Data,found:Bool,record:Fields.Fields,rest:List<&2,Fields.Fields>) -> List<&2,Fields.Fields>: 19 match found: 20 case True{}:record <> rest 21 case False{}:rest 22 def identified(~S:Data,namespace:U32,id:U32,+record:Fields.Fields,rest:List<&2,Fields.Fields>) -> List<&2,Fields.Fields>: 23 match record: 24 case Fields.Fields{otherNamespace,otherId,_,_,_,_,_,_}:selected(~S,Bool.and(U32.is_eq(namespace,otherNamespace),U32.is_eq(id,otherId)),record,rest) 25 def matching(~S:Data,+namespace:U32,+id:U32,records:List<&2,Fields.Fields>) -> List<&2,Fields.Fields>: 26 match records: 27 case []:[] 28 case +record <> rest:identified(~S,namespace,id,record,matching(~S,namespace,id,rest)) 29 def step(~S:Data,namespace:U32,records:List<&2,Fields.Fields>,planned:Schedule.PlannedStep) -> List<&2,Fields.Fields>: 30 match planned: 31 case Schedule.PlannedStep{Sch.System{id,_},_}:matching(~S,namespace,id,records) 32 case _ :[] 33 # Advanced metadata selector: keep registration fields matching each System 34 # placement's exact namespace/id in step order; phase/barrier entries add no fields. 35 # No unmatched registration is invented and no capability is derived from strings. 36 def placed(~S:Data,steps:List<&2,Schedule.PlannedStep>,+namespace:U32,+records:List<&2,Fields.Fields>) -> List<&2,Fields.Fields>: 37 match steps: 38 case []:[] 39 case first <> rest:List.append(&2,Fields.Fields,step(~S,namespace,records,first),placed(~S,rest,namespace,records)) 40 def folded(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Fields.Fields>,schema:Schema.Schema,world:W.World,recipe:Tree.Recipe,Rows,observe>,+plan:SP.Plan,+namespace:U32,+name:String,steps:List<&2,Sch.Step>,needs:List<&2,SP.Requirement>,result:H & List<&2,Fields.Fields>) -> Schedule.Application & Maybe<&2,Index>: 41 match result: 42 case (owners,records):(Schedule.Application{SchemaApp.Application{schema,Build.Registered{world,owners,recipe,True{}}},plan,namespace,name,steps,needs},Some{Index{namespace,name,Access.grouped(Access.fields(~S,placed(~S,Schedule.planned(~S,plan),namespace,records)),[])}}) 43 # Return the same scheduled App and optional grouped declared-access index. 44 # Disabled returns None before folding owners; enabled selects fields using the 45 # retained operational plan. Does not run systems, inspect payloads, advance 46 # readers or apply pending commands; arbitrary fold adapters remain trusted. 47 def index(~S:Data,~C:Type,~R:Type,~E:Data,~H:Type,~Rows:Data,~observe:W.World -> W.World & DTO.Observation,~fold:H -> H & List<&2,Fields.Fields>,value:Schedule.Application) -> Schedule.Application & Maybe<&2,Index>: 48 match value: 49 case Schedule.Application{SchemaApp.Application{schema,Build.Registered{world,owners,recipe,False{}}},plan,namespace,name,steps,needs}:(Schedule.Application{SchemaApp.Application{schema,Build.Registered{world,owners,recipe,False{}}},plan,namespace,name,steps,needs},None{}) 50 case Schedule.Application{SchemaApp.Application{schema,Build.Registered{world,owners,recipe,True{}}},plan,namespace,name,steps,needs}:folded(~S,~C,~R,~E,~H,~Rows,~observe,~fold,schema,world,recipe,plan,namespace,name,steps,needs,fold(owners))