code wiki / (root) / nx_photomark_gate.nx

nx_photomark_gate.nx

buildroot/runtime/nx_photomark_gate.nx

35532 B519 linesdepth 11pulls 52 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_photomark_gate.nx -- the referee for nx_photomark_lib (aesthetictwin AT4 / AT23, 2026-09-16). In-process on a synthetic frontal face (no network, no decoder, no real card): a skin ellipse on a non-skin non-dark field, two dark lens-shaped eyes whose canthi are PLANTED with ASYMMETRIC tilts (right 85, left 57 deg10), a red mouth with a dark stomion line splitting it 10 over 14. The ruler must find the face box, both eye pairs of canthi within pixels, both tilts within tolerance with the asymmetry preserved, the two canon ratios the planted geometry implies, the stomion row and the lip ratio; a field with no face is UNMEASURED, a face without eyes is UNMEASURED, and a MIRRORED fixture swaps the sides while each tilt keeps its sign. The card write appends five measured rows once and refuses the second time. The file door (AT33): the same fixture encoded through the sovereign PNG writer and read back through pm_landmarks_file_auto must reproduce the in-process numbers exactly and announce the PNG codec; a non-image file is a named decode refusal and an absent file is unreadable. AT44 (2026-09-18): the mouth's five landmarks on the planted lines; DECOYS that must not move them (a black chin fold wider and darker than the seam, a shadow redder than the lip between them); a mouth with no seam and a seam shorter than a lip refused by name; a one-pixel lash wing followed to its tip past the blob with a decoy dot one pixel beyond the fissure's bridge left alone; a fissure run onto its window's side refused as PINNED; the referee scoring the planted mouth (ruler and anchored) FOUND and a mouth shifted 40 px PLACED-OFF. Each of these teeth was bitten by a mutant of the lib (see the board's AT44 log). Values are printed with gv_kv. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_photomark_lib.nx nx_png.nx nx_photomark_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_photomark_lib.nxnx_png.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_head gv_puts sys_write gv_ctr sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_mmap ↻ pg_face pg_fill pg_set pg_ellipse pg_set ↻ pg_lens pg_abs pg_set ↻ pg_hband pg_set ↻ pm_landmarks pm_min sys_mmap ↻ sks_is_skin pm_luma pm_largest_component sys_mmap ↻ pm_max pm_luma_at

structs

none

consts

