code wiki / _hdl_build / nx_orch_dashboard.nx

nx_orch_dashboard.nx source

↩ module page · 136 lines · 10823 B

1// nx_orch_dashboard.nx -- LIVE orchestration visualization for /wiki. Renders the Nishi team-coordination 2// state into a self-contained HTML page (inline CSS, ZERO 3rd-party JS = the wiki sovereignty invariant): 3// 1. the RACI matrix (activity -> Accountable[bold] / Responsible / Consulted / Informed) from the registry, 4// 2. per-role intake QUEUE status (PENDING / APPLIED / CONFLICT / AMBIGUOUS counts) from knowledge/roles/*, 5// 3. the recent PM routings (activity -> accountable role -> disposition) from pm_coord.tsv. 6// Published to /wiki via the Publisher (dogfoods the coordination spine). Re-render on a cadence = "live". 7// 8// in: knowledge/registry/nishi_raci.tsv (RACI registry, unchanged) ยท the role queue + PM-routing data now read 9// from the SOVEREIGN seg-store knowledge/store/roles-* (channels <role>q / pmcoord) -- NO roles/*.tsv. 10// out: knowledge/status/orch_dashboard.html (argv[1] overrides) 11// license_tier: ORIGINAL 12import "nx_syscalls.nx" 13import "nx_role_store.nx" // rs_count / rs_get_seq / rs_field / rs_chan -- role queues + PM routings from the seg-store 14import "nx_raci_sov.nx" // raci_read_all -- the RACI matrix now read from the SOVEREIGN seg-store (NO TSV) 15const OD_MAGIC_2026: i64 = 2026 16const OD_MAGIC_524288: i64 = 524288 17 18// OD_RACI retired 2026-07-16: the RACI matrix reads from the sovereign store via raci_read_all (nx_raci_sov) 19const OD_COORD: *u8 = "knowledge/roles/pm_coord.tsv" // RETIRED file (kept for provenance); routings now read from the pmcoord channel 20const OD_OUT: *u8 = "knowledge/status/orch_dashboard.html" 21const OD_CAP: i64 = 262144 22const OD_MAXROWS: i64 = 512 23const OD_STR: i64 = 48 24 25func od_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 26func od_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 27func od_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } 28func od_has(s: *u8, ch: i64) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ if (s[i] as i64)==ch{return 1} i=i+1 } return 0 } 29func od_read(path: *u8, buf: *u8, cap: i64) -> i64 { 30 let fd: i64=sys_openat_rd(path); if fd<0 {return 0-1} 31 var off: i64=0; var go: i64=1 32 while go==1 { if off>=cap {go=0} else { let r: i64=sys_read(fd, buf+off, cap-off); if r<=0 {go=0} else {off=off+r} } } 33 sys_close(fd); return off 34} 35func od_field(line: *u8, len: i64, idx: i64, out: *u8, outcap: i64) -> i64 { 36 var f: i64=0; var i: i64=0; var w: i64=0 37 while i<len { let c: i64=line[i] as i64; if c==9 { if f==idx {out[w]=0 as u8; return 1} f=f+1 } else { if f==idx { if w<outcap-1 {out[w]=line[i];w=w+1} } } i=i+1 } 38 if f==idx {out[w]=0 as u8; return 1} return 0 39} 40func od_cpy(dst: *u8, src: *u8, max: i64) -> i64 { var i: i64=0; while src[i]!=(0 as u8){ if i<max-1{dst[i]=src[i]} i=i+1 } dst[i]=0 as u8; return 0 } 41func od_bs(buf: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){buf[o]=s[i];o=o+1;i=i+1} return o } 42func od_bn(buf: *u8, off: i64, v: i64) -> i64 { var o: i64=off; var m: i64=v; if m<0{buf[o]=45 as u8;o=o+1;m=0-m} let t: *u8=sys_mmap(24); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m-(m/10)*10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{buf[o+i]=t[k-1-i];i=i+1} return o+k } 43// append the comma-separated roles for (activity, letter) into hb; returns new off + count via cnt[0]. 44func od_roles(roleS: *u8, actS: *u8, letS: *u8, nrows: i64, act: *u8, ch: i64, hb: *u8, off: i64, cnt: *i64) -> i64 { 45 var o: i64=off; var c: i64=0; var i: i64=0 46 while i<nrows { if od_streq(actS+i*OD_STR, act)==1 { if od_has(letS+i*OD_STR, ch)==1 { if c>0 {o=od_bs(hb,o," " as *u8)} o=od_bs(hb,o,roleS+i*OD_STR); c=c+1 } } i=i+1 } 47 if c==0 { o=od_bs(hb,o,"-" as *u8) } 48 cnt[0]=c; return o 49} 50// count rows of seg-store CHANNEL ch whose field0 == status (replaces the raw-.tsv line count) 51func od_count(ch: *u8, status: *u8) -> i64 { 52 let n: i64=rs_count(ch); let pq: *i64=sys_mmap(16) as *i64; let lq: *i64=sys_mmap(16) as *i64 53 let st: *u8=sys_mmap(64); var c: i64=0; var seq: i64=0 54 while seq<n { 55 if rs_get_seq(ch, seq, pq, lq)==1 { rs_field(pq[0] as *u8, lq[0], 0, st); if od_streq(st,status)==1 {c=c+1} } 56 seq=seq+1 57 } 58 return c 59} 60// render one role's queue card into hb at off (queue counts read from the '<role>q' seg-store channel) 61func od_role_card(role: *u8, hb: *u8, off: i64) -> i64 { 62 let q: *u8=sys_mmap(96); rs_chan(role, 113, q) // '<role>q' 63 let pend: i64=od_count(q,"PENDING" as *u8); let app: i64=od_count(q,"APPLIED" as *u8); let conf: i64=od_count(q,"CONFLICT" as *u8); let amb: i64=od_count(q,"AMBIGUOUS" as *u8) 64 var col: *u8="#1a7f37" as *u8; if pend>0 {col="#bf8700" as *u8} if conf>0 {col="#cf222e" as *u8} 65 var o: i64=off 66 o=od_bs(hb,o,"<div class=card style='border-left-color:" as *u8); o=od_bs(hb,o,col); o=od_bs(hb,o,"'><div class=nm>" as *u8); o=od_bs(hb,o,role); o=od_bs(hb,o,"</div><div class=mut>queue</div>" as *u8) 67 o=od_bs(hb,o,"<div class=lat>" as *u8); o=od_bn(hb,o,pend); o=od_bs(hb,o,"<span class=mut> pending</span></div>" as *u8) 68 o=od_bs(hb,o,"<div class=mut>applied " as *u8); o=od_bn(hb,o,app); o=od_bs(hb,o," &middot; conflict " as *u8); o=od_bn(hb,o,conf); o=od_bs(hb,o," &middot; ambig " as *u8); o=od_bn(hb,o,amb); o=od_bs(hb,o,"</div></div>" as *u8) 69 return o 70} 71 72func main(argc: i64, argv: *i64) -> i64 { 73 var outp: *u8 = OD_OUT; if argc>=2 { outp = argv[1] as *u8 } 74 // parse the RACI registry 75 let rbuf: *u8=sys_mmap(OD_CAP); let rn: i64=raci_read_all(rbuf, OD_CAP) // was od_read(OD_RACI,..) -- store-flip OD_MAGIC_2026-07-16 76 let roleS: *u8=sys_mmap(OD_MAXROWS*OD_STR); let actS: *u8=sys_mmap(OD_MAXROWS*OD_STR); let letS: *u8=sys_mmap(OD_MAXROWS*OD_STR) 77 let f: *u8=sys_mmap(OD_STR); var nrows: i64=0; var ls: i64=0; var i: i64=0 78 while i<=rn { var nl: i64=0; if i>=rn{nl=1} else { if rbuf[i]==(10 as u8){nl=1} } 79 if nl==1 { let ll: i64=i-ls; if ll>0 { let line: *u8=((rbuf as i64)+ls) as *u8; if line[0]!=(35 as u8) { 80 if od_field(line,ll,0,f,OD_STR)==1 { if f[0]!=(0 as u8) { if nrows<OD_MAXROWS { od_cpy(roleS+nrows*OD_STR,f,OD_STR); od_field(line,ll,1,actS+nrows*OD_STR,OD_STR); od_field(line,ll,2,letS+nrows*OD_STR,OD_STR); nrows=nrows+1 } } } } } 81 ls=i+1 } 82 i=i+1 } 83 // distinct activities (first-seen order) 84 let dact: *u8=sys_mmap(64*OD_STR); var ndact: i64=0; var r: i64=0 85 while r<nrows { let a: *u8=actS+r*OD_STR; var seen: i64=0; var d: i64=0; while d<ndact { if od_streq(dact+d*OD_STR,a)==1 {seen=1} d=d+1 } if seen==0 { if ndact<64 { od_cpy(dact+ndact*OD_STR,a,OD_STR); ndact=ndact+1 } } r=r+1 } 86 87 let hb: *u8=sys_mmap(OD_MAGIC_524288); var o: i64=0 88 o=od_bs(hb,o,"<!doctype html><html><head><meta charset=utf-8><meta name=viewport content='width=device-width,initial-scale=1'><title>Nishi Orchestration</title><style>" as *u8) 89 o=od_bs(hb,o,"body{background:#0d1117;color:#e6edf3;font:14px system-ui,sans-serif;margin:0;padding:24px}h1{font-size:20px;margin:0 0 4px}h2{font-size:15px;margin:22px 0 8px}.sub{color:#8b949e;font-size:12px;margin-bottom:14px}" as *u8) 90 o=od_bs(hb,o,"table{border-collapse:collapse;width:100%;font-size:13px}th,td{border:1px solid #30363d;padding:5px 9px;text-align:left}th{background:#161b22}.acc{color:#1a7f37;font-weight:700}.mutc{color:#8b949e}" as *u8) 91 o=od_bs(hb,o,".grid{display:flex;flex-wrap:wrap;gap:12px}.card{background:#161b22;border:1px solid #30363d;border-left-width:5px;border-radius:8px;padding:12px 14px;min-width:150px}.nm{font-weight:600;font-size:15px}.lat{font-size:22px;margin:6px 0 2px}.mut{color:#8b949e;font-size:12px}ul{font-size:13px;line-height:1.6}</style></head><body>" as *u8) 92 o=od_bs(hb,o,"<h1>Nishi Orchestration &mdash; live</h1><div class=sub>The team coordination spine: every activity has ONE Accountable role (RACI), work routes to that role's serialized intake (no competition), all auditable.</div>" as *u8) 93 94 // SECTION 1: RACI matrix 95 o=od_bs(hb,o,"<h2>RACI &mdash; who owns what (" as *u8); o=od_bn(hb,o,ndact); o=od_bs(hb,o," activities)</h2><table><tr><th>Activity</th><th>Accountable</th><th>Responsible</th><th>Consulted</th><th>Informed</th></tr>" as *u8) 96 var k: i64=0; let cnt: *i64=sys_mmap(8) as *i64 97 while k<ndact { let a: *u8=dact+k*OD_STR 98 o=od_bs(hb,o,"<tr><td>" as *u8); o=od_bs(hb,o,a); o=od_bs(hb,o,"</td><td class=acc>" as *u8); o=od_roles(roleS,actS,letS,nrows,a,65,hb,o,cnt) 99 o=od_bs(hb,o,"</td><td>" as *u8); o=od_roles(roleS,actS,letS,nrows,a,82,hb,o,cnt) 100 o=od_bs(hb,o,"</td><td class=mutc>" as *u8); o=od_roles(roleS,actS,letS,nrows,a,67,hb,o,cnt) 101 o=od_bs(hb,o,"</td><td class=mutc>" as *u8); o=od_roles(roleS,actS,letS,nrows,a,73,hb,o,cnt) 102 o=od_bs(hb,o,"</td></tr>" as *u8); k=k+1 } 103 o=od_bs(hb,o,"</table>" as *u8) 104 105 // SECTION 2: role intake queues 106 o=od_bs(hb,o,"<h2>Role intake queues</h2><div class=grid>" as *u8) 107 o=od_role_card("doctor" as *u8, hb, o) 108 o=od_role_card("engineer" as *u8, hb, o) 109 o=od_bs(hb,o,"</div>" as *u8) 110 111 // SECTION 3: recent PM routings (last <=12 rows of the pmcoord seg-store channel) 112 o=od_bs(hb,o,"<h2>Recent PM routings</h2>" as *u8) 113 let cn: i64 = rs_count("pmcoord" as *u8) 114 if cn<=0 { o=od_bs(hb,o,"<div class=mut>(no routings yet)</div>" as *u8) } 115 else { 116 o=od_bs(hb,o,"<ul>" as *u8) 117 let ac: *u8=sys_mmap(64); let ro: *u8=sys_mmap(64); let rq: *u8=sys_mmap(64); let di: *u8=sys_mmap(128) 118 let pq: *i64=sys_mmap(16) as *i64; let lq: *i64=sys_mmap(16) as *i64 119 var s0: i64=0; if cn>12 { s0=cn-12 } 120 var li: i64=s0 121 while li<cn { 122 if rs_get_seq("pmcoord" as *u8, li, pq, lq)==1 { 123 let line: *u8=pq[0] as *u8; let llen: i64=lq[0] 124 od_field(line,llen,1,ac,64); od_field(line,llen,2,ro,64); od_field(line,llen,3,rq,64); od_field(line,llen,4,di,128) 125 o=od_bs(hb,o,"<li><b>" as *u8); o=od_bs(hb,o,ac); o=od_bs(hb,o,"</b> &rarr; <span class=acc>" as *u8); o=od_bs(hb,o,ro); o=od_bs(hb,o,"</span> <span class=mut>(" as *u8); o=od_bs(hb,o,rq); o=od_bs(hb,o,": " as *u8); o=od_bs(hb,o,di); o=od_bs(hb,o,")</span></li>" as *u8) 126 } 127 li=li+1 } 128 o=od_bs(hb,o,"</ul>" as *u8) 129 } 130 o=od_bs(hb,o,"</body></html>" as *u8) 131 132 let fd: i64=sys_openat_wr(outp, 0x1a4); if fd<0 { od_w("orch_dashboard: cannot write " as *u8); od_w(outp); od_w("\n" as *u8); return 1 } 133 sys_write(fd, hb, o); sys_close(fd) 134 od_w("orch_dashboard: wrote " as *u8); od_w(outp); od_w(" (" as *u8); let b: *u8=sys_mmap(16); let e: i64=od_bn(b,0,ndact); sys_write(1,b,e); od_w(" activities)\n" as *u8) 135 return 0 136}