code wiki / _hdl_build / nx_build_gov_census.nx

nx_build_gov_census.nx source

↩ module page · 79 lines · 6024 B

1// nx_build_gov_census.nx -- Performs a build-time census of governance responsibilities, verifying file existence for claimed sovereign organs. 2import "nx_gate_base.nx" 3// nx_build_gov_census.nx -- R0 HONEST STARTING LINE for BACKEND-BUILD GOVERNANCE (the build-time 4// equivalent of the Nishi Publisher). Operator 2026-06-21: front-end publishing = the Publisher; 5// backend BUILDING should gain an equivalent owning role, split PM (control-plane) + Librarian 6// (catalog/SSOT). One row per governance RESPONSIBILITY, tagged by owning role (PM/LIB), graded 7// ABSENT/PARTIAL/PRESENT by whether a REAL sovereign organ does it TODAY -- and the grade is 8// MECHANICAL: a PRESENT/PARTIAL row must name a backing organ whose FILE EXISTS on disk 9// (sys_openat_rd), else it's INVALID (liar-kill). Plus a neg-control self-test (a fabricated PRESENT 10// with a bogus path MUST be caught). Mirrors nx_pub_census. Honest finding it encodes: the PARTS exist 11// scattered (registry/live-board/dedup/audit); the UNIFYING governance (no-bypass law + role 12// assignment + policy) is what we build next. 13// Sovereign: imports only nx_syscalls. license_tier: ORIGINAL expect_exit: 0 14import "nx_syscalls.nx" 15 16func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 17" as *u8); return ok } 18func 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 } 19 20func file_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 21 22func grade_str(g: i64) -> *u8 { if g==0 { return "ABSENT " as *u8 } if g==1 { return "PRESENT" as *u8 } return "PARTIAL" } 23 24// st[0]=absent st[1]=present st[2]=partial st[3]=invalid st[4]=total 25func row(name: *u8, owner: *u8, g: i64, backing: *u8, st: *i64) -> i64 { 26 st[4] = st[4] + 1 27 gw(" [" as *u8); gw(grade_str(g)); gw("] (" as *u8); gw(owner); gw(") " as *u8); gw(name) 28 if g == 0 { 29 st[0] = st[0] + 1 30 gw(" <= (none -- BUILD IT)\n" as *u8) 31 } else { 32 if g == 1 { st[1] = st[1] + 1 } else { st[2] = st[2] + 1 } 33 if file_exists(backing) == 1 { 34 gw(" <= " as *u8); gw(backing); gw("\n" as *u8) 35 } else { 36 gw(" !!INVALID: claims built but backing organ file is MISSING (liar-kill)\n" as *u8) 37 st[3] = st[3] + 1 38 } 39 } 40 return 0 41} 42 43func main() -> i64 { 44 let st: *i64 = sys_mmap(64) as *i64 45 st[0]=0; st[1]=0; st[2]=0; st[3]=0; st[4]=0 46 gw("=== BACKEND-BUILD GOVERNANCE -- R0 RESPONSIBILITY CENSUS (build-time twin of the Nishi Publisher) ===\n" as *u8) 47 gw("owner: PM=control-plane (submit/state/no-bypass/policy) ยท LIB=catalog/SSOT (registry/live-view/dedup)\n" as *u8) 48 gw("grade = does a REAL sovereign organ do this TODAY? PRESENT/PARTIAL must name an organ whose FILE EXISTS.\n\n" as *u8) 49 50 // NOTE: paths are full so the file-existence check is unambiguous regardless of cwd. 51 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) 52 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) 53 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) 54 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) 55 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) 56 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) 57 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) 58 row("NO-BYPASS LAW -- every build MUST register (enforced)\x00" as *u8, "PM \x00" as *u8, 0, "-\x00" as *u8, st) 59 row("ROLE ASSIGNMENT -- PM=control-plane + LIB=catalog, codified\x00" as *u8, "P+L" as *u8, 0, "-\x00" as *u8, st) 60 row("POLICY / cross-workstream coordination -- non-collision\x00" as *u8, "PM \x00" as *u8, 0, "-\x00" as *u8, st) 61 62 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) 63 let real_invalid: i64 = st[3] 64 65 gw("\n -- liar-kill self-test (a fabricated PRESENT whose organ file is missing MUST be caught) --\n" as *u8) 66 let st2: *i64 = sys_mmap(64) as *i64 67 st2[0]=0; st2[1]=0; st2[2]=0; st2[3]=0; st2[4]=0 68 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) 69 gw(" liar-kill fired=" as *u8); pn(st2[3]); gw(" (expect 1)\n" as *u8) 70 71 gw("\n NEXT (the unifying governance to build, mirroring the Publisher): R1 build-registrar submit() ->\n" as *u8) 72 gw(" dedup + record owner/state into the SSOT (LIB) ; R2 NO-BYPASS LAW + audit (PM) ; R3 role-split gate.\n" as *u8) 73 74 gw("\nBUILD-GOV-CENSUS verdict=" as *u8) 75 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 } } 76 gw("RED (a real row faked PRESENT, or the liar-kill is disarmed)\n" as *u8) 77 sys_exit(1) 78 return 1 79}