Let Idunn manage VoidBot keepalive

This commit is contained in:
Meta Vens 2026-06-07 02:43:24 +01:00
commit 993c98788c
7 changed files with 61 additions and 3 deletions

View file

@ -56,6 +56,8 @@ Local package surfaces:
- Rust daemon crate: `crates/idunn-daemon`
- Rust lifecycle logic: `crates/odin-core/src/idunn.rs`
- Runtime store: `scratch/idunn/idunn.keepalive.cc`
- Local VoidBot keepalive: `scripts\health-voidbot.cmd` and
`scripts\restart-voidbot.cmd`
- Operator escalation: Bifrost-owned CultMesh crossing; current compatibility
delivery may call `voidbot.operator-dm` command `owner.dm.send`

View file

@ -1,8 +1,8 @@
use anyhow::{Context, Result, anyhow};
use cultmesh_rs::{CultMesh, CultMeshNodeOptions};
use odin_core::{
IdunnDaemonHealthRecord, IdunnDesiredDaemonRecord, IdunnRestartResultRecord, OdinDocuments,
plan_keepalive,
IdunnDaemonHealthRecord, IdunnDesiredDaemonRecord, IdunnOperatorAlarmRecord,
IdunnRestartResultRecord, OdinDocuments, plan_keepalive,
};
use std::env;
use std::path::PathBuf;
@ -82,6 +82,14 @@ fn run_cycle(options: &Options) -> Result<()> {
"Idunn restart {} for {}: {}",
result.state, result.daemon_id, result.detail
);
if result.state != "succeeded" {
let alarm = restart_failure_alarm(&result, &now);
node.put(&alarm.alarm_id, &alarm)?;
println!(
"Idunn raised operator alarm for {} through {}: {}",
alarm.daemon_id, alarm.escalation_target, alarm.reason
);
}
} else {
println!(
"Idunn requested restart for {} but did not execute it. Pass --execute to actuate.",
@ -106,6 +114,23 @@ fn run_cycle(options: &Options) -> Result<()> {
Ok(())
}
fn restart_failure_alarm(
result: &IdunnRestartResultRecord,
raised_at: &str,
) -> IdunnOperatorAlarmRecord {
IdunnOperatorAlarmRecord {
alarm_id: format!("alarm:restart-failed:{}:{}", result.daemon_id, raised_at),
daemon_id: result.daemon_id.clone(),
severity: "operator-action-required".to_string(),
reason: format!(
"restart command failed for request {}: {}",
result.request_id, result.detail
),
escalation_target: "bifrost.operator-notification".to_string(),
raised_at: raised_at.to_string(),
}
}
impl Options {
fn parse(args: impl Iterator<Item = String>) -> Result<Self> {
let mut options = Options {

View file

@ -48,6 +48,8 @@ Idunn now shares Odin's Rust body:
- `crates/idunn-daemon` is the local keepalive actuator crate.
- `src/Idunn/README.md` is the user-facing introduction for developers,
operators, and daemon authors.
- `scripts/start-idunn-local.ps1` starts resident local watchdogs, including
VoidBot through `health-voidbot.cmd` and `restart-voidbot.cmd`.
- `npm run idunn:build` builds the Rust daemon.
- `npm run idunn:start -- ...` probes a daemon, records the decision, and can
execute the restart command when `--execute` is present.

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\Odin\scripts\health-voidbot.ps1

View file

@ -0,0 +1,17 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$voidBotRoot = "E:\Projects\VoidBot"
$checkScript = Join-Path $voidBotRoot "scripts\check-voidbot-operations.ps1"
if (-not (Test-Path -LiteralPath $checkScript)) {
throw "VoidBot operations probe is missing at $checkScript."
}
Push-Location -LiteralPath $voidBotRoot
try {
& powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $checkScript -FailOnIssues
exit $LASTEXITCODE
} finally {
Pop-Location
}

View file

@ -0,0 +1,2 @@
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File E:\Projects\VoidBot\scripts\start-voidbot-stack.ps1

View file

@ -46,6 +46,14 @@ $watchdogs = @(
Health = "$repoRoot\scripts\health-stonks.cmd"
Restart = "$repoRoot\scripts\restart-stonks.cmd"
},
[pscustomobject]@{
Id = "voidbot"
Name = "VoidBot local stack"
Verse = "starfire.local"
Health = "$repoRoot\scripts\health-voidbot.cmd"
Restart = "$repoRoot\scripts\restart-voidbot.cmd"
IntervalSeconds = 300
},
[pscustomobject]@{
Id = "nightwing-gjallar"
Name = "Nightwing Gjallar framebuffer compositor"
@ -111,7 +119,7 @@ function Start-Watchdog {
"--verse", $Watchdog.Verse,
"--store", $storePath,
"--health-command", $Watchdog.Health,
"--interval-seconds", "$IntervalSeconds"
"--interval-seconds", "$(if ($Watchdog.PSObject.Properties['IntervalSeconds']) { $Watchdog.IntervalSeconds } else { $IntervalSeconds })"
)
if (-not [string]::IsNullOrWhiteSpace($Watchdog.Restart)) {
$arguments += @("--restart-command", $Watchdog.Restart, "--execute")