code wiki / _hdl_build / nx_gen_cid_gate.nx
nx_gen_cid_gate.nx
buildroot/runtime/_hdl_build/nx_gen_cid_gate.nx
about
nx_gen_cid_gate.nx -- REFEREE for the GALLERY CID CANON (debt 1785881333 / 1785881657).
WHAT IT PROTECTS. The gallery CID is NOT a hash of the pixels, despite the name: it is a hash of a
CANONICAL FORM built from the PNG's tEXt fields. Twice on 2026-08-04 that canon was missing a
field that genuinely changes the image, and the consequence each time was SILENT DATA LOSS -- the
second render collided onto the first cid and gp_one's openat_wr truncated the earlier blob:
* resolution: 512x512 (md5 a9fa671a) then 768x1024 under the SAME cid -> the 512 image was gone.
* cfg_scale: cfg 1.0 (md5 f10849c2) vs 5.0 (md5 6471d466), two different pictures, ONE cid.
Fixed by adding `size` and then `args` (the exact generator-facing argument string) to the canon.
★WHY A GATE AND NOT JUST THE FIX: the second collision existed the whole time the first was being
celebrated as fixed. Nothing was checking, so a narrower trigger survived. This gate encodes the
INVARIANT rather than the two instances: ANY tEXt field that differs must move the cid.
★HERMETIC AND GPU-FREE. It builds tiny synthetic PNGs in memory and drives the REAL
png_insert_genrec + nx_store_ingest_compute_cid -- the same code the daemon runs. No render, no
engine, no network, so it is safe on any cadence. (A gate that needs a GPU is a gate nobody runs.)
license_tier: ORIGINAL expect_exit: 0
module: nishi-core.gen.cidgate
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_png_textw.nxnx_store_ingest.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 25 | const CG_BUF: i64 = 262144 |
functions
| 27 | func cw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 28 | func cn(v: i64) -> i64 |
| 40 | func cg_be32(b: *u8, o: i64, v: i64) -> i64 called by 1: cg_stub |
| 45 | func cg_stub(dst: *u8, w: i64, h: i64) -> i64 |
| 65 | func cg_cid(seed: *u8, model: *u8, sampler: *u8, steps: *u8, host: *u8, prompt: *u8, size: *u8, args: *u8, cidout: *u8) -> i64 |
| 76 | func cg_same(a: *u8, b: *u8) -> i64 called by 1: main |
| 82 | func main(argc: i64, argv: *i64) -> i64 |