~/bend-docscommunity

policy/types.bend checks

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

1 import
import Base

Types

type AcctKind source · line 13 · raw

Data

type Account source · line 18 · raw

Data

type Scoped source · line 22 · raw

Data

A per-model scoped window (Opus, Fable, ...).

type ErrKind source · line 25 · raw

Data

type Sentinel source · line 41 · raw

Data

type Usage source · line 48 · raw

Data

One account's usage row. five/seven are None when the API sent no such window. fetched_at is None before the first success.

type Win source · line 52 · raw

Data

One relevant window: the utilization and, if the API sent one, its reset.

type Strategy source · line 55 · raw

Data

type Config source · line 59 · raw

Data

type Trigger source · line 72 · raw

Data

type Snap source · line 81 · raw

Data

What the last switch recorded (autoswitch_state.json): the headroom and binding recovery of the account it left, and the trigger. NoSnap is a record written before the snapshot existed.

type State source · line 85 · raw

Data

type Mem source · line 90 · raw

Data

The engine's in-memory counters: consecutive unhealthy ticks, and when the idle hold for an expired token began. Mem{0n, None{}} is a fresh process.

type Reason source · line 93 · raw

Data

type Mode source · line 111 · raw

Data

How the target was ranked: by headroom (MHead), by weekly reset (consume-first, MReset), by recovery (all accounts above the threshold: MRec0 back soon, MRec1 back late, MFallback the one-way fallback), or as the last-resort API-key account (MApiLast).

type Decision source · line 121 · raw

Data

Switch.rec is the winner's ranking time (reset or recovery) when the mode ranks by one; bar is the no-return bar that applied to this pick.

Definitions

def failing source · line 34 · raw

@+e:ErrKind -> Nat

A derived state laid over a stored row at read time. TokenExpired is the idle-Claude-Code sentinel; every sentinel hides the row's windows. 0 when the last fetch left no error, else 1: how a row built without a stored failure count says whether it is failing.

def full source · line 125 · raw

Nat

def default_config source · line 128 · raw

Config

def fresh_state source · line 131 · raw

State

def fresh_mem source · line 134 · raw

Mem

def reason.name.more source · line 139 · raw

@+r:Reason -> String

def reason.name source · line 156 · raw

@+r:Reason -> String

def trigger.name source · line 171 · raw

@+t:Trigger -> String

def reason.exit source · line 183 · raw

@+r:Reason -> U32

Exit codes of auto --once: 0 switched, 2 no action, 3 blocked.

def exit_code source · line 196 · raw

@+d:Decision -> U32