code wiki / _hdl_build / nx_eng_diff_miscompile.nx

nx_eng_diff_miscompile.nx

buildroot/runtime/_hdl_build/nx_eng_diff_miscompile.nx

4459 B104 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic eng
docsdependenciesstructsconstsfunctions

about

nx_eng_diff_miscompile.nx -- the ENGINEER's DIFFERENTIAL miscompile detector. The full-pipeline gate (nx_engineer_gate_runner) catches crashes and compile-fails; it is BLIND to a LOGIC miscompile -- a wrong result from correct-looking code. The known-good compiler does exactly this under register pressure (a value held live across many calls is not spilled, so a later comparison reads garbage and flips -- see project-knowngood-compiler-regpressure-miscompile-2026-06-03). This detects that class by DIFFERENTIAL execution: compute the SAME logical value two structurally different ways and flag any divergence -- ed_hp HIGH register pressure: the value is held live across many ed_noise() calls, then tested (the exact shape that miscompiled rc_bad / v1). ed_lp LOW pressure: the value is staged in MEMORY and reloaded for the test. Both must equal the compile-time-known answer (K = -3 -> "is K<0?" -> 1). If ed_hp disagrees with ed_lp or with the known answer, a logic miscompile is present. RACI: detection only -- the Engineer reports; it does not fix or admit. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_eng_diff_miscompile.nx nx_eng_diff_miscompile_test.nx

imports: nx_syscalls.nx

imported by: nx_eng_diff_miscompile_test.nx

structs

none

consts

18const ED_MAGIC_999999: i64 = 999999
20const ED_AGREE: i64 = 0
21const ED_DIVERGE: i64 = 1

functions

24func eng_diff(a: i64, b: i64) -> i64 { if a == b { return ED_AGREE } return ED_DIVERGE }
29func ed_heavy(x: i64) -> i64
called by 2: ed_hped_lp calls 1: sys_mmap
41func ed_hp() -> i64
74func ed_lp() -> i64
96func eng_detect_logic_miscompile(out: *i64) -> i64
called by 1: main calls 3: ed_hped_lpeng_diff