code wiki / _hdl_build / nx_compare_growth_integration_gate_20260910.nx

nx_compare_growth_integration_gate_20260910.nx source

↩ module page · 66 lines · 4590 B

1// nx_compare_growth_integration_gate_20260910.nx -- Generates JSON and HTML reports comparing growth models across specified domains. 2import "nx_swcompare_growth_candidate_20260910.nx" 3import "nx_gatekit_lib.nx" 4import "nx_gate_verdict.nx" 5func cgi_path(prefix: *u8,suffix: *u8) -> *u8 { 6 let out: *u8=sys_mmap(SGP_PATH_CAP) 7 let a: i64=sg_len(prefix); let b: i64=sg_len(suffix) 8 if a+b+1>SGP_PATH_CAP { return 0 as *u8 } 9 var p: i64=scopy(out,0,prefix); p=scopy(out,p,suffix); out[p]=0 as u8; return out 10} 11func cgi_domain(domain: *u8,fd: i64,ctr: *i64) -> i64 { 12 let m: *SgPlan=sg_load(domain) 13 gv_check(domain,(m as i64)>0,ctr) 14 if (m as i64)<=0 { return 0 } 15 gv_check("growth model captured" as *u8,(m.growth as i64)>0,ctr) 16 if (m.growth as i64)>0 { 17 gv_check("real growth parse valid" as *u8,m.growth.error==0,ctr) 18 gv_check("no invented real learning path" as *u8,m.growth.count==0,ctr) 19 } 20 w(fd,","); wq(fd); wj(fd,domain); w(fd,"\":{\"capture\":true" as *u8); sg_json(m,fd); w(fd,"}" as *u8) 21 return 0 22} 23func main(argc: i64,argv: *i64) -> i64 { 24 if argc!=2 { return 2 } 25 let prefix: *u8=argv[1] as *u8 26 if starts(prefix,"/tmp/cg-" as *u8)!=1 { return 2 } 27 let pn: i64=sg_len(prefix) 28 if sg_id(((prefix as i64)+5) as *u8,pn-5)!=1 { return 2 } 29 let jsonpath: *u8=cgi_path(prefix,".json" as *u8); let htmlpath: *u8=cgi_path(prefix,".html" as *u8) 30 if (jsonpath as i64)==0 { return 2 }; if (htmlpath as i64)==0 { return 2 } 31 let ctr: *i64=gv_ctr(); gv_head("COMPARE-GROWTH-INTEGRATION" as *u8) 32 let fd: i64=sys_openat_exclusive(jsonpath,0x180); if fd<0 { return 3 } 33 let hf: i64=sys_openat_exclusive(htmlpath,0x180); if hf<0 { sys_close(fd); return 3 } 34 w(fd,"{\"capture\":true" as *u8) 35 cgi_domain("gameengine" as *u8,fd,ctr) 36 cgi_domain("charsim" as *u8,fd,ctr) 37 cgi_domain("ecosystem" as *u8,fd,ctr) 38 cgi_domain("deploy" as *u8,fd,ctr) 39 cgi_domain("dataio" as *u8,fd,ctr) 40 let text: *u8="rung|R1|Test|f|done|Organ|1|-\nsotatarget|T1|frontier|B1|Target|ref\ngrowthpath|1|P1|R1|proactive_research|T1|ref|A model <script>alert(\"x\")</script> & Ω|Still unknown\ngrowthexercise|1|E1|P1|-|f|nx_probe|workload|resources|accept|@research\ngrowthexercise|1|E2|P1|E1|f|nx_probe|workload|resources|accept|@learning\ngrowthassessment|1|A1|P1|scope|innovation|receipt|1789030000|reviewer|-\n" as *u8 41 let m: *SgPlan=sg_parse(text,sg_len(text),0 as *u8,0,0 as *u8,0) 42 gv_check("fixture graph valid" as *u8,sg_valid(m)==1,ctr) 43 gv_check("fixture growth valid" as *u8,m.growth.error==0,ctr) 44 gv_check("fixture one path" as *u8,m.growth.paths==1,ctr) 45 gv_check("fixture two exercises" as *u8,m.growth.exercises==2,ctr) 46 gv_check("fixture assessment retained" as *u8,m.growth.assessments==1,ctr) 47 w(fd,",\"synthetic\":{\"capture\":true" as *u8); sg_json(m,fd); w(fd,"}}\n" as *u8) 48 w(hf,"<!doctype html><html lang='en'><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1'><title>Private Compare growth qualification</title><body><main><h1>Private synthetic qualification</h1>" as *u8) 49 sg_html(m,hf); w(hf,"</main></body></html>\n" as *u8) 50 gv_check("JSON fsync" as *u8,sys_fsync(fd)==0,ctr); gv_check("JSON close" as *u8,sys_close(fd)==0,ctr) 51 gv_check("HTML fsync" as *u8,sys_fsync(hf)==0,ctr); gv_check("HTML close" as *u8,sys_close(hf)==0,ctr) 52 var jn: i64=0; let jb: *u8=sys_read_file(jsonpath,&jn) 53 gv_check("JSON retained" as *u8,jn>0,ctr) 54 if jn>0 { gv_check("growth JSON key" as *u8,gk_has(jb,"\"capability_growth\":" as *u8),ctr); gv_check("dispatch remains withheld" as *u8,gk_has(jb,"\"recommendation_state\":\"WITHHELD\"" as *u8),ctr) } 55 var hn: i64=0; let hb: *u8=sys_read_file(htmlpath,&hn) 56 gv_check("HTML retained" as *u8,hn>0,ctr) 57 if hn>0 { 58 gv_check("growth section emitted" as *u8,gk_has(hb,"Learning and practice paths" as *u8),ctr) 59 gv_check("HTML raw script refused" as *u8,gk_has(hb,"<script>alert" as *u8)==0,ctr) 60 gv_check("HTML escaped script retained" as *u8,gk_has(hb,"&lt;script&gt;" as *u8),ctr) 61 gv_check("readiness remains unverified" as *u8,gk_has(hb,"readiness unverified" as *u8),ctr) 62 gv_check("assessment caveat visible" as *u8,gk_has(hb,"evidence not validated" as *u8),ctr) 63 } 64 gv_puts("json=" as *u8); gv_puts(jsonpath); gv_puts("\nhtml=" as *u8); gv_puts(htmlpath); gv_puts("\n" as *u8) 65 return gv_verdict("COMPARE-GROWTH-INTEGRATION" as *u8,ctr,"private authored paths; not eligible dispatch or verified mastery" as *u8) 66}