code wiki / _hdl_build / nx_eng_diff_miscompile.nx
nx_eng_diff_miscompile.nx
buildroot/runtime/_hdl_build/nx_eng_diff_miscompile.nx
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
imports: nx_syscalls.nx
imported by: nx_eng_diff_miscompile_test.nx
structs
| none |
consts
| 18 | const ED_MAGIC_999999: i64 = 999999 |
| 20 | const ED_AGREE: i64 = 0 |
| 21 | const ED_DIVERGE: i64 = 1 |
functions
| 24 | func eng_diff(a: i64, b: i64) -> i64 { if a == b { return ED_AGREE } return ED_DIVERGE } |
| 29 | func ed_heavy(x: i64) -> i64 |
| 41 | func ed_hp() -> i64 |
| 74 | func ed_lp() -> i64 |
| 96 | func eng_detect_logic_miscompile(out: *i64) -> i64 |