Detect stale VoidBot runtime processes
This commit is contained in:
parent
df83123c96
commit
896be9424f
4 changed files with 87 additions and 1 deletions
|
|
@ -364,6 +364,9 @@ async function processJob(job: JobRecord): Promise<void> {
|
|||
!articlePrSubmitted &&
|
||||
!bifrostTopicSubmitted &&
|
||||
repoIdentityUpdateRequests.length > 0;
|
||||
console.log(
|
||||
`Repo-face job ${job.id} parsed actions: say=${repoIdentityPosts.length}, bifrostTopic=${repoIdentityBifrostTopics.length}, updateRequest=${repoIdentityUpdateRequests.length}, article=${repoIdentityArticles.length}, proposalPr=${repoIdentityProposals.length}, prComment=${repoIdentityPrComments.length}.`,
|
||||
);
|
||||
if (repoIdentityProposals.length > 0) {
|
||||
await writeRepoIdentityProposalPrIntent(job, repoIdentityProposals[0]);
|
||||
} else if (repoIdentityPrComments.length > 0) {
|
||||
|
|
@ -735,6 +738,9 @@ async function postRepoIdentityIntent(job: JobRecord, intent: RepoIdentityPostIn
|
|||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.warn(`Could not record repo identity delivery receipt for job ${job.id}: ${message}`);
|
||||
});
|
||||
console.log(
|
||||
`Posted repo identity ${identity.id} to Discord channel ${channelId} from job ${job.id} via ${posted.transport} message ${posted.messageId}.`,
|
||||
);
|
||||
}
|
||||
|
||||
function sanitizeRepoIdentityPostContent(identity: { displayName: string; repoName: string }, content: string): string {
|
||||
|
|
@ -1499,7 +1505,13 @@ function normalizeDslKey(key: string): string {
|
|||
|
||||
function optionalDslString(value: string | undefined): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
return trimmed && trimmed.length > 0 ? trimmed : undefined;
|
||||
if (!trimmed || trimmed.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (["0", "null", "none", "undefined"].includes(trimmed.toLowerCase())) {
|
||||
return undefined;
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function parseDslNumber(value: string | undefined): number | undefined {
|
||||
|
|
|
|||
|
|
@ -475,6 +475,59 @@ function Test-ProcessAlive {
|
|||
}
|
||||
}
|
||||
|
||||
function Get-ProcessCreationTimeUtc {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[int] $ProcessId
|
||||
)
|
||||
|
||||
try {
|
||||
$process = Get-CimInstance Win32_Process -Filter "ProcessId=$ProcessId"
|
||||
if ($null -eq $process -or $null -eq $process.CreationDate) {
|
||||
return $null
|
||||
}
|
||||
return ([datetime]$process.CreationDate).ToUniversalTime()
|
||||
} catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
function Test-ProcessFreshForEntrypoint {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[int] $ProcessId,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $EntrypointPath
|
||||
)
|
||||
|
||||
if (-not (Test-Path -LiteralPath $EntrypointPath)) {
|
||||
return [pscustomobject]@{
|
||||
ok = $false
|
||||
reason = "missing_entrypoint"
|
||||
processStartedAt = $null
|
||||
entrypointUpdatedAt = $null
|
||||
}
|
||||
}
|
||||
|
||||
$startedAt = Get-ProcessCreationTimeUtc -ProcessId $ProcessId
|
||||
$updatedAt = (Get-Item -LiteralPath $EntrypointPath).LastWriteTimeUtc
|
||||
if ($null -eq $startedAt) {
|
||||
return [pscustomobject]@{
|
||||
ok = $false
|
||||
reason = "unknown_process_start_time"
|
||||
processStartedAt = $null
|
||||
entrypointUpdatedAt = $updatedAt.ToString("o")
|
||||
}
|
||||
}
|
||||
|
||||
return [pscustomobject]@{
|
||||
ok = $startedAt -ge $updatedAt
|
||||
reason = if ($startedAt -ge $updatedAt) { "fresh" } else { "process_started_before_entrypoint_update" }
|
||||
processStartedAt = $startedAt.ToString("o")
|
||||
entrypointUpdatedAt = $updatedAt.ToString("o")
|
||||
}
|
||||
}
|
||||
|
||||
function Escape-SingleQuotedPowerShell {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
|
|
@ -795,6 +848,8 @@ try {
|
|||
$componentStatus = Get-OptionalPropertyValue -InputObject $runtimeStatus -PropertyName $component
|
||||
$processIdValueRaw = Get-OptionalPropertyValue -InputObject $componentStatus -PropertyName "pid"
|
||||
$processIdValue = if ($null -ne $processIdValueRaw) { ($processIdValueRaw -as [int]) } else { $null }
|
||||
$entrypointRelativePath = if ($component -eq "bot") { "apps\bot\dist\index.js" } else { "apps\worker\dist\index.js" }
|
||||
$entrypointPath = Join-Path $repoRoot $entrypointRelativePath
|
||||
|
||||
if ($null -eq $processIdValue -or $processIdValue -le 0) {
|
||||
Add-Check -Name "runtime.$component" -Status "failed" -Detail "$component PID is missing from runtime-stack.json."
|
||||
|
|
@ -805,6 +860,23 @@ try {
|
|||
Add-Check -Name "runtime.$component" -Status "passed" -Detail "$component process $processIdValue is running." -Data @{
|
||||
pid = $processIdValue
|
||||
}
|
||||
$freshness = Test-ProcessFreshForEntrypoint -ProcessId $processIdValue -EntrypointPath $entrypointPath
|
||||
if ($freshness.ok) {
|
||||
Add-Check -Name "runtime.$component.freshness" -Status "passed" -Detail "$component process $processIdValue is fresh for $entrypointPath." -Data @{
|
||||
pid = $processIdValue
|
||||
entrypoint = $entrypointPath
|
||||
processStartedAt = $freshness.processStartedAt
|
||||
entrypointUpdatedAt = $freshness.entrypointUpdatedAt
|
||||
}
|
||||
} else {
|
||||
Add-Check -Name "runtime.$component.freshness" -Status "failed" -Detail "$component process $processIdValue is stale or unverifiable for $entrypointPath ($($freshness.reason))." -Data @{
|
||||
pid = $processIdValue
|
||||
entrypoint = $entrypointPath
|
||||
reason = $freshness.reason
|
||||
processStartedAt = $freshness.processStartedAt
|
||||
entrypointUpdatedAt = $freshness.entrypointUpdatedAt
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Add-Check -Name "runtime.$component" -Status "failed" -Detail "$component process $processIdValue is not running anymore." -Data @{
|
||||
pid = $processIdValue
|
||||
|
|
|
|||
|
|
@ -214,3 +214,4 @@
|
|||
{"ts":"2026-05-20T22:53:46Z","type":"implementation","status":"ok","note":"Imported EpiphanyAgent's affect-appraisal lesson into VoidBot as typed face affect: needs, social bonds, status reads, and mood dimensions. Seeded active Faces and Void with initial substrate/status affect; CTB now folds affect into Face speaking pressure."}
|
||||
{"ts":"2026-05-21T00:01:39Z","type":"verification","status":"ok","note":"Repo Face affect now has an MCP-surface smoke fixture: agents:repo-face-affect-mcp-fixture spawns the built VoidBot MCP server and verifies read_repo_face_state exposes typedState.faceAffect for Nibu/Mimir. Direct state service was already healthy; stale mounted MCP processes can still fail until refreshed."}
|
||||
{"ts":"2026-05-21T00:05:42Z","type":"implementation","status":"ok","note":"VoidBot MCP now exposes get_voidbot_runtime_info with process id, workspace, self-state schema fingerprint, and registered document types. The repo Face affect MCP fixture checks that runtime fingerprint before trusting read_repo_face_state, turning stale MCP mounts into an explicit runtime-version failure."}
|
||||
{"ts":"2026-05-21T00:17:31Z","type":"verification","status":"ok","note":"Repo Face silence was caused by a stale worker process that predated the rebuilt DSL parser; watchdog now fails runtime.*.freshness when bot/worker started before its dist entrypoint, and fresh worker logged/posted a Mimir SAY receipt after restart."}
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ accepted_design:
|
|||
- First chat under a repo identity must initialize the target repo's own `.voidbot` home: `voice/` for identity and mouth files, `state/` for Face/swarm state, `birth/` for Epiphany birth artifacts, and `logs/` for durable worker output. The birth hook uses EpiphanyAgent's repo-personality/birth-runner path over repo contents and git history instead of inventing a VoidBot-only personality generator.
|
||||
- Recent chat consensus can now be packaged for any target Codex workspace through `scripts/feed-codex-chat-consensus.mjs`. The helper reads archived Discord messages, defaults to Aquarium, writes a markdown consensus packet plus a Codex prompt under `.voidbot/artifacts/chat-consensus/`, and only feeds `codex exec` when `--execute` is explicit.
|
||||
- Agent standing heartbeats are owned by one CTB-style initiative scheduler, not by one task per agent. Wall-clock elapsed time advances initiative; the scheduled task only supplies frequent pulses. The scheduler stores per-agent speed/load/groups/heat/effective-speed/next-turn/active-turn state at `REPO_FACE_HEARTBEAT_STATE_PATH`, dispatches repo Faces as ordinary `repo-face-rumination` jobs, and dispatches built-in `void` as the existing moderation rumination runner. Heat can be turned up globally, by participant kind, turn kind, identity, repo, display name, channel, or `all` group without creating new schedulers, but heat only changes recovery speed; it must not fast-forward time. Active-turn freeze and rest gating remain hard brakes unless a direct mention creates room debt. An agent's initiative is frozen while its owner-Codex job or moderation lock is active; recovery is scheduled after completion, not when the job is queued. The Windows pulse task supports a one-minute floor; stream mode should raise heat or temporarily loosen fatigue, not compress wall-clock time.
|
||||
- Runtime liveness is not enough. The operations watchdog must also verify bot/worker freshness by comparing each live process start time against its built `dist/index.js` entrypoint timestamp. A process that predates its entrypoint is stale and must fail `runtime.<component>.freshness`; otherwise source/build repairs can silently sit beside an old in-memory worker that keeps eating new Face action DSL output as private summaries.
|
||||
- Active-turn freeze is bounded by actual job liveness, not blind faith in an old `running` row. Repo Face heartbeat jobs that remain approved/running past the stale-job window are marked failed through the job queue, recorded as `stale_active_turn_recovered`, and removed from the active-turn map so one dead worker claim cannot silence a Face indefinitely.
|
||||
- Repo Face rest projection is parent-owned state, not a read-only scheduler illusion. If the heartbeat runner projects a Face sleep cycle forward, it must persist the normalized `update_sleep_cycle` operation to that Face's `.cc` state before ready selection. Missed nap windows roll forward as completed rest instead of starting a brand-new nap at inspection time; otherwise overdue agents can be skipped forever as "currently napping" while raw state keeps the same stale boundary.
|
||||
- Repo Face memory distillation now shares Void's typed maintenance organ instead of relying on rumination turns to eventually clean themselves. `scripts/run-repo-face-heartbeats.ts` starts repo-local `run-void-memory-maintenance.ps1 -ForceDistillation` when a Face is napping with short-term memory or has stale short-term memory older than six hours, with status/logs isolated under the target repo's `.voidbot/status` and `.voidbot/logs`. `run-void-memory-maintenance.ps1` validates the entire proposed operation batch against `voidSelfStateOperationSchema` before applying anything, so one malformed late operation cannot leave a partial maintenance pass. The maintenance prompt is identity-neutral and explicitly forbids shorthand operation payloads, `type` instead of `operation`, `memoryIds` for pruning, and `null` optional fields.
|
||||
|
|
|
|||
Loading…
Reference in a new issue