Skip to main content

csd/commands/
state.rs

1//! `csd state` — report the hybrid-detector verdict for one session.
2
3use crate::backend;
4use crate::detect::{self, State};
5use crate::error::Result;
6use crate::session::Session;
7
8/// State output: the detector verdict plus the marker drift warning (computed from the
9/// spawn-time `backend_version`, so polling stays subprocess-free).
10#[derive(Debug, serde::Serialize)]
11pub struct StateResult {
12    #[serde(flatten)]
13    pub state: State,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub marker_warning: Option<String>,
16}
17
18pub fn run(session_name: &str) -> Result<StateResult> {
19    let session = Session::load(session_name)?;
20    let state = detect::detect(&session)?;
21    let backend = backend::resolve(&session.backend)?;
22    let marker_warning = backend::marker_warning(backend.as_ref(), session.backend_version.as_deref());
23    Ok(StateResult { state, marker_warning })
24}