code wiki / _hdl_build / nx_voxel_census.nx
nx_voxel_census.nx source
↩ module page · 166 lines · 7767 B
1// nx_voxel_census.nx -- VOXEL / 3D-WORLD-GEN / REALISM competitive census (operator 2026-06-13:
2// "are you better than as of today minecraft and other procedural voxel generators let alone unreal
3// level pure realism generators if not grow the nishi team and ecosystem").
4//
5// AUTHOR=ORGAN, NO-WAVE: reads voxel_incumbent_ref.tsv (bench-reference = the QUESTIONS: real killer
6// capabilities of Minecraft / procedural voxel gens / Unreal-realism) and COMPUTES Nishi's PRESENT/
7// ABSENT per row via re_has against the REAL Nishi gate log (knowledge/status/voxel3d.log = the PROOF
8// of what actually ran green) -- never tutor-asserted. Writes voxel_competitive_census.tsv + an honest
9// bm_verdict (BEHIND while the renderer is young = the TRUE starting line; ABSENT rows = the grow
10// backlog). Self-validating: pos control "perspective-projection" MUST be PRESENT, neg control ABSENT.
11// Twin of nx_kernel_census; composes nx_research_extract (re_has) + nx_benchmark (honest verdict).
12// license_tier: ORIGINAL
13import "nx_syscalls.nx"
14import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
15import "nx_research_extract.nx"
16import "nx_benchmark.nx"
17const VC_MAGIC_2000000: i64 = 2000000
18const VC_MAGIC_80000: i64 = 80000
19const VC_MAGIC_300000: i64 = 300000
20
21const VC_REF: *u8 = "knowledge/registry/voxel_incumbent_ref.tsv"
22const VC_OUT: *u8 = "knowledge/registry/voxel_competitive_census.tsv"
23const VC_LOG: *u8 = "knowledge/status/voxel_census.log"
24const VC_MAXF: i64 = 256
25
26// evidence = the REAL Nishi voxel/3D-render GREEN gate log (proof of what is actually built)
27const VC_E0: *u8 = "knowledge/status/voxel3d.log"
28
29func vc_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
30// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
31// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
32// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
33// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
34func vc_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
35
36func vc_read_file(path: *u8, buf: *u8, cap: i64) -> i64 {
37 let fd: i64 = sys_openat_rd(path)
38 if fd < 0 { return 0 - 1 }
39 var tot: i64 = 0
40 var r: i64 = 1
41 while r > 0 {
42 let dst: *u8 = ((buf as i64) + tot) as *u8
43 r = sys_read(fd, dst, cap - tot)
44 if r > 0 { tot = tot + r }
45 }
46 sys_close(fd)
47 return tot
48}
49
50func vc_read_into(path: *u8, buf: *u8, off: i64, cap: i64) -> i64 {
51 let fd: i64 = sys_openat_rd(path)
52 if fd < 0 { return off }
53 var tot: i64 = off
54 var r: i64 = 1
55 while r > 0 {
56 let dst: *u8 = ((buf as i64) + tot) as *u8
57 r = sys_read(fd, dst, cap - tot)
58 if r > 0 { tot = tot + r }
59 }
60 sys_close(fd)
61 return tot
62}
63
64func vc_scan_to(buf: *u8, n: i64, start: i64, delim: i64) -> i64 {
65 var i: i64 = start
66 var s: i64 = 1
67 while s == 1 { if i >= n { s = 0 } else { if buf[i] == (delim as u8) { s = 0 } else { i = i + 1 } } }
68 return i
69}
70
71func vc_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 }
72
73func vc_vstr(v: i64) -> *u8 {
74 if v == BM_AHEAD { return "AHEAD" as *u8 }
75 if v == BM_PARITY { return "PARITY" as *u8 }
76 if v == BM_BEHIND { return "BEHIND" as *u8 }
77 if v == BM_DIFFERENTIATED { return "DIFFERENTIATED" as *u8 }
78 return "REFUSE-cherrypick" as *u8
79}
80
81func vc_emit(fd: i64, nf: i64, present: i64, cpos: i64, cneg: i64, cov: i64, verdict: i64, ok: i64) -> i64 {
82 vc_w(fd, "VOXELCENSUSGATE authored=organ source=voxel_incumbent_ref.tsv evidence=voxel3d.log features=" as *u8); vc_wn(fd, nf)
83 vc_w(fd, " present=" as *u8); vc_wn(fd, present)
84 vc_w(fd, " absent=" as *u8); vc_wn(fd, nf - present)
85 vc_w(fd, " control_pos=" as *u8); vc_wn(fd, cpos)
86 vc_w(fd, " control_neg=" as *u8); vc_wn(fd, cneg)
87 vc_w(fd, " reach_permil=" as *u8); vc_wn(fd, cov)
88 vc_w(fd, " exceed_verdict=" as *u8); vc_w(fd, vc_vstr(verdict))
89 if ok == 1 { vc_w(fd, " verdict=GREEN\n" as *u8) } else { vc_w(fd, " verdict=RED reason=control-or-empty\n" as *u8) }
90 return 0
91}
92
93func main() -> i64 {
94 // 1. load evidence = the REAL Nishi voxel/3D gate log.
95 let ev: *u8 = sys_mmap(VC_MAGIC_2000000)
96 var eo: i64 = 0
97 eo = vc_read_into(VC_E0, ev, eo, VC_MAGIC_2000000)
98 let evlen: i64 = eo
99 if evlen <= 0 { vc_w(1, "VOXELCENSUSGATE verdict=RED reason=no-evidence (run nx_pets_voxel3d first)\n" as *u8); return 1 }
100
101 // 2. load + parse the bench-reference (feature \t probe \t incumbent).
102 let rb: *u8 = sys_mmap(VC_MAGIC_80000)
103 let rbn: i64 = vc_read_file(VC_REF, rb, VC_MAGIC_80000)
104 if rbn <= 0 { vc_w(1, "VOXELCENSUSGATE verdict=RED reason=ref-unreadable\n" as *u8); return 1 }
105 let feat: *i64 = sys_mmap(8 * VC_MAXF) as *i64
106 let prob: *i64 = sys_mmap(8 * VC_MAXF) as *i64
107 let unin: *i64 = sys_mmap(8 * VC_MAXF) as *i64
108 var nf: i64 = 0
109 var p: i64 = 0
110 while p < rbn {
111 if rb[p] == (35 as u8) { let e: i64 = vc_scan_to(rb, rbn, p, 10); p = e + 1 }
112 else { if rb[p] == (10 as u8) { p = p + 1 }
113 else {
114 let a0: i64 = p
115 let t1: i64 = vc_scan_to(rb, rbn, a0, 9); rb[t1] = 0 as u8
116 let a1: i64 = t1 + 1
117 let t2: i64 = vc_scan_to(rb, rbn, a1, 9); rb[t2] = 0 as u8
118 let a2: i64 = t2 + 1
119 let t3: i64 = vc_scan_to(rb, rbn, a2, 10); rb[t3] = 0 as u8
120 if nf < VC_MAXF { feat[nf] = (rb as i64) + a0; prob[nf] = (rb as i64) + a1; unin[nf] = (rb as i64) + a2; nf = nf + 1 }
121 p = t3 + 1
122 } }
123 }
124
125 // 3. compute status per feature from the evidence + author the census.
126 let ob: *u8 = sys_mmap(VC_MAGIC_300000)
127 var o: i64 = 0
128 o = vc_app(ob, o, "# AUTHORED BY nx_voxel_census -- Nishi 3D/voxel/realism vs Minecraft + procedural voxel gens + Unreal. Status COMPUTED via re_has against the REAL Nishi gate log (voxel3d.log), NOT asserted. PRESENT=gate-proven floor, ABSENT=grow-to-exceed backlog.\n" as *u8)
129 o = vc_app(ob, o, "# columns: status\tfeature\tincumbent\tevidence-probe\n" as *u8)
130 var present: i64 = 0
131 var i: i64 = 0
132 while i < nf {
133 let st: i64 = re_has(ev, evlen, (prob[i]) as *u8)
134 if st == 1 { o = vc_app(ob, o, "PRESENT\t" as *u8); present = present + 1 } else { o = vc_app(ob, o, "ABSENT\t" as *u8) }
135 o = vc_app(ob, o, (feat[i]) as *u8)
136 o = vc_app(ob, o, "\t" as *u8)
137 o = vc_app(ob, o, (unin[i]) as *u8)
138 o = vc_app(ob, o, "\tprobe=" as *u8)
139 o = vc_app(ob, o, (prob[i]) as *u8)
140 o = vc_app(ob, o, "\n" as *u8)
141 i = i + 1
142 }
143 let wfd: i64 = sys_openat_wr(VC_OUT, 420)
144 if wfd < 0 { vc_w(1, "VOXELCENSUSGATE verdict=RED reason=out-unwritable\n" as *u8); return 1 }
145 sys_write(wfd, ob, o)
146 sys_close(wfd)
147
148 // 4. self-validating controls + honest verdict (refuses cherry-pick).
149 let cpos: i64 = re_has(ev, evlen, "perspective-projection" as *u8)
150 let cneg: i64 = re_has(ev, evlen, "zzqnonexistentvoxelfeature" as *u8)
151 let valid: i64 = bm_is_valid(nf, nf, 800)
152 var cov: i64 = 0
153 if nf > 0 { cov = (present * 1000) / nf }
154 let verdict: i64 = bm_verdict(valid, cov, 1000)
155 var ok: i64 = 1
156 if cpos != 1 { ok = 0 }
157 if cneg != 0 { ok = 0 }
158 if nf <= 0 { ok = 0 }
159
160 // 5. emit gate evidence to stdout + append to the gate log.
161 vc_emit(1, nf, present, cpos, cneg, cov, verdict, ok)
162 let lf: i64 = sys_openat_append(VC_LOG, 420)
163 if lf >= 0 { vc_emit(lf, nf, present, cpos, cneg, cov, verdict, ok); sys_close(lf) }
164 if ok == 1 { return 0 }
165 return 1
166}