Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/spark-debugger/src/daemon.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / spark-debugger / src / daemon.rs` 84 lines ยท 2793 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use aien_localhttp::Client; 17 use std::time::Duration; 18 use tokio::time::sleep; 19 use tracing::{info, warn}; 20 21 use crate::audit::run_full_audit; 22 use crate::reporter::report_incident; 23 24 pub async fn run_watchdog_daemon( 25 client: Client, 26 workspace_dir: String, 27 interval_secs: u64, 28 ) -> Result<(), Box> { 29 info!( 30 "[Watchdog] Starting spark-debugger watchdog daemon (interval: {}s)...", 31 interval_secs 32 ); 33 34 let mut consecutive_failures = 0; 35 36 loop { 37 let report = run_full_audit(&client, &workspace_dir).await; 38 39 if !report.overall_healthy { 40 consecutive_failures += 1; 41 let mut issues = Vec::new(); 42 for s in &report.services { 43 if !s.reachable { 44 issues.push(format!("Service {} unreachable at {}", s.name, s.endpoint)); 45 } 46 } 47 if !report.invariants.passed { 48 issues.push("Vault or unslop invariants violated".to_string()); 49 } 50 if !report.build.passed { 51 issues.push(format!( 52 "Workspace build failed with {} errors", 53 report.build.errors.len() 54 )); 55 } 56 57 let summary = issues.join("; "); 58 warn!( 59 "[Watchdog] Audit failed (attempt {}): {}", 60 consecutive_failures, summary 61 ); 62 63 if consecutive_failures == 1 || consecutive_failures % 5 == 0 { 64 report_incident(&client, &report, &summary).await; 65 } 66 } else { 67 if consecutive_failures > 0 { 68 info!("[Watchdog] All systems recovered to healthy state."); 69 } 70 consecutive_failures = 0; 71 info!("[Watchdog] All 5 services and workspace invariants OK."); 72 } 73 74 tokio::select! { 75 _ = tokio::signal::ctrl_c() => { 76 info!("[Watchdog] Received termination signal. Halting daemon."); 77 break; 78 } 79 _ = sleep(Duration::from_secs(interval_secs)) => {} 80 } 81 } 82 83 Ok(()) 84 }