code wiki / _hdl_build / nx_org_research.nx
nx_org_research.nx source
↩ module page · 144 lines · 6934 B
1// nx_org_research.nx -- drive the SOVEREIGN NISHI RESEARCHER over the universal-ORGANIZATION-TOOLING gap
2// research (one asset+knowledge inventory tracking EVERY artifact -- professional + private + machine-created --
3// so we always know WHAT WE HAVE / WHAT TO DO / WHAT'S GOING ON) vs best-in-class DAM/KM (Adobe AEM Assets,
4// Bynder, Notion/Confluence, Google Photos).
5//
6// module: nishi-core.research.org
7// capability: CORE_COMPUTE (turn delegated organization-tooling research into a verified reproducible gap backlog)
8//
9// Reads knowledge/registry/org_research.tsv (the delegated SOVEREIGN fetch+extract: claims + 3 adversarial votes
10// each, grounded in real authoritative sources fetched live over Nishi's own TLS) and runs nx_researcher's
11// DETERMINISTIC verify (>=2 confirm => CONFIRMED) + synthesize (CONFIRMED+actionable => gap-task). Prints the
12// verdict census + the ranked gap-task backlog + the REPRODUCIBILITY proof (same evidence -> same tasks).
13// Refuted/contested => ZERO tasks (the no-wasted-work exceed over a one-shot LLM report). Sovereign: nx_syscalls
14// + nx_researcher. license_tier: ORIGINAL
15import "nx_syscalls.nx"
16import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
17import "nx_researcher.nx"
18
19const OR_FILE: *u8 = "knowledge/registry/org_research.tsv"
20
21static OR_N: i64
22static OR_FID: i64
23static OR_CLAIM: i64
24static OR_CV: i64
25static OR_RV: i64
26static OR_ACT: i64
27static OR_ORGAN: i64
28static OR_NOTE: i64
29
30func or_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 }
31// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
32// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
33// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
34// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
35func or_putn(v: i64) -> i64 { nxi_out(v); return 0 }
36func or_field(b: *u8, ls: i64, le: i64, f: i64) -> *u8 {
37 var cur: i64 = 0; var i: i64 = ls
38 while cur < f { if i >= le { let e: *u8 = sys_mmap(2); e[0] = 0 as u8; return e } if b[i] == 9 as u8 { cur = cur + 1 } i = i + 1 }
39 let out: *u8 = sys_mmap(512); var o: i64 = 0
40 while i < le { if b[i] == 9 as u8 { i = le } else { if o < 511 { out[o] = b[i]; o = o + 1 } i = i + 1 } }
41 out[o] = 0 as u8
42 return out
43}
44func or_atoi(s: *u8) -> i64 { if s[0] >= 48 as u8 { if s[0] <= 57 as u8 { return (s[0] - 48 as u8) as i64 } } return 0 }
45
46func or_parse() -> i64 {
47 let lenbox: *i64 = sys_mmap(16) as *i64; lenbox[0] = 0
48 let data: *u8 = sys_read_file(OR_FILE, lenbox)
49 if (data as i64) == 0 { return 0 - 1 }
50 let n: i64 = lenbox[0]
51 var rows: i64 = 0; var ls: i64 = 0; var i: i64 = 0
52 while i <= n {
53 var atend: i64 = 0
54 if i == n { atend = 1 }
55 if i < n { if data[i] == 10 as u8 { atend = 1 } }
56 if atend == 1 { if i > ls { if data[ls] != 35 as u8 { rows = rows + 1 } } ls = i + 1 }
57 i = i + 1
58 }
59 let fid: *i64 = sys_mmap(8 * (rows + 1)) as *i64
60 let claim: *i64 = sys_mmap(8 * (rows + 1)) as *i64
61 let cv: *i64 = sys_mmap(8 * (rows + 1)) as *i64
62 let rv: *i64 = sys_mmap(8 * (rows + 1)) as *i64
63 let act: *i64 = sys_mmap(8 * (rows + 1)) as *i64
64 let organ: *i64 = sys_mmap(8 * (rows + 1)) as *i64
65 let note: *i64 = sys_mmap(8 * (rows + 1)) as *i64
66 var r: i64 = 0; ls = 0; i = 0
67 while i <= n {
68 var atend: i64 = 0
69 if i == n { atend = 1 }
70 if i < n { if data[i] == 10 as u8 { atend = 1 } }
71 if atend == 1 {
72 if i > ls { if data[ls] != 35 as u8 {
73 fid[r] = or_field(data, ls, i, 0) as i64
74 claim[r] = or_field(data, ls, i, 1) as i64
75 cv[r] = or_atoi(or_field(data, ls, i, 2))
76 rv[r] = or_atoi(or_field(data, ls, i, 3))
77 act[r] = or_atoi(or_field(data, ls, i, 4))
78 organ[r] = or_field(data, ls, i, 5) as i64
79 note[r] = or_field(data, ls, i, 6) as i64
80 r = r + 1
81 } }
82 ls = i + 1
83 }
84 i = i + 1
85 }
86 OR_N = r
87 OR_FID = fid as i64; OR_CLAIM = claim as i64; OR_CV = cv as i64; OR_RV = rv as i64
88 OR_ACT = act as i64; OR_ORGAN = organ as i64; OR_NOTE = note as i64
89 return 0
90}
91
92func main() -> i64 {
93 or_puts("=== NISHI RESEARCHER: universal organization tooling vs best-in-class -- verified gap-task backlog ===\n")
94 or_puts(" fetch path = SOVEREIGN nx_research_fetch (own TLS-1.3, 167-root CA, no curl/wget); votes = grep-corroboration of retrieved bodies\n")
95 if or_parse() != 0 { or_puts("FATAL: org_research.tsv unreadable\n"); sys_exit(1); return 1 }
96 let cv: *i64 = OR_CV as *i64
97 let rv: *i64 = OR_RV as *i64
98 let act: *i64 = OR_ACT as *i64
99 let fid: *i64 = OR_FID as *i64
100 let claim: *i64 = OR_CLAIM as *i64
101 let organ: *i64 = OR_ORGAN as *i64
102 let note: *i64 = OR_NOTE as *i64
103
104 let oid: *i64 = sys_mmap(8 * (OR_N + 4)) as *i64
105 var z: i64 = 0; while z < OR_N { oid[z] = z; z = z + 1 }
106
107 let confirmed: i64 = res_count_verdict(OR_N, cv, rv, RES_CONFIRMED)
108 let refuted: i64 = res_count_verdict(OR_N, cv, rv, RES_REFUTED)
109 let contested: i64 = res_count_verdict(OR_N, cv, rv, RES_CONTESTED)
110 let repro: i64 = res_is_reproducible(OR_N, cv, rv, act, oid)
111
112 let out_idx: *i64 = sys_mmap(8 * (OR_N + 4)) as *i64
113 let out_org: *i64 = sys_mmap(8 * (OR_N + 4)) as *i64
114 let tasks: i64 = res_synthesize(OR_N, cv, rv, act, oid, out_idx, out_org)
115
116 or_puts(" findings="); or_putn(OR_N)
117 or_puts(" CONFIRMED="); or_putn(confirmed)
118 or_puts(" REFUTED="); or_putn(refuted)
119 or_puts(" CONTESTED="); or_putn(contested)
120 or_puts(" -> gap-tasks="); or_putn(tasks)
121 or_puts(" (refuted/contested -> 0 tasks, the no-wasted-work exceed)\n")
122 or_puts(" reproducible(same evidence -> same tasks)="); or_putn(repro); or_puts(" (an LLM one-shot cannot guarantee this)\n\n")
123
124 or_puts(" GAP-TASK BACKLOG (CONFIRMED + actionable, ranked source order):\n")
125 var t: i64 = 0
126 while t < tasks {
127 let i: i64 = out_idx[t]
128 or_puts(" ["); or_putn(res_confidence_permil(cv[i])); or_puts("permil] ")
129 or_puts(fid[i] as *u8); or_puts(" -> "); or_puts(organ[i] as *u8); or_puts("\n")
130 or_puts(" "); or_puts(claim[i] as *u8); or_puts("\n")
131 t = t + 1
132 }
133 or_puts("\n KILLED (not built -- the researcher refused these anti-patterns):\n")
134 var j: i64 = 0
135 while j < OR_N {
136 let v: i64 = res_verify(cv[j], rv[j])
137 if v != RES_CONFIRMED {
138 or_puts(" ["); if v == RES_REFUTED { or_puts("REFUTED ") } else { or_puts("CONTESTED") }
139 or_puts("] "); or_puts(fid[j] as *u8); or_puts(" -- "); or_puts(note[j] as *u8); or_puts("\n")
140 }
141 j = j + 1
142 }
143 sys_exit(0); return 0
144}