[PR #3995] [CLOSED] fix(mcp): advertise a screenshot example with a valid PNG checksum #5984

Closed
opened 2026-10-31 01:10:56 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3995
Author: @jackie-cqz
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/3938-advertised-screenshot-png-checksum


📝 Commits (1)

  • 066a48a fix(mcp): advertise a screenshot example with a valid PNG checksum

📊 Changes

2 files changed (+62 additions, -2 deletions)

View changed files

📝 src/contracts/browserToolContracts.ts (+5 -2)
➕ tests/conformance/contracts/advertisedScreenshotExamples.test.ts (+57 -0)

📄 Description

Summary

Fixes #3938.

Prepared with AI assistance. A human owner reviews the final diff and owns this
PR, per the Author readiness declarations below.

The advertised compare_web_screenshots example embedded a one-pixel PNG whose
IDAT chunk checksum was stale. The artifact schema validated the bytes, so the
example passed input-schema checks and shipped in the default full catalog, but
the comparison parser rejects an invalid chunk checksum. A caller following the
advertised example therefore received an invalid_input / invalid_format
failure instead of comparison Evidence.

Problem and expected behavior

Smallest trigger: submit the advertised compare_web_screenshots example to
either production entry point.

  • CLI: rea compare-web-screenshots "<advertised artifact>" "<same>" --json
    exited 1 with details.issues[0].message: "Invalid PNG chunk checksum".
  • MCP: tools/call with the example read from the same server's tools/list.

Byte inspection of the advertised artifact: the IHDR and IEND checksums match,
the IDAT chunk stores 3f35af59, and CRC-32 of its type and data is 3dc848ef.

Violated invariant: docs/mcp-contracts.md states "Every advertised example is
a distinct valid canonical input." The example was schema-valid but not a valid
canonical input for its own tool.

Expected: the advertised example compares successfully, reporting
status: identical, compared_pixels: 1, changed_pixels: 0. Deliberately
malformed PNGs must still be rejected.

Change and scope

  • Correct the advertised base64 encoding and its matching sha256 in
    exampleScreenshot().
  • Add tests/conformance/contracts/advertisedScreenshotExamples.test.ts, which
    admits every advertised PNG artifact through the same comparison parser a
    caller reaches, so a stale hand-written encoding cannot return unnoticed.

Why this fits REA's architecture: the schema validates artifact identity
(base64, byte count, digest) but only the parser owns PNG structure, so no
schema-level test could catch this. The new test asserts at the parser boundary
and deliberately fails if it examines no artifacts, so it cannot pass vacuously.
The artifact stays a literal in the contract rather than being generated at
import, because contracts are a pure layer and must not pull node:zlib in.

Intentionally not included: no change to PNG validation strictness, no change to
the artifact schema, and no authored change to generated catalogs (they are
ignored build outputs).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the browser tool contract's
    advertised example value; request parsing/validation stage.
  • Contribution scope fit and linked maintainer decision: not applicable —
    ordinary fix inside existing boundaries.
  • CLI and MCP/tool-catalog contract: the compare_web_screenshots
    inputSchema.examples[0] value changes. No schema, field, or tool changes.
  • Provider, bridge, target-format, or platform compatibility: none; no provider
    or platform behavior changes.
  • Evidence, artifact, provenance, or reconstruction contract: none. The
    corrected artifact remains a 70-byte, 1x1, image/png artifact whose digest
    matches its bytes.
  • Target selection, authority, upstream behavior, and cleanup details (if
    applicable): not applicable; no process, target, or browser is involved.
  • Generated metadata impact: none authored. .cache/mcp-tool-catalog.json
    regenerates with the new value; it is an ignored, test-only output.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Documentation or usability only; no target interaction.
  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    tests/conformance/contracts/advertisedScreenshotExamples.test.ts (new, 2 tests).
  • Base reproduction or other evidence: on the base revision the new test fails
    with TypeError: Invalid PNG chunk checksum at src/browser/PngVisualDiff.ts:129,
    the same rejection the CLI and MCP reported. With the corrected bytes it passes.
  • User-visible CLI/MCP output (if applicable): see "Validation performed".
  • Remaining proof gaps: this fixes one tool's example. The new guard asserts it
    examined at least the comparison example so it cannot pass vacuously, but PNG
    structure is still validated only by the parser, not by the artifact schema.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- tests/conformance/contracts/advertisedScreenshotExamples.test.ts src/contracts/advertisedInputExamples.test.ts src/browser/PngVisualDiff.test.ts — 3 files, 24 tests passed.
  • The new test against the base revision's artifact bytes — fails with Invalid PNG chunk checksum at src/browser/PngVisualDiff.ts:129; passes after the fix.
  • npm run check:fast — typecheck and lint (including verify:module-boundaries) succeeded, 2/2 tasks.
  • npm run test:focused -- tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/contractPresentation.test.ts — 2 files, 15 tests passed with the regenerated catalog.
  • CLI before the fix: HOME=$(mktemp -d) node scripts/rea.mjs compare-web-screenshots "<example>" "<example>" --json — exit 1, reason: invalid_format, message: "Invalid PNG chunk checksum".
  • CLI after the fix, with the artifact read back from the live catalog: exit 0, normalized_result.status: identical, compared_pixels: 1, changed_pixels: 0.
  • MCP after the fix: tools/list from node scripts/rea.mjs mcp, then tools/call with the advertised example unchanged — isError unset, status: identical, compared_pixels: 1, changed_pixels: 0.
  • Node v22.23.2 on macOS arm64. Not run: npm run check:pr (the complete local gate), and no real browser was involved.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. An advertised example value is
    corrected; no caller-visible contract, schema, or behavior is removed.
  • Real Hopper/Ghidra, browser, or OS coverage: no provider, browser, or OS
    behavior is exercised by this change; the comparison parser is exercised
    directly and through both production adapters.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; the change touches a
    constant example value and a test.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3995 **Author:** [@jackie-cqz](https://github.com/jackie-cqz) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/3938-advertised-screenshot-png-checksum` --- ### 📝 Commits (1) - [`066a48a`](https://github.com/morluto/rea/commit/066a48ab692a4b5141ce3ec15e6650896214cf5e) fix(mcp): advertise a screenshot example with a valid PNG checksum ### 📊 Changes **2 files changed** (+62 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/contracts/browserToolContracts.ts` (+5 -2) ➕ `tests/conformance/contracts/advertisedScreenshotExamples.test.ts` (+57 -0) </details> ### 📄 Description ## Summary Fixes #3938. _Prepared with AI assistance. A human owner reviews the final diff and owns this PR, per the Author readiness declarations below._ The advertised `compare_web_screenshots` example embedded a one-pixel PNG whose IDAT chunk checksum was stale. The artifact schema validated the bytes, so the example passed input-schema checks and shipped in the default full catalog, but the comparison parser rejects an invalid chunk checksum. A caller following the advertised example therefore received an `invalid_input` / `invalid_format` failure instead of comparison Evidence. ## Problem and expected behavior Smallest trigger: submit the advertised `compare_web_screenshots` example to either production entry point. - CLI: `rea compare-web-screenshots "<advertised artifact>" "<same>" --json` exited 1 with `details.issues[0].message: "Invalid PNG chunk checksum"`. - MCP: `tools/call` with the example read from the same server's `tools/list`. Byte inspection of the advertised artifact: the IHDR and IEND checksums match, the IDAT chunk stores `3f35af59`, and CRC-32 of its type and data is `3dc848ef`. Violated invariant: `docs/mcp-contracts.md` states "Every advertised example is a distinct valid canonical input." The example was schema-valid but not a valid canonical input for its own tool. Expected: the advertised example compares successfully, reporting `status: identical`, `compared_pixels: 1`, `changed_pixels: 0`. Deliberately malformed PNGs must still be rejected. ## Change and scope - Correct the advertised base64 encoding and its matching `sha256` in `exampleScreenshot()`. - Add `tests/conformance/contracts/advertisedScreenshotExamples.test.ts`, which admits every advertised PNG artifact through the same comparison parser a caller reaches, so a stale hand-written encoding cannot return unnoticed. Why this fits REA's architecture: the schema validates artifact identity (base64, byte count, digest) but only the parser owns PNG structure, so no schema-level test could catch this. The new test asserts at the parser boundary and deliberately fails if it examines no artifacts, so it cannot pass vacuously. The artifact stays a literal in the contract rather than being generated at import, because contracts are a pure layer and must not pull `node:zlib` in. Intentionally not included: no change to PNG validation strictness, no change to the artifact schema, and no authored change to generated catalogs (they are ignored build outputs). ## Contract and boundary impact - Semantic owner and earliest changed stage: the browser tool contract's advertised example value; request parsing/validation stage. - Contribution scope fit and linked maintainer decision: not applicable — ordinary fix inside existing boundaries. - CLI and MCP/tool-catalog contract: the `compare_web_screenshots` `inputSchema.examples[0]` value changes. No schema, field, or tool changes. - Provider, bridge, target-format, or platform compatibility: none; no provider or platform behavior changes. - Evidence, artifact, provenance, or reconstruction contract: none. The corrected artifact remains a 70-byte, 1x1, `image/png` artifact whose digest matches its bytes. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable; no process, target, or browser is involved. - Generated metadata impact: none authored. `.cache/mcp-tool-catalog.json` regenerates with the new value; it is an ignored, test-only output. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Documentation or usability only; no target interaction. - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/conformance/contracts/advertisedScreenshotExamples.test.ts` (new, 2 tests). - Base reproduction or other evidence: on the base revision the new test fails with `TypeError: Invalid PNG chunk checksum` at `src/browser/PngVisualDiff.ts:129`, the same rejection the CLI and MCP reported. With the corrected bytes it passes. - User-visible CLI/MCP output (if applicable): see "Validation performed". - Remaining proof gaps: this fixes one tool's example. The new guard asserts it examined at least the comparison example so it cannot pass vacuously, but PNG structure is still validated only by the parser, not by the artifact schema. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- tests/conformance/contracts/advertisedScreenshotExamples.test.ts src/contracts/advertisedInputExamples.test.ts src/browser/PngVisualDiff.test.ts` — 3 files, 24 tests passed. - The new test against the base revision's artifact bytes — fails with `Invalid PNG chunk checksum` at `src/browser/PngVisualDiff.ts:129`; passes after the fix. - `npm run check:fast` — typecheck and lint (including `verify:module-boundaries`) succeeded, 2/2 tasks. - `npm run test:focused -- tests/boundary/mcp/toolSchemaValidity.test.ts tests/boundary/mcp/contractPresentation.test.ts` — 2 files, 15 tests passed with the regenerated catalog. - CLI before the fix: `HOME=$(mktemp -d) node scripts/rea.mjs compare-web-screenshots "<example>" "<example>" --json` — exit 1, `reason: invalid_format`, `message: "Invalid PNG chunk checksum"`. - CLI after the fix, with the artifact read back from the live catalog: exit 0, `normalized_result.status: identical`, `compared_pixels: 1`, `changed_pixels: 0`. - MCP after the fix: `tools/list` from `node scripts/rea.mjs mcp`, then `tools/call` with the advertised example unchanged — `isError` unset, `status: identical`, `compared_pixels: 1`, `changed_pixels: 0`. - Node v22.23.2 on macOS arm64. Not run: `npm run check:pr` (the complete local gate), and no real browser was involved. ## Compatibility, safety, and release - Breaking changes or migration steps: none. An advertised example value is corrected; no caller-visible contract, schema, or behavior is removed. - Real Hopper/Ghidra, browser, or OS coverage: no provider, browser, or OS behavior is exercised by this change; the comparison parser is exercised directly and through both production adapters. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none; the change touches a constant example value and a test. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:56 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5984
No description provided.