code wiki / _hdl_build / nx_pipeline_census.nx
nx_pipeline_census.nx source
↩ module page · 121 lines · 6182 B
1// nx_pipeline_census.nx -- R0 CENSUS of the autonomy pipeline (discover -> research -> spec ->
2// build), the census-first rung the operator's "all s-class exceed" vision needs. MECHANICAL +
3// FILE-GROUNDED (the genealogy "don't-lie audit" rule: classify from real on-disk existence via
4// stat, NEVER from memory/assumption). For each representative stage capability it checks whether
5// the organ source exists (PRESENT) and whether a <name>_gate exists (GATED), then LIAR-KILLS the
6// census with a fabricated capability that MUST come back ABSENT -- a census that reports the fake
7// as present is itself lying and goes RED. Separately probes the WIRING driver (nx_pipeline_run):
8// its absence is the measured GAP -- the stages exist but nothing CHAINS them (= the R1 build).
9// Sovereign: imports only nx_framed_append + nx_syscalls. license_tier: ORIGINAL
10import "nx_framed_append.nx"
11import "nx_syscalls.nx"
12
13const PC_LOG: *u8 = "knowledge/status/pipeline_census.log"
14
15func cp_(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
16func cn_(v: i64) -> i64 {
17 let bb: *u8 = sys_mmap(28); var m: i64 = v
18 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
19 let t: *u8 = sys_mmap(28); var k: i64 = 0
20 if m == 0 { t[0] = 48 as u8; k = 1 }
21 while m > 0 { t[k] = ((48 + (m % 10)) as u8); m = m / 10; k = k + 1 }
22 var i: i64 = 0; while i < k { bb[i] = t[k - 1 - i]; i = i + 1 }
23 sys_write(1, bb, k); return 0
24}
25
26// 1 iff dir+name+suffix exists on disk (stat==0).
27func pc_stat1(dir: *u8, name: *u8, suffix: *u8) -> i64 {
28 let p: *u8 = sys_mmap(512)
29 let stbuf: *u8 = sys_mmap(256)
30 var o: i64 = fa_cat(p, 0, dir)
31 o = fa_cat(p, o, name)
32 o = fa_cat(p, o, suffix)
33 p[o] = 0 as u8
34 if sys_fstatat(p, stbuf) == 0 { return 1 }
35 return 0
36}
37
38// 1 iff <name>.nx exists in runtime/_hdl_build/ or runtime/.
39func pc_src_exists(name: *u8) -> i64 {
40 if pc_stat1("runtime/_hdl_build/" as *u8, name, ".nx" as *u8) == 1 { return 1 }
41 if pc_stat1("runtime/" as *u8, name, ".nx" as *u8) == 1 { return 1 }
42 return 0
43}
44
45// 1 iff <name>_gate.nx exists in either dir (the capability is gated).
46func pc_gate_exists(name: *u8) -> i64 {
47 if pc_stat1("runtime/_hdl_build/" as *u8, name, "_gate.nx" as *u8) == 1 { return 1 }
48 if pc_stat1("runtime/" as *u8, name, "_gate.nx" as *u8) == 1 { return 1 }
49 return 0
50}
51
52// classify ONE capability; tally into t[0]=absent t[1]=present t[2]=gated. returns class.
53func pc_check(name: *u8, stage: *u8, t: *i64) -> i64 {
54 let src: i64 = pc_src_exists(name)
55 let gate: i64 = pc_gate_exists(name)
56 var cls: i64 = 0
57 if src == 1 { cls = 1 }
58 if src == 1 { if gate == 1 { cls = 2 } }
59 cp_(" stage=" as *u8); cp_(stage); cp_(" cap=" as *u8); cp_(name)
60 cp_(" src=" as *u8); cn_(src); cp_(" gate=" as *u8); cn_(gate); cp_(" -> " as *u8)
61 if cls == 0 { cp_("ABSENT\n" as *u8) }
62 if cls == 1 { cp_("PRESENT\n" as *u8) }
63 if cls == 2 { cp_("GATED\n" as *u8) }
64 t[cls] = t[cls] + 1
65 return cls
66}
67
68func main(argc: i64, argv: *i64) -> i64 {
69 let t: *i64 = sys_mmap(64) as *i64
70 cp_("=== PIPELINE R0 CENSUS (discover -> research -> spec -> build) ===\n" as *u8)
71
72 pc_check("nx_cap_gap_sov" as *u8, "1-DISCOVER" as *u8, t)
73 pc_check("nx_work_predict" as *u8, "1-DISCOVER" as *u8, t)
74 pc_check("nx_ws_ingest" as *u8, "1-DISCOVER" as *u8, t)
75 pc_check("nx_ws_discover_gate" as *u8, "1-DISCOVER" as *u8, t)
76 pc_check("nx_research_fetch" as *u8, "2-RESEARCH" as *u8, t)
77 pc_check("nx_research_signal" as *u8, "2-RESEARCH" as *u8, t)
78 pc_check("nx_research_journal" as *u8, "2-RESEARCH" as *u8, t)
79 pc_check("nx_research_corroborate" as *u8, "2-RESEARCH" as *u8, t)
80 pc_check("nx_research_digest" as *u8, "2-RESEARCH" as *u8, t)
81 pc_check("nx_pattern_emit16" as *u8, "3-SPEC" as *u8, t)
82 pc_check("nx_nishi_builder" as *u8, "3-SPEC" as *u8, t)
83 pc_check("nx_researcher_spec" as *u8, "3-SPEC" as *u8, t)
84 pc_check("nx_auto_builder" as *u8, "4-BUILD" as *u8, t)
85 pc_check("nx_warden_build" as *u8, "4-BUILD" as *u8, t)
86 pc_check("nx_capability_audit" as *u8, "4-BUILD" as *u8, t)
87 pc_check("nx_emitter_transduce" as *u8, "4-BUILD" as *u8, t)
88
89 // LIAR-KILL: a fabricated capability MUST classify ABSENT (a present->fake census is lying).
90 let negcls: i64 = pc_check("nx_FAKE_pipeline_capability_zzz" as *u8, "NEG-CONTROL" as *u8, t)
91
92 let real_total: i64 = 16
93 // WIRING probe (reported, NOT in the presence tally): the single chaining driver.
94 let wire: i64 = pc_src_exists("nx_pipeline_run" as *u8)
95 cp_(" WIRING cap=nx_pipeline_run src=" as *u8); cn_(wire)
96 if wire == 0 { cp_(" -> CHAIN ABSENT: stages exist but nothing wires them = the R1 build\n" as *u8) }
97 if wire == 1 { cp_(" -> chain present\n" as *u8) }
98
99 cp_("SUMMARY real=" as *u8); cn_(real_total)
100 cp_(" absent=" as *u8); cn_(t[0]); cp_(" present=" as *u8); cn_(t[1]); cp_(" gated=" as *u8); cn_(t[2])
101 cp_(" neg_absent=" as *u8); cn_(negcls)
102
103 // GREEN = census integrity: the liar-kill holds (fake ABSENT) AND every real stage organ is
104 // present (so the ONLY absent is the neg-control). NOT a claim the pipeline is wired.
105 var green: i64 = 0
106 if negcls == 0 { if t[0] == 1 { green = 1 } }
107
108 let buf: *u8 = sys_mmap(512)
109 var o: i64 = 0
110 o = fa_cat(buf, o, "PIPELINE-R0-CENSUS ts=\x00" as *u8); o = fa_catn(buf, o, sys_now_realtime_sec())
111 o = fa_cat(buf, o, " real=\x00" as *u8); o = fa_catn(buf, o, real_total)
112 o = fa_cat(buf, o, " absent=\x00" as *u8); o = fa_catn(buf, o, t[0])
113 o = fa_cat(buf, o, " present=\x00" as *u8); o = fa_catn(buf, o, t[1])
114 o = fa_cat(buf, o, " gated=\x00" as *u8); o = fa_catn(buf, o, t[2])
115 o = fa_cat(buf, o, " wired=\x00" as *u8); o = fa_catn(buf, o, wire)
116 if green == 1 { o = fa_cat(buf, o, " verdict=GREEN\x00" as *u8) } else { o = fa_cat(buf, o, " verdict=RED\x00" as *u8) }
117 fa_appendz(PC_LOG, buf, 512)
118
119 if green == 1 { cp_(" verdict=GREEN\n" as *u8); sys_exit(0); return 0 }
120 cp_(" verdict=RED\n" as *u8); sys_exit(1); return 1
121}