code wiki / _hdl_build / nx_cms_rungs_register.nx
nx_cms_rungs_register.nx source
↩ module page · 107 lines · 7070 B
1// nx_cms_rungs_register.nx -- registers the CMS arc's C7/C8/C9/C10 rungs (landed 2026-06-10) via
2// the Librarian's atomic allocator (cl_next_idx + dual-write). ENGINEER evidence here = the durable
3// gate log itself: the latest row for EACH rung must say verdict=PASS (the rows were appended by the
4// re-runnable gates minutes ago; absent/failing rows refuse registration), plus a fresh arc-board
5// re-route. RACI: caps named for their role's verb (BLD = Builder authored, VER = Engineer gate).
6// license_tier: ORIGINAL
7import "nx_cap_register.nx"
8import "nx_capreg_librarian.nx"
9import "nx_syscalls.nx"
10const K_MAGIC_262144: i64 = 262144
11
12func crr_find_last(buf: *u8, len: i64, pat: *u8) -> i64 {
13 var plen: i64 = 0
14 while pat[plen] != (0 as u8) { plen = plen + 1 }
15 if plen == 0 { return 0 - 1 }
16 var best: i64 = 0 - 1
17 var i: i64 = 0
18 while i + plen <= len {
19 var j: i64 = 0
20 var ok: i64 = 1
21 while j < plen {
22 if buf[i + j] != pat[j] { ok = 0; j = plen }
23 if ok == 1 { j = j + 1 }
24 }
25 if ok == 1 { best = i }
26 i = i + 1
27 }
28 return best
29}
30
31// latest line containing rowpat must also contain "verdict=PASS"
32func crr_row_pass(buf: *u8, len: i64, rowpat: *u8) -> i64 {
33 let at: i64 = crr_find_last(buf, len, rowpat)
34 if at < 0 { return 0 }
35 var e: i64 = at
36 var scanning: i64 = 1
37 while scanning == 1 {
38 if e >= len { scanning = 0 }
39 if scanning == 1 { if buf[e] == (10 as u8) { scanning = 0 } }
40 if scanning == 1 { e = e + 1 }
41 }
42 let sub: *u8 = ((buf as i64) + at) as *u8
43 if crr_find_last(sub, e - at, "verdict=PASS" as *u8) >= 0 { return 1 }
44 return 0
45}
46
47func crr_build_run(name: *u8) -> i64 {
48 let pid: i64 = sys_fork()
49 if pid == 0 {
50 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
51 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
52 let argv: *i64 = sys_mmap(32) as *i64
53 argv[0] = "_offc/nx_sov_build_run.elf" as *u8 as i64
54 argv[1] = name as i64
55 argv[2] = 0
56 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
57 sys_execve("_offc/nx_sov_build_run.elf" as *u8, argv, envp); sys_exit(127)
58 }
59 let st: *i64 = sys_mmap(16) as *i64
60 sys_wait4(pid, st, 0)
61 return st[0]
62}
63
64func main() -> i64 {
65 // evidence 1: fresh Warden board re-route (derives stages from the durable log)
66 var allok: i64 = 1
67 if crr_build_run("nx_cms_arc_pipeline" as *u8) != 0 { allok = 0 }
68 // evidence 2: every landed rung's LATEST gate row is PASS
69 let buf: *u8 = sys_mmap(K_MAGIC_262144)
70 let fd: i64 = sys_openat_rd("knowledge/status/cms_gate.log" as *u8)
71 var len: i64 = 0
72 if fd >= 0 {
73 var go: i64 = 1
74 while go == 1 {
75 let r: i64 = sys_read(fd, (buf + len) as *u8, K_MAGIC_262144 - len)
76 go = 0
77 if r > 0 { len = len + r; if len < K_MAGIC_262144 { go = 1 } }
78 }
79 sys_close(fd)
80 }
81 if crr_row_pass(buf, len, "row=nx_cms_draft " as *u8) != 1 { allok = 0 }
82 if crr_row_pass(buf, len, "row=nx_cms_argon " as *u8) != 1 { allok = 0 }
83 if crr_row_pass(buf, len, "row=nx_cms_multisite " as *u8) != 1 { allok = 0 }
84 if crr_row_pass(buf, len, "row=nx_cms_tls " as *u8) != 1 { allok = 0 }
85 cr_w(1, "ENGINEER: board re-routed + 4 rung rows verdict=PASS in durable log -> pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8)
86 let eng: i64 = ig_engineer(1, 1, 1, allok)
87 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1)
88 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) }
89 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) }
90 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
91 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
92 let i1: i64 = cl_next_idx(lp, jp)
93 let o1: i64 = cl_register_dual(lp, jp, i1, 3, 2, "BLD CMS-DRAFT-PREVIEW (C9, team/scaffold lane) -- the STATE_FLOW emitter AUTHORED _pe_draft (CLEAN/DRAFTED x SAVE_DRAFT/PUBLISH_DRAFT/DISCARD; absent transitions refused -1; emitted KATs green) with ZERO Claude core logic, exactly the _pe_pub division of labor; admin grew mode=draft save, /admin/preview (session-only render, no-store+noindex), /admin/publish + /admin/discard (team guard -> 409 from CLEAN at the wire), draft survives restarts, consumed drafts set aside additively (draft.last). GATE 10/10 row=nx_cms_draft: draft never touches the public page, preview sanitized + auth-only, promote atomic, discard leaves publish intact" as *u8)
94 let i2: i64 = cl_next_idx(lp, jp)
95 let o2: i64 = cl_register_dual(lp, jp, i2, 3, 2, "VER CMS-ARGON2ID-CREDENTIAL (C10, unblocked by vault KDF v2: the 2026-06-10 CRYPTO-DEFECT was the lane cc >6-arg tail-call drop, killed+blessed) -- nx_cms_pw: self-describing admin_pw.ar2 (ar2 m t salt tag; params are DATA in the file, prod = measured m=32768 t=3, gates say m=8192) + ONE reusable ctx arena per daemon + nx_cms_setpw2 (urandom salt). Admin verifies memory-hard FIRST; legacy sha256 file = migration fallback that can NEVER bypass when .ar2 exists. GATE 6/6 row=nx_cms_argon incl. the downgrade-bait row (valid legacy pw refused 403) + lockout on the argon path. Retires the CMS weak-credential debt" as *u8)
96 let i3: i64 = cl_next_idx(lp, jp)
97 let o3: i64 = cl_register_dual(lp, jp, i3, 3, 2, "VER CMS-MULTISITE-ISOLATION (C7) -- deployment model = one admin daemon per site (rule 9; the front door routes by host); gate boots TWO real admins on two sitedirs w/ distinct credentials and proves at the wire: distinct seeds, A's session WORTHLESS at B, A's password refused by B, A's edit never perturbs B's published bytes, cross-site save A->B refused 403 with B intact. GATE 7/7 row=nx_cms_multisite" as *u8)
98 let i4: i64 = cl_next_idx(lp, jp)
99 let o4: i64 = cl_register_dual(lp, jp, i4, 3, 2, "VER CMS-TLS-FRONT (C8, the sites-daemon integration shape) -- nx_cms_tls_front: TLS1.3-terminating reverse proxy (Ed25519 CV = the andelinwest/wiki daemon path, record-framed recv, chunked app_send) to the loopback admin; admin cookie gains Secure behind the front (argv tls flag, rule 17). GATE 5/5 row=nx_cms_tls: gate self-generates a sovereign self-signed Ed25519 cert (nx_x509_build) as the client's ONLY trust anchor, OUR client full-validation handshake + login/edit/publish round trips encrypted, NEGATIVE CONTROL empty-trust-store handshake REFUSED = validation proven real. Single-record request reassembly contract NAMED (C11 uploads follow-on)" as *u8)
100 if o1 != 1 { cr_w(1, "DUAL-WRITE-1 FAILED\n" as *u8); sys_exit(1) }
101 if o2 != 1 { cr_w(1, "DUAL-WRITE-2 FAILED\n" as *u8); sys_exit(1) }
102 if o3 != 1 { cr_w(1, "DUAL-WRITE-3 FAILED\n" as *u8); sys_exit(1) }
103 if o4 != 1 { cr_w(1, "DUAL-WRITE-4 FAILED\n" as *u8); sys_exit(1) }
104 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, i1); cr_w(1, "," as *u8); cr_wn(1, i2); cr_w(1, "," as *u8); cr_wn(1, i3); cr_w(1, "," as *u8); cr_wn(1, i4); cr_w(1, " REGISTERED (CMS C9/C10/C7/C8 rungs)\n" as *u8)
105 sys_exit(0)
106 return 0
107}