nx_cc_probe.nx source
↩ module page · 84 lines · 3465 B
1// nx_cc_probe.nx -- sovereign compiler A/B LOOP-DETECTOR (no shell).
2//
3// Runs the ACTIVE vs the pinned KNOWN-GOOD compiler on each print module via
4// nx_run_timeout, and classifies each: ok / **LOOP** (hung, killed) / err.
5// The module where ACTIVE=LOOP but KNOWN-GOOD=ok is the P0 front-end regression
6// trigger. This is the NishiLang replacement for the _p0_*.sh triage scaffolding
7// the operator (rightly) rejected -- the medium embodies the message.
8// license_tier: ORIGINAL
9
10import "nx_run_timeout.nx"
11const K_MAGIC_40000: i64 = 40000
12
13func cp_puts(s: *u8) -> i64 {
14 var n: i64 = 0
15 while s[n] != 0 as u8 { n = n + 1 }
16 sys_write(1, s, n)
17 return 0
18}
19func cp_putn(n: i64) -> i64 {
20 if n == 0 { sys_write(1, "0" as *u8, 1); return 0 }
21 var m: i64 = n
22 let d: *u8 = sys_mmap(24)
23 var k: i64 = 0
24 while m > 0 { d[k] = (0x30 + (m % 10)) as u8; m = m / 10; k = k + 1 }
25 var j: i64 = k - 1
26 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 }
27 return 0
28}
29
30// run one compiler on one module; print "ok|**LOOP**|err(n) <ms>ms".
31func cp_run(compiler: *u8, module: *u8, timeout_ms: i64) -> i64 {
32 let argv: *i64 = sys_mmap(32) as *i64
33 argv[0] = compiler as i64
34 argv[1] = module as i64
35 argv[2] = 0
36 let envp: *i64 = sys_mmap(8) as *i64
37 envp[0] = 0
38 let elbox: *i64 = sys_mmap(8) as *i64
39 elbox[0] = 0
40 let rc: i64 = nx_run_timeout(compiler, argv, envp, timeout_ms, elbox)
41 if rc == NX_RT_TIMEOUT { cp_puts("**LOOP**") }
42 else {
43 if rc == 0 { cp_puts("ok ") }
44 else { cp_puts("err("); cp_putn(rc); cp_puts(")") }
45 }
46 cp_puts(" "); cp_putn(elbox[0]); cp_puts("ms")
47 return rc
48}
49
50func main() -> i64 {
51 let active: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_compile_x86_native.elf" as *u8
52 let kg: *u8 = "/mnt/c/Users/elder/nishi-core/nxc2/_offc/nx_cc_known_good.elf" as *u8
53 let to_ms: i64 = K_MAGIC_40000
54
55 cp_puts("NISHI BUILDER -- sovereign compiler loop-detector (nx_run_timeout, no shell)\n")
56 cp_puts("module | ACTIVE | KNOWN-GOOD\n")
57 cp_puts("---------------------------- | ------------------- | -------------------\n")
58
59 let N: i64 = 5
60 let mods: *i64 = sys_mmap(N * 8) as *i64
61 let labs: *i64 = sys_mmap(N * 8) as *i64
62 mods[0] = ("/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_slice_plane.nx" as *u8) as i64
63 labs[0] = ("nx_slice_plane " as *u8) as i64
64 mods[1] = ("/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_slice_contour.nx" as *u8) as i64
65 labs[1] = ("nx_slice_contour " as *u8) as i64
66 mods[2] = ("/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_mesh_print_check.nx" as *u8) as i64
67 labs[2] = ("nx_mesh_print_check " as *u8) as i64
68 mods[3] = ("/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_gcode_emit.nx" as *u8) as i64
69 labs[3] = ("nx_gcode_emit " as *u8) as i64
70 mods[4] = ("/mnt/c/Users/elder/nishi-core/nxc2/runtime/nx_gcode_emit_test.nx" as *u8) as i64
71 labs[4] = ("nx_gcode_emit_test " as *u8) as i64
72
73 var i: i64 = 0
74 while i < N {
75 cp_puts(" "); cp_puts(labs[i] as *u8); cp_puts(" | ")
76 cp_run(active, mods[i] as *u8, to_ms)
77 cp_puts(" | ")
78 cp_run(kg, mods[i] as *u8, to_ms)
79 cp_puts("\n")
80 i = i + 1
81 }
82 cp_puts("=> module with ACTIVE=**LOOP** + KNOWN-GOOD=ok is the P0 regression trigger\n")
83 return 0
84}