testsAndMisc/python_pkg/artgate/styles/pixel_icon.toml
Krzysztof kuhy Rudnicki da8ca6d827
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
artgate: deterministic exit-code gates for generated game art
Adds the route-independent spine of the planned art-generation bake-off: a
harness that decides whether generated art is well-formed, so "non-sloppy"
becomes machine-checkable instead of a judgement call.

Findings that shaped the design, all measured rather than assumed:

- Integer-scale invariance separates true pixel art (impurity 0.0000) from
  interpolated fakes (1.0000) exactly -- but passes trivially at scale 1, so
  it must never be trusted alone on native-resolution output.
- Gate ORDER is load-bearing. A soft-alpha image has no fully-opaque pixels,
  so an opaque-only colour count returns 0 and silently passes. ALPHA_NOT_BINARY
  now runs first and COLOR_COUNT fails closed on an empty opaque set.
- Counting must be over opaque RGB only: transparent pixels retain arbitrary
  RGB and inflated a naive RGBA count, rejecting correct art at 18/16.
- Declaring a gate was not enough to run it. hand_painted.toml shipped
  declaring SILHOUETTE_LOW_CONTRAST with no implementation, so it parsed, ran
  nothing, and reported a pass. load_spec now fails closed on unimplemented
  gates, result-only codes, and gates missing their config.

Thresholds are calibrated against 250 genuine 32x32 CC0 icons, not guessed:
p50=7 p90=13 p99=26 opaque colours; cap 32 rejects 0.0% of real art while raw
generator output measured 34403 colours. An initial cap of 16 wrongly rejected
a real DCSS icon -- re-derived from the corpus rather than nudged.

Verified: 57 tests, 100% branch coverage, zero suppressions, all hooks pass.
58/60 (96.7%) of real CC0 icons pass the full stack; both failures confirmed
true positives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9rQ12yZ7sJxiPQTCS5dUF
2026-08-15 22:20:36 +02:00

34 lines
1.4 KiB
TOML

# Pixel-art item icon: the most machine-checkable style, and the one where
# "AI slop" is most detectable.
#
# CALIBRATION (measured, not guessed) over 250 genuine 32x32 CC0 icons from
# ~/opengameart-downloads:
# p50=7 p75=10 p90=13 p95=14 p99=26 max=30
# Rejection rate of real hand-made art by cap:
# cap 16 -> 3.6% cap 24 -> 1.2% cap 32 -> 0.0%
#
# A first attempt at 16 rejected a real DCSS rambutan icon (18 colours, clean
# binary alpha). That is the "the threshold was wrong, not the art" failure the
# seamless-tilesets skill documents, so the cap was re-derived from the corpus
# rather than nudged until one file passed. 32 admits all observed hand-made
# art while still rejecting un-quantized generator output by a wide margin
# (a raw diffusion sample measured 34403 colours before its finishing stage).
name = "pixel_icon"
canvas = [32, 32]
max_colors = 32
alpha_binary = true
min_margin = 1
# ALPHA_NOT_BINARY is listed first because ordering is load-bearing: a
# soft-alpha image has no fully-opaque pixels, so the colour gate would
# otherwise count zero and pass. See pixels.py module docstring.
# NO_OPAQUE_PIXELS is deliberately absent: it is a result code emitted by the
# colour/palette gates when they fail closed, not a gate you can request.
gates = [
"ALPHA_NOT_BINARY",
"TOO_MANY_COLORS",
"CANVAS_SIZE",
"SCALE_NOT_INVARIANT",
"SILHOUETTE_LOW_CONTRAST",
]