メインコンテンツへスキップ
P

dsh-image-integrity

perrylink/dsh-image-integrity

Image integrity checks for DeepSeek Harness: zero-dependency 8-bit PNG decoding (grey/RGB/RGBA) with mean-threshold block fingerprints and NCC confirmation to find duplicated or mirrored regions inside one figure or shared between two figures, plus REP evidence and Markdown/SARIF reports. Finds reused pixels, not manipulation intent; JPEG is out of scope.

インストール

dsh plugin --profile web add github:perrylink/dsh-image-integrity

README

dsh-image-integrity: the frozen 100-pair benchmark — manipulated precision, recall and F1 all 1.0000, false-positive rate 0.0000, with TP 50 / FP 0 / TN 50 / FN 0 on the right; below it the three match kinds, the Markdown + SARIF report surface and the boundary that this finds reused pixels, not manipulation intent

dsh-image-integrity

当前版本 0.1.5。

Is that panel reused — duplicated in place, or pasted mirrored from another figure?

Zero-dependency PNG decoding, mean-threshold block fingerprints with NCC confirmation, duplicate/mirror region reports, REP evidence and SARIF. It finds reused pixels, not manipulation intent.

简体中文 · Español · Português · हिन्दी

License Node


What it does

  • image_check — finds a textured block that appears twice (or mirrored) inside one image.
  • image_compare — finds blocks shared between two images, including mirrored copies.
  • image_report — Markdown + SARIF 2.1.0, one warning per matched region with coordinates, Hamming distance and NCC.

How it works: decode PNG → luma → 16×16 blocks → mean-threshold bit pattern (robust to brightness offsets) + zero-mean NCC confirmation. Blocks that are flat or close to a fitted plane are skipped, so a smooth gradient is not reported as "duplicated".

dsh-image-integrity structure: a PNG is decoded to RGBA and luma with the pixel cap checked from the IHDR before inflation, 16×16 blocks are fingerprinted by a mean-threshold bit pattern after flat and near-plane blocks are skipped, candidate shifts are confirmed by Hamming distance and NCC against the defaults, and matches[] becomes REP evidence plus a Markdown and SARIF 2.1.0 report; the token labels inside the diagram are the real fields and defaults

Structure: decode → fingerprint → match; matches[] and the derived analysis are the two outputs, and every match carries its coordinates, kind, Hamming distance and NCC. The token labels inside the diagram are the real field names and defaults, so the same picture serves all five languages.

What it does not do

  • No JPEG. Only 8-bit non-interlaced PNG (grey/RGB/RGBA) is decoded. JPEG/16-bit/interlaced are rejected with a clear code — no silent garbage.
  • No alignment. Images must have identical dimensions; a mismatch is reported, never resized.
  • No blur/compression robustness. JPEG recompression, scaling, rotation or splice blending will usually defeat it.
  • No misconduct claim. Repeated controls, scale bars, icons and background texture are legitimate shared blocks. The report says so.
  • No GUI, no upload. Local bytes only.

Tools

image_check

{ path, persist?, blockSize?, maxShiftBits?, minVariance?, nccThreshold? } → { ok, analysis, evidenceId?, recordPath? }.

image_compare

{ pathA, pathB, persist?, ...thresholds } → { ok, analysis, evidenceId?, recordPath? }.

image_report

{ analysis, imageId? } → { ok, markdown, sarif }.

Error codes

INVALID_INPUT · NOT_FOUND · PATH_ESCAPE · NOT_A_FILE · TOO_LARGE · UNSUPPORTED_IMAGE · STORE_ERROR

Compatibility & install

DeepSeek Harnessdsh-v0.2.3-alpha.1 (verified 2026-11-22); peer >=0.2.1-0 <0.3.0 || >=0.2.2-0 <0.3.0
Node^22.19.0 || >=24.9.0 (tested 24.22.1), ESM only
Peers@perrylink/dsh-research-core ^0.1.0, @deepseek-ai/cordis ^4.0.5-alpha.1, @deepseek-ai/dsh-tools, @deepseek-ai/schemastery ^3.18.5-alpha.1
Runtime dependencieszero (PNG via node:zlib)
dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-image-integrity
dsh --profile <name> --dump-config | grep dsh-image-integrity

