Skip awake rumination during sleep
This commit is contained in:
parent
c671ecd081
commit
574c340933
8 changed files with 131 additions and 5 deletions
|
|
@ -295,6 +295,13 @@ function Convert-ToOperationArray {
|
|||
return @($Value)
|
||||
}
|
||||
|
||||
function Test-OpenCaseRequiresRumination {
|
||||
param($Case)
|
||||
|
||||
$status = Get-ObjectPropertyString -Value $Case -Name "status"
|
||||
return $null -ne $status -and -not @("answered", "resolved", "closed", "retired", "dropped").Contains($status)
|
||||
}
|
||||
|
||||
function Assert-AllowedRuminationOperation {
|
||||
param($Operation)
|
||||
|
||||
|
|
@ -602,6 +609,35 @@ Write-JsonFile -Path $contextPath -Data @{
|
|||
repoActivity = Select-RuminationRepoActivity -RepoActivity $repoActivity -Now $startedAtUtc
|
||||
}
|
||||
|
||||
$isNapping = [bool](Get-ObjectPropertyValue -Value $typedState.scheduledRuntime.sleepCycle -Name "isNapping")
|
||||
$openCaseCount = @(
|
||||
@(Convert-ToValueArray -Value $typedState.moderationCursor.openCases) |
|
||||
Where-Object { Test-OpenCaseRequiresRumination -Case $_ }
|
||||
).Count
|
||||
if ($isNapping -and $messageCount -eq 0 -and $openCaseCount -eq 0) {
|
||||
Append-RunLog "napping: no new room messages or open cases; skipping awake rumination."
|
||||
Write-JsonFile -Path $operationOutputPath -Data @()
|
||||
$finishedAtUtc = [DateTime]::UtcNow
|
||||
Write-JsonFile -Path $statusPath -Data @{
|
||||
status = "skipped"
|
||||
reason = "napping_without_room_debt"
|
||||
startedAt = $startedAtUtc.ToString("o")
|
||||
finishedAt = $finishedAtUtc.ToString("o")
|
||||
durationSeconds = [Math]::Round(($finishedAtUtc - $startedAtUtc).TotalSeconds, 2)
|
||||
noPost = [bool]$NoPost
|
||||
skipModel = [bool]$SkipModel
|
||||
stateFile = [string]$stateFilePath
|
||||
contextPath = [string]$contextPath
|
||||
operationOutputPath = [string]$operationOutputPath
|
||||
observedMessageCount = [int]$messageCount
|
||||
openCaseCount = [int]$openCaseCount
|
||||
tracePath = [string]$tracePath
|
||||
lastMessagePath = [string]$lastMessagePath
|
||||
}
|
||||
Remove-Item -Path $lockPath -Force -ErrorAction SilentlyContinue
|
||||
return
|
||||
}
|
||||
|
||||
$stateWriteBefore = if (Test-Path $stateFilePath) { (Get-Item $stateFilePath).LastWriteTimeUtc } else { [DateTime]::MinValue }
|
||||
|
||||
$prompt = Read-TextFile -Path $promptTemplatePath
|
||||
|
|
|
|||
75
scripts/smoke-void-rumination-nap-skip-fixture.ps1
Normal file
75
scripts/smoke-void-rumination-nap-skip-fixture.ps1
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location -LiteralPath $repoRoot
|
||||
|
||||
$tempRoot = Join-Path $env:TEMP ("void-rumination-nap-skip-fixture-" + [guid]::NewGuid().ToString("n"))
|
||||
$stateFilePath = Join-Path $tempRoot "void-self-state.cc"
|
||||
$cursorOperationPath = Join-Path $tempRoot "cursor.json"
|
||||
$sleepOperationPath = Join-Path $tempRoot "sleep-cycle.json"
|
||||
$fixtureStatusDir = Join-Path $tempRoot "status"
|
||||
$fixtureLogDir = Join-Path $tempRoot "logs"
|
||||
$statusPath = Join-Path $fixtureStatusDir "moderation-rumination.json"
|
||||
$operationOutputPath = Join-Path $fixtureStatusDir "moderation-rumination-operations.json"
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $tempRoot | Out-Null
|
||||
|
||||
try {
|
||||
$cursorOperation = @{
|
||||
operation = "record_reviewed_messages"
|
||||
lastReviewedMessageId = "fixture-future-cursor"
|
||||
lastReviewedTimestamp = "2099-05-17T00:00:00.000Z"
|
||||
}
|
||||
$sleepOperation = @{
|
||||
operation = "update_sleep_cycle"
|
||||
sleepCycle = @{
|
||||
isNapping = $true
|
||||
currentNapStartedAt = "2026-05-17T03:00:00.000Z"
|
||||
currentNapEndsAt = "2099-05-17T04:00:00.000Z"
|
||||
nextNapStartsAt = "2099-05-17T07:00:00.000Z"
|
||||
activeDreamThemes = @("fixture-nap-skip")
|
||||
}
|
||||
}
|
||||
|
||||
$cursorOperation | ConvertTo-Json -Depth 32 | Set-Content -LiteralPath $cursorOperationPath -Encoding UTF8
|
||||
$sleepOperation | ConvertTo-Json -Depth 32 | Set-Content -LiteralPath $sleepOperationPath -Encoding UTF8
|
||||
node .\scripts\void-self-state.mjs apply-operation --canonical $stateFilePath --operation-file $cursorOperationPath | Out-Null
|
||||
node .\scripts\void-self-state.mjs apply-operation --canonical $stateFilePath --operation-file $sleepOperationPath | Out-Null
|
||||
|
||||
$previousCodexExecutable = $env:CODEX_EXECUTABLE
|
||||
$previousStatusDir = $env:VOID_RUMINATION_STATUS_DIR
|
||||
$previousLogDir = $env:VOID_RUMINATION_LOG_DIR
|
||||
|
||||
try {
|
||||
$env:CODEX_EXECUTABLE = "this-command-should-not-run-during-nap-skip"
|
||||
$env:VOID_RUMINATION_STATUS_DIR = $fixtureStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $fixtureLogDir
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\run-void-moderator-rumination.ps1 -StateFilePath $stateFilePath | Out-Null
|
||||
} finally {
|
||||
$env:CODEX_EXECUTABLE = $previousCodexExecutable
|
||||
$env:VOID_RUMINATION_STATUS_DIR = $previousStatusDir
|
||||
$env:VOID_RUMINATION_LOG_DIR = $previousLogDir
|
||||
}
|
||||
|
||||
$status = Get-Content -LiteralPath $statusPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
if ($status.status -ne "skipped" -or $status.reason -ne "napping_without_room_debt") {
|
||||
throw "Nap skip fixture expected skipped/napping_without_room_debt."
|
||||
}
|
||||
|
||||
$operations = Get-Content -LiteralPath $operationOutputPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
if (@($operations).Count -ne 0) {
|
||||
throw "Nap skip fixture expected no operation proposals."
|
||||
}
|
||||
|
||||
@{
|
||||
status = "ok"
|
||||
runnerStatus = $status.status
|
||||
reason = $status.reason
|
||||
proposedOperationCount = @($operations).Count
|
||||
} | ConvertTo-Json -Compress
|
||||
} finally {
|
||||
Remove-Item -LiteralPath $tempRoot -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Loading…
Reference in a new issue