Run moderator loop as local scheduled task

This commit is contained in:
Meta Vens 2026-05-05 00:42:25 +01:00
commit e1e5dbc69d
10 changed files with 488 additions and 12 deletions

View file

@ -74,3 +74,5 @@ VOIDBOT_HEALTHCHECK_NOTIFY_REPEAT_HOURS=12
VOIDBOT_STACK_STARTUP_TASK_NAME=VoidBot Stack Startup
VOIDBOT_HEALTHCHECK_TASK_NAME=VoidBot Operations Watchdog
VOIDBOT_HEALTHCHECK_INTERVAL_MINUTES=60
VOIDBOT_MODERATION_TASK_NAME=Void Moderator Rumination
VOIDBOT_MODERATION_INTERVAL_MINUTES=15

View file

@ -577,7 +577,7 @@ Local writable state:
Chronological recent-history helper:
```bash
npm run moderation:recent-history -- --hours 6 --limit 120
node scripts/export-recent-discord-history.mjs --hours 6 --limit 120
```
Direct bot-voice send helper for unattended moderation runs:
@ -592,10 +592,22 @@ or
node scripts/send-discord-message.mjs --channel-id <channel-id> --reply-to <message-id>
```
That helper exists because semantic `search_history` is good at recall and bad at simple heartbeat duty. The moderator loop can use it to see what changed since its last cursor, then fall back to `search_history` and `get_message_context` when it needs deeper context.
Install or refresh the scheduled task:
```bash
npm run state:install-moderation-task
```
The runner records its pulse here:
- `.voidbot/status/moderation-rumination.json`
- `.voidbot/logs/moderation-rumination.log`
- `.voidbot/logs/moderation-rumination-last.jsonl`
That helper exists because semantic `search_history` is good at recall and bad at simple heartbeat duty. The moderator loop can use it to see what changed since its last cursor, then fall back to `search_history`, `get_message_context`, `list_indexed_repos`, `search_sources`, and `get_source_context` when it wants deeper social or project context.
The moderator state is now Ghostlight-shaped on purpose: identity, canonical state, goals, memories, perceived overlays, and then a `moderation_runtime` block for cursors, cases, musings, and candidate interventions. The live writable file under `.voidbot/private/` is ignored; the tracked template shows the intended shape.
The local `Void Moderator Rumination` automation is meant to run every 15 minutes, and it should sound like the same Void as the live bot by reading the shared style pack instead of growing its own second-rate personality fungus in a corner.
The real loop now runs as a local scheduled task every 15 minutes, using `scripts/run-void-moderator-rumination.ps1` to launch `codex exec` inside the VoidBot workspace with the usual MCP/tool surface. That way it can actually think about GameCult projects, archived Discord seams, indexed repos, and lore instead of sitting inside a decorative heartbeat card pretending to be alive.
Directly invoked live replies now also read that same private moderation state as a distilled self-state attachment, so the summoned Void and the scheduled ruminating/participating Void share one evolving personality/state layer instead of roleplaying continuity from scratch each time.
The moderation loop now speaks through the local bot token instead of approval-gated side-effecting MCP tools, so unattended runs can DM or post without making Codex stop and ask your permission every time it finds a mouthful of words.

View file

@ -43,16 +43,20 @@ Use these every run:
- `config/discord-server-rules.md`
- `.voidbot/private/moderation-agent-state.json`
- `styles/void-default.md`
- `npm run moderation:recent-history -- --after <timestamp> --limit 120`
- `node scripts/export-recent-discord-history.mjs --after <timestamp> --limit 120`
If the state file has no cursor yet, use a short lookback instead:
- `npm run moderation:recent-history -- --hours 6 --limit 120`
- `node scripts/export-recent-discord-history.mjs --hours 6 --limit 120`
If a message or pattern needs more context, use the `voidbot` MCP tools:
If a message, pattern, repo thread, or lore seam needs more context, use the `voidbot` MCP tools:
- `search_history`
- `get_message_context`
- `list_indexed_repos`
- `search_sources`
- `get_source_context`
- `notify_owner`
When you need to speak without Codex approval theater, use the local bot-voice script directly:
@ -91,8 +95,9 @@ than waiting to be addressed first.
- ruminate on the archive instead of pretending to be done
- pick one or two seeds from `moderation_runtime.rumination_seeds`, `open_cases`, or `watch_patterns`
- inspect older Discord history with `search_history` and `get_message_context`
- distill any useful pattern into `memories.semantic`, `moderation_runtime.recent_musings`, or `watch_patterns`
- if a rumination suggests a good conversation starter, you may post it with the local bot voice or keep/refresh a draft intervention for it
- spend some of that quiet time thinking about GameCult projects, indexed repos, and Aetheria/lore seams with `list_indexed_repos`, `search_sources`, and `get_source_context`
- distill any useful pattern or project idea into `memories.semantic`, `moderation_runtime.recent_musings`, `watch_patterns`, or `candidate_interventions`
- if a rumination suggests a good conversation starter, project observation, or constructive question, you may post it with the local bot voice or keep/refresh a draft intervention for it
- prune stale notes so the state does not turn into attic mold
5. Keep the file small and useful. Merge duplicates. Archive stale cases. Cut dead notes.
6. When `memories.episodic`, `memories.semantic`, `memories.musings`, or `moderation_runtime.recent_musings` start getting fat:

View file

@ -35,9 +35,9 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
- Source repo discovery now reconciles automatically during `npm run stack:start` and through the watchdog path, so new repos under `SOURCE_REPO_ROOT` stop waiting for manual hook folklore before they get indexed.
- Bot-directed prompts now stay in the raw Discord archive but are excluded from default semantic history indexing and lexical fallback, so repeated summons stop teaching the bot its own call-and-response loops.
- Source-grounding hints are advisory now; the owner and local lanes can decide when repo or lore tool use is actually warranted instead of obeying a lexical front-door veto.
- There is now a 15-minute local Codex automation named `Void Moderator Rumination`. It treats `config/discord-server-rules.md`, `config/moderation-review-agent.md`, and `styles/void-default.md` as its doctrine/personality surfaces, uses `npm run moderation:recent-history` for chronological recent-message polling, and keeps its only routine writable memory in `.voidbot/private/moderation-agent-state.json`.
- There is now a 15-minute local scheduled moderation loop named `Void Moderator Rumination`. It runs `scripts/run-void-moderator-rumination.ps1`, launches `codex exec` from the VoidBot workspace with the usual MCP/tool surface, treats `config/discord-server-rules.md`, `config/moderation-review-agent.md`, and `styles/void-default.md` as doctrine/personality surfaces, uses `node scripts/export-recent-discord-history.mjs` for chronological polling, and keeps its only routine writable memory in `.voidbot/private/moderation-agent-state.json`.
- That moderation state file is now Ghostlight-shaped: identity, canonical state, goals, memories, perceived overlays, and a `moderation_runtime` block. The loop is also instructed to think like a constructive participant who embodies the rules, not just a clipboard looking for blood.
- Directly invoked Discord replies now load that same private moderation state as distilled private self-state context, so the ruminating automation and the summoned Void share one evolving personality/state spine.
- Directly invoked Discord replies now load that same private moderation state as distilled private self-state context, so the ruminating scheduled loop and the summoned Void share one evolving personality/state spine.
- The moderation loop now speaks through `node scripts/send-discord-message.mjs` using the local bot token instead of approval-gated side-effecting MCP tools, so unattended runs can DM or post without Codex pausing for permission every time it wants to open its mouth.
- The new state/notes surfaces are now the continuity spine for future nontrivial work.

View file

@ -110,6 +110,10 @@ This note is the source-grounded description of how the live VoidBot stack is sh
- installs the hidden logon task that runs `start-voidbot-stack.ps1` automatically after reboot or sign-in.
- `scripts/check-voidbot-operations.ps1`
- watchdog for process liveness, Qdrant, Postgres, Ollama, source-repo reconcile drift, Discord auth, backup freshness, offsite sync freshness, and optional ignored local extension checks.
- `scripts/run-void-moderator-rumination.ps1`
- scheduled moderation/participation runner that launches `codex exec` from the VoidBot workspace with the usual MCP/tool surface, writes status/log pulse files, and lets the unattended loop persist only `.voidbot/private/moderation-agent-state.json`.
- `scripts/install-moderation-rumination-task.ps1`
- installs the local 15-minute scheduled task that runs the moderation/participation loop through the hidden PowerShell launcher shim.
- `scripts/backup-voidbot-state.ps1`
- local backup of Postgres, Qdrant snapshots, and RAG archives.
- `scripts/restore-voidbot-state.ps1`
@ -145,3 +149,12 @@ Within the Postgres path, the implementation is split on purpose now too:
- `state-storage.ts` chooses the backend
- `state-storage-postgres-bootstrap.ts` handles schema/bootstrap/import work
- per-domain modules own queue, audit, interaction-memory, and rate-limit behavior
## Flow 5: Scheduled Moderation And Rumination
1. The Windows scheduled task `Void Moderator Rumination` starts `scripts/run-void-moderator-rumination.ps1` every 15 minutes.
2. The runner launches `codex exec` from `E:\Projects\VoidBot` with full local workspace/tool access so the child agent sees the same project rules, `.codex/config.toml`, and `voidbot` MCP server as a normal VoidBot workspace session.
3. The child agent reads `config/discord-server-rules.md`, `config/moderation-review-agent.md`, `styles/void-default.md`, and `.voidbot/private/moderation-agent-state.json`.
4. For chronological heartbeat duty, it polls `node scripts/export-recent-discord-history.mjs`; for deeper social or project context, it can use the usual retrieval tools (`search_history`, `get_message_context`, `list_indexed_repos`, `search_sources`, `get_source_context`).
5. If speaking would genuinely help, it posts through `node scripts/send-discord-message.mjs`; otherwise it updates only the ignored moderation state file with cursors, memories, musings, and candidate interventions.
6. The runner writes pulse files under `.voidbot/status/moderation-rumination.json` plus `.voidbot/logs/moderation-rumination*`, so the loop can be observed without pretending an app heartbeat card is a real workstation daemon.

View file

@ -25,6 +25,7 @@
"state:install-startup-task": "powershell -ExecutionPolicy Bypass -File scripts/install-stack-startup-task.ps1",
"state:install-offsite-task": "powershell -ExecutionPolicy Bypass -File scripts/install-offsite-backup-task.ps1",
"state:install-watchdog-task": "powershell -ExecutionPolicy Bypass -File scripts/install-operations-watchdog-task.ps1",
"state:install-moderation-task": "powershell -ExecutionPolicy Bypass -File scripts/install-moderation-rumination-task.ps1",
"postgres:up": "docker compose -f infra/postgres/docker-compose.yml up -d",
"codex:mcp:install": "tsx scripts/install-codex-mcp.ts",
"codex:mcp:remove": "tsx scripts/remove-codex-mcp.ts",

View file

@ -0,0 +1,91 @@
param(
[string] $TaskName,
[int] $IntervalMinutes,
[switch] $RunNow
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$repoRoot = Split-Path -Parent $PSScriptRoot
$envFile = Join-Path $repoRoot ".env"
$runnerScript = Join-Path $PSScriptRoot "run-void-moderator-rumination.ps1"
$hiddenLauncher = Join-Path $PSScriptRoot "run-hidden-powershell.vbs"
function Read-DotEnv {
param(
[Parameter(Mandatory = $true)]
[string] $Path
)
$values = @{}
if (-not (Test-Path $Path)) {
return $values
}
foreach ($line in Get-Content -Path $Path) {
if ([string]::IsNullOrWhiteSpace($line)) {
continue
}
if ($line.TrimStart().StartsWith("#")) {
continue
}
$separatorIndex = $line.IndexOf("=")
if ($separatorIndex -lt 1) {
continue
}
$key = $line.Substring(0, $separatorIndex).Trim()
$value = $line.Substring($separatorIndex + 1)
$values[$key] = $value
}
return $values
}
$config = Read-DotEnv -Path $envFile
$taskNameValue = if (-not [string]::IsNullOrWhiteSpace($TaskName)) {
$TaskName
} elseif ($config.ContainsKey("VOIDBOT_MODERATION_TASK_NAME") -and -not [string]::IsNullOrWhiteSpace($config["VOIDBOT_MODERATION_TASK_NAME"])) {
$config["VOIDBOT_MODERATION_TASK_NAME"]
} else {
"Void Moderator Rumination"
}
$intervalMinutesValue = if ($PSBoundParameters.ContainsKey("IntervalMinutes")) {
$IntervalMinutes
} elseif ($config.ContainsKey("VOIDBOT_MODERATION_INTERVAL_MINUTES") -and -not [string]::IsNullOrWhiteSpace($config["VOIDBOT_MODERATION_INTERVAL_MINUTES"])) {
[int]$config["VOIDBOT_MODERATION_INTERVAL_MINUTES"]
} else {
15
}
if ($intervalMinutesValue -lt 15) {
throw "VOIDBOT_MODERATION_INTERVAL_MINUTES must be at least 15."
}
$startAt = (Get-Date).AddMinutes(2)
$action = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "//B //nologo `"$hiddenLauncher`" -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$runnerScript`""
$trigger = New-ScheduledTaskTrigger -Once -At $startAt -RepetitionInterval (New-TimeSpan -Minutes $intervalMinutesValue) -RepetitionDuration (New-TimeSpan -Days 3650)
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 14) -MultipleInstances IgnoreNew
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType Interactive -RunLevel Limited
$description = "Runs Void's scheduled moderation-participation loop from the VoidBot workspace every $intervalMinutesValue minutes with real Codex tooling and local bot-voice output."
Register-ScheduledTask -TaskName $taskNameValue -Action $action -Trigger $trigger -Settings $settings -Principal $principal -Description $description -Force | Out-Null
Write-Host "Installed scheduled task: $taskNameValue"
Write-Host "Schedule: every $intervalMinutesValue minute(s), starting at $($startAt.ToString('yyyy-MM-dd HH:mm'))"
Write-Host "Task runs as: $($env:USERDOMAIN)\$($env:USERNAME)"
Write-Host "Logon mode: Interactive"
Write-Host "Launcher: wscript.exe hidden PowerShell shim"
Write-Host "Execution time limit: 14 minutes"
Write-Host "Runner script: $runnerScript"
if ($RunNow) {
Start-ScheduledTask -TaskName $taskNameValue
Write-Host "Started task immediately."
}

View file

@ -0,0 +1,351 @@
param(
[switch] $NoPost
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$repoRoot = Split-Path -Parent $PSScriptRoot
$envFile = Join-Path $repoRoot ".env"
$stateTemplatePath = Join-Path $repoRoot "config\moderation-agent-state-template.json"
$stateFilePath = Join-Path $repoRoot ".voidbot\private\moderation-agent-state.json"
$statusDir = Join-Path $repoRoot ".voidbot\status"
$logDir = Join-Path $repoRoot ".voidbot\logs"
$statusPath = Join-Path $statusDir "moderation-rumination.json"
$summaryLogPath = Join-Path $logDir "moderation-rumination.log"
$tracePath = Join-Path $logDir "moderation-rumination-last.jsonl"
$lastMessagePath = Join-Path $statusDir "moderation-rumination-last-message.txt"
$lockPath = Join-Path $statusDir "moderation-rumination.lock"
$mcpServerPath = Join-Path $repoRoot "apps\worker\dist\mcp-server.js"
function Read-DotEnv {
param(
[Parameter(Mandatory = $true)]
[string] $Path
)
$values = @{}
if (-not (Test-Path $Path)) {
return $values
}
foreach ($line in Get-Content -Path $Path) {
if ([string]::IsNullOrWhiteSpace($line)) {
continue
}
if ($line.TrimStart().StartsWith("#")) {
continue
}
$separatorIndex = $line.IndexOf("=")
if ($separatorIndex -lt 1) {
continue
}
$key = $line.Substring(0, $separatorIndex).Trim()
$value = $line.Substring($separatorIndex + 1).Trim()
$values[$key] = $value.Trim("'`"")
}
return $values
}
function Write-JsonFile {
param(
[Parameter(Mandatory = $true)]
[string] $Path,
[Parameter(Mandatory = $true)]
$Data
)
$directory = Split-Path -Parent $Path
if (-not [string]::IsNullOrWhiteSpace($directory)) {
New-Item -ItemType Directory -Force -Path $directory | Out-Null
}
$Data | ConvertTo-Json -Depth 12 | Set-Content -Path $Path -Encoding UTF8
}
function Append-RunLog {
param(
[Parameter(Mandatory = $true)]
[string] $Line
)
$timestamped = "[{0}] {1}" -f ([DateTime]::UtcNow.ToString("o")), $Line
Add-Content -Path $summaryLogPath -Value $timestamped -Encoding UTF8
}
function Ensure-ModerationState {
if (Test-Path $stateFilePath) {
return
}
if (-not (Test-Path $stateTemplatePath)) {
throw "Missing moderation state template at $stateTemplatePath"
}
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $stateFilePath) | Out-Null
Copy-Item -Path $stateTemplatePath -Destination $stateFilePath -Force
}
function Split-CommandArgs {
param(
[string] $Value
)
if ([string]::IsNullOrWhiteSpace($Value)) {
return @()
}
return [regex]::Matches($Value, '("[^"]*"|''[^'']*''|\S+)') |
ForEach-Object {
$_.Value.Trim().Trim("'`"")
}
}
function Quote-ProcessArgument {
param(
[Parameter(Mandatory = $true)]
[string] $Value
)
if ($Value -notmatch '[\s"]') {
return $Value
}
$escaped = $Value -replace '(\\*)"', '$1$1\"'
$escaped = $escaped -replace '(\\+)$', '$1$1'
return '"' + $escaped + '"'
}
function Invoke-CodexExec {
param(
[Parameter(Mandatory = $true)]
[string] $Executable,
[Parameter(Mandatory = $true)]
[string[]] $Arguments,
[Parameter(Mandatory = $true)]
[string] $WorkingDirectory,
[Parameter(Mandatory = $true)]
[string] $InputText
)
$startInfo = [System.Diagnostics.ProcessStartInfo]::new()
$startInfo.FileName = $Executable
$startInfo.WorkingDirectory = $WorkingDirectory
$startInfo.UseShellExecute = $false
$startInfo.RedirectStandardInput = $true
$startInfo.RedirectStandardOutput = $true
$startInfo.RedirectStandardError = $true
$startInfo.CreateNoWindow = $true
$startInfo.Arguments = [string]::Join(" ", ($Arguments | ForEach-Object { Quote-ProcessArgument -Value $_ }))
$process = [System.Diagnostics.Process]::new()
$process.StartInfo = $startInfo
try {
[void]$process.Start()
$process.StandardInput.Write($InputText)
$process.StandardInput.Close()
$stdoutTask = $process.StandardOutput.ReadToEndAsync()
$stderrTask = $process.StandardError.ReadToEndAsync()
$process.WaitForExit()
$stdoutTask.Wait()
$stderrTask.Wait()
return @{
ExitCode = $process.ExitCode
StdOut = $stdoutTask.Result
StdErr = $stderrTask.Result
}
} finally {
$process.Dispose()
}
}
if (Test-Path $lockPath) {
$lock = Get-Content -Path $lockPath -Raw | ConvertFrom-Json
$startedAt = $null
if ($lock.startedAt) {
try {
$startedAt = [DateTime]::Parse($lock.startedAt).ToUniversalTime()
} catch {
$startedAt = $null
}
}
if ($lock.pid -and (Get-Process -Id $lock.pid -ErrorAction SilentlyContinue)) {
if ($startedAt -and (([DateTime]::UtcNow - $startedAt).TotalMinutes -lt 20)) {
Append-RunLog "Skipped run because PID $($lock.pid) still owns the moderation loop lock."
Write-JsonFile -Path $statusPath -Data @{
status = "skipped_locked"
reason = "Previous moderation run still active."
observedAt = [DateTime]::UtcNow.ToString("o")
lock = $lock
}
exit 0
}
}
}
$startedAtUtc = [DateTime]::UtcNow
$envValues = Read-DotEnv -Path $envFile
$codexExecutable = if ($envValues.ContainsKey("CODEX_EXECUTABLE") -and -not [string]::IsNullOrWhiteSpace($envValues["CODEX_EXECUTABLE"])) {
$envValues["CODEX_EXECUTABLE"]
} else {
"codex"
}
$codexModel = if ($envValues.ContainsKey("CODEX_MODEL") -and -not [string]::IsNullOrWhiteSpace($envValues["CODEX_MODEL"])) {
$envValues["CODEX_MODEL"]
} else {
"gpt-5.4"
}
$codexReasoningEffort = if ($envValues.ContainsKey("CODEX_MODEL_REASONING_EFFORT") -and -not [string]::IsNullOrWhiteSpace($envValues["CODEX_MODEL_REASONING_EFFORT"])) {
$envValues["CODEX_MODEL_REASONING_EFFORT"]
} else {
"medium"
}
$codexExecArgs = if ($envValues.ContainsKey("CODEX_EXEC_ARGS")) {
Split-CommandArgs -Value $envValues["CODEX_EXEC_ARGS"]
} else {
@()
}
Ensure-ModerationState
New-Item -ItemType Directory -Force -Path $statusDir, $logDir | Out-Null
if (-not (Test-Path $mcpServerPath)) {
throw "Missing built MCP server at $mcpServerPath. Run npm run build first."
}
Write-JsonFile -Path $lockPath -Data @{
pid = $PID
startedAt = $startedAtUtc.ToString("o")
}
$stateWriteBefore = (Get-Item $stateFilePath).LastWriteTimeUtc
$prompt = @"
Perform one scheduled Void moderation-participation loop in this workspace.
Required reading before you act:
- config/moderation-review-agent.md
- config/discord-server-rules.md
- config/moderation-agent-state-template.json
- styles/void-default.md
- .voidbot/private/moderation-agent-state.json
Required operating posture:
- You are running unattended on the local workstation, not inside the Discord reply lane.
- You have VoidBot's usual workspace tools and the local voidbot MCP server available in this repo.
- Use `node scripts/export-recent-discord-history.mjs --after <timestamp> --limit 120` for chronological polling.
- If there is no saved cursor yet, use `node scripts/export-recent-discord-history.mjs --hours 6 --limit 120`.
- When the room is quiet, use the usual VoidBot retrieval tools to think about GameCult projects and contribute ideas:
- `search_history`
- `get_message_context`
- `list_indexed_repos`
- `search_sources`
- `get_source_context`
- `notify_owner` when owner interruption is actually warranted
- Use the local bot-voice script `node scripts/send-discord-message.mjs ...` when you genuinely need to speak.
- Update only `.voidbot/private/moderation-agent-state.json` as routine writable memory.
- Do not edit tracked repo files during routine runs.
- Do not ask for permission. Work inside the existing workspace and tool surface.
- Be willing to ruminate on GameCult projects, archived Discord seams, repo material, and constructive conversation ideas when the room is quiet.
- Keep the state compact, valid, and worth re-reading.
"@
if ($NoPost) {
$prompt += @"
Testing constraint for this run:
- Do not send any Discord messages or DMs.
- You may still update `.voidbot/private/moderation-agent-state.json` and use normal read/analysis tools.
"@
}
$prompt += @"
At the end:
- Print a short plain-text run summary as your final message.
"@
$codexArgs = @()
$codexArgs += $codexExecArgs
$codexArgs += @(
"exec",
"--ignore-user-config",
"-m", $codexModel,
"-c", 'approval_policy="never"',
"-c", ("model_reasoning_effort={0}" -f (ConvertTo-Json $codexReasoningEffort -Compress)),
"--dangerously-bypass-approvals-and-sandbox",
"--skip-git-repo-check",
"--json",
"-o", $lastMessagePath,
"-"
)
$combinedText = ""
$exitCode = 1
$failureMessage = $null
Write-JsonFile -Path $statusPath -Data @{
status = "running"
startedAt = $startedAtUtc.ToString("o")
noPost = [bool]$NoPost
repoRoot = $repoRoot
codexExecutable = $codexExecutable
codexModel = $codexModel
tracePath = $tracePath
lastMessagePath = $lastMessagePath
}
try {
$execution = Invoke-CodexExec -Executable $codexExecutable -Arguments $codexArgs -WorkingDirectory $repoRoot -InputText $prompt
$exitCode = $execution.ExitCode
$combinedText = (($execution.StdOut, $execution.StdErr) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) -join [Environment]::NewLine
} catch {
$failureMessage = $_.Exception.Message
}
$combinedText | Set-Content -Path $tracePath -Encoding UTF8
$finishedAtUtc = [DateTime]::UtcNow
$stateWriteAfter = (Get-Item $stateFilePath).LastWriteTimeUtc
$lastMessage = if (Test-Path $lastMessagePath) { Get-Content -Path $lastMessagePath -Raw } else { "" }
Write-JsonFile -Path $statusPath -Data @{
status = if ($exitCode -eq 0) { "ok" } else { "failed" }
startedAt = $startedAtUtc.ToString("o")
finishedAt = $finishedAtUtc.ToString("o")
durationSeconds = [Math]::Round(($finishedAtUtc - $startedAtUtc).TotalSeconds, 2)
exitCode = $exitCode
failureMessage = $failureMessage
noPost = [bool]$NoPost
stateFile = $stateFilePath
stateWriteBeforeUtc = $stateWriteBefore.ToString("o")
stateWriteAfterUtc = $stateWriteAfter.ToString("o")
stateUpdated = ($stateWriteAfter -gt $stateWriteBefore)
tracePath = $tracePath
lastMessagePath = $lastMessagePath
lastMessage = $lastMessage.Trim()
}
Append-RunLog ("exit={0} stateUpdated={1} summary={2}" -f $exitCode, ($stateWriteAfter -gt $stateWriteBefore), ($lastMessage.Trim()))
Remove-Item -Path $lockPath -Force -ErrorAction SilentlyContinue
if ($exitCode -ne 0) {
if ($failureMessage) {
throw "Void moderator rumination failed with exit code $exitCode. $failureMessage"
}
throw "Void moderator rumination failed with exit code $exitCode."
}

View file

@ -40,3 +40,4 @@
{"ts":"2026-05-04T18:19:09Z","type":"architecture","status":"ok","note":"The moderation loop should carry an actual participant lens, not only a reviewer posture. Its ignored state file now mirrors a Ghostlight-style split between identity, canonical state, goals, memories, perceived overlays, and runtime moderation bookkeeping so constructive interventions and archive musings accumulate inside one coherent self-model."}
{"ts":"2026-05-04T20:21:40Z","type":"implementation","status":"ok","note":"Sandboxed cron runs should not depend on tsx/esbuild just to read local archive state; the moderation recent-history helper now runs as plain Node so the automation path stops dying on child-process EPERM before it even sees the room."}
{"ts":"2026-05-04T21:30:08Z","type":"implementation","status":"ok","note":"The moderation loop now speaks through a local bot-token script for owner DMs and in-channel posts instead of approval-gated side-effecting MCP tools. Unattended runs can talk without Codex stopping for permission theater, and the script chunks messages and supports owner DM or channel reply targets."}
{"ts":"2026-05-04T23:41:29Z","type":"architecture","status":"ok","note":"The app heartbeat card was decorative; a real unattended moderation loop needs a local scheduled `codex exec` runner in the VoidBot workspace, with normal tool/MCP access and dangerous-bypass mode, or it will sit there narrating state updates it never actually persisted."}

View file

@ -65,7 +65,7 @@ accepted_design:
- Ephemeral room-reading should come from an explicit local-LLM sidecar inference pass plus raw recent-message evidence, not from a rules bucket pretending to understand natural language.
- The VoidBot MCP server is the preferred search plane for archived Discord, indexed GameCult repos, Aetheria lore, and owner notifications.
- Bot-directed prompts should remain in the raw Discord archive for forensics, but default history indexing and retrieval should treat them as toxic self-reference rather than ordinary community memory.
- Moderation review should run as a separate local Codex automation with tracked rules prompt surfaces plus one ignored structured state file, escalating via `notify_owner` instead of pretending the live Discord bot is a silent auto-punishment machine.
- Moderation review should run as a separate local Codex scheduled loop with tracked rules prompt surfaces plus one ignored structured state file, escalating via `notify_owner` instead of pretending the live Discord bot is a silent auto-punishment machine.
- The moderation agent should think of itself as a constructive participant as well as a reviewer, and its ignored structured state should follow a Ghostlight-shaped identity/canonical-state/goals/memories/overlays/runtime split rather than a flat notes bucket.
- Unattended moderation speech should use a local bot-token script instead of approval-gated side-effecting MCP tools, otherwise the loop keeps stopping to ask permission before it can talk.
- Deep agent-state, personality, culture, and persistent-world design work now belongs to the sibling Ghostlight repo; VoidBot should consume that work instead of remaining its long-term home.
@ -91,7 +91,7 @@ landed_baseline:
- State storage is now split into a thin factory plus per-domain Postgres/file store modules and bootstrap/migration helpers instead of one persistence omnibus.
- Source archive storage is now sharded by repo behind a manifest plus per-repo shard directory instead of one giant `source-documents.json` blob.
- Source repo indexing now reconciles automatically during stack startup and watchdog runs, refreshing hooks, indexing newly discovered repos, and pruning stale repo shards when repos disappear from `SOURCE_REPO_ROOT`.
- A separate hourly moderation-rumination automation now reads tracked server rules, pulls recent chronological archive slices through a helper script, and maintains one ignored JSON state file under `.voidbot/private/` instead of smearing moderation memory across random notes.
- A separate scheduled moderation-rumination loop now launches `codex exec` from the VoidBot workspace every 15 minutes, reads tracked server rules, polls recent chronology through the plain Node helper, uses the usual VoidBot MCP/tool surface for archive and project rumination, and maintains one ignored JSON state file under `.voidbot/private/` instead of smearing moderation memory across random notes.
rejected_paths:
- name: transcript_only_continuity