22const PG_W: i64 = 240
23const PG_H: i64 = 300
24const PG_BG_R: i64 = 120
25const PG_BG_G: i64 = 140
26const PG_BG_B: i64 = 200
27const PG_SKIN_R: i64 = 200
28const PG_SKIN_G: i64 = 150
29const PG_SKIN_B: i64 = 120
30const PG_FACE_CX: i64 = 120
31const PG_FACE_CY: i64 = 150
32const PG_FACE_RX: i64 = 80
33const PG_FACE_RY: i64 = 110
34const PG_EYE_DARK: i64 = 20
35const PG_RLAT_X: i64 = 65
36const PG_RLAT_Y: i64 = 116
37const PG_RMED_X: i64 = 105
38const PG_RMED_Y: i64 = 122
39const PG_LMED_X: i64 = 135
40const PG_LMED_Y: i64 = 122
41const PG_LLAT_X: i64 = 175
42const PG_LLAT_Y: i64 = 118
43const PG_EYE_HALF_H: i64 = 7
44const PG_EXP_TILT_R: i64 = 85
45const PG_EXP_TILT_L: i64 = 57
46const PG_TOL_TILT: i64 = 20
47const PG_TOL_PX: i64 = 4
48const PG_TOL_BOX: i64 = 6
49const PG_MOUTH_CX: i64 = 120
50const PG_MOUTH_CY: i64 = 205
51const PG_MOUTH_RX: i64 = 28
52const PG_MOUTH_RY: i64 = 12
53const PG_LIP_R: i64 = 190
54const PG_LIP_G: i64 = 80
55const PG_LIP_B: i64 = 90
56const PG_STOMION_Y: i64 = 203
57const PG_STOMION_ROWS: i64 = 2
58const PG_TOL_STOMION: i64 = 2
59const PG_EXP_LIP: i64 = 714 // 10 over 14 to the stomion row; since AT44 each lip runs to its own inner edge (10 over 13 = 769, within tolerance)
60const PG_TOL_LIP: i64 = 120
61const PG_EXP_ICI: i64 = 272
62const PG_TOL_ICI: i64 = 40
63const PG_EXP_ICF: i64 = 744
64const PG_TOL_ICF: i64 = 70
65const PG_BPP: i64 = 3
66const PG_I64: i64 = 8
67const PG_PERMIL: i64 = 1000
68const PG_CARD_ROWS: i64 = 5
69const PG_DIR: *u8 = "/tmp/photomark_gate"
70const PG_KDIR: *u8 = "/tmp/photomark_gate/knowledge"
71const PG_CARD_DIR: *u8 = "/tmp/photomark_gate/knowledge/twincard"
72const PG_CARD_BARE: *u8 = "/tmp/photomark_gate/knowledge/twincard/fy.card"
73const PG_PNG_PATH: *u8 = "/tmp/photomark_gate/fixture_face.png"
74const PG_JUNK_PATH: *u8 = "/tmp/photomark_gate/not_an_image.txt"
75const PG_JUNK_TEXT: *u8 = "this is prose, not a still: neither the PNG signature nor a JPEG marker opens it\n"
76const PG_ABSENT_PATH: *u8 = "/tmp/photomark_gate/absent/nothing.png"
77const PG_SHIFT_G: i64 = 8
78const PG_SHIFT_B: i64 = 16
81const PG_DIR_SLASH: *u8 = "/tmp/photomark_gate/"
82const PG_ORACLE_PATH: *u8 = "/tmp/photomark_gate/fixture.oracle"
83const PG_ORACLE_SHIFT_PATH: *u8 = "/tmp/photomark_gate/fixture_shifted.oracle"
84const PG_ORACLE_ABSENT_PATH: *u8 = "/tmp/photomark_gate/absent/none.oracle"
85const PG_ROW_CAP: i64 = 512
86const PG_X10: i64 = 10
87const PG_ORACLE_ZERO_XY: i64 = 11
88const PG_LIP_DECOY_X: i64 = 3
89const PG_ORACLE_SHIFT_PX: i64 = 30
90const PG_DIAG_PERMIL_OF_TOL: i64 = 1500
91const PG_CARD_BARE_TEXT: *u8 = "card|fy|Fixture Bare|2026-09-16|fixture\n"
92const PG_MODE644: i64 = 420
93const PG_MODE755: i64 = 493
96const PG_LS_Y: i64 = 193 // PG_MOUTH_CY - PG_MOUTH_RY
97const PG_LI_Y: i64 = 217 // PG_MOUTH_CY + PG_MOUTH_RY
98const PG_CHR_X: i64 = 94 // PG_MOUTH_CX - PG_MOUTH_RX + 2: where the planted seam band starts
99const PG_CHL_X: i64 = 146 // PG_MOUTH_CX + PG_MOUTH_RX - 2
100const PG_TOL_LIPLINE: i64 = 2
103const PG_FOLD_Y: i64 = 224
104const PG_FOLD_ROWS: i64 = 2
105const PG_FOLD_X0: i64 = 90 // wider than the seam (94..146), narrower than half the mouth window (1.8 eye spans), as a real fold
106const PG_FOLD_X1: i64 = 150
107const PG_SHADOW_Y: i64 = 218
108const PG_SHADOW_ROWS: i64 = 4
109const PG_SHADOW_R: i64 = 150
110const PG_SHADOW_G: i64 = 40
111const PG_SHADOW_B: i64 = 60
112const PG_DARKEST: i64 = 0
114const PG_DASH_HALF: i64 = 5
118const PG_WING_LEN: i64 = 14
119const PG_WING_TIP_X: i64 = 51 // PG_RLAT_X - PG_WING_LEN
120const PG_DOT_GAP: i64 = 3
121const PG_DOT_HALF: i64 = 1
122const PG_TOL_WING: i64 = 1
125const PG_WING_DARK: i64 = 60
127const PG_BAR_X0: i64 = 0
128const PG_REF_LIP_ORACLE_PATH: *u8 = "/tmp/photomark_gate/fixture_lips.oracle"
129const PG_REF_LIP_SHIFT_PATH: *u8 = "/tmp/photomark_gate/fixture_lips_shifted.oracle"
130const PG_LIP_SHIFT_PX: i64 = 40
131const PG_EXP_LIP_ORACLE: i64 = 769 // the planted mouth to each lip's own inner edge: (203 - 193) over (217 - 204)
132const PG_ORACLE_LIP_XY: i64 = 6 // the lip points an oracle row carries before its iris, nose, chin and brow points
135const PG_TOL_LIP_BORDERS: i64 = 136

