code wiki / _hdl_build / nx_transient_sweep.nx
nx_transient_sweep.nx source
↩ module page · 33 lines · 1980 B
1// nx_transient_sweep.nx -- S-CLASS transient ACCOUNTING SWEEP: runs the transient monitor across a LIST of
2// targets so the ecosystem accounts for EVERY component's flakiness (not just the one a human happened to
3// notice). Each target -> N runs under a watchdog -> STABLE / FLAKY / BROKEN, durably recorded (seg-store).
4// Exits non-zero if ANY target is flaky/broken -> a transient is never silently tolerated.
5// usage: nx_transient_sweep <runs> <timeout_ms> <elf1> [elf2 ...]
6// license_tier: ORIGINAL
7import "nx_syscalls.nx"
8import "nx_transient_monitor.nx" // tm_probe / tm_verdict / tm_record / tm_w / tm_wn / tm_atoi
9
10func main(argc: i64, argv: *i64) -> i64 {
11 if argc < 4 { tm_w("usage: nx_transient_sweep <runs> <timeout_ms> <elf1> [elf2 ...]\n" as *u8); return 2 }
12 let runs: i64 = tm_atoi(argv[1] as *u8)
13 let timeout: i64 = tm_atoi(argv[2] as *u8)
14 var stable: i64=0; var flaky: i64=0; var broken: i64=0
15 let out: *i64 = sys_mmap(8*8) as *i64
16 tm_w("=== TRANSIENT SWEEP (account for ALL transients; runs=" as *u8); tm_wn(runs); tm_w(" timeout_ms=" as *u8); tm_wn(timeout); tm_w(") ===\n" as *u8)
17 var i: i64 = 3
18 while i < argc {
19 let elf: *u8 = argv[i] as *u8
20 tm_probe(elf, runs, timeout, out)
21 let v: i64 = tm_verdict(out[0], runs)
22 tm_w(" " as *u8); tm_w(elf); tm_w(" : " as *u8); tm_wn(out[0]); tm_w("/" as *u8); tm_wn(runs); tm_w(" pass, max_ms=" as *u8); tm_wn(out[4]); tm_w(" => " as *u8)
23 if v==0 { tm_w("STABLE\n" as *u8); stable=stable+1 }
24 if v==1 { tm_w("FLAKY <-- ROOT-CAUSE REQUIRED\n" as *u8); flaky=flaky+1 }
25 if v==2 { tm_w("BROKEN <-- FIX REQUIRED\n" as *u8); broken=broken+1 }
26 tm_record(elf, runs, out, v)
27 i = i + 1
28 }
29 tm_w("SWEEP RESULT: stable=" as *u8); tm_wn(stable); tm_w(" flaky=" as *u8); tm_wn(flaky); tm_w(" broken=" as *u8); tm_wn(broken); tm_w("\n" as *u8)
30 if flaky > 0 { return 1 }
31 if broken > 0 { return 2 }
32 return 0
33}