From 7be81763c61710947c4057a37dc0386e41d8be58 Mon Sep 17 00:00:00 2001 From: Lyon <88232613+pikasTech@users.noreply.github.com> Date: Fri, 26 Jun 2026 04:23:42 +0800 Subject: [PATCH] fix: speed up web sentinel quick verify polling (#925) Co-authored-by: Codex --- .../scenarios.workbench.yaml | 2 +- scripts/src/hwlab-node-web-sentinel-cicd.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/config/hwlab-web-probe-sentinel/scenarios.workbench.yaml b/config/hwlab-web-probe-sentinel/scenarios.workbench.yaml index c906c233..dd3b9456 100644 --- a/config/hwlab-web-probe-sentinel/scenarios.workbench.yaml +++ b/config/hwlab-web-probe-sentinel/scenarios.workbench.yaml @@ -10,7 +10,7 @@ sentinel: enabled: true cadence: 10m observeTargetPath: /workbench - sampleIntervalMs: 5000 + sampleIntervalMs: 1000 screenshotIntervalMs: 60000 maxRunSeconds: 1200 providerProfile: dsflash-go diff --git a/scripts/src/hwlab-node-web-sentinel-cicd.ts b/scripts/src/hwlab-node-web-sentinel-cicd.ts index 7e07e4d8..3f7d8f7c 100644 --- a/scripts/src/hwlab-node-web-sentinel-cicd.ts +++ b/scripts/src/hwlab-node-web-sentinel-cicd.ts @@ -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[] = []; @@ -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 { +function waitForQuickVerifyPromptTurn(state: SentinelCicdState, observerId: string, promptIndex: number, deadline: number, pollIntervalMs: number): Record { const observations: Record[] = []; + 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,