Skip to main content

WorkspaceState

Enum WorkspaceState 

Source
#[repr(u8)]
pub enum WorkspaceState { Unloaded = 0, Loading = 1, Loaded = 2, Rebuilding = 3, Evicted = 4, Failed = 5, }
Expand description

Six-state workspace lifecycle per plan Task 6 Step 1 and Amendment 2 §G.5 / §G.7.

The #[repr(u8)] is load-bearing: sqry-daemon’s LoadedWorkspace::state is an AtomicU8, and the conversions Self::from_u8 / Self::as_u8 serialise the state machine without allocation. Values are deliberately contiguous from 0 so adding a variant stays backwards-compatible with persisted telemetry.

This type lives in the leaf wire-type crate so ResponseMeta can carry a canonical workspace_state string on every successful tool response without the leaf crate taking a dep on sqry-daemon itself.

Variants§

§

Unloaded = 0

Workspace entry exists but no graph has been loaded yet.

§

Loading = 1

Initial load is in progress — a single blocking read from disk or a full rebuild with no prior snapshot.

§

Loaded = 2

Graph is loaded, idle, and ready to serve queries.

§

Rebuilding = 3

A rebuild (incremental or full) is actively running on the dispatcher’s background task. Queries keep serving the prior ArcSwap<CodeGraph> snapshot until publish_and_retain swaps the new graph in.

§

Evicted = 4

Workspace was LRU-evicted or explicitly unloaded. The entry is REMOVED from the manager map — the next query must re-load via get_or_load. This discriminant exists for the short window between execute_eviction storing the state and workspaces.remove(key) completing (both under workspaces.write()); external observers routed through WorkspaceManager::classify_for_serve see the map-missing arm first and get DaemonError::WorkspaceEvicted regardless.

§

Failed = 5

The most recent rebuild failed. Queries are served from the last good snapshot with meta.stale = true; if the stale_serve_max_age_hours cap is exceeded, queries receive the JSON-RPC -32002 workspace_stale_expired error instead.

Implementations§

Source§

impl WorkspaceState

Source

pub const fn as_u8(self) -> u8

Round-trip the state to its discriminant.

Source

pub const fn from_u8(value: u8) -> Option<Self>

Parse a discriminant back to a state. Returns None on any value outside the current enum range — callers should treat this as a telemetry corruption rather than silently map to Unloaded.

Source

pub const fn as_str(self) -> &'static str

Canonical display string. Used by daemon/status output and tracing spans.

Source

pub const fn is_serving(self) -> bool

Whether the workspace can still serve queries in this state.

true for Self::Loaded, Self::Rebuilding (old snapshot still served), and Self::Failed (stale-serve subject to the age cap). false for Self::Unloaded, Self::Loading, and Self::Evicted.

Trait Implementations§

Source§

impl Clone for WorkspaceState

Source§

fn clone(&self) -> WorkspaceState

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkspaceState

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WorkspaceState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for WorkspaceState

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Hash for WorkspaceState

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for WorkspaceState

Source§

fn eq(&self, other: &WorkspaceState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WorkspaceState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for WorkspaceState

Source§

impl Eq for WorkspaceState

Source§

impl StructuralPartialEq for WorkspaceState

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.

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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,