code wiki / _hdl_build / nx_spec_synth_test.nx

nx_spec_synth_test.nx source

↩ module page · 64 lines · 5275 B

1// nx_spec_synth_test.nx -- the team builds a SPEC from research, the Genealogist guards against 2// duplication, and the WIDENED search authors the solution -- all team-owned. The headline: a 3// PERCEPTION-weighted spec (justified by the confirmed Blau-Michaeli finding) makes the team author 4// a DIFFERENT allocation than the distortion-only one -- protecting the weights that matter for 5// REALISM, not pixel-fidelity (the gap the Critic flagged). And re-proposing imatrix is caught as a 6// duplicate. Exit 0 if all hold. license_tier: ORIGINAL 7 8import "nx_genealogist.nx" 9import "nx_spec_author.nx" 10import "nx_builder_synth.nx" 11import "nx_syscalls.nx" 12 13func st_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 14func st_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 15func st_alloc(n: i64, b: *i64) -> i64 { st_puts("[" as *u8); var i: i64=0; while i<n { st_num(b[i]); if i<n-1 {st_puts("," as *u8)} i=i+1 } st_puts("]" as *u8); return 0 } 16 17func main() -> i64 { 18 st_puts("=== research -> SPEC -> widened search -> solution (team-owned, dedup-guarded) ===\n" as *u8) 19 // GENEALOGIST registry: what we already have 20 let rart: *i64 = sys_mmap(8*16) as *i64; let robj: *i64 = sys_mmap(8*16) as *i64 21 rart[0]=ART_ALLOC; robj[0]=OBJ_IMPORTANCE // imatrix 22 rart[1]=ART_FIDELITY; robj[1]=OBJ_DISTORTION // nx_image_fidelity 23 rart[2]=ART_FIDELITY; robj[2]=OBJ_PERCEPTION // nx_rd_perception 24 rart[3]=ART_SEARCH; robj[3]=OBJ_GENERIC // nx_builder_synth 25 let RN: i64 = 4 26 27 let novel_percep: i64 = gen_clear_to_build(ART_ALLOC, OBJ_PERCEPTION, rart, robj, RN) // new: percep allocation 28 let dup_imatrix: i64 = gen_is_duplicate(ART_ALLOC, OBJ_IMPORTANCE, rart, robj, RN) // would rebuild imatrix 29 30 // RESEARCH -> SPEC: confirmed findings about what matters set the objective weights 31 let fobj: *i64 = sys_mmap(8*8) as *i64; let fconf: *i64 = sys_mmap(8*8) as *i64; let fstr: *i64 = sys_mmap(8*8) as *i64 32 fobj[0]=OBJ_DISTORTION; fconf[0]=1; fstr[0]=1 // imatrix finding (confirmed) 33 fobj[1]=OBJ_PERCEPTION; fconf[1]=1; fstr[1]=1 // Blau-Michaeli finding (confirmed + Critic-blessed) 34 let w_dist: i64 = spec_weight_from_findings(OBJ_DISTORTION, 2, fobj, fconf, fstr) 35 let w_perc: i64 = spec_weight_from_findings(OBJ_PERCEPTION, 2, fobj, fconf, fstr) 36 37 // per-group sensitivities: group0 matters for DISTORTION, group3 matters for PERCEPTION (different!) 38 let N: i64 = 4; let budget: i64 = 16 39 let dist_sens: *i64 = sys_mmap(8*8) as *i64; dist_sens[0]=100; dist_sens[1]=10; dist_sens[2]=10; dist_sens[3]=1 40 let perc_sens: *i64 = sys_mmap(8*8) as *i64; perc_sens[0]=1; perc_sens[1]=10; perc_sens[2]=10; perc_sens[3]=100 41 let imp_d: *i64 = sys_mmap(8*8) as *i64; let imp_p: *i64 = sys_mmap(8*8) as *i64 42 spec_compose_importance(N, 1, 0, dist_sens, perc_sens, imp_d) // distortion-only spec 43 spec_compose_importance(N, 0, w_perc, dist_sens, perc_sens, imp_p) // perception spec (w_perc from research) 44 let alloc_d: *i64 = sys_mmap(8*8) as *i64; let alloc_p: *i64 = sys_mmap(8*8) as *i64 45 bsy_author_alloc(N, imp_d, budget, alloc_d) // team searches the distortion spec 46 bsy_author_alloc(N, imp_p, budget, alloc_p) // team searches the perception spec 47 48 st_puts(" genealogist: percep-alloc novel=" as *u8); st_num(novel_percep); st_puts(" imatrix-rebuild duplicate=" as *u8); st_num(dup_imatrix); st_puts("\n" as *u8) 49 st_puts(" research->spec weights: w_dist=" as *u8); st_num(w_dist); st_puts(" w_perc=" as *u8); st_num(w_perc); st_puts(" (perc>0 only because the finding is confirmed)\n" as *u8) 50 st_puts(" distortion spec -> team authored " as *u8); st_alloc(N, alloc_d); st_puts("\n" as *u8) 51 st_puts(" PERCEPTION spec -> team authored " as *u8); st_alloc(N, alloc_p); st_puts(" (bits protect the perception-sensitive group)\n" as *u8) 52 53 let r: *i64 = sys_mmap(8*8) as *i64 54 r[0] = 0; if novel_percep == 1 { r[0] = 1 } // genealogist: clear to build the new spec 55 r[1] = 0; if dup_imatrix == GEN_DUPLICATE { r[1] = 1 } // genealogist: caught the rebuild 56 r[2] = 0; if w_perc > 0 { r[2] = 1 } // research -> spec (confirmed finding enables it) 57 r[3] = 0; if alloc_p[3] > alloc_d[3] { r[3] = 1 } // perception spec protects the perception group 58 r[4] = 0; if bsy_verify(N, imp_p, budget, alloc_p) == 1 { r[4] = 1 } // engineer verifies the authored solution 59 var pass: i64 = 0; var i: i64 = 0 60 while i < 5 { pass = pass + r[i]; i = i + 1 } 61 st_puts("----\n passed " as *u8); st_num(pass); st_puts("/5\n" as *u8) 62 if pass == 5 { st_puts(" TEAM BUILDS SPECS: research->spec, widened search authors a perception-protecting allocation, no duplication. Claude built the loop only.\n" as *u8); sys_exit(0); return 0 } 63 st_puts(" FAIL\n" as *u8); sys_exit(1); return 1 64}