Skip to main content

AccountState

Struct AccountState 

Source
pub struct AccountState {
Show 13 fields pub provider: Provider, pub models: Vec<String>, pub model_aliases: HashMap<String, Vec<String>>, pub model_slugs: HashMap<String, String>, pub env: HashMap<String, String>, pub usage: Option<UsageSnapshot>, pub limit_reading: Option<UsageSnapshot>, pub last_error: Option<UsageFetchStatus>, pub next_probe_at: Option<Instant>, pub consecutive_failures: u32, pub override_armed: bool, pub loading: LoadingState, pub retired: bool,
}

Fields§

§provider: Provider

Declared backend from [[accounts]] provider. Decides which endpoint the usage probe hits and which credential it carries.

§models: Vec<String>

The canonical model names the account serves. Selection and the route’s model gate match through account_serves.

§model_aliases: HashMap<String, Vec<String>>

Canonical name -> the other names a request may arrive under for that model. Keys are always members of Self::models.

§model_slugs: HashMap<String, String>

Canonical name -> upstream slug, only where the spellings differ. The forward splices the slug into the request body.

§env: HashMap<String, String>

Per-account environment: provider-behaviour extras plus the derived credential and base-url variable stamps. Stamped onto the account’s claude subprocess at spawn, and read by the usage probe for the ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN a base-url provider authenticates with.

§usage: Option<UsageSnapshot>

Latest usage snapshot fetched by the workspace’s background poller. None until the first successful fetch. Drives the selection walk’s order and the cooldown’s reset; a view reads Self::limit_reading with it, in that order.

§limit_reading: Option<UsageSnapshot>

The windows a rate-limited probe carried, kept for the view beside usage rather than in it: they never heal the account, and selection and cooldowns must keep reading the successful probe.

§last_error: Option<UsageFetchStatus>

Latest poll-attempt outcome when the fetch failed. Cleared (set to None) on the next successful fetch. unusable_reason reads this to classify a probe-blocked account, and the write schedules the next probe’s backoff (next_probe_at).

§next_probe_at: Option<Instant>

Earliest wall-clock time we’re allowed to probe this account again. The poller skips accounts whose next_probe_at is in the future. Used for per-account exponential backoff when Anthropic’s /api/oauth/usage endpoint keeps returning 429 (without backoff every poll cycle re-trips the per-IP rate limit and we never accumulate usage data). None means “probe on the next tick” (default).

§consecutive_failures: u32

Consecutive probe failures since the last success. Drives the backoff schedule: each consecutive failure doubles the next-probe delay (capped at a sensible ceiling). Reset to 0 on success.

§override_armed: bool

One-shot arming flag for the has_just_cleared_cap_window scheduler hook. Without it, a stale-reset snapshot paired with sustained probe failure would re-trigger the override every poll cycle, defeating the exponential backoff schedule - forge would hammer Anthropic’s /api/oauth/usage endpoint once per minute through a multi-hour outage instead of backing off. set_usage arms it (a fresh snapshot earns one override attempt once its resets_at passes); disarm_override clears it after the scheduler fires an override. False until the first successful probe lands a snapshot. Distinct from LoadingState - rate-limit concern, not auth-recovery.

§loading: LoadingState

Where this account sits in the boot-time loading state machine. The boot wave and the cron spawn path gate on this across every account; the selection walk only considers accounts whose state is Ready (or a saturated Ready).

§retired: bool

A config reload removed this account from the file. It is not in the selection walk any more, but a session already bound to it keeps working until the session ends.

Trait Implementations§

Source§

impl Clone for AccountState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccountState

Hand-written because the env map carries the account’s credential stamps, which the derived output would print.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more