#[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
impl WorkspaceState
Sourcepub const fn from_u8(value: u8) -> Option<Self>
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.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
Canonical display string. Used by daemon/status output and
tracing spans.
Sourcepub const fn is_serving(self) -> bool
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
impl Clone for WorkspaceState
Source§fn clone(&self) -> WorkspaceState
fn clone(&self) -> WorkspaceState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WorkspaceState
impl Debug for WorkspaceState
Source§impl<'de> Deserialize<'de> for WorkspaceState
impl<'de> Deserialize<'de> for WorkspaceState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for WorkspaceState
impl Display for WorkspaceState
Source§impl Hash for WorkspaceState
impl Hash for WorkspaceState
Source§impl PartialEq for WorkspaceState
impl PartialEq for WorkspaceState
Source§fn eq(&self, other: &WorkspaceState) -> bool
fn eq(&self, other: &WorkspaceState) -> bool
self and other values to be equal, and is used by ==.