nx_search_competitor_census.nx source
↩ module page · 138 lines · 8533 B
1// nx_search_competitor_census.nx -- the SEARCH lane's COMPETITOR-FEATURE census: how much of the incumbent
2// (Ecosia/DDG/Bing/Google/Brave/Mojeek/Kagi) feature UNION does the sovereign engine already have? Data-driven over
3// knowledge/registry/search_competitor_features.conf (add a row = a graded feature, ZERO rebuild). Each feature reads
4// PRESENT iff its proving SEARCH gate log's last verdict is GREEN (gate-derived via nx_gate_green -- NEVER asserted,
5// the anti-cheat law); a BUILD-TARGET (gate="-") reads ABSENT with the incumbents that have it. Prints per-LADDER-TIER
6// rollup (mojeek < ddg < bing < google) so we see exactly which competitor tier we've matched + where the climb is.
7// Grades from the SEARCH gate logs (NOT the substrate self-model -- that would false-ABSENT every search capability).
8// Composes nx_gate_green (the scorecard's proven line-judge). Durable -> knowledge/status/search_competitor_census.log.
9// license_tier: ORIGINAL
10import "nx_str.nx"
11import "nx_syscalls.nx"
12import "nx_gate_green.nx"
13const SCC_MAGIC_65536: i64 = 65536
14const SCC_MAGIC_65520: i64 = 65520
15const SCC_MAGIC_200000: i64 = 200000
16
17const SCC_CONF: *u8 = "knowledge/registry/search_competitor_features.conf"
18const SCC_OUT: *u8 = "knowledge/registry/search_competitor_census.tsv"
19const SCC_LOG: *u8 = "knowledge/status/search_competitor_census.log"
20
21func scp(s: *u8) -> i64 { sys_write(1, s, nx_str_len(s)); return 0 }
22func scn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let t: *u8=sys_mmap(28); var k: i64=0; while m>0 { t[k]=48+(m%10); m=m/10; k=k+1 } while k>0 { k=k-1; sys_write(1,(((t as i64)+k) as *u8),1) } return 0 }
23func scw(fd: i64, s: *u8) -> i64 { if fd>=0 { sys_write(fd, s, nx_str_len(s)) } return 0 }
24func scfn(fd: i64, v: i64) -> i64 { let b: *u8=sys_mmap(28); let t: *u8=sys_mmap(28); var m: i64=v; if m<0 { m=0-m } 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 { b[i]=t[k-1-i]; i=i+1 } if fd>=0 { sys_write(fd,b,k) } return 0 }
25
26func scc_read(path: *u8, buf: *u8, cap: i64) -> i64 {
27 let fd: i64 = sys_openat_rd(path); if fd<0 { return 0-1 }
28 var tot: i64=0; var r: i64=1
29 while r>0 { let dst: *u8=((buf as i64)+tot) as *u8; r=sys_read(fd,dst,cap-tot); if r>0 { tot=tot+r } }
30 sys_close(fd); return tot
31}
32func scc_scan_to(buf: *u8, n: i64, start: i64, delim: i64) -> i64 {
33 var i: i64=start; var s: i64=1
34 while s==1 { if i>=n { s=0 } else { if buf[i]==(delim as u8) { s=0 } else { i=i+1 } } }
35 return i
36}
37func scc_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]!=(0 as u8) { return 0 } return 1 }
38func scc_app(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { dst[off+i]=s[i]; i=i+1 } return off+i }
39
40func scc_tier_idx(t: *u8) -> i64 {
41 if scc_streq(t,"mojeek" as *u8)==1 { return 0 }
42 if scc_streq(t,"exceed" as *u8)==1 { return 1 }
43 if scc_streq(t,"ddg" as *u8)==1 { return 2 }
44 if scc_streq(t,"bing" as *u8)==1 { return 3 }
45 if scc_streq(t,"google" as *u8)==1 { return 4 }
46 if scc_streq(t,"scale" as *u8)==1 { return 5 }
47 if scc_streq(t,"foundational" as *u8)==1 { return 6 }
48 return 6
49}
50func scc_tier_name(i: i64) -> *u8 {
51 if i==0 { return "mojeek/brave (indep-index + core ORGANS present)" as *u8 }
52 if i==1 { return "EXCEED (reach-policy/neutrality -- proven on the 46-doc micro-set)" as *u8 }
53 if i==2 { return "duckduckgo (privacy + basic verticals)" as *u8 }
54 if i==3 { return "bing (maps + shopping + panels)" as *u8 }
55 if i==4 { return "google (ai-overview + universal cart)" as *u8 }
56 if i==5 { return "cross-cutting (perf race)" as *u8 }
57 return "FOUNDATIONAL (bigger index: common-crawl + pagerank + anti-slop + memex-reach = the REAL edge)" as *u8
58}
59
60func main() -> i64 {
61 scp("=== nx_search_competitor_census: incumbent FEATURE-UNION coverage (gate-derived, honest) ===\n" as *u8)
62 let cb: *u8 = sys_mmap(SCC_MAGIC_65536)
63 let cn: i64 = scc_read(SCC_CONF, cb, SCC_MAGIC_65520)
64 if cn<=0 { scp(" conf unreadable\n" as *u8); sys_exit(1); return 1 }
65 let lfd: i64 = sys_openat_append(SCC_LOG, 420)
66 let ob: *u8 = sys_mmap(SCC_MAGIC_200000); var oo: i64=0
67 oo = scc_app(ob, oo, "# nx_search_competitor_census -- STATUS computed via nx_gate_green over search gate logs; build-targets=ABSENT.\n" as *u8)
68
69 let tpres: *i64 = sys_mmap(8*7) as *i64
70 let ttot: *i64 = sys_mmap(8*7) as *i64
71 var ti: i64=0; while ti<7 { tpres[ti]=0; ttot[ti]=0; ti=ti+1 }
72 var present: i64=0; var total: i64=0
73 var ctl_present: i64=0; var ctl_target_absent: i64=0
74
75 var p: i64=0
76 while p<cn {
77 if cb[p]==(35 as u8) { let e: i64=scc_scan_to(cb,cn,p,10); p=e+1 }
78 else { if cb[p]==(10 as u8) { p=p+1 }
79 else {
80 let f0: i64=p
81 let e1: i64=scc_scan_to(cb,cn,f0,9); cb[e1]=0 as u8
82 let f1: i64=e1+1; let e2: i64=scc_scan_to(cb,cn,f1,9); cb[e2]=0 as u8
83 let f2: i64=e2+1; let e3: i64=scc_scan_to(cb,cn,f2,9); cb[e3]=0 as u8
84 let f3: i64=e3+1; let e4: i64=scc_scan_to(cb,cn,f3,9); cb[e4]=0 as u8
85 let f4: i64=e4+1; let e5: i64=scc_scan_to(cb,cn,f4,9); cb[e5]=0 as u8
86 let f5: i64=e5+1; let e6: i64=scc_scan_to(cb,cn,f5,10); cb[e6]=0 as u8
87 let feat: *u8=((cb as i64)+f0) as *u8
88 let inc: *u8=((cb as i64)+f1) as *u8
89 let tier: *u8=((cb as i64)+f2) as *u8
90 let gate: *u8=((cb as i64)+f3) as *u8
91 let anch: *u8=((cb as i64)+f4) as *u8
92 let pat: *u8=((cb as i64)+f5) as *u8
93
94 var st: i64=0
95 if scc_streq(gate,"-" as *u8)==1 { st=0 } else { st=gg_gate_green(gate, anch, pat) }
96 let tix: i64=scc_tier_idx(tier)
97 total=total+1; ttot[tix]=ttot[tix]+1
98 if st==1 { present=present+1; tpres[tix]=tpres[tix]+1 }
99 if scc_streq(feat,"content-neutral-no-censor" as *u8)==1 { if st==1 { ctl_present=1 } }
100 if scc_streq(feat,"ai-overview-generative" as *u8)==1 { if st==0 { ctl_target_absent=1 } }
101
102 scp(" "); if st==1 { scp("[HAVE] " as *u8) } else { scp("[GAP ] " as *u8) }
103 scp(feat); scp(" tier=" as *u8); scp(tier); scp(" incumbents=" as *u8); scp(inc); scp("\n" as *u8)
104 if st==1 { oo=scc_app(ob,oo,"PRESENT\t" as *u8) } else { oo=scc_app(ob,oo,"ABSENT\t" as *u8) }
105 oo=scc_app(ob,oo,feat); oo=scc_app(ob,oo,"\t" as *u8); oo=scc_app(ob,oo,tier); oo=scc_app(ob,oo,"\t" as *u8); oo=scc_app(ob,oo,inc); oo=scc_app(ob,oo,"\n" as *u8)
106 p=e6+1
107 } }
108 }
109
110 let cfd: i64 = sys_openat_wr(SCC_OUT, 420)
111 if cfd>=0 { sys_write(cfd, ob, oo); sys_close(cfd) }
112
113 scp("\n -- LADDER (present/total per tier) --\n" as *u8)
114 var i: i64=0
115 while i<7 {
116 scp(" "); scn(tpres[i]); scp("/" as *u8); scn(ttot[i]); scp(" " as *u8); scp(scc_tier_name(i)); scp("\n" as *u8)
117 i=i+1
118 }
119 let permil: i64 = (present*1000)/total
120 scp("\n coverage: " as *u8); scn(present); scp("/" as *u8); scn(total); scp(" features = " as *u8); scn(permil); scp(" permil\n" as *u8)
121 scp(" STANDING (HONEST): core search ORGANS present + a reach-POLICY edge proven ONLY on a 46-doc micro-benchmark -- NOT a bigger index than Mojeek (billions of pages).\n" as *u8)
122 scp(" THE REAL GAP = the FOUNDATIONAL tier above (mostly ABSENT): common-crawl ingest at scale + anti-slop filter + memex deep-reach; the SCALE outcomes (index-scale-billions, bigger-than-Mojeek) stay ABSENT until MEASURED on the NAS, never claimed.\n" as *u8)
123
124 scw(lfd, "SEARCH-COMPETITOR-CENSUS epoch=" as *u8); scfn(lfd, sys_now_realtime_sec())
125 scw(lfd, " present=" as *u8); scfn(lfd, present); scw(lfd, "/" as *u8); scfn(lfd, total)
126 scw(lfd, " permil=" as *u8); scfn(lfd, permil)
127 scw(lfd, " ctl_present=" as *u8); scfn(lfd, ctl_present)
128 scw(lfd, " ctl_target_absent=" as *u8); scfn(lfd, ctl_target_absent)
129
130 var ok: i64=1
131 if ctl_present!=1 { ok=0 }
132 if ctl_target_absent!=1 { ok=0 }
133 if total<=0 { ok=0 }
134 if ok==1 { scw(lfd, " verdict=GREEN\n" as *u8); scp(" CENSUS GREEN (controls held: known-green core PRESENT, build-target ABSENT)\n" as *u8); if lfd>=0 { sys_close(lfd) } sys_exit(0); return 0 }
135 scw(lfd, " verdict=RED\n" as *u8); scp(" CENSUS RED (control failed -- grader or pathing bug)\n" as *u8)
136 if lfd>=0 { sys_close(lfd) }
137 sys_exit(1); return 1
138}