code wiki / (root) / nx_fieldfit_verified_r2_gate_t333.nx

nx_fieldfit_verified_r2_gate_t333.nx

buildroot/runtime/nx_fieldfit_verified_r2_gate_t333.nx

15378 B252 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tooltopic fieldfit
docsdependenciesstructsconstsfunctions

about

nx_fieldfit_gate.nx -- THE FIELD-FIT MACHINERY (nx_fieldfit_lib) ON A SYNTHETIC ORACLE WITH A KNOWN ANSWER (anatomy AN17, 2026-09-19). The oracle is a point sphere of radius FG_R centred (FG_CX, FG_CY, FG_CZ), sampled on a 10-degree lattice; the field is a sphere whose centre and radius are stations 0..3 of a five-station vector, with station 4 a DECOY the field never reads and the live mask retires. Started from a wrong vector, the descent must recover the centre and the radius to FG_TOL mm, must leave the decoy untouched, and must not move from the true vector (a move accepted at the optimum is a broken accept rule). The fit file's prefix contract and the spatial hash are held to exact answers. NEG-CONTROL: the two-sided objective must charge a shrunken sphere MORE than the true one (a one-sided objective is gamed by deleting geometry; this is the tooth that cannot pass on one side). license_tier: ORIGINAL. No hw writes (Rule 26).

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_sdfprim_lib.nx nx_fieldfit_verified_r2_t333.nx nx_fieldfit_verified_r2_gate_t

imports: nx_syscalls.nxnx_gate_verdict.nxnx_sdfprim_lib.nxnx_fieldfit_verified_r2_t333.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 ↻ ff_ctx_new sys_mmap ↻ fg_oracle sp_isin sp_icos sp_isin ↻ gv_check gv_puts ↻ ff_bin ff_cell ff_regions gv_check_eq gv_check ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap ff_near ff_isqrt

structs

none

consts

15const FG_NP: i64 = 5
16const FG_NREG: i64 = 8 // the octants
17const FG_CAP: i64 = 4096
18const FG_EXT: i64 = 60 // the sphere (centre 8, radius 40) fits in +/- 60
19const FG_DIM: i64 = 12
20const FG_LAT: i64 = 6
21const FG_R: i64 = 40
22const FG_CX: i64 = 5
23const FG_CY: i64 = 0-3
24const FG_CZ: i64 = 8
25const FG_DECOY: i64 = 777
26const FG_WRONG_DX: i64 = 12 // the wrong start: centre x shifted, radius shrunk
27const FG_WRONG_R: i64 = 25
28const FG_SHRUNK_R: i64 = 20 // the neg-control's deleted geometry
29const FG_PASSES: i64 = 6
30const FG_STEP0: i64 = 8
31const FG_TOL: i64 = 2 // mm: the reverse lattice at 6 mm bounds the placement
32const FG_STEP_DEG: i64 = 10
33const FG_FILE: *u8 = "/tmp/nx_fieldfit_gate.fit"
34const FG_FILE3: *u8 = "/tmp/nx_fieldfit_gate.fit3"
35const FG_FILE2: *u8 = "/tmp/nx_fieldfit_gate.fit2"
36const FG_ABSENT: *u8 = "/tmp/nx_fieldfit_gate.absent"
37const FG_MODE644: i64 = 420
53const FG_EXTRA: i64 = 900

functions

39func fg_field(px: i64, py: i64, pz: i64, a: i64, b: i64, P: *i64) -> i64
calls 1: sp_isqrt
45func fg_region(x: i64, y: i64, z: i64) -> i64
52func fg_live(k: i64) -> i64 { if k == 4 { return 0 } return 1 }
54func fg_extra(P: *i64) -> i64 { return FG_EXTRA }
55func fg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
57func fg_oracle(c: *FfCtx) -> i64
called by 1: main calls 2: sp_isinsp_icos
79func fg_write(path: *u8, s: *u8) -> i64
90func fg_valid(P: *i64, np: i64) -> i64 { if np != FG_NP { return 0 } if P[3] <= 0 { return 0 } return 1 }
called by 2: fg_bound_validmain
91func fg_contract() -> *FfFitContract
called by 1: main calls 1: sys_mmap
101func fg_decoy_live(k: i64) -> i64 { if k == 4 { return 1 } return 0 }
102func fg_bound_valid(P: *i64, np: i64) -> i64 { if P[4] < 0 { FG_BAD_TRIAL = FG_BAD_TRIAL + 1; return 0 } return fg_valid(P, np) }
calls 1: fg_valid
104func main(argc: i64, argv: *i64) -> i64