code wiki / _hdl_build / nx_research_landscape.nx

nx_research_landscape.nx source

↩ module page · 151 lines · 6580 B

1// nx_research_landscape.nx -- Researcher rung R4: the CORROBORATED COMPETITIVE 2// LANDSCAPE (Gartner-Magic-Quadrant-grade, and EXCEEDING it). 3// 4// Not "one source, one claim" -- this aggregates claims about MANY options across 5// MANY sources, counts DISTINCT corroborating sources per option (>=2 = CONFIRMED, 6// the no-hearsay rule), flags single-source claims honestly, names the LEADER (the 7// bar), and -- per the no-third-party law -- emits the SOVEREIGN-BUILD TARGET that 8// must EXCEED the field. Exceeds a Gartner report on: every option cited to its 9// source count, reproducible, sovereign, single-source flagged (no hand-waving). 10// Inspectable. license_tier: ORIGINAL. 11 12import "nx_syscalls.nx" 13import "nx_research_extract.nx" 14import "nx_research_relation.nx" 15import "nx_research_relations.nx" 16import "nx_research_relation_clean.nx" 17import "nx_research_sovereign_lens.nx" 18const K_MAGIC_1024: i64 = 1024 19const K_MAGIC_2048: i64 = 2048 20 21func la_streq(a: *u8, b: *u8) -> i64 { 22 var i: i64 = 0 23 while i < K_MAGIC_1024 { if a[i] != b[i] { return 0 } if a[i] == (0 as u8) { return 1 } i = i + 1 } 24 return 1 25} 26func la_app(out: *u8, off: *i64, s: *u8) -> i64 { 27 var i: i64 = 0 28 while s[i] != (0 as u8) { out[off[0]] = s[i]; off[0] = off[0] + 1; i = i + 1 } 29 return 0 30} 31func la_wn(out: *u8, off: *i64, v: i64) -> i64 { 32 var m: i64 = v 33 if m < 0 { m = 0 - m } 34 let t: *u8 = sys_mmap(28); var k: i64 = 0 35 if m == 0 { t[0] = 48 as u8; k = 1 } 36 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 37 var i: i64 = k - 1 38 while i >= 0 { out[off[0]] = t[i]; off[0] = off[0] + 1; i = i - 1 } 39 return 0 40} 41// add distinct source id s to srcset 42func la_add_src(srcset: *i64, nsrc: *i64, s: i64) -> i64 { 43 var i: i64 = 0 44 while i < nsrc[0] { if srcset[i] == s { return 0 } i = i + 1 } 45 srcset[nsrc[0]] = s 46 nsrc[0] = nsrc[0] + 1 47 return 0 48} 49 50// Render the corroborated landscape. subjs/rels/objs are arrays of *u8 (stored as 51// i64); srcs is the source id per claim; n = claim count. Returns option count. 52func ls_render(subjs: *i64, rels: *i64, objs: *i64, srcs: *i64, n: i64, out: *u8) -> i64 { 53 let off: *i64 = (sys_mmap(8)) as *i64 54 off[0] = 0 55 let seen: *i64 = (sys_mmap(n * 8 + 8)) as *i64 56 la_app(out, off, "=== CAPABILITY LANDSCAPE (corroborated, sovereign) ===\n" as *u8) 57 la_app(out, off, "methodology: claims=" as *u8); la_wn(out, off, n) 58 la_app(out, off, " ; rule: >=2 distinct sources = CONFIRMED (no hearsay)\n" as *u8) 59 la_app(out, off, "OPTIONS (the field = benchmarks to EXCEED):\n" as *u8) 60 61 var opt: i64 = 0 62 var max_src: i64 = 0 63 var leader: i64 = 0 64 var i: i64 = 0 65 while i < n { 66 if seen[i] == 0 { 67 let subj_i: *u8 = subjs[i] as *u8 68 let srcset: *i64 = (sys_mmap(n * 8 + 8)) as *i64 69 let nsrc: *i64 = (sys_mmap(8)) as *i64 70 nsrc[0] = 0 71 var j: i64 = i 72 while j < n { 73 if la_streq(subjs[j] as *u8, subj_i) == 1 { seen[j] = 1; la_add_src(srcset, nsrc, srcs[j]) } 74 j = j + 1 75 } 76 la_app(out, off, " " as *u8); la_app(out, off, subj_i) 77 la_app(out, off, " [" as *u8); la_wn(out, off, nsrc[0]); la_app(out, off, " sources] " as *u8) 78 if nsrc[0] >= 2 { la_app(out, off, "CONFIRMED\n" as *u8) } else { la_app(out, off, "UNCONFIRMED (single source)\n" as *u8) } 79 var k: i64 = i 80 while k < n { 81 if la_streq(subjs[k] as *u8, subj_i) == 1 { 82 la_app(out, off, " - " as *u8); la_app(out, off, rels[k] as *u8) 83 la_app(out, off, " -> " as *u8); la_app(out, off, objs[k] as *u8); la_app(out, off, "\n" as *u8) 84 } 85 k = k + 1 86 } 87 if nsrc[0] > max_src { max_src = nsrc[0]; leader = i } 88 opt = opt + 1 89 } 90 i = i + 1 91 } 92 93 la_app(out, off, "LEADER (bar to beat): " as *u8); la_app(out, off, subjs[leader] as *u8) 94 la_app(out, off, " (" as *u8); la_wn(out, off, max_src); la_app(out, off, " sources)\n" as *u8) 95 let dir: *u8 = sys_mmap(K_MAGIC_2048) 96 let li: i64 = nx_sovereign_lens(subjs[leader] as *u8, objs[leader] as *u8, dir) 97 if li >= 0 { la_app(out, off, "=> " as *u8); la_app(out, off, dir); la_app(out, off, "\n" as *u8) } 98 else { la_app(out, off, "=> SOVEREIGN BUILD TARGET: build it ourselves, S-class, hardware rung up, exceed the field\n" as *u8) } 99 la_app(out, off, "EXCEED-GARTNER axes: every option cited to its source count | reproducible | sovereign | single-source flagged\n" as *u8) 100 out[off[0]] = 0 as u8 101 return opt 102} 103 104// own a copy of a NUL-terminated string 105func la_dup(s: *u8) -> *u8 { 106 var n: i64 = 0 107 while s[n] != (0 as u8) { n = n + 1 } 108 let o: *u8 = sys_mmap(n + 1) 109 var i: i64 = 0 110 while i <= n { o[i] = s[i]; i = i + 1 } 111 return o 112} 113 114// HARVEST: extract+clean every claim from text[0..n) (source src_id) straight into 115// the landscape arrays. Tool subjects are CANONICALIZED to the lens tool name so 116// the same option from different sources/phrasings groups -> real corroboration. 117func nx_rel_harvest(text: *u8, n: i64, src_id: i64, subjs: *i64, rels: *i64, objs: *i64, srcs: *i64, np: *i64, cap: i64) -> i64 { 118 let subj: *u8 = sys_mmap(K_MAGIC_2048) 119 let obj: *u8 = sys_mmap(K_MAGIC_2048) 120 let cs: *u8 = sys_mmap(K_MAGIC_2048) 121 let co: *u8 = sys_mmap(K_MAGIC_2048) 122 var s: i64 = 0 123 var i: i64 = 0 124 while i <= n { 125 var atend: i64 = 0 126 if i == n { atend = 1 } else { if rel_is_sent_end(text[i]) == 1 { atend = 1 } } 127 if atend == 1 { 128 let slen: i64 = i - s 129 if slen > 0 { 130 let ri: i64 = nx_rel_extract(text + s, slen, subj, obj) 131 if ri >= 0 { 132 if nx_claim_clean(subj, obj, cs, co) == 1 { 133 if np[0] < cap { 134 var keyptr: i64 = (la_dup(cs)) as i64 135 let tool: i64 = sl_detect(cs, re_strlen(cs)) 136 if tool >= 0 { keyptr = (la_dup(sl_tool(tool))) as i64 } 137 subjs[np[0]] = keyptr 138 rels[np[0]] = (rel_name(ri)) as i64 139 objs[np[0]] = (la_dup(co)) as i64 140 srcs[np[0]] = src_id 141 np[0] = np[0] + 1 142 } 143 } 144 } 145 } 146 s = i + 1 147 } 148 i = i + 1 149 } 150 return np[0] 151}