refactor(producer): share DE verify-fallback telemetry mapping across capture paths

This commit is contained in:
Vance Ingalls
2026-07-23 16:52:57 -07:00
parent c85cfae8fa
commit 92ffd0476d
@@ -1574,6 +1574,29 @@ export function extractStandaloneEntryFromIndex(
return document.toString(); return document.toString();
} }
/**
* Telemetry fields a drawElement self-verify failure contributes to the
* fallback record. Shared by the streaming and parallel-disk verify catches
* so the `verifyDetails` → `de_fallback_*` mapping lives in one place — a new
* field is added once, not once per capture path. `kind` is read structurally
* off the error (never from message text), so a reworded/translated/
* cross-module-serialized error can't flip "blank" into "psnr".
*/
function deVerifyFallbackTelemetry(err: unknown): {
reason: "psnr" | "blank";
failedDb?: number;
frameIndex?: number;
thresholdDb?: number;
} {
const details = getDrawElementVerificationDetails(err);
return {
reason: details?.kind ?? "psnr",
failedDb: roundDb(details?.failedDb),
frameIndex: details?.frameIndex,
thresholdDb: roundDb(details?.verifyThresholdDb),
};
}
/** /**
* Render a `RenderJob` end-to-end: compile → probe → extract videos → * Render a `RenderJob` end-to-end: compile → probe → extract videos →
* audio → capture → encode → assemble. The function body is a thin * audio → capture → encode → assemble. The function body is a thin
@@ -3026,20 +3049,14 @@ async function executeRenderPipeline(input: {
throw err; throw err;
const isMemoryExhaustion = !isVerifyError && isMemoryExhaustionError(err); const isMemoryExhaustion = !isVerifyError && isMemoryExhaustionError(err);
deSelfVerifyFallback = isVerifyError; deSelfVerifyFallback = isVerifyError;
// `kind` is a structural field on the error (DrawElementVerificationDetails),
// never derived from message text — a reworded message, a translated
// string, or a cross-module/serialized error must never be able to
// flip "blank" into "psnr" or vice versa (review finding).
const verifyDetails = isVerifyError ? getDrawElementVerificationDetails(err) : undefined;
deFallbackReason = isVerifyError
? (verifyDetails?.kind ?? "psnr")
: isMemoryExhaustion
? "oom"
: "capture_error";
if (isVerifyError) { if (isVerifyError) {
deFallbackFailedDb = roundDb(verifyDetails?.failedDb); const t = deVerifyFallbackTelemetry(err);
deFallbackFrameIndex = verifyDetails?.frameIndex; deFallbackReason = t.reason;
deFallbackThresholdDb = roundDb(verifyDetails?.verifyThresholdDb); deFallbackFailedDb = t.failedDb;
deFallbackFrameIndex = t.frameIndex;
deFallbackThresholdDb = t.thresholdDb;
} else {
deFallbackReason = isMemoryExhaustion ? "oom" : "capture_error";
} }
log.warn( log.warn(
isVerifyError isVerifyError
@@ -3203,12 +3220,12 @@ async function executeRenderPipeline(input: {
) { ) {
throw err; throw err;
} }
const verifyDetails = getDrawElementVerificationDetails(err);
deSelfVerifyFallback = true; deSelfVerifyFallback = true;
deFallbackReason = verifyDetails?.kind ?? "psnr"; const t = deVerifyFallbackTelemetry(err);
deFallbackFailedDb = roundDb(verifyDetails?.failedDb); deFallbackReason = t.reason;
deFallbackFrameIndex = verifyDetails?.frameIndex; deFallbackFailedDb = t.failedDb;
deFallbackThresholdDb = roundDb(verifyDetails?.verifyThresholdDb); deFallbackFrameIndex = t.frameIndex;
deFallbackThresholdDb = t.thresholdDb;
log.warn( log.warn(
"[Render] drawElement self-verification failed on the parallel disk path; " + "[Render] drawElement self-verification failed on the parallel disk path; " +
"re-rendering via screenshot", "re-rendering via screenshot",