code wiki / _hdl_build / nx_opportunity_loop_test.nx

nx_opportunity_loop_test.nx source

↩ module page · 61 lines · 4513 B

1// nx_opportunity_loop_test.nx -- RUN the self-running opportunity loop on the team's REAL current 2// frontier, and report its state: which opportunity the loop picks next, and how autonomous the cycle is. 3// Opportunities are scored value x feasibility; the loop is autonomous on 5/6 stages for existing search 4// spaces (6/6 when no novel module is needed). Exit 0 on 7/7. license_tier: ORIGINAL 5 6import "nx_opportunity_loop.nx" 7import "nx_syscalls.nx" 8 9func op_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10func op_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 } 11 12func main() -> i64 { 13 op_puts("=== SELF-RUNNING OPPORTUNITY LOOP -- current state ===\n" as *u8) 14 op_puts(" cycle: SCAN -> EVALUATE -> PRIORITIZE -> EXECUTE -> JUDGE -> BANK -> loop\n" as *u8) 15 16 // --- the loop's autonomy (who owns each stage) --- 17 // existing search space (no new module): all 6 stages team-owned -> runs UNSUPERVISED. 18 let auto_existing: i64 = ol_autonomous_stages(0) 19 // novel module needed: EXECUTE falls to Claude -> 5/6, Claude-gated. 20 let auto_novel: i64 = ol_autonomous_stages(1) 21 op_puts(" autonomy: existing-space = " as *u8); op_num(auto_existing); op_puts("/6 (UNSUPERVISED) novel-module = " as *u8); op_num(auto_novel); op_puts("/6 (Claude-gated on EXECUTE only)\n" as *u8) 22 23 // --- the Market Researcher's scan: this session's real frontier (value x feasibility) --- 24 // 0 sovereign assembler (retire gcc -> all-sovereign) 1 daemon-build (site live) 25 // 2 function-cache S-exceed vs ccache 3 PPMI+SVD dense embeddings (semantic rung) 26 // 4 andelinwest live deploy 27 let n: i64 = 5 28 let val: *i64 = sys_mmap(8*8) as *i64 29 let fea: *i64 = sys_mmap(8*8) as *i64 30 val[0]=9; fea[0]=7 // assembler: closes the LAST dependency; bounded build (asm already emitted) 31 val[1]=6; fea[1]=5 // daemon-build: hang-resolve prescribed, but source-drift risk 32 val[2]=6; fea[2]=6 // cache-exceed: needs triangulated benchmark 33 val[3]=7; fea[3]=8 // embeddings: pieces exist (PPMI, power-iter), high feasibility 34 val[4]=8; fea[4]=4 // andelinwest-live: blocked on lost source + compiled daemon 35 36 let top: i64 = ol_pick_top(val, fea, n) 37 op_puts(" scanned " as *u8); op_num(n); op_puts(" opportunities; TOP pick = #" as *u8); op_num(top) 38 op_puts(" (value " as *u8); op_num(val[top]); op_puts(" x feasibility " as *u8); op_num(fea[top]); op_puts(" = " as *u8); op_num(ol_score(val[top], fea[top])); op_puts(")\n" as *u8) 39 if top == 0 { op_puts(" => SOVEREIGN ASSEMBLER (retire gcc, the last dependency) -- coheres with the all-sovereign thread.\n" as *u8) } 40 41 // --- gate --- 42 let r: *i64 = sys_mmap(8*8) as *i64 43 r[0]=0; if auto_existing == 6 { r[0]=1 } // unsupervised on existing spaces 44 r[1]=0; if auto_novel == 5 { r[1]=1 } // novel module = the ONE gated stage 45 r[2]=0; if ol_runs_autonomously(0) == 1 { r[2]=1 } // existing-space => autonomous 46 r[3]=0; if ol_runs_autonomously(1) == 0 { r[3]=1 } // novel-module => not (yet) 47 r[4]=0; if top == 0 { r[4]=1 } // top pick = sovereign assembler 48 r[5]=0; if ol_score(0, 9) == 0 { r[5]=1 } // non-feasible scores 0 (only deliverable picked) 49 r[6]=0; if ol_stage_owner(OL_JUDGE, 1) == OL_TEAM { r[6]=1 } // JUDGE always team (Referee), even for novel work 50 var pass: i64 = 0; var i: i64 = 0 51 while i < 7 { pass = pass + r[i]; i = i + 1 } 52 op_puts("----\n passed " as *u8); op_num(pass); op_puts("/7\n" as *u8) 53 if pass == 7 { 54 op_puts(" STATE: the loop SCANS/EVALUATES/PRIORITIZES/JUDGES/BANKS autonomously and ticks when triggered;\n" as *u8) 55 op_puts(" it is UNSUPERVISED on existing search spaces and Claude-gated ONLY when EXECUTE must author a\n" as *u8) 56 op_puts(" brand-new module (the novel-module LLM-gap). Next move it picks itself = the sovereign assembler.\n" as *u8) 57 op_puts(" Owed for full M4 autonomy: continuous trigger (Conductor heartbeat) + close the novel-module gap.\n" as *u8) 58 sys_exit(0); return 0 59 } 60 op_puts(" FAIL\n" as *u8); sys_exit(1); return 1 61}