Skip to main content

subc_daemon/supervise/
config_exit_failure.rs

1use super::*;
2
3/// Why a configuration-exit fence remains closed after bounded reconciliation.
4/// Codes and error kinds are diagnostic names, never raw store or program data.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct ModuleStopReason {
7    pub code: String,
8    pub error_kind: String,
9}
10
11impl SupervisedModule {
12    pub(crate) fn config_exit_failed(
13        &self,
14        reason: ModuleStopReason,
15        approval: Option<crate::config_gate::runtime::ApprovalIdentity>,
16    ) -> Result<(), SuperviseError> {
17        update_snapshot(&self.inner.snapshot, Some(self.module_id()), |state| {
18            state.state = ModuleState::Stopped;
19            state.respawn_pending = false;
20            state.failed_retry.pending = None;
21            state.config_hold_parked = false;
22            state.config_hold_daemon_initiated = false;
23            state.config_hold_approval = None;
24            clear_current_process_facts(state);
25            state.stop_reason = Some(reason);
26            state.config_exit_failed_approval = approval;
27        })
28    }
29}
30
31impl SupervisorSnapshot {
32    pub(super) fn needs_approved_gate_restart(
33        &self,
34        approval: &crate::config_gate::runtime::ApprovalIdentity,
35    ) -> bool {
36        self.enabled
37            && self.state == ModuleState::Stopped
38            && !self.process_alive
39            && !self.config_hold_parked
40            && self.stop_reason.is_some()
41            && self.config_exit_failed_approval.as_ref() != Some(approval)
42    }
43}