Document swarm teardown and add pause gate
This commit is contained in:
parent
1c8d96b76f
commit
2b84082101
8 changed files with 424 additions and 5 deletions
|
|
@ -12,6 +12,7 @@ $statusDir = Join-Path $repoRoot ".voidbot\status"
|
|||
$logDir = Join-Path $repoRoot ".voidbot\logs\orchestrator"
|
||||
$statePath = Join-Path $statusDir "gamecult-orchestrator.json"
|
||||
$lockPath = Join-Path $statusDir "gamecult-orchestrator.lock"
|
||||
$agentSwarmPausePath = Join-Path $repoRoot "state\agent-swarm-paused.json"
|
||||
$hiddenLauncher = Join-Path $PSScriptRoot "run-hidden-powershell.vbs"
|
||||
$bifrostRoot = "E:\Projects\Bifrost"
|
||||
|
||||
|
|
@ -211,6 +212,24 @@ function Test-OrchestratorLock {
|
|||
return $true
|
||||
}
|
||||
|
||||
function Test-AgentSwarmPaused {
|
||||
if (-not (Test-Path -LiteralPath $agentSwarmPausePath)) {
|
||||
return $false
|
||||
}
|
||||
try {
|
||||
$pause = Read-JsonFile -Path $agentSwarmPausePath
|
||||
if ($null -eq $pause) {
|
||||
return $true
|
||||
}
|
||||
if ($pause.PSObject.Properties["paused"] -and $pause.paused -eq $false) {
|
||||
return $false
|
||||
}
|
||||
return $true
|
||||
} catch {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $statusDir, $logDir | Out-Null
|
||||
if (Test-OrchestratorLock) {
|
||||
exit 0
|
||||
|
|
@ -232,6 +251,13 @@ try {
|
|||
$node = (Get-Command node.exe -ErrorAction Stop).Source
|
||||
$powershell = Join-Path $env:SystemRoot "System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||
$now = [DateTime]::UtcNow
|
||||
$agentSwarmPaused = Test-AgentSwarmPaused
|
||||
$agentSwarmOrganIds = @{
|
||||
"bifrost-dispatch" = $true
|
||||
"repo-face-heartbeats" = $true
|
||||
"void-mood-drift" = $true
|
||||
"void-moderation-rumination" = $true
|
||||
}
|
||||
$onlySet = @{}
|
||||
$onlyValues = @()
|
||||
if ($null -ne $Only) {
|
||||
|
|
@ -298,6 +324,20 @@ try {
|
|||
continue
|
||||
}
|
||||
|
||||
if ($agentSwarmPaused -and $agentSwarmOrganIds.ContainsKey($organ.Id)) {
|
||||
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_agent_swarm_paused"
|
||||
lastLogPath = $agentSwarmPausePath
|
||||
})
|
||||
Write-JsonFile -Path $statePath -Data $state
|
||||
continue
|
||||
}
|
||||
|
||||
$result = Invoke-Organ -Organ $organ -Now $now
|
||||
$runs += $result
|
||||
Set-OrganState -State $state -Id $organ.Id -Value ([pscustomobject]@{
|
||||
|
|
|
|||
|
|
@ -132,6 +132,35 @@ async function main(): Promise<void> {
|
|||
const config = loadConfig();
|
||||
const dryRun = process.argv.includes("--dry-run");
|
||||
|
||||
const pause = await readAgentSwarmPause();
|
||||
if (pause.paused) {
|
||||
const state = await readHeartbeatState(config.repoFaceHeartbeats.statePath);
|
||||
state.lastTickAt = new Date().toISOString();
|
||||
state.history.push({
|
||||
type: "skipped",
|
||||
reason: "agent_swarm_paused",
|
||||
skippedAt: state.lastTickAt,
|
||||
pausePath: pause.path,
|
||||
pauseReason: pause.reason,
|
||||
});
|
||||
state.history = state.history.slice(-80);
|
||||
if (!dryRun) {
|
||||
await writeHeartbeatState(config.repoFaceHeartbeats.statePath, state);
|
||||
}
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
ok: true,
|
||||
queuedCount: 0,
|
||||
dryRun,
|
||||
skipped: true,
|
||||
reason: "agent_swarm_paused",
|
||||
pausePath: pause.path,
|
||||
statePath: config.repoFaceHeartbeats.statePath,
|
||||
})}\n`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.repoFaceHeartbeats.enabled && !process.argv.includes("--force")) {
|
||||
const state = await readHeartbeatState(config.repoFaceHeartbeats.statePath);
|
||||
state.lastTickAt = new Date().toISOString();
|
||||
|
|
@ -309,6 +338,27 @@ async function main(): Promise<void> {
|
|||
);
|
||||
}
|
||||
|
||||
async function readAgentSwarmPause(): Promise<{ paused: boolean; path: string; reason?: string }> {
|
||||
const path = resolve(process.cwd(), "state", "agent-swarm-paused.json");
|
||||
try {
|
||||
const parsed = JSON.parse(stripLeadingBom(await readFile(path, "utf8"))) as Record<string, unknown>;
|
||||
return {
|
||||
paused: parsed.paused !== false,
|
||||
path,
|
||||
reason: typeof parsed.reason === "string" ? parsed.reason : undefined,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
||||
return { paused: false, path };
|
||||
}
|
||||
return {
|
||||
paused: true,
|
||||
path,
|
||||
reason: "Pause file exists but could not be parsed; failing closed.",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
interface ParticipantSpec {
|
||||
id: string;
|
||||
participantKind: FaceHeartbeatParticipant["participantKind"];
|
||||
|
|
|
|||
Loading…
Reference in a new issue