code wiki / _hdl_build / nx_cms_arc_pipeline.nx

nx_cms_arc_pipeline.nx source

↩ module page · 164 lines · 9500 B

1// nx_cms_arc_pipeline.nx -- the WARDEN routes the CMS/WYSIWYG arc's rungs (pm_plan arc=CMS) through the 2// team's CLEAN RACI. Evidence-driven exactly like nx_browser_arc_pipeline: a rung's stage is DERIVED 3// from the Engineer's durable gate log (knowledge/status/cms_gate.log), never asserted. A rung whose 4// named gate row PASSES is ADMITTED; a FAILING row routes to the Doctor (HEAL-QUEUED); an ABSENT row 5// is a fresh assignment -- pattern-covered core = SCAFFOLD-READY (team authors hands-off), novel core = 6// NEEDS_TUTOR (the honest, MEASURED Claude dependency). The arc's autonomy permil is the fraction the 7// team can advance without Claude (ADMITTED + SCAFFOLD-READY + HEAL-QUEUED, since healing is the team's 8// Doctor too) -- driven UP only by adding pattern emitters or landing gates, never by hiding the gap. 9// Composes nx_build_pipeline (Warden) + nx_build_raci (RACI). LAWS: struct-free, integer-only, no shell. 10// license_tier: ORIGINAL 11import "nx_build_pipeline.nx" 12import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 13import "nx_syscalls.nx" 14const K_MAGIC_262144: i64 = 262144 15 16// last occurrence of NUL-terminated pat in buf[0..len); -1 if absent (append-only log = latest wins). 17func ca_find_last(buf: *u8, len: i64, pat: *u8) -> i64 { 18 var plen: i64 = 0 19 while pat[plen] != (0 as u8) { plen = plen + 1 } 20 if plen == 0 { return 0 - 1 } 21 var best: i64 = 0 - 1 22 var i: i64 = 0 23 while i + plen <= len { 24 var j: i64 = 0 25 var ok: i64 = 1 26 while j < plen { 27 if buf[i + j] != pat[j] { ok = 0; j = plen } 28 if ok == 1 { j = j + 1 } 29 } 30 if ok == 1 { best = i } 31 i = i + 1 32 } 33 return best 34} 35 36// status of the rung whose latest log line contains rowpat: 1=PASS 0=FAIL -1=ABSENT. The pass marker 37// (passpat) is per-rung because gates differ (the E2E gate emits permil=1000, the fuzz gate verdict=PASS). 38func ca_row_status(buf: *u8, len: i64, rowpat: *u8, passpat: *u8) -> i64 { 39 let at: i64 = ca_find_last(buf, len, rowpat) 40 if at < 0 { return 0 - 1 } 41 var e: i64 = at 42 var scanning: i64 = 1 43 while scanning == 1 { 44 if e >= len { scanning = 0 } 45 if scanning == 1 { if buf[e] == (10 as u8) { scanning = 0 } } 46 if scanning == 1 { e = e + 1 } 47 } 48 let sub: *u8 = ((buf as i64) + at) as *u8 49 if ca_find_last(sub, e - at, passpat) >= 0 { return 1 } 50 return 0 51} 52 53// route one rung from (pattern coverage, gate-row evidence). Mirrors ba_rung_stage. 54func ca_rung_stage(pattern_id: i64, row_status: i64) -> i64 { 55 let d0: i64 = br_decide(BR_BUILDER, BR_ENGINEER, BR_DOCTOR, 1, 1, 0, 2) 56 if d0 == BR_FLOW_RACI_BAD { return BP_RACI_BAD } 57 if row_status < 0 { 58 if bp_core_autonomous(pattern_id) == 0 { return BP_NEEDS_TUTOR } 59 return BP_SCAFFOLDED 60 } 61 let d: i64 = br_decide(BR_BUILDER, BR_ENGINEER, BR_DOCTOR, 1, row_status, 0, 2) 62 if d == BR_FLOW_ADMIT { return BP_ADMITTED } 63 if d == BR_FLOW_HEAL { return BP_HEALED } 64 return BP_REJECTED 65} 66 67func ca_stage_name(stage: i64) -> *u8 { 68 if stage == BP_ADMITTED { return "ADMITTED\x00" as *u8 } 69 if stage == BP_NEEDS_TUTOR { return "NEEDS_TUTOR\x00" as *u8 } 70 if stage == BP_SCAFFOLDED { return "SCAFFOLD-READY\x00" as *u8 } 71 if stage == BP_HEALED { return "HEAL-QUEUED\x00" as *u8 } 72 if stage == BP_REJECTED { return "REJECTED\x00" as *u8 } 73 return "RACI-BAD\x00" as *u8 74} 75 76// a rung counts toward team-autonomous progress if it does NOT require Claude: ADMITTED (done), 77// SCAFFOLD-READY (team authors it), HEAL-QUEUED (the team's Doctor heals it). NEEDS_TUTOR/REJECTED/ 78// RACI-BAD do not. This is the honest autonomy fraction. 79func ca_autonomous(stage: i64) -> i64 { 80 if stage == BP_ADMITTED { return 1 } 81 if stage == BP_SCAFFOLDED { return 1 } 82 if stage == BP_HEALED { return 1 } 83 return 0 84} 85 86func ca_fputs(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 87// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 88// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 89// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 90// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 91func ca_fputn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } 92 93func main() -> i64 { 94 // load the durable gate log 95 let buf: *u8 = sys_mmap(K_MAGIC_262144) 96 let fd: i64 = sys_openat_rd("knowledge/status/cms_gate.log" as *u8) 97 var len: i64 = 0 98 if fd >= 0 { 99 var go: i64 = 1 100 while go == 1 { 101 let r: i64 = sys_read(fd, (buf + len) as *u8, K_MAGIC_262144 - len) 102 go = 0 103 if r > 0 { len = len + r; if len < K_MAGIC_262144 { go = 1 } } 104 } 105 sys_close(fd) 106 } 107 108 // the CMS arc rung table: (id, label, row-pattern, pass-pattern, pattern_id-for-ABSENT) 109 // pattern_id>0 => covered core (SCAFFOLD-READY when no evidence yet); 0 => novel (NEEDS_TUTOR). 110 // C9core+C6b carry real gate rows; the rest are the open backlog (no evidence yet). 111 let ids: *u8 = sys_mmap(64) 112 // labels/patterns as parallel arrays of *u8 (i64 cells) 113 let labels: *i64 = sys_mmap(8*16) as *i64 114 let rowpats: *i64 = sys_mmap(8*16) as *i64 115 let passpats: *i64 = sys_mmap(8*16) as *i64 116 let patids: *i64 = sys_mmap(8*16) as *i64 117 var n: i64 = 0 118 labels[n] = "C9core content-model+editor E2E\x00" as *u8 as i64; rowpats[n] = "target=andelinwest \x00" as *u8 as i64; passpats[n] = "permil=1000\x00" as *u8 as i64; patids[n] = 7; n = n + 1 119 labels[n] = "C6b security fuzz (graceful degrade)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_fuzz \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 120 labels[n] = "C7 multi-site isolation\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_multisite \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 121 labels[n] = "C8 sites-daemon TLS integration\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_tls \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 0; n = n + 1 122 labels[n] = "C9 draft-preview mode\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_draft \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 123 labels[n] = "C10 argon2id pw (vault KDF v2 verify)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_argon \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 0; n = n + 1 124 labels[n] = "C11 block editor + uploads (Gutenberg-class)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_blocks \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 125 // ---- EXCEED-WORDPRESS rungs (program W; spec 2026-06-10-cms-exceed-wordpress-ladder.md). The 126 // WP plugin buckets the matrix prints OPEN until each gate lands. patid 7 = a covered emitter 127 // shape authors the core hands-off (SCAFFOLD-READY); 0 = genuine tutor dependency (the honest gap). 128 labels[n] = "W2 SEO head/meta + sitemap (vs Yoast)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_seo \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 129 labels[n] = "W3 forms + anti-spam (vs CF7/Akismet)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_forms \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 130 labels[n] = "W5 first-party analytics (vs Site Kit)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_analytics \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 131 labels[n] = "W4 snapshot/restore (vs UpdraftPlus)\x00" as *u8 as i64; rowpats[n] = "row=nx_cms_snapshot \x00" as *u8 as i64; passpats[n] = "verdict=PASS\x00" as *u8 as i64; patids[n] = 7; n = n + 1 132 133 let lf: i64 = sys_openat_wr("knowledge/status/cms_arc.log" as *u8, 0x1a4) 134 ca_fputs(1, "=== CMS/WYSIWYG ARC BOARD (Warden routes from gate evidence) ===\n" as *u8) 135 var auton: i64 = 0 136 var i: i64 = 0 137 while i < n { 138 let rs: i64 = ca_row_status(buf, len, rowpats[i] as *u8, passpats[i] as *u8) 139 let stage: i64 = ca_rung_stage(patids[i], rs) 140 auton = auton + ca_autonomous(stage) 141 // stdout + durable 142 ca_fputs(1, "CMSARC " as *u8); ca_fputs(1, labels[i] as *u8) 143 ca_fputs(1, " -> " as *u8); ca_fputs(1, ca_stage_name(stage)); ca_fputs(1, "\n" as *u8) 144 if lf >= 0 { 145 ca_fputs(lf, "CMSARC " as *u8); ca_fputs(lf, labels[i] as *u8) 146 ca_fputs(lf, " evidence=" as *u8); ca_fputn(lf, rs) 147 ca_fputs(lf, " stage=" as *u8); ca_fputs(lf, ca_stage_name(stage)); ca_fputs(lf, "\n" as *u8) 148 } 149 i = i + 1 150 } 151 let permil: i64 = auton * 1000 / n 152 ca_fputs(1, "ARC-AUTONOMY rungs=" as *u8); ca_fputn(1, n) 153 ca_fputs(1, " team-advanceable=" as *u8); ca_fputn(1, auton) 154 ca_fputs(1, " permil=" as *u8); ca_fputn(1, permil); ca_fputs(1, "\n" as *u8) 155 if lf >= 0 { 156 ca_fputs(lf, "ARC-AUTONOMY rungs=" as *u8); ca_fputn(lf, n) 157 ca_fputs(lf, " team-advanceable=" as *u8); ca_fputn(lf, auton) 158 ca_fputs(lf, " permil=" as *u8); ca_fputn(lf, permil) 159 ca_fputs(lf, " epoch=" as *u8); ca_fputn(lf, sys_now_realtime_sec()); ca_fputs(lf, "\n" as *u8) 160 sys_close(lf) 161 } 162 sys_exit(0) 163 return 0 164}