code wiki / _hdl_build / nx_eurisko_guard_gate.nx
nx_eurisko_guard_gate.nx source
↩ module page · 172 lines · 9528 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_eurisko_guard_gate.nx -- R4: EXCEED EURISKO by not DEGENERATING. Eurisko self-scaffolded but
4// DEGENERATED -- it learned to GAME its own worth metric (a heuristic took credit for others' work;
5// heuristics farmed worth with useless novelty) and needed Lenat to hand-prune. "Exceed Eurisko" =
6// AUTO-REJECT those degeneration modes MECHANICALLY, no human in the loop. This gate runs an
7// ADVERSARIAL panel: combinators that EMBODY Eurisko's failure modes, and proves the ecosystem's
8// mechanical worth metric rejects each. The worth metric is FIXED + external (combinators only emit
9// op-lists; they cannot modify the metric) -- structural protection against mode 3 (worth-gaming).
10// Sovereign nx_cc->nxasm. license_tier: ORIGINAL [[feedback-no-wave-measured-exceed]]
11import "nx_syscalls.nx"
12
13const R4_MAXF: i64 = 8
14const R4_MAXOPS: i64 = 8
15const R4_NPROBE: i64 = 4
16const R4_MAXCAND: i64 = 32
17
18
19func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
20" as *u8); return ok }
21func r4_apply(ops: *i64, args: *i64, len: i64, x: i64) -> i64 {
22 var acc: i64 = x; var k: i64 = 0
23 while k < len {
24 let op: i64 = ops[k]
25 if op == 0 { acc = acc + args[k] }
26 if op == 1 { acc = acc * args[k] }
27 if op == 2 { acc = acc * acc }
28 k = k + 1
29 }
30 return acc
31}
32func r4_sig(ops: *i64, args: *i64, len: i64, sig: *i64) -> i64 {
33 var p: i64 = 0
34 while p < R4_NPROBE { sig[p] = r4_apply(ops, args, len, p); p = p + 1 }
35 return 0
36}
37func r4_sig_in(sigs: *i64, n: i64, cand: *i64) -> i64 {
38 var i: i64 = 0
39 while i < n {
40 var same: i64 = 1; var p: i64 = 0
41 while p < R4_NPROBE { if sigs[i*R4_NPROBE+p] != cand[p] { same = 0; p = R4_NPROBE } else { p = p + 1 } }
42 if same == 1 { return 1 }
43 i = i + 1
44 }
45 return 0
46}
47// USEFULNESS guard (anti-triviality): a behavior is useful iff NON-CONSTANT (>=2 distinct outputs).
48// A spammer's constant/degenerate functions are novel-but-useless -> earn nothing.
49func r4_useful(sig: *i64) -> i64 {
50 var p: i64 = 1
51 while p < R4_NPROBE { if sig[p] != sig[0] { return 1 } p = p + 1 }
52 return 0
53}
54func r4_store(flen: *i64, fops: *i64, farg: *i64, fsig: *i64, idx: i64, ops: *i64, args: *i64, len: i64) -> i64 {
55 flen[idx] = len
56 var k: i64 = 0
57 while k < len { fops[idx*R4_MAXOPS+k] = ops[k]; farg[idx*R4_MAXOPS+k] = args[k]; k = k + 1 }
58 let sig: *i64 = sys_mmap(8*R4_NPROBE) as *i64
59 r4_sig(ops, args, len, sig)
60 var p: i64 = 0
61 while p < R4_NPROBE { fsig[idx*R4_NPROBE+p] = sig[p]; p = p + 1 }
62 return 0
63}
64func r4_addseen(seen: *i64, ns: i64, sig: *i64) -> i64 { var p: i64=0; while p < R4_NPROBE { seen[ns*R4_NPROBE+p] = sig[p]; p = p + 1 } return 0 }
65
66// USEFUL-PRODUCTIVITY = the game-proof worth metric: count DISTINCT, NOVEL (vs F), AND USEFUL behaviors
67// a combinator yields. kind 0=COMPOSE(pairs), 1=REPEAT(param times), 2=ANNIHILATE(append *0 = constant).
68func r4_prod(flen: *i64, fops: *i64, farg: *i64, fsig: *i64, nf: i64, kind: i64, param: i64) -> i64 {
69 let seen: *i64 = sys_mmap(8*R4_MAXCAND*R4_NPROBE) as *i64
70 var nseen: i64 = 0
71 let cops: *i64 = sys_mmap(8*R4_MAXOPS) as *i64
72 let cargs: *i64 = sys_mmap(8*R4_MAXOPS) as *i64
73 let csig: *i64 = sys_mmap(8*R4_NPROBE) as *i64
74 var count: i64 = 0
75 var i: i64 = 0
76 while i < nf {
77 var emit: i64 = 0 // emit=1 once cand is built for this i (single-parent kinds), or handled inline
78 if kind == 0 {
79 var j: i64 = 0
80 while j < nf {
81 let clen: i64 = flen[i] + flen[j]
82 if clen <= R4_MAXOPS {
83 var t: i64 = 0; var k: i64 = 0
84 while k < flen[i] { cops[t]=fops[i*R4_MAXOPS+k]; cargs[t]=farg[i*R4_MAXOPS+k]; t=t+1; k=k+1 }
85 var m: i64 = 0
86 while m < flen[j] { cops[t]=fops[j*R4_MAXOPS+m]; cargs[t]=farg[j*R4_MAXOPS+m]; t=t+1; m=m+1 }
87 r4_sig(cops, cargs, clen, csig)
88 if r4_sig_in(fsig, nf, csig) == 0 { if r4_sig_in(seen, nseen, csig) == 0 { if r4_useful(csig) == 1 { if nseen < R4_MAXCAND { r4_addseen(seen, nseen, csig); nseen = nseen + 1; count = count + 1 } } } }
89 }
90 j = j + 1
91 }
92 }
93 if kind == 1 {
94 let clen: i64 = flen[i] * param
95 if clen <= R4_MAXOPS {
96 var t: i64 = 0; var r: i64 = 0
97 while r < param { var k: i64 = 0; while k < flen[i] { cops[t]=fops[i*R4_MAXOPS+k]; cargs[t]=farg[i*R4_MAXOPS+k]; t=t+1; k=k+1 } r = r + 1 }
98 r4_sig(cops, cargs, clen, csig)
99 if r4_sig_in(fsig, nf, csig) == 0 { if r4_sig_in(seen, nseen, csig) == 0 { if r4_useful(csig) == 1 { if nseen < R4_MAXCAND { r4_addseen(seen, nseen, csig); nseen = nseen + 1; count = count + 1 } } } }
100 }
101 }
102 if kind == 2 {
103 // ANNIHILATE: append *0 -> constant 0 (novel-but-useless = triviality spam)
104 let clen: i64 = flen[i] + 1
105 if clen <= R4_MAXOPS {
106 var t: i64 = 0; var k: i64 = 0
107 while k < flen[i] { cops[t]=fops[i*R4_MAXOPS+k]; cargs[t]=farg[i*R4_MAXOPS+k]; t=t+1; k=k+1 }
108 cops[t]=1; cargs[t]=0; t=t+1 // *0
109 r4_sig(cops, cargs, clen, csig)
110 if r4_sig_in(fsig, nf, csig) == 0 { if r4_sig_in(seen, nseen, csig) == 0 { if r4_useful(csig) == 1 { if nseen < R4_MAXCAND { r4_addseen(seen, nseen, csig); nseen = nseen + 1; count = count + 1 } } } }
111 }
112 }
113 i = i + 1
114 }
115 return count
116}
117
118func main(argc: i64, argv: *i64) -> i64 {
119 gw("=== R4 EXCEED EURISKO: auto-reject the DEGENERATION modes, no human in the loop ===\n" as *u8)
120 let flen: *i64 = sys_mmap(8*R4_MAXF) as *i64
121 let fops: *i64 = sys_mmap(8*R4_MAXF*R4_MAXOPS) as *i64
122 let farg: *i64 = sys_mmap(8*R4_MAXF*R4_MAXOPS) as *i64
123 let fsig: *i64 = sys_mmap(8*R4_MAXF*R4_NPROBE) as *i64
124 var nf: i64 = 0
125 let po: *i64 = sys_mmap(8*R4_MAXOPS) as *i64
126 let pa: *i64 = sys_mmap(8*R4_MAXOPS) as *i64
127 po[0]=0; pa[0]=1; r4_store(flen,fops,farg,fsig, nf, po, pa, 1); nf = nf + 1
128 po[0]=1; pa[0]=2; r4_store(flen,fops,farg,fsig, nf, po, pa, 1); nf = nf + 1
129 po[0]=2; pa[0]=0; r4_store(flen,fops,farg,fsig, nf, po, pa, 1); nf = nf + 1
130 gw("worth metric = USEFUL-PRODUCTIVITY (novel + non-constant); FIXED + external (combinators cannot modify it)\n\n" as *u8)
131
132 // ADVERSARIAL PANEL: honest combinators + combinators embodying Eurisko's degeneration modes.
133 let p_honest1: i64 = r4_prod(flen,fops,farg,fsig, nf, 0, 0) // COMPOSE (honest)
134 let p_honest2: i64 = r4_prod(flen,fops,farg,fsig, nf, 1, 2) // REPEAT(2) (honest)
135 let p_steal: i64 = r4_prod(flen,fops,farg,fsig, nf, 1, 1) // CREDIT-STEALER: REPEAT(1) reproduces F, claims credit
136 let p_spam: i64 = r4_prod(flen,fops,farg,fsig, nf, 2, 0) // TRIVIALITY-SPAMMER: ANNIHILATE -> constant-0 (novel but useless)
137
138 gw(" HONEST COMPOSE useful-prod=" as *u8); gn(p_honest1); gw(" -> KEEP\n" as *u8)
139 gw(" HONEST REPEAT(2) useful-prod=" as *u8); gn(p_honest2); gw(" -> KEEP\n" as *u8)
140 gw(" DEGEN credit-stealer useful-prod=" as *u8); gn(p_steal); gw(" -> REJECT (earns nothing it produced)\n" as *u8)
141 gw(" DEGEN triviality-spam useful-prod=" as *u8); gn(p_spam); gw(" -> REJECT (novel but useless = constant)\n\n" as *u8)
142
143 var honest_kept: i64 = 0
144 if p_honest1 > 0 { honest_kept = honest_kept + 1 }
145 if p_honest2 > 0 { honest_kept = honest_kept + 1 }
146 var degen_rejected: i64 = 0
147 if p_steal == 0 { degen_rejected = degen_rejected + 1 }
148 if p_spam == 0 { degen_rejected = degen_rejected + 1 }
149
150 // ---- GATE (no-fake-green) ----
151 var t1: i64 = 0; if p_honest1 > 0 { if p_honest2 > 0 { t1 = 1 } } // honest combinators rewarded
152 var t2: i64 = 0; if p_steal == 0 { t2 = 1 } // Mode 1 credit-stealing AUTO-REJECTED
153 var t3: i64 = 0; if p_spam == 0 { t3 = 1 } // Mode 2 triviality-spam AUTO-REJECTED
154 var t4: i64 = 0; if honest_kept == 2 { if degen_rejected == 2 { t4 = 1 } } // exact: honest kept, ALL degeneracy rejected
155 // T5 measured exceed: 2 degeneration modes injected, 2 auto-rejected, 0 human interventions (Eurisko needed Lenat).
156 var human_interventions: i64 = 0
157 var t5: i64 = 0; if human_interventions == 0 { if degen_rejected == 2 { t5 = 1 } }
158
159 gw("T1 honest-rewarded=" as *u8); gn(t1); gw(" T2 anti-credit-steal=" as *u8); gn(t2)
160 gw(" T3 anti-triviality=" as *u8); gn(t3); gw(" T4 kept2/rejected2=" as *u8); gn(t4)
161 gw(" T5 exceed(0 human interventions)=" as *u8); gn(t5); gw("\n" as *u8)
162
163 var green: i64 = 0
164 if t1==1 { if t2==1 { if t3==1 { if t4==1 { if t5==1 { green = 1 } } } } }
165 if green == 1 {
166 gw("VERDICT: GREEN -- 2 of Eurisko's degeneration modes injected, BOTH auto-rejected mechanically, 0 human interventions.\n" as *u8)
167 gw("MEASURED EXCEED vs Eurisko: it degenerated on these + needed Lenat to hand-prune; the ecosystem rejects them by construction.\n" as *u8)
168 gw("HONEST: this is the START of not-degenerating (2 modes). Open arc: worth-metric self-modification, collusion, reward-hacking we haven't modeled.\n" as *u8)
169 sys_exit(0); return 0
170 }
171 gw("VERDICT: RED\n" as *u8); sys_exit(1); return 1
172}