From 4c844da11ca97ddd5d7edca175d52541419afdcb Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 18 Jun 2026 03:36:53 +0000 Subject: [PATCH] fix: read async web probe reports from file --- scripts/src/hwlab-node.ts | 42 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/scripts/src/hwlab-node.ts b/scripts/src/hwlab-node.ts index aa0a314f..46165078 100644 --- a/scripts/src/hwlab-node.ts +++ b/scripts/src/hwlab-node.ts @@ -5149,7 +5149,12 @@ function runNodeWebProbeAsync( }; } const poll = pollNodeWebProbeJob(options, spec, jobId); - const report = record(record(poll.status).report); + const statusReport = record(record(poll.status).report); + const reportPath = typeof start.reportPath === "string" ? start.reportPath : null; + const reportLoad = Object.keys(statusReport).length > 0 + ? { source: "status", report: statusReport, result: null as CommandResult | null, degradedReason: null as string | null, path: null as string | null } + : readNodeWebProbeReport(options, spec, reportPath); + const report = reportLoad.report ?? {}; const probe = compactWebProbeResult(Object.keys(report).length > 0 ? report : null); const passed = probe?.status === "pass"; const summary = nullableRecord(probe?.summary); @@ -5158,8 +5163,8 @@ function runNodeWebProbeAsync( : typeof probe?.degradedReason === "string" ? probe.degradedReason : poll.status === null - ? "web-probe-async-status-failed" - : null; + ? reportLoad.degradedReason ?? "web-probe-async-status-failed" + : reportLoad.degradedReason; return { ok: passed, status: passed ? "pass" : "blocked", @@ -5191,10 +5196,39 @@ function runNodeWebProbeAsync( screenshotPath: start.screenshotPath ?? null, }, statusResult: poll.result === null ? null : compactCommandResult(poll.result), + reportLoad: { + source: reportLoad.source, + path: reportLoad.path, + result: reportLoad.result === null ? null : compactCommandResult(reportLoad.result), + degradedReason: reportLoad.degradedReason, + }, valuesRedacted: true, }; } +function readNodeWebProbeReport( + options: NodeWebProbeRunOptions, + spec: HwlabRuntimeLaneSpec, + reportPath: string | null, +): { source: string; report: Record | null; result: CommandResult | null; degradedReason: string | null; path: string | null } { + if (!reportPath) return { source: "missing", report: null, result: null, degradedReason: "web-probe-report-path-missing", path: null }; + if (!isSafeWebProbeReportPath(reportPath)) return { source: "unsafe-path", report: null, result: null, degradedReason: "web-probe-report-path-invalid", path: reportPath }; + const result = runTransWorkspaceStdinScript(options.node, spec.workspace, `cat ${shellQuote(reportPath)}`, 55); + if (result.exitCode !== 0 || result.timedOut) return { source: "report-file", report: null, result, degradedReason: result.timedOut ? "web-probe-command-timeout" : "web-probe-report-read-failed", path: reportPath }; + const report = parseJsonObject(result.stdout); + return { + source: "report-file", + report, + result, + degradedReason: report === null ? "web-probe-report-parse-failed" : null, + path: reportPath, + }; +} + +function isSafeWebProbeReportPath(reportPath: string): boolean { + return reportPath.includes("/.state/web-live-dom-probe/") && reportPath.endsWith(".result.json") && !reportPath.includes("\0"); +} + function pollNodeWebProbeJob(options: NodeWebProbeRunOptions, spec: HwlabRuntimeLaneSpec, jobId: string): { status: Record | null; result: CommandResult | null; @@ -10065,6 +10099,8 @@ function compactWebProbeTraceSamples(value: unknown): Record[] rowCount: sample.rowCount ?? null, emptyLabel: sample.emptyLabel ?? null, latestRowPreview: sample.latestRowPreview ?? null, + userVisibleRowCount: sample.userVisibleRowCount ?? null, + latestUserVisibleRowPreview: sample.latestUserVisibleRowPreview ?? null, conversationId: sample.conversationId ?? null, sessionId: sample.sessionId ?? null, traceId: sample.traceId ?? null,