code wiki / _hdl_build / nx_sourced_census_test.nx

nx_sourced_census_test.nx source

↩ module page · 168 lines · 9131 B

1// nx_sourced_census_test.nx -- X-CENSUS-003: LIVE-SOURCED competitive census, 2// union-DATA-aware (the honest no-wave verdict). 3// 4// Insight from reading the live source: a single encyclopedic stub does NOT 5// enumerate granular features, so token/fuzzy matching alone under-measures. 6// But the bench-reference `union` column already states which incumbents claim 7// each feature -- so the VALID head-to-head is computable NOW: 8// 9// nishi_has = re_has(self_model, probe) -- COMPUTED, do WE have it 10// incumbent = union does NOT start with "none" -- bench-reference: any rival claims it 11// jelly_live = fuzzy_has(live_jelly_text, feat|probe) -- live PROVENANCE (case/hyphen-safe) 12// 13// classification (no faked semantics): 14// nishi & !incumbent -> DIFFERENTIATED (sovereign axis: union says no rival has it) 15// nishi & incumbent -> PARITY (we + a rival both have it) 16// !nishi & incumbent -> BEHIND (rival has it, we lack it -- media breadth) 17// !nishi & !incumbent -> NEITHER 18// 19// The live Jellyfin fetch CONFIRMS the union claim where its prose literally 20// states the feature (provenance); where prose words it differently that's the 21// remaining prose->feature SEMANTIC seat (a model seat) -- NOT faked here, just 22// not required for the differentiation/parity/behind verdict. 23// 24// SOURCE-INTEGRITY GATE (no-false-green): live text MUST contain "Jellyfin" + 25// MUST NOT contain a nonsense token; self-model pos/neg controls. license_tier: ORIGINAL 26 27import "nx_syscalls.nx" 28import "nx_research_extract.nx" 29import "nx_html_to_text.nx" 30import "nx_fuzzy_match.nx" 31 32const SC_SELF: *u8 = "runtime/_hdl_build/nx_ecosystem_test.nx" 33const SC_REF: *u8 = "knowledge/registry/media_incumbent_ref.tsv" 34const SC_RAW: *u8 = "knowledge/fetched/jellyfin_sovereign.raw" 35const SC_OUT: *u8 = "knowledge/registry/media_sourced_census.tsv" 36const SC_MAXF: i64 = 256 37 38func sc_msg(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 39func sc_putn(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 } 40func sc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 41 42func sc_read_file(path: *u8, buf: *u8, cap: i64) -> i64 { 43 let fd: i64 = sys_openat_rd(path) 44 if fd < 0 { return 0 - 1 } 45 var tot: i64 = 0 46 var r: i64 = 1 47 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} } 48 sys_close(fd) 49 return tot 50} 51func sc_scan_to(buf: *u8, n: i64, start: i64, delim: i64) -> i64 { 52 var i: i64 = start 53 var s: i64 = 1 54 while s == 1 { if i >= n { s = 0 } else { if buf[i] == (delim as u8) { s = 0 } else { i = i + 1 } } } 55 return i 56} 57func sc_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 } 58 59// union starts with "none" => NO incumbent claims this feature (sovereign axis). 60func sc_union_none(u: *u8) -> i64 { 61 if u[0]==(110 as u8) { if u[1]==(111 as u8) { if u[2]==(110 as u8) { if u[3]==(101 as u8) { return 1 } } } } 62 return 0 63} 64 65func main() -> i64 { 66 let sm: *u8 = sys_mmap(300000) 67 let smn: i64 = sc_read_file(SC_SELF, sm, 300000) 68 if smn <= 0 { sc_msg("SOURCEDGATE verdict=RED reason=selfmodel-unreadable\n" as *u8); return 1 } 69 70 let raw: *u8 = sys_mmap(2097152) 71 let rn: i64 = sc_read_file(SC_RAW, raw, 2097151) 72 if rn <= 0 { sc_msg("SOURCEDGATE verdict=RED reason=live-raw-missing (run nx_fetch_jellyfin first)\n" as *u8); return 1 } 73 var bo: i64 = 0 74 var pp: i64 = 0 75 while pp + 3 < rn { 76 if raw[pp]==(13 as u8) { if raw[pp+1]==(10 as u8) { if raw[pp+2]==(13 as u8) { if raw[pp+3]==(10 as u8) { bo = pp+4; pp = rn } } } } 77 pp = pp + 1 78 } 79 if bo == 0 { sc_msg("SOURCEDGATE verdict=RED reason=no-header-boundary\n" as *u8); return 1 } 80 let jtxt: *u8 = sys_mmap(2097152) 81 let jtn: i64 = nx_html_to_text((raw as i64 + bo) as *u8, rn - bo, jtxt, 2097151) 82 if jtn <= 0 { sc_msg("SOURCEDGATE verdict=RED reason=render-empty\n" as *u8); return 1 } 83 let jfd: i64 = sys_openat_wr("knowledge/fetched/jellyfin_sovereign.txt\x00" as *u8, 0x1A4) 84 if jfd > 0 { sys_write(jfd, jtxt, jtn); sys_close(jfd) } 85 86 let src_pos: i64 = re_has(jtxt, jtn, "Jellyfin" as *u8) 87 let src_neg: i64 = re_has(jtxt, jtn, "zzqnonexistentfeature" as *u8) 88 let sm_pos: i64 = re_has(sm, smn, "divider" as *u8) 89 let sm_neg: i64 = re_has(sm, smn, "zzqnonexistentcapability" as *u8) 90 91 let rb: *u8 = sys_mmap(80000) 92 let rbn: i64 = sc_read_file(SC_REF, rb, 80000) 93 if rbn <= 0 { sc_msg("SOURCEDGATE verdict=RED reason=ref-unreadable\n" as *u8); return 1 } 94 let feat: *i64 = sys_mmap(8*SC_MAXF) as *i64 95 let prob: *i64 = sys_mmap(8*SC_MAXF) as *i64 96 let unin: *i64 = sys_mmap(8*SC_MAXF) as *i64 97 var nf: i64 = 0 98 var p: i64 = 0 99 while p < rbn { 100 if rb[p] == (35 as u8) { let e: i64 = sc_scan_to(rb, rbn, p, 10); p = e + 1 } 101 else { if rb[p] == (10 as u8) { p = p + 1 } 102 else { 103 let a0: i64 = p 104 let t1: i64 = sc_scan_to(rb, rbn, a0, 9); rb[t1] = 0 as u8 105 let a1: i64 = t1 + 1 106 let t2: i64 = sc_scan_to(rb, rbn, a1, 9); rb[t2] = 0 as u8 107 let a2: i64 = t2 + 1 108 let t3: i64 = sc_scan_to(rb, rbn, a2, 10); rb[t3] = 0 as u8 109 if nf < SC_MAXF { feat[nf]=(rb as i64)+a0; prob[nf]=(rb as i64)+a1; unin[nf]=(rb as i64)+a2; nf = nf + 1 } 110 p = t3 + 1 111 } } 112 } 113 114 let ob: *u8 = sys_mmap(300000) 115 var o: i64 = 0 116 o = sc_app(ob, o, "# LIVE-SOURCED census, union-aware -- competitor surface=bench-reference union; live confirm=en.wikipedia.org/wiki/Jellyfin (sovereign fetch). class from nishi_has(COMPUTED) x incumbent(union) ; jelly_live=case/hyphen-safe provenance.\n# feature\tnishi_has\tincumbent_claims\tjelly_live_confirm\tclass\n" as *u8) 117 var differ: i64 = 0 118 var parity: i64 = 0 119 var behind: i64 = 0 120 var neither: i64 = 0 121 var jelly_union: i64 = 0 122 var jelly_live_confirmed: i64 = 0 123 var i: i64 = 0 124 while i < nf { 125 let nishi: i64 = re_has(sm, smn, (prob[i]) as *u8) 126 var incumbent: i64 = 1 127 if sc_union_none((unin[i]) as *u8) == 1 { incumbent = 0 } 128 var jelly: i64 = fuzzy_has(jtxt, jtn, (feat[i]) as *u8) 129 if jelly == 0 { jelly = fuzzy_has(jtxt, jtn, (prob[i]) as *u8) } 130 // is Jellyfin specifically a claimed incumbent for this feature? 131 let jin: i64 = re_has((unin[i]) as *u8, sc_slen((unin[i]) as *u8), "jellyfin" as *u8) 132 if jin == 1 { jelly_union = jelly_union + 1; if jelly == 1 { jelly_live_confirmed = jelly_live_confirmed + 1 } } 133 134 o = sc_app(ob, o, (feat[i]) as *u8); o = sc_app(ob, o, "\t" as *u8) 135 if nishi==1 { o=sc_app(ob,o,"1\t" as *u8) } else { o=sc_app(ob,o,"0\t" as *u8) } 136 if incumbent==1 { o=sc_app(ob,o,"1\t" as *u8) } else { o=sc_app(ob,o,"0\t" as *u8) } 137 if jelly==1 { o=sc_app(ob,o,"1\t" as *u8) } else { o=sc_app(ob,o,"0\t" as *u8) } 138 if nishi==1 { if incumbent==0 { differ=differ+1; o=sc_app(ob,o,"DIFFERENTIATED(sovereign-axis)\n" as *u8) } else { parity=parity+1; o=sc_app(ob,o,"PARITY\n" as *u8) } } 139 else { if incumbent==1 { behind=behind+1; o=sc_app(ob,o,"BEHIND(media-breadth)\n" as *u8) } else { neither=neither+1; o=sc_app(ob,o,"neither\n" as *u8) } } 140 i = i + 1 141 } 142 let fdo: i64 = sys_openat_wr(SC_OUT, 420) 143 if fdo >= 0 { sys_write(fdo, ob, o); sys_close(fdo) } 144 145 sc_msg("SOURCEDGATE competitor-class=union-DATA live-confirm=en.wikipedia.org/wiki/Jellyfin(sovereign;static-mirror) live_text_bytes=" as *u8); sc_putn(jtn) 146 sc_msg(" features=" as *u8); sc_putn(nf) 147 sc_msg(" DIFFERENTIATED_sovereign=" as *u8); sc_putn(differ) 148 sc_msg(" PARITY=" as *u8); sc_putn(parity) 149 sc_msg(" BEHIND_breadth=" as *u8); sc_putn(behind) 150 sc_msg(" neither=" as *u8); sc_putn(neither) 151 sc_msg(" | jellyfin_union_features=" as *u8); sc_putn(jelly_union) 152 sc_msg(" of_which_live_prose_confirmed=" as *u8); sc_putn(jelly_live_confirmed) 153 sc_msg("\n HONEST VERDICT: Nishi DIFFERENTIATED on " as *u8); sc_putn(differ) 154 sc_msg(" sovereign axes (union=no-rival), PARITY on " as *u8); sc_putn(parity) 155 sc_msg(", BEHIND on " as *u8); sc_putn(behind) 156 sc_msg(" media-breadth axes. NOT a single 'exceed' -- a measured per-axis split (no-wave).\n" as *u8) 157 sc_msg(" RESIDUAL SEAT: fine prose->feature matching on contested axes (e.g. transcoding/Live-TV worded differently) = model seat, NOT faked.\n" as *u8) 158 159 var ok: i64 = 1 160 if src_pos != 1 { ok = 0 } 161 if src_neg != 0 { ok = 0 } 162 if sm_pos != 1 { ok = 0 } 163 if sm_neg != 0 { ok = 0 } 164 if nf <= 0 { ok = 0 } 165 if ok == 1 { sc_msg("SOURCEDGATE verdict=GREEN\n" as *u8); return 0 } 166 sc_msg("SOURCEDGATE verdict=RED reason=control src_pos=" as *u8); sc_putn(src_pos); sc_msg(" src_neg=" as *u8); sc_putn(src_neg); sc_msg("\n" as *u8) 167 return 1 168}