# Texel invariant — zero is a sentinel, not a colour

**Slug:** `texel-invariant` · **Lesson:** `zero-is-not-black` · **Status:** check green in this tree (tally in the library receipt; registry flip is the integrator's step).

## Lesson

In claim art, the value **0 is not black**. It is the substitution
seam's never-sampled sentinel — the same 0 that marks transparent
subpixels in every claim. A claim carrying 0 on a stock-*opaque*
subpixel drops that texel at render time: the pixel falls through
the sprite to whatever is behind it. In the v16 anchor that was the
road / palette-0 grey ladder showing through the NPCs — the
founder's "grey/checkered holes" (escalation 2026-11-06 21:35 EST).

So the invariant is checked where the defect lives — on the pack,
against the stock silhouette, for every claim — never by frame
colour heuristics (the night grade remaps whole frames, and
legitimately authored greys exist; a frame cannot isolate this).
States do not change claim art: a pack that passes here cannot drop
a texel in *any* state (day / night / weather). That is the whole
law: **zero-on-opaque == 0, across all claims, or the pack fails.**

The check must also prove the detector can see: it fires on real
convicted data with exact counts, fires on a labeled synthetic
negative control with exactly the zeroed count, and does *not* fire
when zeroes are confined to transparent subpixels — the stock mask
is the instrument, not the zero count.

## Provenance

Faithful Node port of `gbc-guest/fork-work/pipeline-grade/
gamem8c-sprites1/verify_texel_invariant.py` (`load_objs`,
`idxmap`, `check_pack`), the standing gate retained by
`RULING-character-standard.md` and passed by the better-artwork
pack (`RECEIPT-better-artwork.md`: "pk565 sentinel floor / texel
invariant: PASS — zero-on-opaque = 0 across all claims"). The
defect case is filed in `RECEIPT-sprite-regression.md`.

**Fixtures (real extraction, house tooling):** at build time the
house's own `verify_texel_invariant.py` (`load_objs` + `idxmap`)
extracted JSON claim sets — pattern bytes + 1024 uint16 art values
per claim:

- `example/claims-artwork.json` — first 6 claims by hash from
  `crystal-fdcc3c8c-v1-artwork.n8pk`.
- `example/claims-v16-convicted.json` — the 6 worst claims of
  `crystal-fdcc3c8c-v16.n8pk`, with the per-claim counts the house
  tool measured.
- `example/claims-negative-synthetic.json` — **synthetic** negative
  control (labeled in the file): the first artwork claim with its
  first 12 opaque subpixels zeroed. Not pack data.

## How to run

```text
node example.cjs   # invariant over all three fixture sets + JSON line
node check.cjs     # self-check: prints PASS <n> FAIL <m>, exit 1 on any failure
const { runCheck } = require('./check.cjs');
const P = require('./program.cjs');  // loadObjs, checkPack, checkClaims, zeroOnOpaque, makeNegativeControl
```

`program.cjs` also carries the full pack reader (`loadObjs` /
`checkPack` over an .n8pk buffer), so a lane can gate a whole pack,
not only fixture subsets.

## Worked example

`example.cjs` reports: artwork subset 6 claims → 0 zero-on-opaque
(PASS); v16 worst-6 → 791 zero-on-opaque across 6 claims, per claim
161 / 145 / 137 / 118 / 116 / 114 (detector fires); synthetic
control → exactly 12.

## Numbers reproduced

- **Per-claim filed counts, exact:** each v16 fixture claim's
  zero-on-opaque as measured by the house Python tool at extraction
  (161, 145, 137, 118, 116, 114; subset total 791) is reproduced by
  the Node port claim for claim.
- **Filed gate value, exact:** 0 zero-on-opaque on the real artwork
  claims — the subset of the pack whose filed gate result is
  "zero-on-opaque = 0 across all claims".
- **Synthetic control, exact by construction:** 12 zeroed → 12
  detected; 12 zeroes on transparent positions → 0 detected.

## Cited, not reproduced (pipeline-level)

The v16 pack totals — **14,979 zero-on-opaque across 218 claims** —
were reproduced exactly by the house tool at extraction time
(330 hash-distinct claims read) and are recorded in the fixtures'
`packLevel` fields, but the library check does not claim them: a
6-claim subset cannot reproduce a pack total, and pretending
otherwise would be the exact inflation this library exists to
prevent. Running `checkPack` over the full v16 .n8pk with this
port is the route to the pack-level number.

## Consumers

GameM8c pack gate (every pack, every state — the standing
invariant), Emerald packs (same claim format, same gate).

## Honest limits

- The reader inherits the source tool's shape: claims are keyed by
  hash alone, so scope variants sharing a hash share one slot —
  330 distinct hashes serve 395 (hash, palette) entries. The filed
  pack totals are this reader's numbers; the port keeps the shape
  deliberately rather than silently "fixing" the instrument.
- Fixtures are subsets (6 + 6 claims) chosen for size; they prove
  the detector both ways but are not a pack audit. The full-pack
  path (`checkPack`) is untested against a committed .n8pk fixture
  because packs are ~800 KB and live in the source tree; it is a
  line-for-line port of the reader that produced the filed totals.
- The invariant is necessary, not sufficient: a pack can pass it
  and still be bad art. Painting quality is the painting-grammar
  program's and the founder's zoom court's business, not this gate's.
