import Base import ./machine_handler_phases.bend as Phase import ./machine_handler_phases_context.bend as PhaseContext import ./execution_context.bend as Ctx import ./trace_facts.bend as Facts import ./world.bend as W import ./system.bend as Sys import ./machine.bend as M import ./machine_handlers.bend as H import ./machine_handler_bundle.bend as B import ./schedule.bend as Sch import ./ordinary_machine_schedule.bend as Ordinary # Bundle preflight precedes ordinary barrier; selected registry owners recover authored order. type Owners -> H.Invocation -> Sys.Outcome,String,Unit>> is Type: Pending{entries:List<&1,B.Scheduled>,trace:Facts.State} Unavailable{entries:List<&1,B.Scheduled>,trace:Facts.State} Selected{positions:List<&2,B.Position>,kept:List<&1,H.Entry>,active:Phase.Owners,phase:H.Phase,trace:Facts.State} type MarkerResult -> H.Invocation -> Sys.Outcome,String,Unit>> is Type: MarkerResult{result:B.BundleResult,steps:List<&2,Sch.Step>,observations:List<&2,Sch.Observation>,trace:Facts.State} def unchanged(~S:Data,~C:Type,~R:Type,~E:Data,world:W.World) -> W.World:world def phase_returned(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,positions:List<&2,B.Position>,kept:List<&1,H.Entry>,phase:H.Phase,result:Phase.Owners & Sys.Outcome>,String,Unit>) -> Owners & Sys.Outcome,String,Unit>: match result: case (active,Sys.Succeeded{Ctx.Context{world,trace},output}):(Selected{positions,kept,active,phase,trace},Sys.Succeeded{world,output}) case (active,Sys.Failed{Ctx.Context{world,trace},error}):(Selected{positions,kept,active,phase,trace},Sys.Failed{world,error}) def applied(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,positions:List<&2,B.Position>,kept:List<&1,H.Entry>,result:Phase.Owners & Sys.Outcome>,String,Unit>) -> Owners & Sys.Outcome,String,Unit>: phase_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,positions,kept,H.Exit{},result) def selected(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,world:W.World,partition:B.Partition,trace:Facts.State) -> Owners & Sys.Outcome,String,Unit>: match partition: case B.Partition{positions,kept,handlers}:applied(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,positions,kept,PhaseContext.apply(~S,~K,~V,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~unchanged(~S,~C,~R,~E),Phase.Owners{handlers,Phase.Idle{}},Ctx.Context{world,trace})) def targeted(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,entries:List<&1,B.Scheduled>,pair:W.World & M.Slot,trace:Facts.State) -> Owners & Sys.Outcome,String,Unit>: match pair: case (world,M.Missing{}):(Unavailable{entries,trace},Sys.Succeeded{put(world,M.Missing{}),Unit{}}) case (world,M.Present{current,M.NoPending{},previous,_}):(Pending{entries,trace},Sys.Succeeded{put(world,M.Present{current,M.NoPending{},previous,False{}}),Unit{}}) case (world,M.Present{+current,M.Queued{+to,+skip},previous,changed}):selected(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,put(world,M.Present{current,M.Queued{to,skip},previous,changed}),B.partition(~S,~K,~V,~Q,~C,~R,~E,~runner,~same,entries,current,to),trace) def apply(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World) -> Owners & Sys.Outcome,String,Unit>: match owners: case Pending{entries,trace}:targeted(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,entries,take(frame(world)),trace) case owners:(owners,Sys.Succeeded{world,Unit{}}) def exit(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World) -> Owners & Sys.Outcome,String,Unit>: match owners: case Selected{positions,kept,active,_,trace}:phase_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,positions,kept,H.Exit{},PhaseContext.exit(~S,~K,~V,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~frame,active,Ctx.Context{world,trace})) case owners:(owners,Sys.Succeeded{world,Unit{}}) def transition(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World) -> Owners & Sys.Outcome,String,Unit>: match owners: case Selected{positions,kept,active,_,trace}:phase_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,positions,kept,H.Transition{},PhaseContext.transition(~S,~K,~V,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~frame,active,Ctx.Context{world,trace})) case owners:(owners,Sys.Succeeded{world,Unit{}}) def enter(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World) -> Owners & Sys.Outcome,String,Unit>: match owners: case Selected{positions,kept,active,_,trace}:phase_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,positions,kept,H.Enter{},PhaseContext.enter(~S,~K,~V,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~frame,active,Ctx.Context{world,trace})) case owners:(owners,Sys.Succeeded{world,Unit{}}) def recovered(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,namespace:U32,positions:List<&2,B.Position>,kept:List<&1,H.Entry>,active:Phase.Owners,world:W.World,status:B.Status) -> B.BundleResult: match active: case Phase.Owners{handlers,_}:B.recovered(~S,~K,~V,~Q,~C,~R,~E,~runner,namespace,B.recover(~S,~K,~V,~Q,~C,~R,~E,~runner,positions,kept,handlers),world,status) def finished(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,namespace:U32,owners:Owners,world:W.World,error:Maybe<&2,String>) -> B.BundleResult & Facts.State: match owners error: case Pending{entries,trace} None{}:(B.Returned{B.Bundle{namespace,entries},world,B.Completed{}},trace) case Pending{entries,trace} Some{_}:(B.Returned{B.Bundle{namespace,entries},world,B.ForeignBundle{}},trace) case Unavailable{entries,trace} _:(B.Returned{B.Bundle{namespace,entries},world,B.MachineUnavailable{}},trace) case Selected{positions,kept,active,_,trace} None{}:(recovered(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,namespace,positions,kept,active,world,B.Completed{}),trace) case Selected{positions,kept,active,phase,trace} Some{error}:(recovered(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,namespace,positions,kept,active,world,B.HandlerFailed{phase,error}),trace) def marked(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,steps:List<&2,Sch.Step>,observations:List<&2,Sch.Observation>,result:B.BundleResult & Facts.State) -> MarkerResult: match result: case (result,trace):MarkerResult{result,steps,observations,trace} def returned(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,result:Sch.RunResult,String>) -> MarkerResult: match result: case Sch.Finished{Sch.Schedule{namespace,_,steps,owners},world,observations}:marked(~S,~K,~V,~Q,~C,~R,~E,~runner,steps,observations,finished(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,namespace,owners,world,None{})) case Sch.Failed{Sch.Schedule{namespace,_,steps,owners},world,error,observations}:marked(~S,~K,~V,~Q,~C,~R,~E,~runner,steps,observations,finished(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,namespace,owners,world,Some{error})) case Sch.Rejected{Sch.Schedule{namespace,_,steps,owners},world}:marked(~S,~K,~V,~Q,~C,~R,~E,~runner,steps,[],finished(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,namespace,owners,world,Some{"schedule-rejected"})) def replaced_trace(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,owners:Owners,trace:Facts.State) -> Owners: match owners: case Pending{entries,_}:Pending{entries,trace} case Unavailable{entries,_}:Unavailable{entries,trace} case Selected{positions,kept,active,phase,_}:Selected{positions,kept,active,phase,trace} def barrier_returned(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,owners:Owners,result:W.World & Facts.State) -> Owners & W.World: match result: case (world,trace):(replaced_trace(~S,~K,~V,~Q,~C,~R,~E,~runner,owners,Facts.barrier_finished(trace)),world) def barrier(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,owners:Owners,world:W.World) -> Owners & W.World: match owners: case Pending{entries,trace}:barrier_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,Pending{entries,Facts.Off{}},W.barrier_traced(~S,~C,~R,~E,world,Facts.barrier_entered(trace))) case Unavailable{entries,trace}:barrier_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,Unavailable{entries,Facts.Off{}},W.barrier_traced(~S,~C,~R,~E,world,Facts.barrier_entered(trace))) case Selected{positions,kept,active,phase,trace}:barrier_returned(~S,~K,~V,~Q,~C,~R,~E,~runner,Selected{positions,kept,active,phase,Facts.Off{}},W.barrier_traced(~S,~C,~R,~E,world,Facts.barrier_entered(trace))) def phase_started(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,owners:Owners,id:U32) -> Owners: match owners: case Pending{entries,trace}:Pending{entries,Facts.phase_boundary(trace,Ordinary.phase_name(id))} case Unavailable{entries,trace}:Unavailable{entries,Facts.phase_boundary(trace,Ordinary.phase_name(id))} case Selected{positions,kept,active,phase,trace}:Selected{positions,kept,active,phase,Facts.phase_boundary(trace,Ordinary.phase_name(id))} def dispatch_shared(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World,+id:U32) -> Owners & Sys.Outcome,String,Unit>: Ordinary.dispatch(~S,~C,~R,~E,~Owners,~String,~apply(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame),~exit(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame),~transition(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame),~enter(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame),phase_started(~S,~K,~V,~Q,~C,~R,~E,~runner,owners,id),world,id) def dispatch(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,owners:Owners,world:W.World,id:U32) -> Owners & Sys.Outcome,String,Unit>: dispatch_shared(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,owners,world,id) def installed(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,world:W.World,built:Sch.Build>) -> MarkerResult: match built: case Sch.Built{schedule}:returned(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,Sch.run_with_barrier(~S,~C,~R,~E,~Owners,~String,~dispatch(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame),~Ordinary.condition(~S,~C,~R,~E),~barrier(~S,~K,~V,~Q,~C,~R,~E,~runner),schedule,world)) case Sch.Invalid{owners}:marked(~S,~K,~V,~Q,~C,~R,~E,~runner,[],[],finished(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,0,owners,world,Some{"invalid"})) def checked(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,namespace:U32,entries:List<&1,B.Scheduled>,pair:W.World & List<&2,Q>,trace:Facts.State) -> MarkerResult: match pair: case (world,[]):installed(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,declaration,world,Ordinary.install(~S,~C,~R,~E,~Owners,~String,declaration,namespace,Pending{entries,trace})) case (world,missing):MarkerResult{B.Returned{B.Bundle{namespace,entries},world,B.MissingRequirements{missing}},[],[],trace} def gathered(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,namespace:U32,world:W.World,pair:List<&1,B.Scheduled> & List<&2,Q>,trace:Facts.State) -> MarkerResult: (entries,needs)=pair checked(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,declaration,namespace,entries,B.missing(~S,~C,~R,~E,~Q,~has,B.collect(~Q,~requirement_same,needs,[]),world),trace) def allowed(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,yes:Bool,namespace:U32,entries:List<&1,B.Scheduled>,world:W.World,trace:Facts.State) -> MarkerResult: match yes: case False{}:MarkerResult{B.Returned{B.Bundle{namespace,entries},world,B.ForeignBundle{}},[],[],trace} case True{}:gathered(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,declaration,namespace,world,B.requirements(~S,~K,~V,~Q,~C,~R,~E,~runner,entries),trace) def named(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,+namespace:U32,entries:List<&1,B.Scheduled>,pair:W.World & U32,trace:Facts.State) -> MarkerResult: (world,actual)=pair allowed(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,declaration,U32.is_eq(namespace,actual),namespace,entries,world,trace) def run(~S:Data,~K:Data,~V:Data,~Q:Data,~C:Type,~R:Type,~E:Data,~runner:W.World -> H.Invocation -> Sys.Outcome,String,Unit>,~observed:Facts.State -> W.World -> H.Invocation -> Sys.Outcome,String,Unit> & Facts.State,~name:String,~take:W.World -> W.World & M.Slot,~put:W.World -> M.Slot -> W.World,~publish:W.World -> M.Transition -> W.World,~same:V -> V -> Bool,~requirement_same:Q -> Q -> Bool,~has:W.World -> Q -> W.World & Bool,~frame:W.World -> W.World,+declaration:Ordinary.Declaration,bundle:B.Bundle,world:W.World,trace:Facts.State) -> MarkerResult: match bundle: case B.Bundle{namespace,entries}:named(~S,~K,~V,~Q,~C,~R,~E,~runner,~observed,~name,~take,~put,~publish,~same,~requirement_same,~has,~frame,declaration,namespace,entries,W.namespace(~S,~C,~R,~E,world),trace)