code wiki / _hdl_build / nx_cms_wp_register.nx
nx_cms_wp_register.nx source
↩ module page · 101 lines · 7347 B
1// nx_cms_wp_register.nx -- registers the EXCEED-WORDPRESS program rungs (2026-06-10): emit12
2// TEMPLATE_TABLE shape, the TEAM-authored _pe_blockr block renderer, the corrected multipart
3// parser, the C11 block-editor+uploads gate, and the WP scorecard instrument. ENGINEER evidence =
4// the durable gate log: row=nx_cms_blocks must be verdict=PASS (re-runnable gate appended it), the
5// multipart KAT + scorecard rebuild here, and the board re-routes. RACI: caps named per role verb.
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 cwr_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 { if buf[i + j] != pat[j] { ok = 0; j = plen } else { j = j + 1 } }
22 if ok == 1 { best = i }
23 i = i + 1
24 }
25 return best
26}
27func cwr_row_pass(buf: *u8, len: i64, rowpat: *u8) -> i64 {
28 let at: i64 = cwr_find_last(buf, len, rowpat)
29 if at < 0 { return 0 }
30 var e: i64 = at
31 var scanning: i64 = 1
32 while scanning == 1 {
33 if e >= len { scanning = 0 }
34 if scanning == 1 { if buf[e] == (10 as u8) { scanning = 0 } }
35 if scanning == 1 { e = e + 1 }
36 }
37 let sub: *u8 = ((buf as i64) + at) as *u8
38 if cwr_find_last(sub, e - at, "verdict=PASS" as *u8) >= 0 { return 1 }
39 return 0
40}
41func cwr_build_run(name: *u8) -> i64 {
42 let pid: i64 = sys_fork()
43 if pid == 0 {
44 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
45 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
46 let argv: *i64 = sys_mmap(32) as *i64
47 argv[0] = "_offc/nx_sov_build_run.elf" as *u8 as i64
48 argv[1] = name as i64
49 argv[2] = 0
50 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
51 sys_execve("_offc/nx_sov_build_run.elf" as *u8, argv, envp); sys_exit(127)
52 }
53 let st: *i64 = sys_mmap(16) as *i64
54 sys_wait4(pid, st, 0)
55 return st[0]
56}
57
58func main() -> i64 {
59 var allok: i64 = 1
60 if cwr_build_run("nx_cms_multipart_test" as *u8) != 0 { allok = 0 } // corrected parser KAT
61 if cwr_build_run("nx_cms_wp_scorecard" as *u8) != 0 { allok = 0 } // instrument runs (no FAILING bucket)
62 if cwr_build_run("nx_cms_arc_pipeline" as *u8) != 0 { allok = 0 } // board re-routes
63 let buf: *u8 = sys_mmap(K_MAGIC_262144)
64 let fd: i64 = sys_openat_rd("knowledge/status/cms_gate.log" as *u8)
65 var len: i64 = 0
66 if fd >= 0 {
67 var go: i64 = 1
68 while go == 1 {
69 let r: i64 = sys_read(fd, (buf + len) as *u8, K_MAGIC_262144 - len)
70 go = 0
71 if r > 0 { len = len + r; if len < K_MAGIC_262144 { go = 1 } }
72 }
73 sys_close(fd)
74 }
75 if cwr_row_pass(buf, len, "row=nx_cms_blocks " as *u8) != 1 { allok = 0 }
76 cr_w(1, "ENGINEER: multipart KAT + scorecard + board + blocks gate PASS -> pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8)
77 let eng: i64 = ig_engineer(1, 1, 1, allok)
78 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1)
79 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) }
80 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) }
81 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
82 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
83 let i1: i64 = cl_next_idx(lp, jp)
84 let o1: i64 = cl_register_dual(lp, jp, i1, 3, 2, "BLD CMS-TEMPLATE-TABLE-EMITTER (pattern shape 17, emit12) -- the Builder authors an HTML-fragment renderer CORE from a row table (kind, open, mid, close, raw): raw=0 slots ESCAPED via gated hs_escape (render-boundary law), raw=1 verbatim (sanitize-on-WRITE law), non-empty mid = two-slot src|alt shape, unknown kind -> -1 refused. Table is DATA (rule 11). Emits byte-exact KATs from the table + escape KAT + unknown-kind refusal. The CMS block-renderer / nav / OG-meta shape. Landmine filed + dodged: an empty-string \"\" literal aliases the NEXT literal's pointer on this lane -> single-slot rows pass mid=NULL(0) not \"\". Extends emit1-11")
85 let i2: i64 = cl_next_idx(lp, jp)
86 let o2: i64 = cl_register_dual(lp, jp, i2, 3, 2, "BLD CMS-BLOCK-RENDERER (_pe_blockr, TEAM-AUTHORED via emit12, zero Claude core) -- Gutenberg-class block vocabulary as a DATA table: 1=p(rich,sanitized) 2=h2 3=h3(escaped) 4=quote(rich) 5=img(two-slot src|alt, attr-escaped); adding a block kind = adding a table row. Engineer-verified emitted KATs green. Consumed by nx_cms_admin into {{blocks_html}} in document order")
87 let i3: i64 = cl_next_idx(lp, jp)
88 let o3: i64 = cl_register_dual(lp, jp, i3, 3, 2, "VER CMS-MULTIPART (nx_cms_multipart + KAT) -- CORRECT multipart/form-data part finder: the shipped runtime/nx_multipart.nx has a closing-delimiter/CRLF-alignment bug (its main() = compile-only smoke, never gated; returns -1 on a well-formed 2-part body, PROVEN by _cms_mp_probe). Per rule 3 this is a clean REWRITE not a patch: flat i64 output (4 cells/part, no struct-ptr-arith ambiguity), zero-copy offsets, correct closing-delimiter detection. KAT recovers 2 parts' names/filename/binary body byte-exact + rejects a no-closing body. Reusable beyond CMS")
89 let i4: i64 = cl_next_idx(lp, jp)
90 let o4: i64 = cl_register_dual(lp, jp, i4, 3, 2, "VER CMS-BLOCKS-GATE (C11 block editor + uploads, closes the CMS board 7/7) -- 11/11 row=nx_cms_blocks: blocks render through the TEAM renderer in document order, rich blocks sanitized ON WRITE, REAL multipart image upload stored ONLY when magic bytes MATCH the extension + size within the site's upload.conf cap (config DATA) + traversal-proof name, served back BYTE-IDENTICAL with the right Content-Type, refusals gated (magic-mismatch 400 nothing-stored, oversize 413, traversal 400, unauth 403), block ops session+CSRF guarded. The Gutenberg + media-library class, gate-proven")
91 let i5: i64 = cl_next_idx(lp, jp)
92 let o5: i64 = cl_register_dual(lp, jp, i5, 4, 2, "CON CMS-WP-SCORECARD (EXCEED-WORDPRESS instrument, program W) -- nx_cms_wp_scorecard derives each top-WP-plugin bucket's status MECHANICALLY from the durable gate log (matrix knowledge/cms/wp_matrix.txt = buckets as DATA; adding a bucket = editing the file): COVERED (latest evidence passes) / OPEN (honest backlog) / FAILING (regression). BASELINE buckets=14 covered=10 open=4 (seo/forms/backup/analytics) failing=0 permil=714 verdict=ON-LADDER. EXCEED-WP is MEASURED not asserted: permil climbs only by landing gated rungs. Warden board grown to 11 rungs permil=909 (W2 SEO/W3 forms/W5 analytics SCAFFOLD-READY, W4 snapshot NEEDS_TUTOR). Spec 2026-06-10-cms-exceed-wordpress-ladder.md")
93 if o1 != 1 { cr_w(1, "DW1\n" as *u8); sys_exit(1) }
94 if o2 != 1 { cr_w(1, "DW2\n" as *u8); sys_exit(1) }
95 if o3 != 1 { cr_w(1, "DW3\n" as *u8); sys_exit(1) }
96 if o4 != 1 { cr_w(1, "DW4\n" as *u8); sys_exit(1) }
97 if o5 != 1 { cr_w(1, "DW5\n" as *u8); sys_exit(1) }
98 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, i1); cr_w(1, ".." as *u8); cr_wn(1, i5); cr_w(1, " REGISTERED (EXCEED-WP: emit12 + _pe_blockr + multipart + C11 gate + scorecard)\n" as *u8)
99 sys_exit(0)
100 return 0
101}