nx_fabric_census.nx source
↩ module page · 174 lines · 8404 B
1// nx_fabric_census.nx -- the SkyHammer fabric exceed LIVING MAP (the "reviewed by the team" artifact).
2// (knowledge/research/2026-06-23-skyhammer-fabric-sclass-exceed-benchmark.md.)
3//
4// Self-gating census: it GRADES each of the 7 axes (A..G) by reading the REAL on-disk evidence each rung's
5// gate left behind (knowledge/status/fabric_*.log "verdict=GREEN" + the rung's marker) -- so the map reflects
6// what is actually proven, not what a doc claims. LIVING: re-running a rung's gate (re-writing its GREEN log)
7// is picked up here; a regressed/missing log re-grades its axis and FAILS the snapshot assertion.
8//
9// LIAR-KILLED BOTH WAYS (the census cannot rubber-stamp): a real marker in its real log grades EXCEEDS;
10// a BOGUS marker, a real marker in the WRONG log, and a MISSING log all MUST grade 0 -- proving the grader
11// reads the bytes rather than asserting a constant. Mirrors nx_connect_census / nx_media_census / nx_vizsla_census.
12//
13// expect_exit: 0 license_tier: ORIGINAL
14import "nx_syscalls.nx"
15const K_MAGIC_65536: i64 = 65536
16
17func cp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
18func cn(v: i64) -> i64 {
19 let b: *u8 = sys_mmap(28); var m: i64 = v
20 if m < 0 { m = 0 - m; sys_write(1, "-" as *u8, 1) }
21 let t: *u8 = sys_mmap(28); var k: i64 = 0
22 if m == 0 { t[0] = 48 as u8; k = 1 }
23 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
24 var i: i64 = 0
25 while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
26 sys_write(1, b, k); return 0
27}
28func fdn(fd: i64, v: i64) -> i64 {
29 let b: *u8 = sys_mmap(28); var m: i64 = v; if m < 0 { m = 0 - m }
30 let t: *u8 = sys_mmap(28); var k: i64 = 0
31 if m == 0 { t[0] = 48 as u8; k = 1 }
32 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
33 var i: i64 = 0
34 while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
35 sys_write(fd, b, k); return 0
36}
37func cs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
38
39func cs_contains(hay: *u8, hn: i64, ndl: *u8, nn: i64) -> i64 {
40 if nn == 0 { return 1 }
41 var i: i64 = 0
42 while i + nn <= hn {
43 var j: i64 = 0
44 while j < nn { if hay[i+j] != ndl[j] { break } j = j + 1 }
45 if j == nn { return 1 }
46 i = i + 1
47 }
48 return 0
49}
50
51func cs_read(path: *u8, buf: *u8, cap: i64) -> i64 {
52 let fd: i64 = sys_openat_rd(path)
53 if fd < 0 { return 0 }
54 var total: i64 = 0
55 while total < cap {
56 let n: i64 = sys_read(fd, buf + total, cap - total)
57 if n <= 0 { break }
58 total = total + n
59 }
60 sys_close(fd)
61 return total
62}
63
64// 1 iff `logpath` contains BOTH the rung `marker` AND "verdict=GREEN" -- the on-disk proof of a live exceed.
65func axis_green(logpath: *u8, marker: *u8) -> i64 {
66 let buf: *u8 = sys_mmap(K_MAGIC_65536)
67 let n: i64 = cs_read(logpath, buf, K_MAGIC_65536)
68 if n == 0 { return 0 }
69 if cs_contains(buf, n, marker, cs_slen(marker)) == 0 { return 0 }
70 if cs_contains(buf, n, "verdict=GREEN" as *u8, 13) == 0 { return 0 }
71 return 1
72}
73
74func grade_line(axis: *u8, label: *u8, g: i64) -> i64 {
75 cp(" " as *u8); cp(axis); cp(" " as *u8); cp(label); cp(" -> " as *u8)
76 if g == 2 { cp("EXCEEDS (LIVE)\n" as *u8) }
77 if g == 1 { cp("HAVE\n" as *u8) }
78 if g == 4 { cp("DIFFERENT-ALTITUDE (by construction)\n" as *u8) }
79 if g == 0 { cp("MISSING / not-yet\n" as *u8) }
80 return 0
81}
82
83func main() -> i64 {
84 let FLOW: *u8 = "knowledge/status/fabric_nx_fabric_flow.log"
85 let CC: *u8 = "knowledge/status/fabric_nx_fabric_cc.log"
86 let FEC: *u8 = "knowledge/status/fabric_nx_fabric_fec.log"
87 let COLL: *u8 = "knowledge/status/fabric_nx_fabric_collective.log"
88
89 cp("nx_fabric_census -- SkyHammer fabric exceed LIVING MAP (grades from on-disk gate evidence)\n" as *u8)
90
91 // grade the rung-backed axes from their real logs
92 let b: i64 = axis_green(FLOW, "R1-FABRIC-FLOW" as *u8) // B deterministic flow control (R1)
93 let d: i64 = axis_green(CC, "R2-FABRIC-CC" as *u8) // D telemetry / congestion (R2)
94 let c: i64 = axis_green(FEC, "R3-FABRIC-FEC" as *u8) // C resiliency (R3)
95 let f: i64 = axis_green(COLL, "R4-FABRIC-COLLECTIVE" as *u8) // F collective comm (R4)
96
97 // A sovereignty = EXCEEDS by construction, EVIDENCED by the sovereign nx_cc->nxasm chain producing >=1 GREEN gate
98 var a: i64 = 0
99 if b == 1 { a = 1 }
100 if c == 1 { a = 1 }
101 if d == 1 { a = 1 }
102 if f == 1 { a = 1 }
103 // E lossless = HAVE when both R1 (flow) and R2 (over-RTT) are green
104 var e: i64 = 0
105 if b == 1 { if d == 1 { e = 1 } }
106 // G unified compute domain = DIFFERENT-ALTITUDE (needs a real multi-node cluster) -- structural
107
108 var gA: i64 = 0; if a == 1 { gA = 2 }
109 var gB: i64 = 0; if b == 1 { gB = 2 }
110 var gC: i64 = 0; if c == 1 { gC = 2 }
111 var gD: i64 = 0; if d == 1 { gD = 2 }
112 var gE: i64 = 0; if e == 1 { gE = 1 }
113 var gF: i64 = 0; if f == 1 { gF = 2 }
114 let gG: i64 = 4
115
116 grade_line("A" as *u8, "sovereignty / no vendor-lock " as *u8, gA)
117 grade_line("B" as *u8, "deterministic flow control (R1) " as *u8, gB)
118 grade_line("C" as *u8, "built-in resiliency (R3) " as *u8, gC)
119 grade_line("D" as *u8, "real-time telemetry (R2) " as *u8, gD)
120 grade_line("E" as *u8, "lossless behaviour (R1+R2) " as *u8, gE)
121 grade_line("F" as *u8, "collective communication (R4) " as *u8, gF)
122 grade_line("G" as *u8, "unified compute domain " as *u8, gG)
123
124 var n_exceeds: i64 = 0
125 if gA == 2 { n_exceeds = n_exceeds + 1 }
126 if gB == 2 { n_exceeds = n_exceeds + 1 }
127 if gC == 2 { n_exceeds = n_exceeds + 1 }
128 if gD == 2 { n_exceeds = n_exceeds + 1 }
129 if gF == 2 { n_exceeds = n_exceeds + 1 }
130 var n_have: i64 = 0
131 if gE == 1 { n_have = n_have + 1 }
132 let n_diffalt: i64 = 1
133
134 cp("SNAPSHOT: EXCEEDS=" as *u8); cn(n_exceeds); cp(" HAVE=" as *u8); cn(n_have)
135 cp(" DIFFERENT-ALTITUDE=" as *u8); cn(n_diffalt); cp("\n" as *u8)
136
137 // ---- LIAR-KILL (negative controls): the grader must read the bytes, not rubber-stamp ----
138 let nc_bogus: i64 = axis_green(FLOW, "R9-FABRIC-BOGUS" as *u8) // bogus marker -> must be 0
139 let nc_wronglog:i64 = axis_green(COLL, "R1-FABRIC-FLOW" as *u8) // right marker, WRONG log -> 0
140 let nc_missing: i64 = axis_green("knowledge/status/fabric_does_not_exist.log" as *u8, "R1-FABRIC-FLOW" as *u8) // -> 0
141
142 var pass: i64 = 0
143 var tot: i64 = 0
144 var ok: i64 = 0
145 ok = 0; if gB == 2 { if gC == 2 { if gD == 2 { if gF == 2 { ok = 1 } } } }
146 if ok == 1 { cp(" PASS rung axes B,C,D,F all EXCEEDS (LIVE) from real logs\n" as *u8); pass = pass + 1 } else { cp(" FAIL rung axes not all green\n" as *u8) }
147 tot = tot + 1
148 ok = 0; if gA == 2 { if gE == 1 { if gG == 4 { ok = 1 } } }
149 if ok == 1 { cp(" PASS A=EXCEEDS(constr) E=HAVE G=DIFFERENT-ALTITUDE\n" as *u8); pass = pass + 1 } else { cp(" FAIL structural axes\n" as *u8) }
150 tot = tot + 1
151 ok = 0; if n_exceeds == 5 { if n_have == 1 { if n_diffalt == 1 { ok = 1 } } }
152 if ok == 1 { cp(" PASS snapshot == EXCEEDS=5 HAVE=1 DIFFERENT-ALTITUDE=1\n" as *u8); pass = pass + 1 } else { cp(" FAIL snapshot mismatch\n" as *u8) }
153 tot = tot + 1
154 ok = 0; if nc_bogus == 0 { if nc_wronglog == 0 { if nc_missing == 0 { ok = 1 } } }
155 if ok == 1 { cp(" PASS liar-kill: bogus + wrong-log + missing all grade 0 (grader reads reality)\n" as *u8); pass = pass + 1 } else { cp(" FAIL liar-kill (grader rubber-stamps!)\n" as *u8) }
156 tot = tot + 1
157
158 cp("---- nx_fabric_census: passed " as *u8); cn(pass); cp(" / " as *u8); cn(tot); cp("\n" as *u8)
159
160 if pass == tot {
161 let lfd: i64 = sys_openat_append("knowledge/status/fabric_nx_fabric_census.log" as *u8, 0x1a4)
162 if lfd >= 0 {
163 sys_write(lfd, "FABRIC-CENSUS exceeds=" as *u8, 22); fdn(lfd, n_exceeds)
164 sys_write(lfd, " have=" as *u8, 6); fdn(lfd, n_have)
165 sys_write(lfd, " checks=" as *u8, 8); fdn(lfd, pass); sys_write(lfd, "/" as *u8, 1); fdn(lfd, tot)
166 sys_write(lfd, " liar-killed verdict=GREEN\n" as *u8, 26)
167 sys_close(lfd)
168 }
169 cp("FABRIC CENSUS GREEN -- 5/7 axes EXCEEDS (4 LIVE + sovereignty), E HAVE, G out-of-altitude; map matches reality\n" as *u8)
170 sys_exit(0)
171 }
172 sys_exit(1)
173 return 0
174}