From 6ec105be6df5223494ce440a799a18bc3ddf0a38 Mon Sep 17 00:00:00 2001 From: HolyDEEW <87277682+WoWHellgarve-HolyDeeW@users.noreply.github.com> Date: Mon, 30 Nov 2026 11:08:39 +0000 Subject: [PATCH] fix(screenshots): report the PNG comparison memory allowance (#15217) * fix(screenshots): report the PNG comparison memory allowance * style(screenshots): format memory allowance assertion --- scripts/verify/fixed-ceiling-registry.json | 7 +++++++ .../untyped-budget-refusal-baseline.json | 1 - src/domain/pngVisualDiff.test.ts | 18 ++++++++++++++++++ src/domain/pngVisualDiff.ts | 15 +++++++++++---- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/scripts/verify/fixed-ceiling-registry.json b/scripts/verify/fixed-ceiling-registry.json index 8abf3f08f53..7eb3f9915fc 100644 --- a/scripts/verify/fixed-ceiling-registry.json +++ b/scripts/verify/fixed-ceiling-registry.json @@ -280,6 +280,13 @@ "reason": "`fixedNativeAllowance` relays the allowance its caller names." } }, + "src/domain/pngVisualDiff.ts": { + "\"The screenshot comparison working-memory allowance\"": { + "class": "pending", + "issue": 14234, + "reason": "The 256 MiB PNG comparison memory estimate is an REA policy without a per-call control; this refusal previously had only prose recovery." + } + }, "src/domain/xmlDocument.ts": { "XML_ELEMENT_DEPTH_ALLOWANCE.name": { "class": "representation", diff --git a/scripts/verify/untyped-budget-refusal-baseline.json b/scripts/verify/untyped-budget-refusal-baseline.json index 292f44260a5..13f98744521 100644 --- a/scripts/verify/untyped-budget-refusal-baseline.json +++ b/scripts/verify/untyped-budget-refusal-baseline.json @@ -16,7 +16,6 @@ "src/desktop/BuildComputerController.ts": 2, "src/domain/apiContract/GraphqlInventory.ts": 1, "src/domain/apiContract/parseApiContract.ts": 1, - "src/domain/pngVisualDiff.ts": 1, "src/hopper/HopperCallerReconciliation.ts": 1, "src/il2cpp/Il2cppMetadataProvider.ts": 2, "src/javascript/analysis/JavaScriptAnalysisTransfer.ts": 1, diff --git a/src/domain/pngVisualDiff.test.ts b/src/domain/pngVisualDiff.test.ts index 86755472ce4..3435c7f1bdd 100644 --- a/src/domain/pngVisualDiff.test.ts +++ b/src/domain/pngVisualDiff.test.ts @@ -8,6 +8,7 @@ import { AnalysisResourceConstraintError, AnalysisTargetFailureError, } from "./analysisErrorCore.js"; +import { projectAnalysisError } from "./analysisErrorProjection.js"; import { compareWebScreenshotsInputSchema, createWebScreenshotArtifact, @@ -243,6 +244,23 @@ describe("PNG comparison memory budget", () => { after_dimensions: { width: 0x7fffffff, height: 1 }, }, }); + if (!(cause instanceof AnalysisResourceConstraintError)) throw cause; + const projected = projectAnalysisError(cause); + expect(projected.retryable).toBe(false); + expect(projected.details?.refusal).toEqual({ + kind: "fixed_ceiling", + operation: "compare_web_screenshots", + allowance: "The screenshot comparison working-memory allowance", + allowance_kind: "bytes", + limit: 256 * 1024 * 1024, + unit: "bytes", + narrowing: + "Capture smaller screenshots or reduce their viewport dimensions.", + }); + expect(projected.remediation.action).toContain("fixed byte allowance"); + expect(projected.remediation.action).toContain( + "Capture smaller screenshots", + ); } }); }); diff --git a/src/domain/pngVisualDiff.ts b/src/domain/pngVisualDiff.ts index 2b053a8ed2e..a059ed6cc4a 100644 --- a/src/domain/pngVisualDiff.ts +++ b/src/domain/pngVisualDiff.ts @@ -16,6 +16,7 @@ import { readPngIhdrFacts, } from "./pngHeader.js"; import { BinaryReader } from "./binaryContainer.js"; +import { fixedAllowanceOptions } from "./fixedAllowanceRemediation.js"; interface DecodedPng { readonly width: number; @@ -340,10 +341,16 @@ const pngWorkingMemoryError = ( after_dimensions: after === null ? null : { width: after.width, height: after.height }, }, - { - remediationAction: - "Compare smaller screenshots or reduce their viewport dimensions before capture.", - }, + fixedAllowanceOptions( + "The screenshot comparison working-memory allowance", + "bytes", + { + limit: PNG_COMPARISON_WORKING_MEMORY_BYTES, + unit: "bytes", + narrowing: + "Capture smaller screenshots or reduce their viewport dimensions.", + }, + ), ); const inflatePng = (compressed: Buffer, maxOutputLength: number): Buffer => {