~/bend-docscommunity

policy/rank.bend checks

raw source on the hub · import cswap-bend-cli@0.1.0.0/policy/rank.bend as Rank

3 imports
import Base
import ./types.bend as T
import ./usage.bend as U

Types

type Meas source · line 11 · raw

Data

Measured candidates: any, all at or over the threshold, best headroom.

type Sel source · line 16 · raw

Data

What a tick selects with: the live slot, the bar, the least headroom a target needs, the usage rows, the clock and the wanted models.

Definitions

def rec.within source · line 19 · raw

@+r:Maybe<&2, Nat> -> @+now:Nat -> Bool

def rec.ge_minus source · line 27 · raw

@+c:Maybe<&2, Nat> -> @+a:Maybe<&2, Nat> -> Bool

c >= a - 300 s (the recovery hysteresis), with inf for None.

def rec.lt_minus source · line 36 · raw

@+c:Maybe<&2, Nat> -> @+a:Maybe<&2, Nat> -> Bool

def rec.req source · line 39 · raw

@+x:Maybe<&2, Nat> -> @+y:Maybe<&2, Nat> -> Bool

def rec.rle source · line 51 · raw

@+x:Maybe<&2, Nat> -> @+y:Maybe<&2, Nat> -> Bool

x <= y.

def rec.min source · line 62 · raw

@+x:Maybe<&2, Nat> -> @+y:Maybe<&2, Nat> -> Maybe<&2, Nat>

def rec.after.at source · line 71 · raw

@+ok:Bool -> @+t:Nat -> Maybe<&2, Nat>

def rec.after source · line 79 · raw

@+r:Maybe<&2, Nat> -> @+now:Nat -> Maybe<&2, Nat>

A reset that is still ahead of us; past or unknown is inf.

def win.pct source · line 88 · raw

@+w:0x0717344745a30ebad1f19045228e8f18/policy/types.Win -> Nat

def win.bind.pick source · line 93 · raw

@+hit:Bool -> @+b:0x0717344745a30ebad1f19045228e8f18/policy/types.Win -> @+w:0x0717344745a30ebad1f19045228e8f18/policy/types.Win -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win>

def win.bind.step source · line 101 · raw

@+acc:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win> -> @+w:0x0717344745a30ebad1f19045228e8f18/policy/types.Win -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win>

The binding window: highest utilization, the first wins ties.

def win.bind source · line 108 · raw

@+ws:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win> -> @+acc:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win> -> Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win>

def bind.rec.of source · line 115 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win> -> @+now:Nat -> Maybe<&2, Nat>

def bind.rec source · line 125 · raw

@+ws:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Win> -> @+now:Nat -> Maybe<&2, Nat>

When the binding window comes back; inf when unknown or already past.

def rec.row.at source · line 128 · raw

@+ok:Bool -> @+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, Nat>

def rec.row source · line 135 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, Nat>

def usage.seven_reset source · line 142 · raw

@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> Maybe<&2, Nat>

def seven.row.at source · line 147 · raw

@+ok:Bool -> @+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+now:Nat -> Maybe<&2, Nat>

def seven.row source · line 155 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, Nat>

The weekly reset consume-first ranks by; past is unknown.

def is_oauth source · line 164 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/policy/types.AcctKind -> Bool

def is_api source · line 171 · raw

@+k:0x0717344745a30ebad1f19045228e8f18/policy/types.AcctKind -> Bool

def isc source · line 179 · raw

@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> @+active:Nat -> Bool

A switchable OAuth candidate: not disabled, not the live slot.

def isapi source · line 185 · raw

@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> @+active:Nat -> Bool

A last-resort API-key candidate.

def above.thr source · line 190 · raw

@+h:Nat -> @+thr:Nat -> Bool

def meas.step source · line 193 · raw

@+m:Meas -> @+h:Maybe<&2, Nat> -> @+thr:Nat -> Meas

def meas.acct source · line 202 · raw

@+ok:Bool -> @+h:Maybe<&2, Nat> -> @+thr:Nat -> @+m:Meas -> Meas

def meas source · line 209 · raw

@+as:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Account> -> @+active:Nat -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> @+thr:Nat -> @+m:Meas -> Meas

def all_above source · line 217 · raw

@+m:Meas -> @+ah:Maybe<&2, Nat> -> @+thr:Nat -> Bool

Is the active account and every measured candidate at or over the threshold?

def barred source · line 228 · raw

@+bar:Maybe<&2, Nat> -> @+slot:Nat -> Bool

def target.base source · line 236 · raw

@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> @+active:Nat -> @+bar:Maybe<&2, Nat> -> Bool

A candidate that may be chosen: OAuth, enabled, not live, not barred.

def elig.pos.at source · line 241 · raw

@+x:Nat -> Maybe<&2, Nat>

def elig.pos source · line 248 · raw

@+h:Maybe<&2, Nat> -> Maybe<&2, Nat>

def elig.row source · line 257 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, Nat>

A usable reading for a candidate: a row with a trusted headroom above zero. Backoff is not a condition: it throttles polling, not trust.

def sel.ok source · line 264 · raw

@+b:Bool -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, Nat>

def elig source · line 272 · raw

@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> @+s:Sel -> Maybe<&2, Nat>

The headroom of a candidate that may be chosen, or None.

def sel.need source · line 277 · raw

@+s:Sel -> Nat

def cand.gate.at source · line 282 · raw

@+ok:Bool -> @+h:Nat -> Maybe<&2, Nat>

def cand.gate source · line 289 · raw

@+m:Maybe<&2, Nat> -> @+need:Nat -> Maybe<&2, Nat>

def cand source · line 297 · raw

@+a:0x0717344745a30ebad1f19045228e8f18/policy/types.Account -> @+s:Sel -> Maybe<&2, Nat>

A candidate that also clears the headroom gate (landing and hysteresis).