Skip to main content

mur_common/agent/
override_record.rs

1//! What `running.lock` records about a startup override: the one this boot
2//! applied, or why it rejected the one it found. Owned by the lock, so it
3//! lives beside `LockFile`; `crate::startup_override` imports `OverrideFlags`.
4
5use serde::{Deserialize, Serialize};
6
7use crate::startup_override::ConfirmedBy;
8
9/// The three one-shot relaxations an override may request.
10#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
11pub struct OverrideFlags {
12    pub no_hitl: bool,
13    pub net_unrestricted: bool,
14    pub full_perms: bool,
15}
16
17impl OverrideFlags {
18    /// The flags set, as the CLI spells them, in a fixed order. One list for
19    /// the runtime banner, `mur agent status` and the Hub badge.
20    pub fn cli_names(self) -> Vec<&'static str> {
21        [
22            (self.no_hitl, "--no-hitl"),
23            (self.net_unrestricted, "--net=unrestricted"),
24            (self.full_perms, "--full-perms"),
25        ]
26        .into_iter()
27        .filter_map(|(on, name)| on.then_some(name))
28        .collect()
29    }
30}
31
32/// An override this boot applied. Its `nonce` is the acknowledgement the
33/// writer is waiting for.
34#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
35pub struct OverrideRecord {
36    pub nonce: String,
37    pub flags: OverrideFlags,
38    pub confirmed_by: ConfirmedBy,
39}
40
41/// An override this boot found and refused. `nonce` is `None` when the file
42/// could not be read or parsed, so no trustworthy nonce exists.
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
44pub struct OverrideRejection {
45    pub nonce: Option<String>,
46    pub reason: String,
47}