Principle:AI Builder Club Skills Diagram Verification
| Knowledge Sources | |
|---|---|
| Domains | Diagram_Generation, Verification |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
A verification methodology for rendered diagrams that samples GIF frame differences to confirm visible motion and validates output file existence, dimensions, and frame count against the specification.
Description
Diagram verification addresses the problem that a renderer can silently produce broken output: a GIF with no animation (all identical frames), wrong dimensions, or missing files. The technique has two components: motion verification (gif_motion_report) samples 4 frames at positions [0, n/3, 2n/3, n-1], computes ImageChops.difference per adjacent pair, and counts changed pixels — any non-zero diff confirms the GIF has visible motion; output validation (validate_outputs) checks that both PNG and GIF files exist, that pixel dimensions match the spec's canvas, that GIF frame count matches the spec, and that the GIF has motion. With --check, any failed check causes sys.exit(1), making it a hard gate in automated pipelines.
Usage
Always run with --verify --check before delivering a diagram. Use in automated pipelines where broken output must be caught programmatically.
Theoretical Basis
The technique applies differential frame analysis: if two frames in an animated GIF are identical, the difference image has zero non-black pixels. By sampling strategic positions (start, 1/3, 2/3, end), we cover the animation cycle without inspecting every frame. The validation checks enforce the contract between spec and output: the spec declares dimensions and frame count, and the output must match.
# Abstract model:
def verify_motion(gif_path):
frames = sample_frames(gif_path, positions=[0, n//3, 2*n//3, n-1])
diffs = []
for a, b in pairs(frames):
delta = image_difference(a, b)
changed = count_nonzero(delta)
diffs.append({"from": a.index, "to": b.index, "changed_pixels": changed})
return any(d["changed_pixels"] > 0 for d in diffs)
def validate_outputs(result, spec):
checks = [
file_exists(result.png), file_exists(result.gif),
dimensions_match(result.png, spec.canvas),
dimensions_match(result.gif, spec.canvas),
frame_count_matches(result.gif, spec.canvas.frames),
has_motion(result.gif),
]
return all(checks)