code wiki / (root) / nx_coco_ap_gate.nx

nx_coco_ap_gate.nx source

↩ module page · 39 lines · 2104 B

1// nx_coco_ap_gate.nx -- proof of COCO AP@[.5:.95] aggregation. expect_exit: 0 2import "nx_syscalls.nx" 3import "nx_coco_ap.nx" 4import "nx_gate_verdict.nx" 5 6func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return sys_write(1,s,n) } 7func gn(v: i64) -> i64 { let bb:*u8=sys_mmap(28); var m:i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let t:*u8=sys_mmap(28); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} return sys_write(1,bb,k) } 8 9func main(argc: i64, argv: *i64) -> i64 { 10 var pass: i64 = 0 11 let o: *i64=sys_mmap(8*8) as *i64 12 13 // A1 all perfect (1000) -> pass every threshold -> AP=1000 14 var i: i64=0; while i<4 { o[i]=1000; i=i+1 } 15 let a1: i64=coco_ap(o,4) 16 if a1==1000 { pass=pass+1; gp("A1 all-perfect -> AP=1000 OK\n" as *u8) } else { gp("A1 FAIL=" as *u8); gn(a1); gp("\n" as *u8) } 17 18 // A2 two imgs OKS 1000 & 700: thresholds .50-.70 both pass (1000), .75-.95 only img1 (500) -> 19 // (5*1000 + 5*500)/10 = 750 20 o[0]=1000; o[1]=700 21 let a2: i64=coco_ap(o,2) 22 if a2==750 { pass=pass+1; gp("A2 OKS{1000,700} -> AP=750 OK\n" as *u8) } else { gp("A2 FAIL=" as *u8); gn(a2); gp("\n" as *u8) } 23 24 // A3 all OKS 400 (<.50) -> pass nothing -> AP=0 25 i=0; while i<4 { o[i]=400; i=i+1 } 26 let a3: i64=coco_ap(o,4) 27 if a3==0 { pass=pass+1; gp("A3 all-below-.5 -> AP=0 OK\n" as *u8) } else { gp("A3 FAIL=" as *u8); gn(a3); gp("\n" as *u8) } 28 29 gp("COCO-AP-GATE pass=" as *u8); gn(pass); gp("/3\n" as *u8) 30 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 31 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 32 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 33 let ctr__dry: *i64 = gv_ctr() 34 ctr__dry[0] = pass 35 ctr__dry[1] = 3 36 let rc__dry: i64 = gv_verdict("COCO-AP-GATE" as *u8, ctr__dry, "3/3 (AP@[.5:.95] over OKS thresholds) -- industry metric COMPLETE (OKS+AP)" as *u8) 37 sys_exit(rc__dry) 38 return rc__dry 39}