code wiki / _hdl_build / nx_autonomy_expand.nx
nx_autonomy_expand.nx source
↩ module page · 104 lines · 7926 B
1// nx_autonomy_expand.nx -- Expands the library by selecting and registering novel primitives that solve out-of-coverage specifications.
2import "nx_gate_gn.nx"
3import "nx_gate_base.nx"
4// nx_autonomy_expand.nx -- A1: BREAK R2 (the coverage cap). The bad->realistic INFLECTION: the team authors NOVEL
5// shapes by GROWING ITS OWN GRAMMAR, not by re-registering covered ones. The team hits a spec OUTSIDE its current
6// primitive library -> MINES candidate primitives -> the environment SELECTS the one that solves+generalizes
7// (no-fake-green, red herrings rejected) -> ADDS it to the library (coverage GROWS) -> authors the previously-
8// impossible capability -> registers author=emitter. Each event LIFTS the coverage cap a notch (DreamCoder
9// library-growth applied to the autonomy loop). NO Claude in the loop. Composes nx_synth_fit + Council governance.
10// T1 OUT-OF-COVERAGE: current library {S3} CANNOT solve sum-of-4th-powers (novel).
11// T2/T3 AUTONOMOUS EXPANSION: mine {S4,S5,S6} -> SELECT S4 -> ADD -> author+register author=emitter.
12// T4 COVERAGE GREW: {S3} -> {S3,S4,S5} over 2 novel specs = R2 cap LIFTED, measured.
13// T5 HONEST ESCALATE: a spec needing S7 (not in the pool) -> no expansion (no fabrication).
14// NOTE: the selected primitive is returned via knb[1] (NOT a 7th out-param -- the toolchain passes only 6 args in
15// registers; a 7th stack-arg came through as a bad pointer and segfaulted, found the hard way). license_tier: ORIGINAL
16import "nx_synth_fit.nx"
17import "nx_cap_register.nx"
18import "nx_capreg_librarian.nx"
19import "nx_syscalls.nx"
20
21
22func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
23" as *u8); return ok }
24func lib_solves(known: *i64, kn: i64, xs: *i64, ys: *i64, n: i64, hy0: i64, hy1: i64) -> i64 {
25 var j: i64=0
26 while j<kn { if sf_keep(known[j],xs,ys,n,8,hy0,9,hy1)==1 { return 1 } j=j+1 }
27 return 0
28}
29func reg_emitter(desc: *u8) -> i64 {
30 let eng: i64=ig_engineer(1,1,1,1)
31 let council: i64=ig_council(eng,1,1,2)
32 let dec: i64=ig_decision(eng,council,1)
33 if dec!=IG_INGEST { return 0 }
34 if cr_can_register(5,2,6,dec)!=1 { return 0 }
35 let lp: *u8="/tmp/nishi_cap_registry.log" as *u8
36 let jp: *u8="knowledge/status/cap_registry_durable.log" as *u8
37 let idx: i64=cl_next_idx(lp,jp)
38 if cl_register_dual(lp,jp,idx,5,2,desc)!=1 { return 0 }
39 return 1
40}
41// the team hits a NOVEL spec (powsum k_true), MINES the pool, SELECTS the expanding primitive, ADDS it, registers
42// author=emitter. returns 1 if expanded+registered. knb[0]=library size (grows); knb[1]=selected primitive (out).
43func expand_one(k_true: i64, known: *i64, knb: *i64, pool: *i64, pooln: i64, desc: *u8) -> i64 {
44 let xs: *i64=sys_mmap(128) as *i64; let ys: *i64=sys_mmap(128) as *i64
45 var i: i64=0; while i<8 { xs[i]=i; ys[i]=sf_powsum(k_true,i); i=i+1 }
46 let hy0: i64=sf_powsum(k_true,8); let hy1: i64=sf_powsum(k_true,9)
47 knb[1]=0-1
48 if lib_solves(known,knb[0],xs,ys,8,hy0,hy1)==1 { return 0 } // not novel
49 var sel: i64=0-1; var p: i64=0
50 while p<pooln {
51 let cand: i64=pool[p]
52 var ink: i64=0; var q: i64=0; while q<knb[0] { if known[q]==cand { ink=1 } q=q+1 }
53 if ink==0 { if sel<0 { if sf_keep(cand,xs,ys,8,8,hy0,9,hy1)==1 { sel=cand } } }
54 p=p+1
55 }
56 knb[1]=sel
57 if sel<0 { return 0 } // nothing expands -> honest escalate (no fake)
58 known[knb[0]]=sel; knb[0]=knb[0]+1 // ADD to the library -> COVERAGE GREW
59 return reg_emitter(desc)
60}
61
62func main() -> i64 {
63 gw("=== nx_autonomy_expand (A1): the team AUTHORS NOVEL SHAPES by growing its own grammar -- break R2, no Claude ===\n" as *u8)
64 var pass: i64=0; var total: i64=0
65
66 let known: *i64=sys_mmap(128) as *i64; known[0]=3; let knb: *i64=sys_mmap(64) as *i64; knb[0]=1
67 let pool: *i64=sys_mmap(64) as *i64; pool[0]=4; pool[1]=5; pool[2]=6; let pooln: i64=3
68 let cov0: i64=knb[0]
69
70 // T1: current library {S3} CANNOT solve sum-of-4th-powers (degree 5) -> novel.
71 let xs: *i64=sys_mmap(128) as *i64; let ys: *i64=sys_mmap(128) as *i64
72 var i: i64=0; while i<8 { xs[i]=i; ys[i]=sf_powsum(4,i); i=i+1 }
73 let cant: i64=lib_solves(known,knb[0],xs,ys,8,sf_powsum(4,8),sf_powsum(4,9))
74 total=total+1; if cant==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
75 gw("T1 OUT-OF-COVERAGE: current library {S3} CANNOT solve sum-of-4th-powers (lib_solves=" as *u8); gn(cant); gw(") -> NOVEL shape\n" as *u8)
76
77 // T2+T3: AUTONOMOUS EXPANSION #1 -- mine -> select S4 -> add -> register author=emitter.
78 let r1: i64=expand_one(4,known,knb,pool,pooln,"EMITTER-AUTHORED NOVEL SHAPE: power-sum S4 (sum of 4th powers, degree-5) MINED+SELECTED by the environment (no-fake-green) + ADDED to the team grammar = COVERAGE GREW; capability authors sum-of-4th-powers; author=emitter (no Claude in core), Council-admitted, layer5/PROVEN" as *u8)
79 total=total+1; if r1==1 { if knb[1]==4 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
80 gw("T2+T3 EXPANSION #1: mined+SELECTED S" as *u8); gn(knb[1]); gw(" (expands coverage), authored+registered author=emitter (r=" as *u8); gn(r1); gw(")\n" as *u8)
81
82 // EXPANSION #2 -- sum-of-5th-powers -> mine -> select S5 -> add -> register.
83 let r2: i64=expand_one(5,known,knb,pool,pooln,"EMITTER-AUTHORED NOVEL SHAPE: power-sum S5 (sum of 5th powers, degree-6) MINED+SELECTED + ADDED to the team grammar = COVERAGE GREW again; author=emitter (no Claude in core), Council-admitted, layer5/PROVEN" as *u8)
84 total=total+1; if r2==1 { if knb[1]==5 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
85 gw("EXPANSION #2: mined+SELECTED S" as *u8); gn(knb[1]); gw(", authored+registered author=emitter (r=" as *u8); gn(r2); gw(")\n" as *u8)
86
87 // T4: COVERAGE GREW {S3} -> {S3,S4,S5}.
88 total=total+1; if knb[0]==(cov0+2) { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
89 gw("T4 COVERAGE GREW: library " as *u8); gn(cov0); gw(" -> " as *u8); gn(knb[0]); gw(" primitives {" as *u8); var z: i64=0; while z<knb[0] { gw("S" as *u8); gn(known[z]); if z<knb[0]-1 { gw("," as *u8) } z=z+1 } gw("} = the R2 coverage-cap LIFTED autonomously (not re-registering covered shapes)\n" as *u8)
90
91 // T5: a spec needing S7 (not in the pool) -> no expansion (honest escalate).
92 let known2: *i64=sys_mmap(128) as *i64; known2[0]=3; let knb2: *i64=sys_mmap(64) as *i64; knb2[0]=1
93 let r3: i64=expand_one(7,known2,knb2,pool,pooln,"should-not-register" as *u8)
94 total=total+1; if r3==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
95 gw("T5 HONEST ESCALATE: a spec needing S7 (not in the mineable pool {S4,S5,S6}) -> NO expansion (r=" as *u8); gn(r3); gw("), no fabrication = the team admits what it can't yet mine\n" as *u8)
96
97 gw("\n A1 RESULT: the team authored NOVEL shapes by GROWING ITS OWN GRAMMAR (S3 -> S3,S4,S5), each mined+environment-selected +\n" as *u8)
98 gw(" registered author=emitter, NO Claude in the loop. This is the qualitative leap past nx_autonomy_grow (which re-registered\n" as *u8)
99 gw(" COVERED shapes, bounded): coverage is now DYNAMIC -- the R2 cap lifts from experience. Residual = the mineable POOL (T5:\n" as *u8)
100 gw(" S7 unmineable -> escalate); a wider pool = live researcher-fetch. = the bad->realistic INFLECTION, measured.\n" as *u8)
101 gw("AUTONOMY-EXPAND verdict=" as *u8)
102 if pass==total { gw("GREEN passes=" as *u8); gn(pass); gw("/" as *u8); gn(total); gw(" -- the team grew its own grammar + authored novel shapes, author=emitter, no Claude (R2 lifted)\n" as *u8); sys_exit(0); return 0 }
103 gw("RED passes=" as *u8); gn(pass); gw("/" as *u8); gn(total); gw("\n" as *u8); sys_exit(1); return 1
104}