fix: speed up web sentinel quick verify polling (#925)

Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
Lyon
2026-06-26 04:23:42 +08:00
committed by GitHub
parent 6771464b30
commit 7be81763c6
2 changed files with 9 additions and 7 deletions
+8 -6
View File
@@ -1312,6 +1312,7 @@ function runSentinelQuickVerify(state: SentinelCicdState, reason: string, timeou
if (scenario === null) return { ok: false, status: "blocked", reason: "scenario-not-found", scenarioId, valuesRedacted: true };
const prompts = readPromptSetForScenario(scenario);
if (!prompts.ok) return { ok: false, status: "blocked", reason: "prompt-source-unavailable", promptSource: prompts, valuesRedacted: true };
const sampleIntervalMs = numberAt(scenario, "sampleIntervalMs");
const deadline = Date.now() + Math.min(timeoutSeconds, maxSeconds) * 1000;
const runId = `sentinel-run-${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`;
const steps: Record<string, unknown>[] = [];
@@ -1320,7 +1321,7 @@ function runSentinelQuickVerify(state: SentinelCicdState, reason: string, timeou
"--node", state.spec.nodeId,
"--lane", state.spec.lane,
"--target-path", stringAt(scenario, "observeTargetPath"),
"--sample-interval-ms", String(numberAt(scenario, "sampleIntervalMs")),
"--sample-interval-ms", String(sampleIntervalMs),
"--screenshot-interval-ms", String(numberAt(scenario, "screenshotIntervalMs")),
"--command-timeout-seconds", "55",
];
@@ -1379,7 +1380,7 @@ function runSentinelQuickVerify(state: SentinelCicdState, reason: string, timeou
}));
}
if (type === "sendPrompt") {
const waitResult = waitForQuickVerifyPromptTurn(state, observerId, promptIndex, deadline);
const waitResult = waitForQuickVerifyPromptTurn(state, observerId, promptIndex, deadline, sampleIntervalMs);
steps.push({ phase: "observe-wait-turn-terminal", ok: waitResult.ok, promptIndex, result: waitResult });
if (waitResult.ok !== true) {
return recordQuickVerify(state, finalizeQuickVerifyFailure(state, {
@@ -1838,8 +1839,9 @@ function runChildCli(args: string[], timeoutSeconds: number, input?: string): Ch
};
}
function waitForQuickVerifyPromptTurn(state: SentinelCicdState, observerId: string, promptIndex: number, deadline: number): Record<string, unknown> {
function waitForQuickVerifyPromptTurn(state: SentinelCicdState, observerId: string, promptIndex: number, deadline: number, pollIntervalMs: number): Record<string, unknown> {
const observations: Record<string, unknown>[] = [];
const pollSleepMs = Math.max(250, Math.min(5000, Math.trunc(pollIntervalMs)));
while (Date.now() < deadline) {
const view = collectObserveView(state, observerId, "turn-summary", null, remainingSeconds(deadline, 20));
const rows = Array.isArray(record(view.collect).rows) ? record(view.collect).rows.map(record) : [];
@@ -1879,9 +1881,9 @@ function waitForQuickVerifyPromptTurn(state: SentinelCicdState, observerId: stri
valuesRedacted: true,
};
}
const sleepSeconds = Math.min(5, Math.max(1, Math.floor((deadline - Date.now()) / 1000)));
if (sleepSeconds <= 0) break;
runCommand(["sleep", String(sleepSeconds)], repoRoot, { timeoutMs: (sleepSeconds + 1) * 1000 });
const sleepMs = Math.min(pollSleepMs, Math.max(0, deadline - Date.now()));
if (sleepMs <= 0) break;
runCommand(["sleep", String(sleepMs / 1000)], repoRoot, { timeoutMs: sleepMs + 1000 });
}
return {
ok: false,