Compare commits

..
Author SHA1 Message Date
m 5a07a13ac8 ops: notify on production health transitions
CI / test (push) Successful in 11s
CI / test (pull_request) Successful in 10s
2026-08-16 18:29:26 +03:00
m 4016820541 ops: add Domovoy production health monitor
CI / test (pull_request) Successful in 11s
CI / test (push) Successful in 9s
2026-08-16 18:20:40 +03:00
m 0a188ddafe ops: add encrypted off-host PostgreSQL backups
CI / test (pull_request) Successful in 10s
CI / test (push) Successful in 11s
2026-08-16 18:13:03 +03:00
13 changed files with 823 additions and 2 deletions
@@ -0,0 +1,20 @@
[CmdletBinding()]
param(
[string]$HealthScriptPath = (Join-Path $PSScriptRoot 'Test-DomovoyProductionHealth.ps1'),
[string]$NotificationScriptPath = (Join-Path $PSScriptRoot 'Send-DomovoyHealthNotification.ps1')
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
if (-not (Test-Path -LiteralPath $HealthScriptPath -PathType Leaf)) { throw 'Health monitoring script not found' }
if (-not (Test-Path -LiteralPath $NotificationScriptPath -PathType Leaf)) { throw 'Health notification script not found' }
$pwsh = (Get-Command pwsh.exe -ErrorAction Stop).Source
& $pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $HealthScriptPath
$healthExitCode = $LASTEXITCODE
& $pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File $NotificationScriptPath
$notificationExitCode = $LASTEXITCODE
if ($notificationExitCode -ne 0) { exit 2 }
exit $healthExitCode
@@ -0,0 +1,20 @@
[CmdletBinding()]
param(
[string]$ScriptPath = '\\nas\MST\codex\assistent\deploy\windows\Invoke-DomovoyProductionMonitoring.ps1',
[string]$TaskName = 'Domovoy Production Health Monitor'
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
if (-not (Test-Path -LiteralPath $ScriptPath -PathType Leaf)) { throw 'Monitoring script not found' }
$identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name
$pwsh = (Get-Command pwsh.exe -ErrorAction Stop).Source
$arguments = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -File `"$ScriptPath`""
$action = New-ScheduledTaskAction -Execute $pwsh -Argument $arguments
$repeat = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) -RepetitionInterval (New-TimeSpan -Minutes 15) -RepetitionDuration (New-TimeSpan -Days 3650)
$logon = New-ScheduledTaskTrigger -AtLogOn -User $identity
$principal = New-ScheduledTaskPrincipal -UserId $identity -LogonType Interactive -RunLevel Limited
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -MultipleInstances IgnoreNew -ExecutionTimeLimit (New-TimeSpan -Minutes 10)
Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger @($repeat, $logon) -Principal $principal -Settings $settings -Description 'Monitor Domovoy production health and notify the interactive user about transitions.' -Force | Out-Null
Write-Output "Scheduled task registered: $TaskName"
@@ -0,0 +1,52 @@
[CmdletBinding()]
param(
[string]$ScriptPath = '\\nas\MST\codex\assistent\deploy\windows\Sync-PostgresBackupToNas.ps1',
[string]$KeyRecordPath = "$env:LOCALAPPDATA\Domovoy\postgres-backup-key.dpapi.json",
[string]$NasKeyBackupPath = '\\nas\MST\codex\_backups\domovoy\keys\postgres-backup-key.dpapi.json',
[string]$TaskName = 'Domovoy PostgreSQL Off-host Backup'
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$keyDirectory = Split-Path -Parent $KeyRecordPath
New-Item -ItemType Directory -Force -Path $keyDirectory | Out-Null
$identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name
if (-not (Test-Path -LiteralPath $KeyRecordPath) -and (Test-Path -LiteralPath $NasKeyBackupPath -PathType Leaf)) {
Copy-Item -LiteralPath $NasKeyBackupPath -Destination $KeyRecordPath
}
if (-not (Test-Path -LiteralPath $KeyRecordPath)) {
$random = [byte[]]::new(48)
[Security.Cryptography.RandomNumberGenerator]::Fill($random)
$plain = [Convert]::ToBase64String($random)
try {
$protected = ConvertFrom-SecureString (ConvertTo-SecureString $plain -AsPlainText -Force)
$record = [ordered]@{ version = 1; project = 'domovoy'; purpose = 'postgres off-host backup'; protected_value = $protected; created_at_utc = [DateTime]::UtcNow.ToString('o') }
[IO.File]::WriteAllText($KeyRecordPath, ($record | ConvertTo-Json) + "`n", [Text.UTF8Encoding]::new($false))
}
finally {
[Array]::Clear($random, 0, $random.Length)
$plain = $null
}
}
& icacls.exe $KeyRecordPath /inheritance:r /grant:r "${identity}:F" | Out-Null
if ($LASTEXITCODE -ne 0) { throw 'DPAPI key ACL hardening failed' }
$nasKeyDirectory = Split-Path -Parent $NasKeyBackupPath
New-Item -ItemType Directory -Force -Path $nasKeyDirectory | Out-Null
$nasKeyPartial = "$NasKeyBackupPath.$PID.partial"
Copy-Item -LiteralPath $KeyRecordPath -Destination $nasKeyPartial
Move-Item -LiteralPath $nasKeyPartial -Destination $NasKeyBackupPath -Force
if (-not (Test-Path -LiteralPath $ScriptPath -PathType Leaf)) { throw "Scheduled sync script not found" }
$pwsh = (Get-Command pwsh.exe -ErrorAction Stop).Source
$arguments = "-NoProfile -NonInteractive -ExecutionPolicy Bypass -File `"$ScriptPath`""
$action = New-ScheduledTaskAction -Execute $pwsh -Argument $arguments
$daily = New-ScheduledTaskTrigger -Daily -At '04:00'
$logon = New-ScheduledTaskTrigger -AtLogOn -User $identity
$principal = New-ScheduledTaskPrincipal -UserId $identity -LogonType Interactive -RunLevel Limited
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -MultipleInstances IgnoreNew -ExecutionTimeLimit (New-TimeSpan -Hours 2)
Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger @($daily, $logon) -Principal $principal -Settings $settings -Description 'Encrypt and replicate the latest Domovoy PostgreSQL backup to the private NAS.' -Force | Out-Null
Write-Output "Scheduled task registered: $TaskName"
@@ -0,0 +1,125 @@
[CmdletBinding()]
param(
[string]$StatusPath = (Join-Path $env:LOCALAPPDATA 'Domovoy\monitoring\status.json'),
[string]$StatePath = (Join-Path $env:LOCALAPPDATA 'Domovoy\monitoring\notification-state.json'),
[ValidateRange(1, 168)]
[int]$ReminderHours = 6,
[switch]$Force,
[switch]$NoDisplay
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
function Write-AtomicJson {
param([Parameter(Mandatory)]$Value, [Parameter(Mandatory)][string]$Path)
$directory = Split-Path -Parent $Path
if (-not (Test-Path -LiteralPath $directory -PathType Container)) {
New-Item -ItemType Directory -Path $directory -Force | Out-Null
}
$temporary = Join-Path $directory ('.{0}.{1}.tmp' -f (Split-Path -Leaf $Path), [guid]::NewGuid().ToString('N'))
try {
$Value | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $temporary -Encoding utf8NoBOM
Move-Item -LiteralPath $temporary -Destination $Path -Force
}
finally {
if (Test-Path -LiteralPath $temporary) { Remove-Item -LiteralPath $temporary -Force }
}
}
if (-not (Test-Path -LiteralPath $StatusPath -PathType Leaf)) { throw "Health status not found: $StatusPath" }
$status = Get-Content -LiteralPath $StatusPath -Raw | ConvertFrom-Json
if ($status.version -ne 1 -or $status.overall -notin @('healthy', 'degraded')) { throw 'Unsupported health status document' }
$now = [DateTimeOffset]::UtcNow
$previous = $null
if (Test-Path -LiteralPath $StatePath -PathType Leaf) {
$previous = Get-Content -LiteralPath $StatePath -Raw | ConvertFrom-Json
}
$kind = $null
if ($Force) {
$kind = if ($status.overall -eq 'healthy') { 'recovered' } else { 'degraded' }
}
elseif ($status.overall -eq 'degraded') {
if ($null -eq $previous -or $previous.last_status -ne 'degraded') {
$kind = 'degraded'
}
elseif ($null -ne $previous.last_notification_at_utc) {
$lastNotification = if ($previous.last_notification_at_utc -is [DateTime]) {
[DateTimeOffset]$previous.last_notification_at_utc
}
else {
[DateTimeOffset]::Parse([string]$previous.last_notification_at_utc, [Globalization.CultureInfo]::InvariantCulture)
}
if (($now - $lastNotification).TotalHours -ge $ReminderHours) { $kind = 'reminder' }
}
}
elseif ($null -ne $previous -and $previous.last_status -eq 'degraded') {
$kind = 'recovered'
}
$lastNotificationAt = if ($null -ne $previous -and $null -ne $previous.last_notification_at_utc) {
([DateTimeOffset]$previous.last_notification_at_utc).ToString('o')
}
else { $null }
$lastNotificationKind = if ($null -ne $previous) { $previous.last_notification_kind } else { $null }
if ($null -ne $kind) {
$failedNames = @($status.checks | Where-Object { -not $_.ok } | ForEach-Object { [string]$_.name })
switch ($kind) {
'degraded' {
$title = 'Домовой: требуется внимание'
$body = if ($failedNames.Count -gt 0) { 'Сбой: ' + ($failedNames -join ', ') } else { 'Мониторинг обнаружил сбой.' }
$icon = 'Error'
}
'reminder' {
$title = 'Домовой: сбой продолжается'
$body = if ($failedNames.Count -gt 0) { 'Не исправлено: ' + ($failedNames -join ', ') } else { 'Состояние остается ухудшенным.' }
$icon = 'Warning'
}
default {
$title = 'Домовой: работа восстановлена'
$body = 'Все проверки снова проходят успешно.'
$icon = 'Info'
}
}
if (-not $NoDisplay) {
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$notification = [System.Windows.Forms.NotifyIcon]::new()
try {
$notification.Icon = switch ($icon) {
'Error' { [System.Drawing.SystemIcons]::Error }
'Warning' { [System.Drawing.SystemIcons]::Warning }
default { [System.Drawing.SystemIcons]::Information }
}
$notification.Visible = $true
$notification.BalloonTipIcon = [System.Enum]::Parse([System.Windows.Forms.ToolTipIcon], $icon)
$notification.BalloonTipTitle = $title
$notification.BalloonTipText = $body
$notification.ShowBalloonTip(8000)
Start-Sleep -Seconds 9
}
finally {
$notification.Dispose()
}
}
$lastNotificationAt = $now.ToString('o')
$lastNotificationKind = $kind
}
$state = [ordered]@{
version = 1
last_status = [string]$status.overall
last_observed_at_utc = $now.ToString('o')
last_notification_at_utc = $lastNotificationAt
last_notification_kind = $lastNotificationKind
}
Write-AtomicJson -Value $state -Path $StatePath
$result = if ($null -eq $kind) { 'suppressed' } elseif ($NoDisplay) { 'simulated' } else { 'sent' }
Write-Output "notification=$result status=$($status.overall) kind=$kind"
+115
View File
@@ -0,0 +1,115 @@
[CmdletBinding()]
param(
[string]$SshHost = 'docker',
[string]$RemoteBackupRoot = '/home/m/assistant-backups/postgres',
[string]$NasBackupRoot = '\\nas\MST\codex\_backups\domovoy\postgres',
[string]$KeyRecordPath = "$env:LOCALAPPDATA\Domovoy\postgres-backup-key.dpapi.json",
[string]$GpgPath = 'gpg.exe'
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
function Assert-SourceHashes([string]$Directory) {
$allowed = @('assistant.dump', 'globals.sql', 'database.name', 'owner.name')
$expected = @{}
foreach ($line in Get-Content -LiteralPath (Join-Path $Directory 'SHA256SUMS')) {
if ($line -notmatch '^([0-9a-f]{64}) ([A-Za-z0-9.]+)$' -or $matches[2] -notin $allowed) {
throw "Invalid SHA256SUMS entry"
}
$expected[$matches[2]] = $matches[1]
}
foreach ($name in $allowed) {
if (-not $expected.ContainsKey($name)) { throw "Missing SHA256SUMS entry: $name" }
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath (Join-Path $Directory $name)).Hash.ToLowerInvariant()
if ($actual -ne $expected[$name]) { throw "Source hash mismatch: $name" }
}
}
function Get-RecoveryPassphrase([string]$Path) {
if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { throw "DPAPI recovery key is missing" }
$record = Get-Content -LiteralPath $Path -Raw | ConvertFrom-Json
if ($record.version -ne 1 -or [string]::IsNullOrWhiteSpace($record.protected_value)) { throw "Invalid DPAPI recovery key record" }
$secure = ConvertTo-SecureString -String $record.protected_value
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try { return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) }
}
$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())
$work = Join-Path $tempRoot ("domovoy-backup-sync-" + [guid]::NewGuid().ToString('N'))
if (-not ([IO.Path]::GetFullPath($work)).StartsWith($tempRoot, [StringComparison]::OrdinalIgnoreCase)) { throw 'Unsafe temporary path' }
New-Item -ItemType Directory -Path $work | Out-Null
$passphrase = $null
$cipherPartial = $null
$manifestPartial = $null
try {
$latest = ((& ssh.exe $SshHost "find '$RemoteBackupRoot' -mindepth 1 -maxdepth 1 -type d ! -name '.*' -printf '%f\n' | sort | tail -n1") -join '').Trim()
if ($LASTEXITCODE -ne 0 -or $latest -notmatch '^\d{8}T\d{6}Z$') { throw 'No valid completed production backup found' }
New-Item -ItemType Directory -Force -Path $NasBackupRoot | Out-Null
$cipherPath = Join-Path $NasBackupRoot "$latest.tar.gz.gpg"
$manifestPath = Join-Path $NasBackupRoot "$latest.json"
if ((Test-Path -LiteralPath $cipherPath) -xor (Test-Path -LiteralPath $manifestPath)) {
# Neither lone file is a completed backup. Remove only this exact incomplete pair before retry.
Remove-Item -LiteralPath $cipherPath, $manifestPath -Force -ErrorAction SilentlyContinue
}
if ((Test-Path -LiteralPath $cipherPath) -or (Test-Path -LiteralPath $manifestPath)) {
if (-not ((Test-Path -LiteralPath $cipherPath -PathType Leaf) -and (Test-Path -LiteralPath $manifestPath -PathType Leaf))) { throw 'Incomplete existing NAS artifact' }
$existing = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
$actualCipherHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $cipherPath).Hash.ToLowerInvariant()
if ($existing.source_backup -ne $latest -or $existing.ciphertext_sha256 -ne $actualCipherHash) { throw 'Existing NAS artifact does not match its manifest' }
Write-Output "Off-host backup already current: $latest"
return
}
& scp.exe -q -r "${SshHost}:${RemoteBackupRoot}/${latest}" $work
if ($LASTEXITCODE -ne 0) { throw 'SCP backup copy failed' }
$sourceDirectory = Join-Path $work $latest
Assert-SourceHashes $sourceDirectory
$archive = Join-Path $work "$latest.tar.gz"
& tar.exe -czf $archive -C $work $latest
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $archive -PathType Leaf)) { throw 'Archive creation failed' }
$archiveHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant()
$passphrase = Get-RecoveryPassphrase $KeyRecordPath
$passphraseFile = Join-Path $work 'passphrase.txt'
[IO.File]::WriteAllText($passphraseFile, $passphrase, [Text.UTF8Encoding]::new($false))
& icacls.exe $work /inheritance:r /grant:r "$([Security.Principal.WindowsIdentity]::GetCurrent().Name):(OI)(CI)F" | Out-Null
if ($LASTEXITCODE -ne 0) { throw 'Temporary ACL hardening failed' }
$cipherPartial = Join-Path $NasBackupRoot (".$latest.$PID.gpg.partial")
$manifestPartial = Join-Path $NasBackupRoot (".$latest.$PID.json.partial")
& $GpgPath --batch --yes --pinentry-mode loopback --passphrase-file $passphraseFile --symmetric --cipher-algo AES256 --s2k-digest-algo SHA512 --s2k-cipher-algo AES256 --s2k-count 65011712 --compress-algo none --output $cipherPartial $archive
if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $cipherPartial -PathType Leaf)) { throw 'GnuPG encryption failed' }
$roundTrip = Join-Path $work 'roundtrip.tar.gz'
& $GpgPath --batch --yes --pinentry-mode loopback --passphrase-file $passphraseFile --decrypt --output $roundTrip $cipherPartial
if ($LASTEXITCODE -ne 0) { throw 'GnuPG round-trip decryption failed' }
if ((Get-FileHash -Algorithm SHA256 -LiteralPath $roundTrip).Hash.ToLowerInvariant() -ne $archiveHash) { throw 'Encrypted round-trip archive hash mismatch' }
$manifest = [ordered]@{
version = 1
project = 'domovoy'
source_host = 'docker.cin.su'
source_backup = $latest
source_sha256sums_sha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath (Join-Path $sourceDirectory 'SHA256SUMS')).Hash.ToLowerInvariant()
archive_sha256 = $archiveHash
ciphertext_sha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $cipherPartial).Hash.ToLowerInvariant()
encryption = 'GnuPG symmetric AES256, SHA512 S2K'
created_at_utc = [DateTime]::UtcNow.ToString('o')
}
[IO.File]::WriteAllText($manifestPartial, ($manifest | ConvertTo-Json) + "`n", [Text.UTF8Encoding]::new($false))
Move-Item -LiteralPath $cipherPartial -Destination $cipherPath
Move-Item -LiteralPath $manifestPartial -Destination $manifestPath
Write-Output "Off-host backup created: $latest"
}
finally {
$passphrase = $null
foreach ($partial in @($cipherPartial, $manifestPartial)) {
if ($partial -and (Test-Path -LiteralPath $partial)) { Remove-Item -LiteralPath $partial -Force }
}
if (Test-Path -LiteralPath $work) { Remove-Item -LiteralPath $work -Recurse -Force }
}
@@ -0,0 +1,153 @@
[CmdletBinding()]
param(
[string]$DockerContext = 'docker-prod',
[string]$SshHost = 'docker',
[string]$Endpoint = 'https://assistent.cin.su/healthz',
[string]$RemoteBackupRoot = '/home/m/assistant-backups/postgres',
[string]$NasBackupRoot = '\\nas\MST\codex\_backups\domovoy\postgres',
[string]$NasStatusPath = '\\nas\MST\codex\_monitoring\domovoy\status.json',
[string]$LocalStatusPath = "$env:LOCALAPPDATA\Domovoy\monitoring\status.json",
[double]$MaxProductionBackupAgeHours = 30,
[double]$MaxNasBackupAgeHours = 36,
[int]$MinimumCertificateDays = 21,
[string[]]$ExpectedContainers = @(
'assistant-core-runtime-1',
'assistant-creator-web-1',
'assistant-commit-runtime-1',
'assistant-continuity-runtime-1',
'assistant-cognitive-worker-1',
'assistant-postgres-1',
'assistant-nats-1',
'assistant-gitea-runner'
)
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$checks = [Collections.Generic.List[object]]::new()
function Add-Check([string]$Name, [bool]$Ok, [string]$Detail) {
$checks.Add([ordered]@{ name = $Name; ok = $Ok; detail = $Detail })
}
function Write-AtomicJson([string]$Path, [string]$Json) {
$directory = Split-Path -Parent $Path
New-Item -ItemType Directory -Force -Path $directory | Out-Null
$partial = Join-Path $directory ('.' + [IO.Path]::GetFileName($Path) + ".${PID}.partial")
try {
[IO.File]::WriteAllText($partial, $Json + "`n", [Text.UTF8Encoding]::new($false))
Move-Item -LiteralPath $partial -Destination $Path -Force
}
finally {
if (Test-Path -LiteralPath $partial) { Remove-Item -LiteralPath $partial -Force }
}
}
foreach ($container in $ExpectedContainers) {
try {
$raw = ((& docker.exe --context $DockerContext inspect $container --format '{{json .State}}') -join '').Trim()
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($raw)) { throw 'inspect failed' }
$state = $raw | ConvertFrom-Json
$ok = $state.Status -eq 'running'
$detail = "status=$($state.Status)"
if ($state.PSObject.Properties.Name -contains 'Health' -and $null -ne $state.Health) {
$ok = $ok -and $state.Health.Status -eq 'healthy'
$detail += " health=$($state.Health.Status)"
}
Add-Check "container:$container" $ok $detail
}
catch { Add-Check "container:$container" $false $_.Exception.Message }
}
try {
$response = Invoke-RestMethod -Uri $Endpoint -TimeoutSec 15
$ok = $response.status -eq 'ok'
Add-Check 'https-health' $ok "status=$($response.status) runtime=$($response.runtime)"
}
catch { Add-Check 'https-health' $false $_.Exception.Message }
try {
$uri = [Uri]$Endpoint
$tcp = [Net.Sockets.TcpClient]::new()
try {
$tcp.Connect($uri.Host, 443)
$ssl = [Net.Security.SslStream]::new($tcp.GetStream(), $false)
try {
$ssl.AuthenticateAsClient($uri.Host)
$certificate = [Security.Cryptography.X509Certificates.X509Certificate2]::new($ssl.RemoteCertificate)
$days = [math]::Floor(($certificate.NotAfter.ToUniversalTime() - [DateTime]::UtcNow).TotalDays)
Add-Check 'tls-certificate' ($days -ge $MinimumCertificateDays) "expires=$($certificate.NotAfter.ToUniversalTime().ToString('o')) days=$days"
}
finally { $ssl.Dispose() }
}
finally { $tcp.Dispose() }
}
catch { Add-Check 'tls-certificate' $false $_.Exception.Message }
try {
$assistantAddresses = @(Resolve-DnsName assistent.cin.su -Server 8.8.8.8 -Type A -DnsOnly | Where-Object Type -eq A | Select-Object -ExpandProperty IPAddress | Sort-Object -Unique)
$dockerAddresses = @(Resolve-DnsName docker.cin.su -Server 8.8.8.8 -Type A -DnsOnly | Where-Object Type -eq A | Select-Object -ExpandProperty IPAddress | Sort-Object -Unique)
$same = $assistantAddresses.Count -gt 0 -and $dockerAddresses.Count -gt 0 -and @(Compare-Object $assistantAddresses $dockerAddresses).Count -eq 0
Add-Check 'public-dns' $same "assistent=$($assistantAddresses -join ',') docker=$($dockerAddresses -join ',')"
}
catch { Add-Check 'public-dns' $false $_.Exception.Message }
try {
$latestProduction = ((& ssh.exe $SshHost "find '$RemoteBackupRoot' -mindepth 1 -maxdepth 1 -type d ! -name '.*' -printf '%f\n' | sort | tail -n1") -join '').Trim()
if ($LASTEXITCODE -ne 0 -or $latestProduction -notmatch '^\d{8}T\d{6}Z$') { throw 'invalid latest production backup' }
$productionTime = [DateTime]::ParseExact($latestProduction, "yyyyMMdd'T'HHmmss'Z'", [Globalization.CultureInfo]::InvariantCulture, [Globalization.DateTimeStyles]::AssumeUniversal -bor [Globalization.DateTimeStyles]::AdjustToUniversal)
$age = ([DateTime]::UtcNow - $productionTime).TotalHours
$verify = (& ssh.exe $SshHost "cd '$RemoteBackupRoot/$latestProduction' && sha256sum -c SHA256SUMS") -join '; '
if ($LASTEXITCODE -ne 0) { throw 'production backup hash verification failed' }
Add-Check 'production-backup' ($age -le $MaxProductionBackupAgeHours) ("backup=$latestProduction age_hours={0:N2} hashes=ok" -f $age)
}
catch { Add-Check 'production-backup' $false $_.Exception.Message }
try {
$manifestFile = Get-ChildItem -LiteralPath $NasBackupRoot -Filter '*.json' -File | Sort-Object BaseName | Select-Object -Last 1
if (-not $manifestFile -or $manifestFile.BaseName -notmatch '^\d{8}T\d{6}Z$') { throw 'invalid latest NAS backup manifest' }
$manifest = Get-Content -LiteralPath $manifestFile.FullName -Raw | ConvertFrom-Json
$nasTime = [DateTime]::ParseExact($manifestFile.BaseName, "yyyyMMdd'T'HHmmss'Z'", [Globalization.CultureInfo]::InvariantCulture, [Globalization.DateTimeStyles]::AssumeUniversal -bor [Globalization.DateTimeStyles]::AdjustToUniversal)
$age = ([DateTime]::UtcNow - $nasTime).TotalHours
$cipher = Join-Path $NasBackupRoot "$($manifestFile.BaseName).tar.gz.gpg"
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $cipher).Hash.ToLowerInvariant()
$ok = $hash -eq $manifest.ciphertext_sha256 -and $age -le $MaxNasBackupAgeHours
Add-Check 'nas-backup' $ok ("backup=$($manifestFile.BaseName) age_hours={0:N2} ciphertext_hash={1}" -f $age, $(if ($hash -eq $manifest.ciphertext_sha256) { 'ok' } else { 'mismatch' }))
}
catch { Add-Check 'nas-backup' $false $_.Exception.Message }
try {
$cron = ((& ssh.exe $SshHost "systemctl is-active cron && crontab -l | grep -F '/home/m/assistant-ops/backup-postgres.sh'") -join '; ').Trim()
Add-Check 'production-backup-cron' ($LASTEXITCODE -eq 0 -and $cron -match '^active') $cron
}
catch { Add-Check 'production-backup-cron' $false $_.Exception.Message }
try {
$backupTask = Get-ScheduledTask -TaskName 'Domovoy PostgreSQL Off-host Backup'
$backupInfo = Get-ScheduledTaskInfo -TaskName $backupTask.TaskName
$ok = $backupTask.State -ne 'Disabled' -and $backupInfo.LastTaskResult -eq 0
Add-Check 'offhost-backup-task' $ok "state=$($backupTask.State) last_result=$($backupInfo.LastTaskResult) next=$($backupInfo.NextRunTime.ToString('o'))"
}
catch { Add-Check 'offhost-backup-task' $false $_.Exception.Message }
$overall = if (@($checks | Where-Object { -not $_.ok }).Count -eq 0) { 'healthy' } else { 'degraded' }
$record = [ordered]@{
version = 1
project = 'domovoy'
observed_at_utc = [DateTime]::UtcNow.ToString('o')
overall = $overall
checks = $checks
}
$json = $record | ConvertTo-Json -Depth 6
Write-AtomicJson $LocalStatusPath $json
try { Write-AtomicJson $NasStatusPath $json }
catch {
Add-Check 'nas-status-publication' $false $_.Exception.Message
$record.overall = 'degraded'
$record.checks = $checks
Write-AtomicJson $LocalStatusPath ($record | ConvertTo-Json -Depth 6)
$overall = 'degraded'
}
Write-Output "Domovoy production health: $overall"
if ($overall -ne 'healthy') { exit 1 }
@@ -0,0 +1,75 @@
[CmdletBinding()]
param(
[string]$NasBackupRoot = '\\nas\MST\codex\_backups\domovoy\postgres',
[string]$KeyRecordPath = "$env:LOCALAPPDATA\Domovoy\postgres-backup-key.dpapi.json",
[string]$GpgPath = 'gpg.exe',
[string]$SshHost = 'docker',
[switch]$VerifyRemoteRestore
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
function Get-RecoveryPassphrase([string]$Path) {
$record = Get-Content -LiteralPath $Path -Raw | ConvertFrom-Json
if ($record.version -ne 1 -or [string]::IsNullOrWhiteSpace($record.protected_value)) { throw 'Invalid DPAPI recovery key record' }
$secure = ConvertTo-SecureString -String $record.protected_value
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try { return [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) }
}
$manifestFile = Get-ChildItem -LiteralPath $NasBackupRoot -Filter '*.json' -File | Sort-Object BaseName | Select-Object -Last 1
if (-not $manifestFile -or $manifestFile.BaseName -notmatch '^\d{8}T\d{6}Z$') { throw 'No valid NAS backup manifest found' }
$manifest = Get-Content -LiteralPath $manifestFile.FullName -Raw | ConvertFrom-Json
$latest = $manifestFile.BaseName
$cipherPath = Join-Path $NasBackupRoot "$latest.tar.gz.gpg"
if ((Get-FileHash -Algorithm SHA256 -LiteralPath $cipherPath).Hash.ToLowerInvariant() -ne $manifest.ciphertext_sha256) { throw 'NAS ciphertext hash mismatch' }
$tempRoot = [IO.Path]::GetFullPath([IO.Path]::GetTempPath())
$work = Join-Path $tempRoot ("domovoy-backup-test-" + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $work | Out-Null
$passphrase = $null
$remoteCheck = $null
try {
& icacls.exe $work /inheritance:r /grant:r "$([Security.Principal.WindowsIdentity]::GetCurrent().Name):(OI)(CI)F" | Out-Null
if ($LASTEXITCODE -ne 0) { throw 'Temporary ACL hardening failed' }
$passphrase = Get-RecoveryPassphrase $KeyRecordPath
$passphraseFile = Join-Path $work 'passphrase.txt'
[IO.File]::WriteAllText($passphraseFile, $passphrase, [Text.UTF8Encoding]::new($false))
$archive = Join-Path $work "$latest.tar.gz"
& $GpgPath --batch --yes --pinentry-mode loopback --passphrase-file $passphraseFile --decrypt --output $archive $cipherPath
if ($LASTEXITCODE -ne 0) { throw 'NAS backup decryption failed' }
if ((Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant() -ne $manifest.archive_sha256) { throw 'Decrypted archive hash mismatch' }
& tar.exe -xzf $archive -C $work
if ($LASTEXITCODE -ne 0) { throw 'Decrypted archive extraction failed' }
$sourceDirectory = Join-Path $work $latest
Push-Location $sourceDirectory
try {
foreach ($line in Get-Content -LiteralPath 'SHA256SUMS') {
if ($line -notmatch '^([0-9a-f]{64}) ([A-Za-z0-9.]+)$') { throw 'Invalid decrypted SHA256SUMS' }
if ((Get-FileHash -Algorithm SHA256 -LiteralPath $matches[2]).Hash.ToLowerInvariant() -ne $matches[1]) { throw "Decrypted file hash mismatch: $($matches[2])" }
}
}
finally { Pop-Location }
if ($VerifyRemoteRestore) {
$remoteCheck = "/home/m/assistant-backups/offhost-restore-check/$latest-$([guid]::NewGuid().ToString('N'))"
if ($remoteCheck -notmatch '^/home/m/assistant-backups/offhost-restore-check/\d{8}T\d{6}Z-[0-9a-f]{32}$') { throw 'Unsafe remote restore path' }
& ssh.exe $SshHost "mkdir -p '$remoteCheck'"
if ($LASTEXITCODE -ne 0) { throw 'Remote restore-check directory creation failed' }
& scp.exe -q -r "$sourceDirectory\*" "${SshHost}:${remoteCheck}/"
if ($LASTEXITCODE -ne 0) { throw 'Remote restore-check copy failed' }
& ssh.exe $SshHost "/home/m/assistant-ops/verify-postgres-restore.sh '$remoteCheck'"
if ($LASTEXITCODE -ne 0) { throw 'Remote PostgreSQL restore check failed' }
}
Write-Output "Off-host backup verified: $latest"
}
finally {
if ($remoteCheck -and $remoteCheck -match '^/home/m/assistant-backups/offhost-restore-check/\d{8}T\d{6}Z-[0-9a-f]{32}$') {
& ssh.exe $SshHost "rm -rf -- '$remoteCheck'" | Out-Null
}
$passphrase = $null
if (Test-Path -LiteralPath $work) { Remove-Item -LiteralPath $work -Recurse -Force }
}
+2 -2
View File
@@ -1,5 +1,5 @@
{
"task_file": "dev/tasks/DEV-000036-creator-secret-files.json",
"task_id": "DEV-000036",
"task_file": "dev/tasks/DEV-000039-production-health-notifications.json",
"task_id": "DEV-000039",
"task_revision": 1
}
@@ -0,0 +1,85 @@
{
"task_id": "DEV-000037",
"task_revision": 1,
"architecture_revision": "ADR-0004",
"base_repo_revision": "03dde8c1961f214fbb5ebdefa131eb38fd0bef57",
"risk_tier": "E",
"intent": "Replicate verified production PostgreSQL backups to the private NAS as authenticated encrypted artifacts, with a DPAPI-protected recovery key and tested restore path, without using docker-test.",
"requirement_ids": ["CONSTITUTION-1.3.36", "USER-DOCKER-PROD-ONLY"],
"allowed_change_scope": {
"modules": [],
"paths": [
"deploy/windows/Sync-PostgresBackupToNas.ps1",
"deploy/windows/Test-PostgresBackupFromNas.ps1",
"deploy/windows/Register-PostgresBackupNasTask.ps1",
"docs/CREDENTIALS_AND_SECRETS.md",
"docs/DEPLOYMENT.md",
"dev/ACTIVE_TASK.json",
"dev/tasks/DEV-000037-encrypted-offhost-backup.json"
]
},
"forbidden_change_scope": {
"paths": [
"architecture/**",
"ci/**",
".gitea/**",
"cmd/**",
"contracts/**",
"modules/**",
"database/**",
"security/**",
"deploy/docker-compose*.yml"
]
},
"allowed_architecture_delta": {
"new_cross_module_dependencies": 0,
"new_canonical_owners": 0,
"new_privileges": 0,
"new_operator_dependencies": 1
},
"dependencies": {
"operator": ["GnuPG 2.4+ already installed on the authorized Windows backup workstation"]
},
"contracts": {
"consume": ["DEV-000035 verified PostgreSQL backup directory", "SSH key to docker.cin.su", "authenticated NAS session", "Windows DPAPI CurrentUser"],
"may_change": []
},
"semantic_owner": "none; disaster-recovery transport only",
"canonical_state": ["none; backup artifacts are exported recovery copies"],
"state_transitions": ["verified local backup -> encrypted off-host copy -> decrypt-and-restore verified copy"],
"side_effects_and_privileges": ["reads completed production backup artifacts over SSH", "writes encrypted artifacts to the private NAS", "stores a random recovery passphrase as CurrentUser DPAPI ciphertext outside Git", "registers a current-user scheduled task"],
"persistence_and_migrations": ["no database migration", "encrypted .gpg artifact plus non-secret JSON manifest on NAS", "no automatic deletion or retention policy"],
"failure_retry_restart": ["NAS completion is indicated only after ciphertext and manifest are atomically renamed", "existing matching artifacts are idempotently retained", "temporary plaintext is confined to a validated per-run Windows temp directory and removed on exit", "scheduled retries run at logon and daily", "failed remote restore checks remove only their generated temporary directory"],
"assumptions": [
"The authorized Windows user retains access to both the SSH alias docker and the private NAS share",
"GnuPG 2.4+ remains installed on that workstation",
"The DPAPI profile and NAS are independent from the production Docker host",
"docker-test remains prohibited"
],
"acceptance_scenarios": [
"the latest completed production backup is copied and source hashes are checked before encryption",
"NAS contains ciphertext and a non-secret manifest but no plaintext PostgreSQL dump",
"the recovery passphrase is random and stored only as DPAPI ciphertext outside the repository",
"ciphertext decrypts and reproduces the source archive hash",
"the decrypted off-host copy passes SHA-256 checks and an isolated PostgreSQL restore on docker.cin.su",
"daily and logon triggers are registered for the current user",
"no backup is automatically deleted",
"exact diff validation observes only declared paths"
],
"required_tests": [
"PowerShell parser",
"architecture preflight",
"exact diff scope",
"source SHA-256 validation",
"GnuPG encrypt/decrypt round trip",
"NAS ciphertext hash validation",
"isolated restore from decrypted NAS artifact",
"scheduled task registration and manual invocation",
"production health",
"CI"
],
"terminal_gap_states": [
"BLOCKED_BY_MISSING_CAPABILITY",
"BLOCKED_BY_CONFLICT"
]
}
@@ -0,0 +1,81 @@
{
"task_id": "DEV-000038",
"task_revision": 1,
"architecture_revision": "ADR-0004",
"base_repo_revision": "0a188ddafe24dc2b31271f0d47ac31baed1d237f",
"risk_tier": "E",
"intent": "Add an external production health monitor for Domovoy containers, HTTPS certificate, public DNS, verified backups, and scheduled jobs without creating canonical Monitor semantics or using docker-test.",
"requirement_ids": ["CONSTITUTION-1.3.11", "CONSTITUTION-1.3.31", "USER-DOCKER-PROD-ONLY"],
"allowed_change_scope": {
"modules": [],
"paths": [
"deploy/windows/Test-DomovoyProductionHealth.ps1",
"deploy/windows/Register-DomovoyProductionHealthTask.ps1",
"docs/DEPLOYMENT.md",
"dev/ACTIVE_TASK.json",
"dev/tasks/DEV-000038-production-health-monitor.json"
]
},
"forbidden_change_scope": {
"paths": [
"architecture/**",
"ci/**",
".gitea/**",
"cmd/**",
"contracts/**",
"modules/**",
"database/**",
"security/**",
"deploy/docker-compose*.yml"
]
},
"allowed_architecture_delta": {
"new_cross_module_dependencies": 0,
"new_canonical_owners": 0,
"new_privileges": 0,
"new_third_party_dependencies": 0
},
"contracts": {
"consume": ["Docker read-only inspection", "HTTPS/TLS endpoint", "public DNS", "DEV-000035 backup manifest", "DEV-000037 NAS manifest", "Windows Scheduled Tasks"],
"may_change": []
},
"semantic_owner": "none; external rebuildable operational projection",
"canonical_state": ["none; status JSON is non-canonical and may be regenerated"],
"state_transitions": ["observed checks -> healthy or degraded operational snapshot"],
"side_effects_and_privileges": ["read-only inspection of production Docker and backup state", "atomic write of local and NAS status JSON", "registration of a current-user scheduled task"],
"persistence_and_migrations": ["no database migration", "latest status JSON only; no hidden retention deletion"],
"failure_retry_restart": ["checks are independent and record explicit failure details", "the monitor exits nonzero when any check fails", "local status remains available if NAS publication fails", "scheduled execution retries every 15 minutes and at logon"],
"assumptions": [
"The authorized Windows user retains Docker context docker-prod, SSH alias docker, public DNS, and NAS access",
"Production backup should be younger than 30 hours and off-host backup younger than 36 hours",
"TLS certificate should retain at least 21 days",
"docker-test remains prohibited"
],
"acceptance_scenarios": [
"all expected Assistant containers are running and health-enabled containers are healthy",
"HTTPS returns healthy and the certificate has at least 21 remaining days",
"public assistent.cin.su and docker.cin.su A records agree",
"production and NAS backups are recent and their hashes validate",
"backup scheduled tasks and production cron report success",
"status JSON is atomically published locally and to NAS",
"a failed check produces overall degraded and a nonzero exit code",
"monitor runs every 15 minutes and at logon",
"exact diff validation observes only declared paths"
],
"required_tests": [
"PowerShell parser",
"architecture preflight",
"exact diff scope",
"healthy live monitoring run",
"synthetic degraded run",
"atomic local and NAS status validation",
"scheduled task registration and manual invocation",
"go test",
"go vet",
"CI"
],
"terminal_gap_states": [
"BLOCKED_BY_MISSING_CAPABILITY",
"BLOCKED_BY_CONFLICT"
]
}
@@ -0,0 +1,79 @@
{
"task_id": "DEV-000039",
"task_revision": 1,
"architecture_revision": "ADR-0004",
"base_repo_revision": "4016820541229544aae81240cb2e12513fb2ce12",
"risk_tier": "E",
"intent": "Add transition-aware local Windows notifications to the external Domovoy production health monitor without external services, canonical Monitor semantics, or docker-test.",
"requirement_ids": ["CONSTITUTION-1.3.11", "CONSTITUTION-1.3.31", "USER-DOCKER-PROD-ONLY"],
"allowed_change_scope": {
"modules": [],
"paths": [
"deploy/windows/Send-DomovoyHealthNotification.ps1",
"deploy/windows/Invoke-DomovoyProductionMonitoring.ps1",
"deploy/windows/Register-DomovoyProductionHealthTask.ps1",
"docs/DEPLOYMENT.md",
"dev/ACTIVE_TASK.json",
"dev/tasks/DEV-000039-production-health-notifications.json"
]
},
"forbidden_change_scope": {
"paths": [
"architecture/**",
"ci/**",
".gitea/**",
"cmd/**",
"contracts/**",
"modules/**",
"database/**",
"security/**",
"deploy/docker-compose*.yml"
]
},
"allowed_architecture_delta": {
"new_cross_module_dependencies": 0,
"new_canonical_owners": 0,
"new_privileges": 0,
"new_third_party_dependencies": 0
},
"contracts": {
"consume": ["DEV-000038 local production health status JSON", "Windows interactive notification area", "Windows Scheduled Tasks"],
"may_change": []
},
"semantic_owner": "none; external rebuildable operational projection",
"canonical_state": ["none; notification suppression state is non-canonical and may be regenerated"],
"state_transitions": ["first degraded observation -> degraded notification", "healthy to degraded -> degraded notification", "degraded to healthy -> recovery notification", "continued degraded after reminder interval -> reminder notification"],
"side_effects_and_privileges": ["display a local Windows notification for the current interactive user", "atomically write local non-canonical notification state", "update the current-user scheduled task action"],
"persistence_and_migrations": ["no database migration", "single local notification state JSON; no history or retention deletion"],
"failure_retry_restart": ["health collection runs in a child process and publishes status before notification evaluation", "duplicate degraded observations are suppressed for six hours", "notification failure is distinct from health degradation", "the scheduled task returns the health exit code unless notification delivery itself fails"],
"assumptions": [
"The scheduled task runs for an interactive Windows user so notification balloons are visible",
"The DEV-000038 status schema remains version 1 with overall and checks fields",
"Local notification state is not authoritative and can be deleted safely",
"docker-test remains prohibited"
],
"acceptance_scenarios": [
"an initial healthy observation records state without notifying",
"a transition to degraded sends one notification naming failed checks",
"a repeated degraded observation within six hours is suppressed",
"a transition back to healthy sends one recovery notification",
"the wrapper evaluates notifications even when the health child exits nonzero",
"the registered task invokes the wrapper every 15 minutes and at logon",
"exact diff validation observes only declared paths"
],
"required_tests": [
"PowerShell parser",
"architecture preflight",
"exact diff scope",
"synthetic healthy/degraded/repeated/recovered notification transitions",
"healthy live wrapper run",
"scheduled task registration and manual invocation",
"go test",
"go vet",
"CI"
],
"terminal_gap_states": [
"BLOCKED_BY_MISSING_CAPABILITY",
"BLOCKED_BY_CONFLICT"
]
}
+2
View File
@@ -22,3 +22,5 @@ Do not guess Portainer credentials and do not search other project source trees
Each privileged runtime gets only its required secret/capability bindings. `commit-runtime` is intentionally isolated from the general Core Runtime.
Creator authentication secrets are stored in the external Docker volume `assistant_core_secrets` and mounted read-only only at `/run/secrets` in `core-runtime`. The production container environment contains `_FILE` paths, not the secret values. Files are owned by runtime uid 100/gid 101 with mode 0400. `CREATOR_USERNAME` is not secret and remains an environment value. Development may continue to use direct environment values, but a direct value and its matching `_FILE` setting must never be configured together.
The PostgreSQL off-host backup passphrase is generated randomly and stored as CurrentUser DPAPI ciphertext at `%LOCALAPPDATA%\Domovoy\postgres-backup-key.dpapi.json`. An atomic copy of that DPAPI ciphertext, never the plaintext passphrase, is retained at `\\nas\MST\codex\_backups\domovoy\keys\postgres-backup-key.dpapi.json`. The passphrase is never stored in Git, the production Docker host, a scheduled-task argument, or NAS plaintext. The NAS backup directory receives only GnuPG AES-256 ciphertext and a non-secret integrity manifest. Recovery therefore requires both the NAS artifacts and the authorized Windows DPAPI profile.
+14
View File
@@ -27,3 +27,17 @@ Production backups run only on `docker.cin.su`; this project must not use the sh
`deploy/verify-postgres-restore.sh <backup-directory>` verifies all hashes and restores into an isolated PostgreSQL 18.6 container backed by tmpfs. It never mounts or writes `assistant_assistant_pg`, and removes its temporary container on exit. A backup is operationally accepted only after this restore check passes.
The production user crontab installs the single entry from `deploy/cron/assistant-postgres-backup.crontab`. It runs the backup and restore check daily at 00:15 UTC (03:15 Europe/Moscow), survives host reboot without a persistent login session, and writes a private operational log beside the backups.
## Encrypted off-host backup
`deploy/windows/Sync-PostgresBackupToNas.ps1` copies only a completed, hash-verified production backup over SSH, archives it locally, encrypts it with GnuPG AES-256, verifies an immediate decrypt round trip, and atomically publishes ciphertext plus a non-secret manifest under `\\nas\MST\codex\_backups\domovoy\postgres`. Temporary plaintext is removed on exit. The script is idempotent and never deletes existing backups.
`deploy/windows/Test-PostgresBackupFromNas.ps1 -VerifyRemoteRestore` verifies the NAS ciphertext hash, decrypts it with the DPAPI-protected recovery key, checks every source hash, and performs a full isolated PostgreSQL restore on `docker.cin.su`. `deploy/windows/Register-PostgresBackupNasTask.ps1` generates the key when absent, atomically backs up only its DPAPI ciphertext to the NAS, and registers current-user daily and logon triggers. The task intentionally does not use `docker-test`.
## Production health monitoring
`deploy/windows/Test-DomovoyProductionHealth.ps1` is an external, rebuildable operational projection; it is not a canonical Core `Monitor`. It checks all expected production containers, HTTPS health, TLS expiry, public DNS agreement, production backup age and hashes, NAS backup age and ciphertext hash, cron, and the off-host backup task. Thresholds are 30 hours for the production backup, 36 hours for the NAS copy, and 21 remaining certificate days.
The script atomically writes the latest JSON snapshot to `%LOCALAPPDATA%\Domovoy\monitoring\status.json` and `\\nas\MST\codex\_monitoring\domovoy\status.json`, then exits nonzero when any check is degraded. `deploy/windows/Register-DomovoyProductionHealthTask.ps1` registers a current-user execution every 15 minutes and at logon. Monitoring never uses `docker-test` and never mutates product state.
`deploy/windows/Invoke-DomovoyProductionMonitoring.ps1` runs health collection in a child process and then evaluates `deploy/windows/Send-DomovoyHealthNotification.ps1`, including when health is degraded. The notifier shows a local Windows notification on the first degraded observation, recovery, and no more than one continuing-failure reminder per six hours. Its suppression state is an external, non-canonical JSON file at `%LOCALAPPDATA%\Domovoy\monitoring\notification-state.json` and may be regenerated. Notifications require the registered user to have an interactive Windows session; no external notification service or credential is used.