daemon/tick.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/daemon/tick.bend as Tick
20 imports
import Base import ../policy/algo.bend as A import ../json.bend as Json import ../act.bend as Act import ../clock.bend as Clock import ../store.bend as Store import ../store/base.bend as SBase import ../swlive.bend as L import ../policy/types.bend as T import ../policy/usage.bend as PU import ../policy/rank.bend as PR import ../policy/decide.bend as D import ./events.bend as Ev import ./cadence.bend as Cad import ./config.bend as Cfg import ./gather.bend as G import ./view.bend as V import ./plan.bend as Plan import ./dec.bend as Dc import ./status.bend as Stat
Types
type Env source · line 26 · raw
Data
Env@ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @dry_run:Bool -> @opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @mem:0x0717344745a30ebad1f19045228e8f18/policy/types.Mem -> @checked:Bool -> @skip:List<&2, String> -> Env
type Out source · line 31 · raw
Data
The tick's events and sleeper facts, the engine's counters for the next tick, and what the status file shows.
Out@res:0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes -> @mem:0x0717344745a30ebad1f19045228e8f18/policy/types.Mem -> @active:Maybe<&2, String> -> @entries:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry> -> @accts:0x0717344745a30ebad1f19045228e8f18/json.Json -> @checked:Bool -> Out
type Next source · line 36 · raw
Data
Either the tick is over (nothing to decide) or the decision is ready to act
on; out carries the poll events so far.
NDone@out:Out -> Next
NAct@out:Out -> @ctx:0x0717344745a30ebad1f19045228e8f18/daemon/dec.Ctx -> @dec:0x0717344745a30ebad1f19045228e8f18/daemon/dec.Dec -> Next
Definitions
def env_ctx source · line 42 · raw
@e:Env -> 0x0717344745a30ebad1f19045228e8f18/store/base.Ctx
def env_cfg source · line 47 · raw
@e:Env -> 0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg
def env_dry source · line 52 · raw
@e:Env -> Bool
def env_opts source · line 57 · raw
@e:Env -> 0x0717344745a30ebad1f19045228e8f18/swlive.Opts
def env_checked source · line 62 · raw
@e:Env -> Bool
def env_skip source · line 67 · raw
@e:Env -> List<&2, String>
def with_skip source · line 72 · raw
@e:Env -> @+skip:List<&2, String> -> Env
def env_mem source · line 77 · raw
@e:Env -> 0x0717344745a30ebad1f19045228e8f18/policy/types.Mem
def idle_detail source · line 82 · raw
@+live:Bool -> String
def idle_reason source · line 89 · raw
@+live:Bool -> String
def idle_events source · line 96 · raw
@+ts:String -> @+thr:U32 -> @+live:Bool -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def idle_out source · line 99 · raw
@+env:Env -> @+ts:String -> @+live:Bool -> Out
def has_live source · line 102 · raw
@+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> Bool
def secs source · line 109 · raw
@+n:Nat -> U32
def opt_secs source · line 112 · raw
@+m:Maybe<&2, Nat> -> Maybe<&2, U32>
def exhausted_dec source · line 119 · raw
@+e:Maybe<&2, Nat> -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.Dec
def left_headroom source · line 122 · raw
@+a:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Maybe<&2, U32>
def dec_of source · line 131 · raw
@+d:0x0717344745a30ebad1f19045228e8f18/policy/types.Decision -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+active:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.Dec
def active_nat source · line 140 · raw
@+a:String -> Nat
def next_poll_of source · line 145 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> Maybe<&2, U32>
def iso_opt source · line 152 · raw
@+m:Maybe<&2, Nat> -> Maybe<&2, String>
def sel_bo source · line 159 · raw
@+c:Bool -> @+x:Maybe<&2, String> -> @+y:Maybe<&2, String> -> Maybe<&2, String>
def backoff_iso source · line 166 · raw
@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+now:Nat -> Maybe<&2, String>
def opt_u source · line 171 · raw
@+m:Maybe<&2, Nat> -> Maybe<&2, U32>
def entry_of source · line 174 · raw
@+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+now:Nat -> @+ms:List<&2, String> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry
def entry_push source · line 179 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:Nat -> @+ms:List<&2, String> -> @+rest:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry>
def entries_of source · line 186 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:Nat -> @+ms:List<&2, String> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry>
def poll_event source · line 193 · raw
@+ts:String -> @+active:String -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def prefix_poll source · line 196 · raw
@+r:0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes -> @+ts:String -> @+active:String -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+warn:List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes
def attempted2 source · line 201 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+now:U32 -> Bool
def attempted_now source · line 208 · raw
@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> Bool
def ent_kind source · line 211 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> 0x0717344745a30ebad1f19045228e8f18/policy/types.AcctKind
def opt_pct source · line 216 · raw
@+m:Maybe<&2, Nat> -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def source_of source · line 225 · raw
@+attempted_now:Bool -> @+k:0x0717344745a30ebad1f19045228e8f18/policy/types.AcctKind -> String
"usage-endpoint" or "header-probe" when this tick fetched the account (a setup-token is read by the probe), "cache" otherwise.
def log_one source · line 234 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+u:0x0717344745a30ebad1f19045228e8f18/policy/types.Usage -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ms:List<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def log_push source · line 240 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ms:List<&2, String> -> @+rest:List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def log_accts source · line 247 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ms:List<&2, String> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def readable2 source · line 254 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
def readable source · line 261 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
def is_api source · line 264 · raw
@+k:0x0717344745a30ebad1f19045228e8f18/policy/types.AcctKind -> Bool
def watched source · line 271 · raw
@+e:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent -> Bool
def all_readable source · line 276 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ms:List<&2, String> -> Bool
Every account the guard looks at (switchable, not quarantined, not an API key) has a trusted reading.
def keep_name source · line 283 · raw
@+is_all:Bool -> @+h:String -> @+rest:List<&2, String> -> List<&2, String>
def lower_names source · line 290 · raw
@+ms:List<&2, String> -> List<&2, String>
def checked_after source · line 297 · raw
@+env:Env -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> Bool
def check_ready source · line 300 · raw
@+env:Env -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> Bool
def miss_pick source · line 303 · raw
@+found:Bool -> @+h:String -> @+rest:List<&2, String> -> List<&2, String>
def missing source · line 310 · raw
@+wanted:List<&2, String> -> @+seen:List<&2, String> -> List<&2, String>
def scoped_names source · line 317 · raw
@+ss:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Scoped> -> List<&2, String>
def names_of source · line 324 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> List<&2, String>
def seen_names source · line 331 · raw
@+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> List<&2, String>
def warn_text source · line 338 · raw
@+names:List<&2, String> -> String
def warn_events source · line 341 · raw
@+ts:String -> @+miss:List<&2, String> -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def warn2 source · line 348 · raw
@+ready:Bool -> @env:Env -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+ts:String -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def model_warning source · line 355 · raw
@+env:Env -> @+es:List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Ent> -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:Nat -> @+ts:String -> List<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>
def apply_ctx source · line 358 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:U32 -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.Ctx
def to_dec source · line 361 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:U32 -> @+d:0x0717344745a30ebad1f19045228e8f18/policy/types.Decision -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.Dec
def mem_next source · line 364 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+now:U32 -> @+pcfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> 0x0717344745a30ebad1f19045228e8f18/policy/types.Mem
def entries_for source · line 367 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> List<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/status.Entry>
def log_for source · line 370 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> 0x0717344745a30ebad1f19045228e8f18/json.Json
def lead_res source · line 373 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @r:0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes -> 0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes
def made_out source · line 376 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+pcfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> @r:0x0717344745a30ebad1f19045228e8f18/daemon/dec.TickRes -> Out
def lead_out source · line 379 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+pcfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> Out
def decide_out3 source · line 384 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+pcfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> @+d:0x0717344745a30ebad1f19045228e8f18/policy/types.Decision -> Next
The tick up to the decision: the poll (and warning) events, the counters, and
what to do about it. Acting on it is apply's business (it needs the switch).
def decide_out2 source · line 387 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> @+us:List<&2, 0x0717344745a30ebad1f19045228e8f18/policy/types.Usage> -> @+pcfg:0x0717344745a30ebad1f19045228e8f18/policy/types.Config -> Next
def decide_out source · line 390 · raw
@+env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+rows:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+now:U32 -> @+ts:String -> Next
def active_out source · line 393 · raw
@env:Env -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:String -> @+now:U32 -> @+ts:String -> Next
def snap_out2 source · line 396 · raw
@env:Env -> @+now:U32 -> @+ts:String -> @+s:0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap -> @+active:Maybe<&2, String> -> Next
def snap_out source · line 403 · raw
@env:Env -> @+now:U32 -> @+ts:String -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap> -> Next
def tick source · line 411 · raw
@+env:Env -> @+now:U32 -> @+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/daemon/gather.Snap> -> Next
One tick over a snapshot whose rows are already refreshed (see collect).