Keep Face heartbeats from blocked maintenance
This commit is contained in:
parent
2469491f83
commit
01916cbc0f
2 changed files with 57 additions and 0 deletions
|
|
@ -355,6 +355,25 @@ try {
|
|||
if ($onlySet.Count -gt 0 -and -not $onlySet.ContainsKey($organ.Id.ToLowerInvariant())) {
|
||||
continue
|
||||
}
|
||||
$enabledConfigName = switch ($organ.Id) {
|
||||
"repo-face-memory-maintenance" { "REPO_FACE_MEMORY_MAINTENANCE_ENABLED"; break }
|
||||
"void-moderation-rumination" { "VOIDBOT_MODERATION_RUMINATION_ENABLED"; break }
|
||||
"voidbot-operations-watchdog" { "VOIDBOT_OPERATIONS_WATCHDOG_ENABLED"; break }
|
||||
default { $null }
|
||||
}
|
||||
if ($null -ne $enabledConfigName -and -not (Get-ConfigBool -Config $config -Name $enabledConfigName -Default $true)) {
|
||||
Set-OrganState -State $state -Id $organ.Id -Value ([pscustomobject]@{
|
||||
label = $organ.Label
|
||||
intervalMinutes = $organ.IntervalMinutes
|
||||
lastStartedAt = $now.ToString("o")
|
||||
lastFinishedAt = $now.ToString("o")
|
||||
lastExitCode = 0
|
||||
lastStatus = "skipped_disabled"
|
||||
lastLogPath = $null
|
||||
})
|
||||
Write-JsonFile -Path $statePath -Data $state
|
||||
continue
|
||||
}
|
||||
if ($organ.Id -eq "bifrost-dispatch" -and -not (Get-ConfigBool -Config $config -Name "BIFROST_DISPATCH_ENABLED" -Default $false)) {
|
||||
Set-OrganState -State $state -Id $organ.Id -Value ([pscustomobject]@{
|
||||
label = $organ.Label
|
||||
|
|
|
|||
|
|
@ -77,6 +77,40 @@ function Read-JsonFile {
|
|||
return $raw | ConvertFrom-Json
|
||||
}
|
||||
|
||||
function ConvertFrom-PossibleFencedJson {
|
||||
param([Parameter(Mandatory = $true)][string] $Text)
|
||||
|
||||
$trimmed = $Text.Trim()
|
||||
if ($trimmed.StartsWith('```')) {
|
||||
$match = [regex]::Match($trimmed, '(?s)^```(?:json)?\s*(?<json>.*?)\s*```')
|
||||
if ($match.Success) {
|
||||
$trimmed = $match.Groups['json'].Value.Trim()
|
||||
}
|
||||
}
|
||||
return $trimmed | ConvertFrom-Json
|
||||
}
|
||||
|
||||
function Restore-OperationOutputFromLastMessage {
|
||||
if ((Test-Path $operationOutputPath) -or -not (Test-Path $lastMessagePath)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
$lastMessage = Get-Content -Path $lastMessagePath -Raw -Encoding UTF8
|
||||
if ([string]::IsNullOrWhiteSpace($lastMessage)) {
|
||||
return $false
|
||||
}
|
||||
|
||||
try {
|
||||
$parsed = ConvertFrom-PossibleFencedJson -Text $lastMessage
|
||||
$operations = Convert-ToOperationArray -Value $parsed
|
||||
Write-JsonFile -Path $operationOutputPath -Data $operations
|
||||
Append-RunLog "restored operation output from final Codex message."
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Read-TextFile {
|
||||
param([Parameter(Mandatory = $true)][string] $Path)
|
||||
return Get-Content -Path $Path -Raw -Encoding UTF8
|
||||
|
|
@ -614,6 +648,10 @@ if ($exitCode -ne 0) {
|
|||
throw $(if ([string]::IsNullOrWhiteSpace($combinedText)) { "Codex memory maintenance failed with exit code $exitCode." } else { $combinedText })
|
||||
}
|
||||
|
||||
if (-not (Test-Path $operationOutputPath)) {
|
||||
[void](Restore-OperationOutputFromLastMessage)
|
||||
}
|
||||
|
||||
if (-not (Test-Path $operationOutputPath)) {
|
||||
throw "Memory maintenance completed without writing operation output at $operationOutputPath."
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue