code wiki / _hdl_build / nx_build_gov_census.nx
nx_build_gov_census.nx source
↩ module page · 78 lines · 5879 B
1import "nx_gate_base.nx"
2// nx_build_gov_census.nx -- R0 HONEST STARTING LINE for BACKEND-BUILD GOVERNANCE (the build-time
3// equivalent of the Nishi Publisher). Operator 2026-06-21: front-end publishing = the Publisher;
4// backend BUILDING should gain an equivalent owning role, split PM (control-plane) + Librarian
5// (catalog/SSOT). One row per governance RESPONSIBILITY, tagged by owning role (PM/LIB), graded
6// ABSENT/PARTIAL/PRESENT by whether a REAL sovereign organ does it TODAY -- and the grade is
7// MECHANICAL: a PRESENT/PARTIAL row must name a backing organ whose FILE EXISTS on disk
8// (sys_openat_rd), else it's INVALID (liar-kill). Plus a neg-control self-test (a fabricated PRESENT
9// with a bogus path MUST be caught). Mirrors nx_pub_census. Honest finding it encodes: the PARTS exist
10// scattered (registry/live-board/dedup/audit); the UNIFYING governance (no-bypass law + role
11// assignment + policy) is what we build next.
12// Sovereign: imports only nx_syscalls. license_tier: ORIGINAL expect_exit: 0
13import "nx_syscalls.nx"
14
15func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
16" as *u8); return ok }
17func pn(v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(1,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48 as u8;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 }
18
19func file_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
20
21func grade_str(g: i64) -> *u8 { if g==0 { return "ABSENT " as *u8 } if g==1 { return "PRESENT" as *u8 } return "PARTIAL" }
22
23// st[0]=absent st[1]=present st[2]=partial st[3]=invalid st[4]=total
24func row(name: *u8, owner: *u8, g: i64, backing: *u8, st: *i64) -> i64 {
25 st[4] = st[4] + 1
26 gw(" [" as *u8); gw(grade_str(g)); gw("] (" as *u8); gw(owner); gw(") " as *u8); gw(name)
27 if g == 0 {
28 st[0] = st[0] + 1
29 gw(" <= (none -- BUILD IT)\n" as *u8)
30 } else {
31 if g == 1 { st[1] = st[1] + 1 } else { st[2] = st[2] + 1 }
32 if file_exists(backing) == 1 {
33 gw(" <= " as *u8); gw(backing); gw("\n" as *u8)
34 } else {
35 gw(" !!INVALID: claims built but backing organ file is MISSING (liar-kill)\n" as *u8)
36 st[3] = st[3] + 1
37 }
38 }
39 return 0
40}
41
42func main() -> i64 {
43 let st: *i64 = sys_mmap(64) as *i64
44 st[0]=0; st[1]=0; st[2]=0; st[3]=0; st[4]=0
45 gw("=== BACKEND-BUILD GOVERNANCE -- R0 RESPONSIBILITY CENSUS (build-time twin of the Nishi Publisher) ===\n" as *u8)
46 gw("owner: PM=control-plane (submit/state/no-bypass/policy) ยท LIB=catalog/SSOT (registry/live-view/dedup)\n" as *u8)
47 gw("grade = does a REAL sovereign organ do this TODAY? PRESENT/PARTIAL must name an organ whose FILE EXISTS.\n\n" as *u8)
48
49 // NOTE: paths are full so the file-existence check is unambiguous regardless of cwd.
50 row("SUBMIT/REGISTER intake -- every backend organ registers itself\x00" as *u8, "PM \x00" as *u8, 2, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_nishi_builder.nx\x00" as *u8, st)
51 row("CATALOG / SSOT of what is built\x00" as *u8, "LIB" as *u8, 2, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_workstream_store.nx\x00" as *u8, st)
52 row("LIVE BUILD VIEW -- what is being built now\x00" as *u8, "LIB" as *u8, 1, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_ws_active_board.nx\x00" as *u8, st)
53 row("STATE tracking -- per-stream build state\x00" as *u8, "PM \x00" as *u8, 2, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_ws_board.nx\x00" as *u8, st)
54 row("OWNERSHIP record -- who owns each build\x00" as *u8, "PM \x00" as *u8, 2, "/mnt/c/Users/elder/.claude/projects/C--Users-elder/memory/worklog/coordination.tsv\x00" as *u8, st)
55 row("DEDUP / unregistered-detector -- organs with no record\x00" as *u8, "LIB" as *u8, 1, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_work_retro.nx\x00" as *u8, st)
56 row("AUDIT / liar-kill -- orphan/untracked/unregistered sweep\x00" as *u8, "PM \x00" as *u8, 1, "/mnt/c/Users/elder/nishi-core/nxc2/runtime/_hdl_build/nx_workstream_audit.nx\x00" as *u8, st)
57 row("NO-BYPASS LAW -- every build MUST register (enforced)\x00" as *u8, "PM \x00" as *u8, 0, "-\x00" as *u8, st)
58 row("ROLE ASSIGNMENT -- PM=control-plane + LIB=catalog, codified\x00" as *u8, "P+L" as *u8, 0, "-\x00" as *u8, st)
59 row("POLICY / cross-workstream coordination -- non-collision\x00" as *u8, "PM \x00" as *u8, 0, "-\x00" as *u8, st)
60
61 gw("\n TALLY: total=" as *u8); pn(st[4]); gw(" PRESENT=" as *u8); pn(st[1]); gw(" PARTIAL=" as *u8); pn(st[2]); gw(" ABSENT=" as *u8); pn(st[0]); gw(" invalid=" as *u8); pn(st[3]); gw("\n" as *u8)
62 let real_invalid: i64 = st[3]
63
64 gw("\n -- liar-kill self-test (a fabricated PRESENT whose organ file is missing MUST be caught) --\n" as *u8)
65 let st2: *i64 = sys_mmap(64) as *i64
66 st2[0]=0; st2[1]=0; st2[2]=0; st2[3]=0; st2[4]=0
67 row("FABRICATED present, bogus organ path\x00" as *u8, "neg" as *u8, 1, "/tmp/__nx_build_gov_does_not_exist__.nx\x00" as *u8, st2)
68 gw(" liar-kill fired=" as *u8); pn(st2[3]); gw(" (expect 1)\n" as *u8)
69
70 gw("\n NEXT (the unifying governance to build, mirroring the Publisher): R1 build-registrar submit() ->\n" as *u8)
71 gw(" dedup + record owner/state into the SSOT (LIB) ; R2 NO-BYPASS LAW + audit (PM) ; R3 role-split gate.\n" as *u8)
72
73 gw("\nBUILD-GOV-CENSUS verdict=" as *u8)
74 if real_invalid == 0 { if st2[3] == 1 { gw("GREEN (scorecard honest, every PRESENT/PARTIAL organ verified on disk, liar-kill armed)\n" as *u8); sys_exit(0); return 0 } }
75 gw("RED (a real row faked PRESENT, or the liar-kill is disarmed)\n" as *u8)
76 sys_exit(1)
77 return 1
78}