code wiki / (root) / nx_atlas_gate.nx

nx_atlas_gate.nx source

↩ module page · 53 lines · 1724 B

1// nx_atlas_gate.nx -- atlas-hygiene CONFIDENCE-GATE enforcement primitive (blueprint Callout 3 / F264). 2// conf in PERMILLE (0..1000) + optional threshold (default 750 = 0.75) -> hard ALLOW/BLOCK verdict + EXIT 3// CODE so a downstream execution system can BRANCH: exit 0 = ALLOW (conf>=thr), exit 5 = BLOCK (conf<thr). 4// Integer-only (no-float doctrine). Zero side effects. Moves C3 from plane LABEL to ENFORCING gate. 5// license_tier: ORIGINAL expect_exit: 0 6import "nx_syscalls.nx" 7 8func ag_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 9 10func ag_atoi(s: *u8) -> i64 { 11 var n: i64 = 0 12 var i: i64 = 0 13 while s[i] != (0 as u8) { 14 let c: i64 = s[i] as i64 15 if c < 48 { return n } 16 if c > 57 { return n } 17 n = n * 10 + (c - 48) 18 i = i + 1 19 } 20 return n 21} 22 23func main(argc: i64, argv: *i64) -> i64 { 24 if argc < 2 { 25 sys_write(1, "ATLASGATE ERR need conf\n" as *u8, 24) 26 sys_exit(2) 27 return 2 28 } 29 let cs: *u8 = argv[1] as *u8 30 let conf: i64 = ag_atoi(cs) 31 var thr: i64 = 750 32 var ts: *u8 = "750" as *u8 33 if argc >= 3 { 34 ts = argv[2] as *u8 35 thr = ag_atoi(ts) 36 } 37 if conf >= thr { 38 sys_write(1, "ATLASGATE ALLOW conf=" as *u8, 21) 39 sys_write(1, cs, ag_slen(cs)) 40 sys_write(1, " thr=" as *u8, 5) 41 sys_write(1, ts, ag_slen(ts)) 42 sys_write(1, " permille\n" as *u8, 10) 43 sys_exit(0) 44 return 0 45 } 46 sys_write(1, "ATLASGATE BLOCK conf=" as *u8, 21) 47 sys_write(1, cs, ag_slen(cs)) 48 sys_write(1, " thr=" as *u8, 5) 49 sys_write(1, ts, ag_slen(ts)) 50 sys_write(1, " permille\n" as *u8, 10) 51 sys_exit(5) 52 return 5 53}