Configuration

KeyDefaultMeaning
enabledtruefalse mounts nothing
root.image-integritystore/record root
workspaceRootprocess.cwd()paths must resolve inside it
maxBytes20971520file cap (fails, never truncates)
maxPixels4000000decoded pixel cap
persisttruestore images as REP evidence + record
blockSize / maxShiftBits16 / 6block side (2–256); bit tolerance (0–blockSize²)
minVariance / nccThreshold6 / 0.97texture floor; NCC confirmation

Security boundaries

  • Read-only on images; writes only under root.
  • realpath containment rejects symlink escapes.
  • Hard caps on bytes and pixels; the pixel cap is checked from the IHDR before inflation, and inflateSync is bounded by the expected output size. Failures are loud.
  • Per-call thresholds are validated (blockSize 2–256, maxShiftBits 0–blockSize², NCC 0–1); an invalid threshold is INVALID_INPUT, not a crash.
  • PNG parser bounds-checks every chunk; unsupported formats are rejected, not guessed.

Evaluation

dsh-image-integrity test suite and benchmark: a real run of the 23 tests — PNG decoding, duplicate and mirrored block detection, the flat and gradient false-positive controls and the mount contract all pass — followed by the real bench stdout over 100 synthetic pairs: manipulated precision, recall and F1 1.0000, false-positive rate 0.0000, no misclassified pair

Animated: the real pnpm test output and the real pnpm run bench:images stdout on 2026-11-21 (BENCH_DIR naming the dsh-research-bench checkout; frozen 100-pair synthetic dataset, no network). The pass markers are omitted because the terminal font has no check-mark glyph; the file names, counts and benchmark rows are verbatim.

23 tests: PNG round-trip, non-PNG / 16-bit / truncated rejection, pixel-cap rejection from the IHDR before inflation (configured and default), Hamming and NCC primitives, duplicate block detection, horizontal mirror detection, flat-image and gradient false-positive controls, small-image effective block size, pair matching, dimension-mismatch refusal, runtime (valid REP record, two snapshots per comparison, traversal/JPEG/byte-and-pixel oversize rejection, invalid threshold rejection), tools (schemas, check→report, compare, malformed report, failure branch), mount contract (disabled mounts nothing, enabled registers three unique tools), package contract.

Benchmark — 100 synthetic pairs. pnpm run bench:images scores the plugin against the frozen set (dataset version 0.1.0) in the companion dsh-research-bench repository (data/images): 25 duplicate + 25 flip + 25 unrelated + 25 hard-negative pairs of 64×64 8-bit grey PNGs, fixed seed, with positives copying grid-aligned 16×16 blocks. The adapter runs against the built lib/, writes bench/results-images.json with no timestamps (rerunning on the same data is byte-identical), and reads a sibling ../dsh-research-bench checkout by default. Set BENCH_DIR or pass node bench/run-images.mjs --data <dir> for another location.

Metric (50 manipulated / 50 clean)Value
Manipulated precision1.0000
Manipulated recall1.0000
Manipulated F11.0000
False-positive rate (unrelated + hard-negative)0.0000
Subtype recall — duplicate1.0000
Subtype recall — flip (horizontal 13 / vertical 12)1.0000

Confusion: TP 50, FP 0, TN 50, FN 0; no pair was misclassified. Per-category accuracy is 1.0000 in all four categories (25/25 each). Scope: the positives copy grid-aligned 16×16 blocks, i.e. the detector's own unit; sub-grid shifts, JPEG recompression, scaling and rotation are outside this set and remain documented limitations. These are synthetic numbers on a frozen fixture, not a claim about how often real figures reuse panels. The dataset and generator live in the companion repository and are not published with this package.

Known limitations (v0.1)

  • PNG-only; no JPEG/WebP/TIFF.
  • No scaling/rotation/recompression robustness.
  • Block grid is axis-aligned; a duplicated region shifted by a few pixels can be missed.
  • No colour-channel or metadata (EXIF) analysis.

License

Apache-2.0. No third-party runtime code.

関連プラグイン