functions

137func pg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 2: pg_lenspg_near
138func pg_set(rgb: *u8, w: i64, x: i64, y: i64, r: i64, g: i64, b: i64) -> i64
145func pg_fill(rgb: *u8, w: i64, h: i64, r: i64, g: i64, b: i64) -> i64
called by 2: pg_facemain calls 1: pg_set
150func pg_ellipse(rgb: *u8, w: i64, h: i64, cx: i64, cy: i64, rx: i64, ry: i64, r: i64, g: i64, b: i64) -> i64
called by 2: pg_facepg_seamless calls 1: pg_set
167func pg_lens(rgb: *u8, w: i64, h: i64, x0: i64, y0: i64, x1: i64, y1: i64, halfh: i64, r: i64, g: i64, b: i64) -> i64
called by 1: pg_face calls 2: pg_abspg_set
197func pg_hband(rgb: *u8, w: i64, x0: i64, x1: i64, y0: i64, rows: i64, r: i64, g: i64, b: i64) -> i64
202func pg_mirror(src: *u8, dst: *u8, w: i64, h: i64) -> i64
called by 1: main
216func pg_face(rgb: *u8, eyes: i64, mouth: i64) -> i64
229func pg_write(path: *u8, text: *u8) -> i64
236func pg_near(a: i64, b: i64, tol: i64) -> i64 { if pg_abs(a - b) <= tol { return 1 } return 0 }
called by 1: main calls 1: pg_abs
238func pg_xy10(out: *u8, o: i64, x: i64, y: i64) -> i64
245func pg_oracle_row(out: *u8, shift: i64, exo: i64) -> i64
called by 1: main calls 1: pg_xy10
259func pg_rect(rgb: *u8, x0: i64, x1: i64, y0: i64, y1: i64, r: i64, g: i64, b: i64) -> i64
called by 2: pg_mouth_decoyspg_wing calls 1: pg_set
265func pg_mouth_decoys(rgb: *u8) -> i64
called by 1: main calls 2: pg_facepg_rect
272func pg_seamless(rgb: *u8, dash: i64) -> i64
called by 1: main calls 3: pg_facepg_ellipsepg_hband
279func pg_wing(rgb: *u8) -> i64
called by 1: main calls 3: pg_facepg_hbandpg_rect
288func pg_bar(rgb: *u8) -> i64
called by 1: main calls 2: pg_facepg_hband
295func pg_oracle_row_lips(out: *u8, lshift: i64, exo: i64) -> i64
called by 1: main calls 1: pg_xy10
315func pg_pack_fb(rgb: *u8, w: i64, h: i64, fb: *i64) -> i64
called by 1: main
326func main(argc: i64, argv: *i64) -> i64