roboticus_cli/cli/admin/misc/
helper_repairs.rs1#[derive(Debug, Clone, Serialize)]
2struct MechanicRepairPlan {
3 description: String,
4 commands: Vec<String>,
5 safe_auto_repair: bool,
6 requires_human_approval: bool,
7}
8
9#[derive(Debug, Clone, Serialize)]
10struct MechanicFinding {
11 id: String,
12 severity: String,
13 confidence: f64,
14 summary: String,
15 details: String,
16 repair_plan: MechanicRepairPlan,
17 auto_repaired: bool,
18}
19
20#[derive(Debug, Default, Clone, Serialize)]
21struct RepairActionSummary {
22 directories_created: Vec<String>,
23 config_created: bool,
24 permissions_hardened: Vec<String>,
25 schema_normalized: bool,
26 internalized_skills_cleaned: Vec<String>,
27 paused_jobs_reenabled: Vec<String>,
28 security_configured: bool,
29 memory_entries_purged: u32,
30}
31
32#[derive(Debug, Serialize)]
33struct MechanicJsonReport {
34 ok: bool,
35 repair_mode: bool,
36 findings: Vec<MechanicFinding>,
37 actions: RepairActionSummary,
38}
39
40#[allow(clippy::too_many_arguments)]
41fn finding(
42 id: &str,
43 severity: &str,
44 confidence: f64,
45 summary: impl Into<String>,
46 details: impl Into<String>,
47 plan_desc: impl Into<String>,
48 commands: Vec<String>,
49 safe_auto_repair: bool,
50 requires_human_approval: bool,
51) -> MechanicFinding {
52 MechanicFinding {
53 id: id.to_string(),
54 severity: severity.to_string(),
55 confidence,
56 summary: summary.into(),
57 details: details.into(),
58 repair_plan: MechanicRepairPlan {
59 description: plan_desc.into(),
60 commands,
61 safe_auto_repair,
62 requires_human_approval,
63 },
64 auto_repaired: false,
65 }
66}
67
68pub type SchemaHygieneFn = dyn Fn(&Path) -> Result<bool, Box<dyn std::error::Error>>;
70
71fn normalize_schema_safe(state_db_path: &Path) -> Result<bool, Box<dyn std::error::Error>> {
73 let report = crate::state_hygiene::run_state_hygiene(state_db_path)?;
74 Ok(report.changed)
75}
76