From cc9dab29dae81913011b00c3d99715667e8340c2 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 26 Jun 2026 14:12:19 +0000 Subject: [PATCH] fix: compact quick verify report records --- scripts/src/hwlab-node-web-sentinel-cicd.ts | 75 +++++++++++++++++---- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/scripts/src/hwlab-node-web-sentinel-cicd.ts b/scripts/src/hwlab-node-web-sentinel-cicd.ts index 3824ebbe..34413f9b 100644 --- a/scripts/src/hwlab-node-web-sentinel-cicd.ts +++ b/scripts/src/hwlab-node-web-sentinel-cicd.ts @@ -2021,6 +2021,18 @@ function finalizeQuickVerifyFailure(state: SentinelCicdState, input: { } function recordQuickVerify(state: SentinelCicdState, payload: Record): Record { + const views = compactQuickVerifyRecordViews(record(payload.views)); + const summary = { + reason: payload.reason, + status: payload.status, + elapsedMs: payload.elapsedMs, + failure: payload.failure, + warnings: Array.isArray(payload.warnings) ? payload.warnings : [], + analysis: payload.analysis, + promptSource: payload.promptSource, + steps: Array.isArray(payload.steps) ? payload.steps.map(compactQuickVerifyRecordStep) : [], + valuesRedacted: true, + }; const recordResult = callSentinelService(state, "POST", "/api/runs/record", { runId: payload.runId, scenarioId: payload.scenarioId, @@ -2030,25 +2042,62 @@ function recordQuickVerify(state: SentinelCicdState, payload: Record): Record { + const compacted: Record = {}; + for (const [key, value] of Object.entries(views)) { + const item = record(value); + compacted[key] = { + ...item, + renderedText: boundQuickVerifyRecordText(item.renderedText, key === "summary" ? 12_000 : 16_000), + valuesRedacted: true, + }; + } + return compacted; +} + +function compactQuickVerifyRecordStep(value: unknown): Record { + const item = record(value); + return { + phase: stringAtNullable(item, "phase"), + ok: item.ok === true ? true : item.ok === false ? false : null, + promptIndex: numberAtNullable(item, "promptIndex"), + checkId: stringAtNullable(item, "checkId"), + failure: stringAtNullable(item, "failure"), + result: compactQuickVerifyRecordStepResult(record(item.result)), + valuesRedacted: true, + }; +} + +function compactQuickVerifyRecordStepResult(value: Record): Record { + return { + ok: value.ok === true ? true : value.ok === false ? false : null, + status: stringAtNullable(value, "status"), + view: stringAtNullable(value, "view"), + exitCode: numberAtNullable(value, "exitCode"), + timedOut: value.timedOut === true ? true : value.timedOut === false ? false : null, + stdoutBytes: numberAtNullable(value, "stdoutBytes"), + stderrBytes: numberAtNullable(value, "stderrBytes"), + stdoutPreview: boundQuickVerifyRecordText(value.stdoutPreview, 500), + stderrPreview: boundQuickVerifyRecordText(value.stderrPreview, 500), + valuesRedacted: true, + }; +} + +function boundQuickVerifyRecordText(value: unknown, maxChars: number): string | null { + if (typeof value !== "string") return null; + if (value.length <= maxChars) return value; + return `${value.slice(0, maxChars)}\n[truncated ${value.length - maxChars} chars]`; } function callSentinelService(state: SentinelCicdState, method: "GET" | "POST", pathWithQuery: string, body: Record | null, timeoutSeconds: number): Record {