nx_cc nx_int Struct-Field Offset Miscompile

Root cause, minimal repro, validated fix — and the sovereign objective-beauty measuring suite restored to green. 2026-07-21

Compiler correctness · sev8Suite 6/6 green2292 decls / 337 files exposeddebt seq521frontier F-CC-NXINT

Summary

A rigor pass on the “un-migrated beauty/aesthetic measuring systems” found they already exist as sovereign organs — but were bulk-generated 2026-05-16 with verdict: NOT_YET_EVALUATED and never compiled+run. Compiling their self-tests against today’s nx_cc exposed a foundational codegen bug: struct fields declared with the nx_int type alias are laid out as size-0, so field offsets collapse. This produced a SIGSEGV in nx_landmark_anatomy. Root-caused with a minimal repro, fixed on the path, and the full measuring suite is now 6/6 green with no regressions.

The measuring suite (already migrated — consolidate, don’t reinvent)

A complete sovereign objective_beauty pipeline exists in runtime/:

PNG → nx_png_decode → skin mask (nx_color_v2) → nx_segmenter_connected
  → nx_landmark_anatomy_label   (head/torso/arm/leg bboxes)
  → nx_anatomy_measure_body     (eye/face/bust/waist/hip/shoulder axes)
  → nx_beauty_score(canon)      (φ/Loomis/Vitruvian/linear → S/A/B verdict)
  + nx_symmetry_group              (7-axis symmetry report)

Root cause (hardened, not asserted)

Minimal repro runtime/_hdl_build/nx_segfield_repro.nx — identical struct shapes, only the field type varies:

CaseStruct field layoutResult
i64 fields{n:i64, p:*T, w:i64}offset 0 correct
nx_int fields{n:nx_int, p:*T, w:nx_int}pointer lands on offset 0
all-nx_int{a,b,c: nx_int}every field at offset 0
pointer-first{p:*T, n:nx_int}survives

Mechanism: nx_int (an alias for i64) is treated as size 0 during struct layout, so any field following it collapses onto the wrong offset. The hand-written Image struct always worked precisely because it uses i64 fields with the pointer first.

Fix & validation

Declare the affected struct fields as concrete i64. Fixed 5 structs + a separate Sobel border false-edge in nx_aesthetics_sharpness (uniform image was scoring non-zero).

OrganBeforeAfter
nx_landmark_anatomySIGSEGV (139)pass
nx_segmenter_classicaluntestedpass
nx_symmetry_group_testexit 1pass
nx_aesthetics_testexit 20pass
nx_beauty_score_testpasspass
nx_anatomy_measure_testpasspass
=== SUITE: 6 pass / 0 fail ===

Exposure & follow-up

Law banked: an organ whose safety envelope reads verdict: NOT_YET_EVALUATED has not been compiled+run — “it exists in runtime/” is unproven. Run its self-test against today’s compiler before building on it.

Sovereign engineering record · Nishi ecosystem · filed to the information plane (knowledge/store/sota-), debt registry (seq521) and frontier RACI (F-CC-NXINT). Verifiable, reproducible, no regressions.