daemon/plan.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/daemon/plan.bend as Plan
6 imports
import Base import ../store.bend as Store import ../policy/types.bend as T import ../policy/usage.bend as PU import ./gather.bend as G import ./view.bend as V
Definitions
def sel_e source · line 11 · raw
@+c:Bool -> @+x:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+y:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
def is_active source · line 18 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+active:Maybe<&2, String> -> Bool
def acct_disabled source · line 21 · raw
@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> Bool
def eligible source · line 27 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> Bool
A candidate can be fetched: not disabled/quarantined/unswitchable.
def due2 source · line 32 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> Bool
def due source · line 39 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> Bool
def stale2 source · line 42 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
def stale source · line 49 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
def fa2 source · line 52 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> Nat
def fetched_at source · line 59 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> Nat
def active_due source · line 63 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+active:Maybe<&2, String> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
The active account, when it is due.
def due_cands source · line 71 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+active:Maybe<&2, String> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
Due candidates, in roster order.
def sel_m source · line 78 · raw
@+c:Bool -> @+x:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+y:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
def older source · line 85 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+best:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
def oldest source · line 93 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+best:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
The due candidate with the oldest measurement (the first wins ties).
def one_of source · line 100 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
def first_pass source · line 108 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+active:Maybe<&2, String> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
Phase 1: the active account if due, plus at most one due candidate.
def same_slot source · line 111 · raw
@+a:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+b:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> Bool
def in_list source · line 114 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+xs:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> Bool
def exempt3 source · line 121 · raw
@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+h:Maybe<&2, Nat> -> Bool
def exempt2 source · line 128 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
def exempt source · line 136 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
Rows planned past a long wait and exhausted are left alone.
def escalated source · line 140 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+active:Maybe<&2, String> -> @+skip:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+now:Nat -> @+cfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> @+ms:List<&2, String> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent>
Phase 2 (escalation): every other candidate that is due or stale.