pub struct State {
pub stage: Stage,
pub phase: u32,
pub agent: AgentKind,
pub mode: Mode,
pub gate_pending: bool,
pub consecutive_failures: u32,
pub infra_failures: u32,
pub preflight_retries: u32,
pub started_at: String,
pub project_root: PathBuf,
pub worktree_path: Option<PathBuf>,
pub monitor_pid: Option<u32>,
}Expand description
Full workflow state persisted to .devflow/state.json.
Fields§
§stage: StageCurrent workflow stage.
phase: u32Phase number being worked on.
agent: AgentKindWhich coding agent was launched.
mode: ModeHow the pipeline is driven (auto vs. supervise).
gate_pending: boolWhether a gate has been written and is awaiting a human response.
consecutive_failures: u32Consecutive Validate failures — drives the Auto-mode forced gate after
crate::mode::MAX_CONSECUTIVE_FAILURES failures. Persisted across
devflow advance invocations so the counter survives monitor restarts.
infra_failures: u32Consecutive infrastructure-class faults (ResourceKilled,
AgentUnavailable) — distinct from Self::consecutive_failures
(D-08, 17-01). Gates at crate::mode::MAX_INFRA_FAILURES. Any
increment (wired in Plan 04) must use saturating_add so a
long-running stuck loop cannot overflow u32. A serde-absent value
(older persisted state) defaults to 0. Reset to 0 on every successful
stage transition, alongside consecutive_failures (CR-01, 17-06 gap
closure), so the ceiling bounds a stuck loop, not a phase’s lifetime.
preflight_retries: u32How many times a preflight gate has been resolved and retried for
this phase (18f). Bounded by crate::mode::MAX_PREFLIGHT_RETRIES.
Persisted rather than recursion-scoped because the documented wedge
spanned separate devflow invocations after a monitor death — an
in-process recursion-depth counter would reset to zero on every new
process and fail to bound the exact incident it exists to prevent.
Reset to 0 whenever preflight passes and whenever a human explicitly
approves (GateAction::Advance), both inside run_preflight. Unlike
Self::consecutive_failures and Self::infra_failures, this
counter is NOT touched by transition().
started_at: StringWhen the phase started (Unix seconds).
project_root: PathBufPath to the project root.
worktree_path: Option<PathBuf>Working directory for the agent when running in a git worktree.
None means the agent runs in project_root. State and capture files
always live under the main project_root; only the agent’s cwd changes.
monitor_pid: Option<u32>PID of the detached monitor process that owns the agent for the
current stage, recorded by launch_stage at spawn time. None means
no monitor has been spawned for this state yet, OR the state was
written by a binary predating this field — in both cases the
liveness probe reports Unknown, never Stuck.