code wiki / _hdl_build / nx_sponsor_page.nx

nx_sponsor_page.nx source

↩ module page · 172 lines · 7856 B

1// nx_sponsor_page.nx -- the EXECUTIVE SPONSOR'S COCKPIT page (X-I3 rung 1; 2// operator: "interact on something like nishifamily.com/sponsor behind 3// authentication so i can start flagging the novel"). Renders the 4// ACTIONABLE sponsor view from the queue, console-pattern (sovereign 5// NishiLang->HTML, every line derived from the durable queue, atomic write, 6// hot-servable): 7// VIEW queue -- deliverables awaiting a viewpoint, each with the four 8// paste-ready decision lines (APPROVE/REWORK/RESTART/DENY) 9// CO-SPEC batch-- NOVEL rows tagged ||ASK=spec (needs sponsor+tutor) 10// RAISED HANDS -- every NOVEL row with its DENY line (flag no-ROI novel 11// BEFORE tutor time burns; DENY-on-NOVEL is gate-proven) 12// SECURITY HONESTY: this rung renders evidence + paste-ready lines; the 13// authed GET route + POST /sponsor/decide handler are X-I3-002/003 (filed, 14// exact contract in the rows) -- decisions move ONLY via the repo decision 15// file until those land, and the page says so. 16// argv[1]=output path override, argv[2]=queue override (gates use scratch). 17// license_tier: ORIGINAL 18 19import "nx_syscalls.nx" 20import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 21import "nx_assign_core.nx" 22 23func sp_w(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 } 24// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 25// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 26// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 27// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 28func sp_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } 29 30// does the row's gate cell carry pat? 31func sp_gate_has(cx: *i64, r: i64, pat: *u8) -> i64 { 32 let g: *u8 = an_gate_at(cx, r) 33 var gl: i64 = 0 34 while g[gl] != (0 as u8) { gl = gl + 1 } 35 var pl: i64 = 0 36 while pat[pl] != (0 as u8) { pl = pl + 1 } 37 var i: i64 = 0 38 while i + pl <= gl { 39 var k: i64 = 0 40 var hit: i64 = 1 41 while k < pl { 42 if g[i + k] != pat[k] { hit = 0; k = pl } else { k = k + 1 } 43 } 44 if hit == 1 { return 1 } 45 i = i + 1 46 } 47 return 0 48} 49 50func sp_decision_line(fd: i64, verb: *u8, cx: *i64, r: i64) -> i64 { 51 sp_w(fd, "<code>" as *u8) 52 sp_w(fd, verb) 53 sp_w(fd, " " as *u8) 54 sp_w(fd, an_id_at(cx, r)) 55 sp_w(fd, " &lt;reason&gt;</code> " as *u8) 56 return 0 57} 58 59// the VIEW queue: every row awaiting a viewpoint, with all four verbs 60func sp_view_section(fd: i64, cx: *i64) -> i64 { 61 let st: *i64 = cx[4] as *i64 62 sp_w(fd, "<section><h2>Awaiting your viewpoint (VIEW)</h2><p>Objective evidence is green; these wait ONLY on you.</p>" as *u8) 63 var cnt: i64 = 0 64 var r: i64 = 0 65 while r < cx[0] { 66 if st[r] == 86 { 67 cnt = cnt + 1 68 sp_w(fd, "<p><strong>" as *u8) 69 sp_w(fd, an_id_at(cx, r)) 70 sp_w(fd, "</strong> -- " as *u8) 71 sp_w(fd, an_title_at(cx, r)) 72 sp_w(fd, "<br>" as *u8) 73 sp_decision_line(fd, "APPROVE" as *u8, cx, r) 74 sp_decision_line(fd, "REWORK" as *u8, cx, r) 75 sp_decision_line(fd, "RESTART" as *u8, cx, r) 76 sp_decision_line(fd, "DENY" as *u8, cx, r) 77 sp_w(fd, "</p>" as *u8) 78 } 79 r = r + 1 80 } 81 if cnt == 0 { sp_w(fd, "<p><code>nothing awaiting viewpoint</code></p>" as *u8) } 82 sp_w(fd, "</section>" as *u8) 83 return cnt 84} 85 86// the co-spec batch: NOVEL rows that need sponsor+tutor together 87func sp_cospec_section(fd: i64, cx: *i64) -> i64 { 88 let st: *i64 = cx[4] as *i64 89 sp_w(fd, "<section><h2>Co-spec batch (needs us both)</h2>" as *u8) 90 var cnt: i64 = 0 91 var r: i64 = 0 92 while r < cx[0] { 93 if st[r] == 78 { 94 if sp_gate_has(cx, r, "||ASK=spec" as *u8) == 1 { 95 cnt = cnt + 1 96 sp_w(fd, "<p><strong>" as *u8) 97 sp_w(fd, an_id_at(cx, r)) 98 sp_w(fd, "</strong> -- " as *u8) 99 sp_w(fd, an_title_at(cx, r)) 100 sp_w(fd, "</p>" as *u8) 101 } 102 } 103 r = r + 1 104 } 105 if cnt == 0 { sp_w(fd, "<p><code>no co-spec rows raised</code></p>" as *u8) } 106 sp_w(fd, "</section>" as *u8) 107 return cnt 108} 109 110// every raised hand, with the flag-it line (DENY-on-NOVEL is legal) 111func sp_novel_section(fd: i64, cx: *i64) -> i64 { 112 let st: *i64 = cx[4] as *i64 113 sp_w(fd, "<section><h2>Raised hands (flag the novel)</h2><p>Tutor fuel. Flag any row <code>DENY &lt;id&gt; &lt;reason&gt;</code> to kill it for no-ROI before tutor time burns; every reason trains the planner.</p>" as *u8) 114 var cnt: i64 = 0 115 var r: i64 = 0 116 while r < cx[0] { 117 if st[r] == 78 { 118 cnt = cnt + 1 119 sp_w(fd, "<p><strong>" as *u8) 120 sp_w(fd, an_id_at(cx, r)) 121 sp_w(fd, "</strong> -- " as *u8) 122 sp_w(fd, an_title_at(cx, r)) 123 sp_w(fd, "<br>" as *u8) 124 sp_decision_line(fd, "DENY" as *u8, cx, r) 125 sp_w(fd, "</p>" as *u8) 126 } 127 r = r + 1 128 } 129 sp_w(fd, "</section>" as *u8) 130 return cnt 131} 132 133func main(argc: i64, argv: *i64) -> i64 { 134 var outp: *u8 = "knowledge/sponsor.html.new" as *u8 135 var finp: *u8 = "knowledge/sponsor.html" as *u8 136 var qp: *u8 = "knowledge/registry/assignment_queue.tsv" as *u8 137 if argc >= 2 { outp = argv[1] as *u8; finp = argv[1] as *u8 } 138 if argc >= 3 { qp = argv[2] as *u8 } 139 let cx: *i64 = an_newcx() 140 let rows: i64 = an_load(qp, cx) 141 if rows <= 0 { 142 sp_w(1, "SPONSORPAGE verdict=RED reason=queue-missing\n" as *u8) 143 sys_exit(1) 144 } 145 let fd: i64 = sys_openat_wr(outp, 0x1a4) 146 if fd < 0 { sp_w(1, "SPONSORPAGE verdict=RED reason=out-unwritable\n" as *u8); sys_exit(1) } 147 sp_w(fd, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Nishi Executive Sponsor</title>" as *u8) 148 sp_w(fd, "<style>body{font-family:system-ui;margin:0;background:#f6f7f9;color:#16202a}main{max-width:760px;margin:0 auto;padding:1rem}section{background:#fff;border-radius:8px;padding:1rem;margin:1rem 0;box-shadow:0 1px 3px rgba(0,0,0,.08)}code{background:#0f172a;color:#d7e3f4;padding:.15rem .4rem;border-radius:4px;font-size:.8rem}h1{font-size:1.3rem}h2{font-size:1rem}.skip{position:absolute;left:-999px}</style></head><body>" as *u8) 149 sp_w(fd, "<a class=\"skip\" href=\"#main\">Skip to content</a><header><nav aria-label=\"Primary\"><a href=\"/\">Home</a></nav></header><main id=\"main\"><h1>Executive Sponsor</h1><p>Derived from the live queue every beat. ACTION CONTRACT: decisions move ONLY via the authenticated decide route (X-I3-002/003, pending) or the repo file knowledge/registry/sponsor_decisions.tsv -- paste the lines below.</p>" as *u8) 150 let nv: i64 = sp_view_section(fd, cx) 151 let nc: i64 = sp_cospec_section(fd, cx) 152 let nn: i64 = sp_novel_section(fd, cx) 153 sp_w(fd, "<section><h2>Counts</h2><p><code>view=" as *u8) 154 sp_wn(fd, nv) 155 sp_w(fd, " cospec=" as *u8) 156 sp_wn(fd, nc) 157 sp_w(fd, " raised=" as *u8) 158 sp_wn(fd, nn) 159 sp_w(fd, "</code></p></section>" as *u8) 160 sp_w(fd, "</main><footer><p style=\"text-align:center;color:#5a6b7d\">Sovereign NishiLang-&gt;HTML; refreshed every pulse beat; evidence law applies.</p></footer></body></html>" as *u8) 161 sys_close(fd) 162 if argc < 2 { sys_renameat("knowledge/sponsor.html.new" as *u8, "knowledge/sponsor.html" as *u8) } 163 sp_w(1, "SPONSORPAGE view=" as *u8) 164 sp_wn(1, nv) 165 sp_w(1, " cospec=" as *u8) 166 sp_wn(1, nc) 167 sp_w(1, " raised=" as *u8) 168 sp_wn(1, nn) 169 sp_w(1, " verdict=GREEN\n" as *u8) 170 sys_exit(0) 171 return 0 172}