Require Void moderation launch handshake
This commit is contained in:
parent
50f1480f6f
commit
6bbedaab87
2 changed files with 93 additions and 10 deletions
|
|
@ -166,6 +166,21 @@ async function main(): Promise<void> {
|
||||||
heat: participant.heat,
|
heat: participant.heat,
|
||||||
effectiveSpeed: participant.effectiveSpeed,
|
effectiveSpeed: participant.effectiveSpeed,
|
||||||
});
|
});
|
||||||
|
} else if (turn.failureReason) {
|
||||||
|
participant.currentLoad = 0;
|
||||||
|
state.history.push({
|
||||||
|
type: "turn_failed_to_start",
|
||||||
|
identityId: participant.identityId,
|
||||||
|
participantKind: participant.participantKind,
|
||||||
|
turnKind: participant.turnKind,
|
||||||
|
activeJobId: turn.activeJobId,
|
||||||
|
requestMessageId: turn.requestMessageId,
|
||||||
|
queuedAt,
|
||||||
|
initiativeClock: state.initiativeClock,
|
||||||
|
reason: turn.failureReason,
|
||||||
|
heat: participant.heat,
|
||||||
|
effectiveSpeed: participant.effectiveSpeed,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -228,12 +243,12 @@ async function queueParticipantTurn(input: {
|
||||||
config: ReturnType<typeof loadConfig>;
|
config: ReturnType<typeof loadConfig>;
|
||||||
storage: Awaited<ReturnType<typeof createStateStorage>>;
|
storage: Awaited<ReturnType<typeof createStateStorage>>;
|
||||||
queuedAt: string;
|
queuedAt: string;
|
||||||
}): Promise<{ created: boolean; activeJobId?: string; requestMessageId?: string }> {
|
}): Promise<{ created: boolean; activeJobId?: string; requestMessageId?: string; failureReason?: string }> {
|
||||||
switch (input.participant.turnKind) {
|
switch (input.participant.turnKind) {
|
||||||
case "repo_face_rumination":
|
case "repo_face_rumination":
|
||||||
return queueRepoFaceTurn(input);
|
return queueRepoFaceTurn(input);
|
||||||
case "void_moderation":
|
case "void_moderation":
|
||||||
return startVoidModerationTurn(input.queuedAt);
|
return startVoidModerationTurn(input.queuedAt, input.config.storageRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,38 +427,105 @@ interface DiscordApiMessage {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function startVoidModerationTurn(
|
async function startVoidModerationTurn(
|
||||||
queuedAt: string,
|
queuedAt: string,
|
||||||
): { created: boolean; activeJobId?: string; requestMessageId?: string } {
|
storageRoot: string,
|
||||||
|
): Promise<{ created: boolean; activeJobId?: string; requestMessageId?: string; failureReason?: string }> {
|
||||||
const runnerScript = resolve(process.cwd(), "scripts", "run-void-moderator-rumination.ps1");
|
const runnerScript = resolve(process.cwd(), "scripts", "run-void-moderator-rumination.ps1");
|
||||||
|
const lockPath = resolve(storageRoot, "status", "moderation-rumination.lock");
|
||||||
|
const statusPath = resolve(storageRoot, "status", "moderation-rumination.json");
|
||||||
|
const launchedAt = Date.now();
|
||||||
|
const launchCommand = [
|
||||||
|
`$arguments = @(${[
|
||||||
|
"-NoProfile",
|
||||||
|
"-NonInteractive",
|
||||||
|
"-ExecutionPolicy",
|
||||||
|
"Bypass",
|
||||||
|
"-File",
|
||||||
|
runnerScript,
|
||||||
|
].map(toPowerShellSingleQuotedString).join(", ")});`,
|
||||||
|
`Start-Process -FilePath ${toPowerShellSingleQuotedString("powershell.exe")} -ArgumentList $arguments -WorkingDirectory ${toPowerShellSingleQuotedString(process.cwd())} -WindowStyle Hidden;`,
|
||||||
|
].join(" ");
|
||||||
const child = spawn(
|
const child = spawn(
|
||||||
"powershell.exe",
|
"powershell.exe",
|
||||||
[
|
[
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-NonInteractive",
|
"-NonInteractive",
|
||||||
"-WindowStyle",
|
|
||||||
"Hidden",
|
|
||||||
"-ExecutionPolicy",
|
"-ExecutionPolicy",
|
||||||
"Bypass",
|
"Bypass",
|
||||||
"-File",
|
"-Command",
|
||||||
runnerScript,
|
launchCommand,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
detached: true,
|
|
||||||
stdio: "ignore",
|
stdio: "ignore",
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
child.unref();
|
child.unref();
|
||||||
|
const handshake = await waitForVoidModerationHandshake({
|
||||||
|
lockPath,
|
||||||
|
statusPath,
|
||||||
|
launchedAt,
|
||||||
|
timeoutMs: 60000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!handshake.started) {
|
||||||
|
return {
|
||||||
|
created: false,
|
||||||
|
activeJobId: child.pid ? `launcher-process:${child.pid}` : undefined,
|
||||||
|
requestMessageId: `agent-heartbeat:void:${queuedAt}`,
|
||||||
|
failureReason: handshake.reason,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
created: true,
|
created: true,
|
||||||
activeJobId: child.pid ? `process:${child.pid}` : `process:void-moderation:${queuedAt}`,
|
activeJobId: `process:void-moderation:${queuedAt}`,
|
||||||
requestMessageId: `agent-heartbeat:void:${queuedAt}`,
|
requestMessageId: `agent-heartbeat:void:${queuedAt}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toPowerShellSingleQuotedString(value: string): string {
|
||||||
|
return `'${value.replace(/'/g, "''")}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForVoidModerationHandshake(input: {
|
||||||
|
lockPath: string;
|
||||||
|
statusPath: string;
|
||||||
|
launchedAt: number;
|
||||||
|
timeoutMs: number;
|
||||||
|
}): Promise<{ started: true } | { started: false; reason: string }> {
|
||||||
|
const deadline = Date.now() + input.timeoutMs;
|
||||||
|
while (Date.now() < deadline) {
|
||||||
|
if (await wasTouchedAfter(input.lockPath, input.launchedAt)) {
|
||||||
|
return { started: true };
|
||||||
|
}
|
||||||
|
if (await wasTouchedAfter(input.statusPath, input.launchedAt)) {
|
||||||
|
return { started: true };
|
||||||
|
}
|
||||||
|
await sleep(250);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
started: false,
|
||||||
|
reason: "void_moderation_launch_handshake_missing",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function wasTouchedAfter(path: string, timestampMs: number): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const info = await stat(path);
|
||||||
|
return info.mtimeMs >= timestampMs - 500;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sleep(ms: number): Promise<void> {
|
||||||
|
return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
|
||||||
|
}
|
||||||
|
|
||||||
async function listExistingActiveTurns(
|
async function listExistingActiveTurns(
|
||||||
databaseDsn: string,
|
databaseDsn: string,
|
||||||
stateStorageBackend: "file" | "postgres",
|
stateStorageBackend: "file" | "postgres",
|
||||||
|
|
|
||||||
|
|
@ -157,3 +157,4 @@
|
||||||
{"ts":"2026-05-18T18:00:31Z","type":"implementation","status":"ok","note":"Agent CTB roster now includes built-in Void as a system_agent participant alongside repo Faces. The scheduler dispatches repo Faces as repo-face-rumination owner-Codex jobs and dispatches Void by starting the existing moderation rumination runner, with moderation-rumination.lock treated as Void's active turn. Live state now shows participants void and nibu; the old independent Void Moderator Rumination task was disabled so CTB owns Void moderation timing after the currently running pass clears."}
|
{"ts":"2026-05-18T18:00:31Z","type":"implementation","status":"ok","note":"Agent CTB roster now includes built-in Void as a system_agent participant alongside repo Faces. The scheduler dispatches repo Faces as repo-face-rumination owner-Codex jobs and dispatches Void by starting the existing moderation rumination runner, with moderation-rumination.lock treated as Void's active turn. Live state now shows participants void and nibu; the old independent Void Moderator Rumination task was disabled so CTB owns Void moderation timing after the currently running pass clears."}
|
||||||
{"ts":"2026-05-18T18:27:18Z","type":"implementation","status":"ok","note":"CTB pulse cadence can now run at one-minute granularity: config schema and install-repo-face-heartbeat-task.ps1 no longer enforce the old five-minute floor. Local stream mode .env is set to REPO_FACE_HEARTBEAT_INTERVAL_MINUTES=1; reinstall with -RunNow succeeded, LastTaskResult 0, and the immediate pulse advanced CTB and queued Nibu job 0dd3a436."}
|
{"ts":"2026-05-18T18:27:18Z","type":"implementation","status":"ok","note":"CTB pulse cadence can now run at one-minute granularity: config schema and install-repo-face-heartbeat-task.ps1 no longer enforce the old five-minute floor. Local stream mode .env is set to REPO_FACE_HEARTBEAT_INTERVAL_MINUTES=1; reinstall with -RunNow succeeded, LastTaskResult 0, and the immediate pulse advanced CTB and queued Nibu job 0dd3a436."}
|
||||||
{"ts":"2026-05-18T19:35:52Z","type":"implementation","status":"ok","note":"Repo Face heartbeat projection now attaches live Discord channel context plus the Face's typed self-state, and heartbeat prompts must answer directed agent requests visible in recent room context instead of asking what the job is."}
|
{"ts":"2026-05-18T19:35:52Z","type":"implementation","status":"ok","note":"Repo Face heartbeat projection now attaches live Discord channel context plus the Face's typed self-state, and heartbeat prompts must answer directed agent requests visible in recent room context instead of asking what the job is."}
|
||||||
|
{"ts":"2026-05-19T07:04:25Z","type":"implementation","status":"ok","note":"Repo Face CTB now requires a real Void moderation launch handshake before marking Void queued. Direct spawn failures are recorded as turn_failed_to_start instead of fake completed turns; PowerShell Start-Process launch reached the moderation lock and current Void runner is active."}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue