code wiki / _hdl_build / nx_vizsla_render.nx

nx_vizsla_render.nx source

↩ module page · 397 lines · 22857 B

1// nx_vizsla_render.nx -- NISHI VIZSLA: the FIRST-PARTY, privacy-first UI for your relationships. Operator 2// 2026-06-22: "the ui for all our work is 3rd party and our first party nishi browser ... using all these 3// capabilities as s class exceed because it will manage and keep and use the data in a privacy first 4// respectful way where the users data is treated as valuable and not something to be stolen." Third-party 5// browsers + cloud PRMs OWN and monetize your relationship graph; the Nishi browser is first-party + sovereign, 6// so it renders + uses this data while it NEVER leaves your hardware. This organ emits the relationship brief as 7// a static HTML page -- ZERO JavaScript, ZERO third-party loads (no external CSS/font/img/script) -- the same 8// fail-closed-sovereignty pattern the reader uses. It COMPOSES the gated relate engine (rule 22) over a tenant. 9// page <base> <tid> <today> <outfile> render that tenant's brief to a sovereign first-party HTML page 10// coord <digest.conf> <today> <outfile> render the ENGAGEMENT-PARTNER digest (2026-07-08) -- today's 11// calendar, reminders due (birthdays + events), plan board, venue 12// hunt -- by forking the blessed nx_vizsla_digest over the conf. 13// SOVEREIGNTY IS PROVEN, not promised: after building the page the organ SCANS its own bytes for <script / http / 14// <link / @import and REFUSES (exit 1) if any appear. The privacy statement is in the page itself. license_tier: ORIGINAL 15import "nx_syscalls.nx" 16const K_MAGIC_65536: i64 = 65536 17const K_MAGIC_1024: i64 = 1024 18const K_MAGIC_524288: i64 = 524288 19const K_MAGIC_8192: i64 = 8192 20 21func vr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 22func vr_p(s: *u8) -> i64 { sys_write(1, s, vr_slen(s)); return 0 } 23 24func vr_eq_cmd(a: *u8, b: *u8) -> i64 { 25 var i: i64 = 0 26 var go: i64 = 1 27 while go == 1 { if a[i] != b[i] { return 0 } if a[i] == (0 as u8) { return 1 } i = i + 1 } 28 return 0 29} 30 31func vr_cat(dst: *u8, off: i64, s: *u8) -> i64 { 32 var i: i64 = 0 33 while s[i] != (0 as u8) { dst[off + i] = s[i]; i = i + 1 } 34 return off + i 35} 36 37func vr_catn(dst: *u8, off: i64, v: i64) -> i64 { 38 var o: i64 = off 39 var m: i64 = v 40 if m < 0 { dst[o] = 45 as u8; o = o + 1; m = 0 - m } 41 let t: *u8 = sys_mmap(28) 42 var k: i64 = 0 43 if m == 0 { t[0] = 48 as u8; k = 1 } 44 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 45 var i: i64 = 0 46 while i < k { dst[o + i] = t[k - 1 - i]; i = i + 1 } 47 return o + k 48} 49 50// emit one char into out at o, HTML-escaping < > & (defensive at the boundary, law 12) 51func vr_echar(out: *u8, o: i64, c: i64) -> i64 { 52 if c == 60 { return vr_cat(out, o, "&lt;" as *u8) } 53 if c == 62 { return vr_cat(out, o, "&gt;" as *u8) } 54 if c == 38 { return vr_cat(out, o, "&amp;" as *u8) } 55 out[o] = c as u8 56 return o + 1 57} 58 59func vr_readall(path: *u8, szp: *i64) -> *u8 { 60 let fd: i64 = sys_openat_rd(path) 61 if fd < 0 { szp[0] = 0; return 0 as *u8 } 62 let sz: i64 = sys_lseek(fd, 0, 2) 63 sys_lseek(fd, 0, 0) 64 let buf: *u8 = sys_mmap(sz + 64) 65 var got: i64 = 0 66 var n: i64 = 1 67 while n > 0 { n = sys_read(fd, (buf as i64 + got) as *u8, K_MAGIC_65536); if n > 0 { got = got + n } } 68 sys_close(fd) 69 szp[0] = got 70 return buf 71} 72 73// does buf[0,n) contain needle? 74func vr_has(buf: *u8, n: i64, needle: *u8) -> i64 { 75 let nl: i64 = vr_slen(needle) 76 if nl > n { return 0 } 77 var i: i64 = 0 78 while i + nl <= n { 79 var ok: i64 = 1 80 var j: i64 = 0 81 while j < nl { if buf[i + j] != needle[j] { ok = 0; j = nl } else { j = j + 1 } } 82 if ok == 1 { return 1 } 83 i = i + 1 84 } 85 return 0 86} 87 88// index of needle in line[0,llen) or -1 89func vr_find(line: *u8, llen: i64, needle: *u8) -> i64 { 90 let nl: i64 = vr_slen(needle) 91 if nl > llen { return 0 - 1 } 92 var i: i64 = 0 93 while i + nl <= llen { 94 var ok: i64 = 1 95 var j: i64 = 0 96 while j < nl { if line[i + j] != needle[j] { ok = 0; j = nl } else { j = j + 1 } } 97 if ok == 1 { return i } 98 i = i + 1 99 } 100 return 0 - 1 101} 102 103// line[off..] starts with kw ? 104func vr_starts(line: *u8, llen: i64, off: i64, kw: *u8) -> i64 { 105 let kl: i64 = vr_slen(kw) 106 if off + kl > llen { return 0 } 107 var j: i64 = 0 108 while j < kl { if line[off + j] != kw[j] { return 0 } j = j + 1 } 109 return 1 110} 111 112// humanize a brief item line " KEYWORD contact=NAME ...detail" -> "<li><b>NAME</b> -- detail</li>" 113func vr_item(line: *u8, llen: i64, kwlen: i64, out: *u8, off: i64) -> i64 { 114 var o: i64 = off 115 o = vr_cat(out, o, "<li>" as *u8) 116 let c: i64 = vr_find(line, llen, "contact=" as *u8) 117 if c >= 0 { 118 var p: i64 = c + 8 119 o = vr_cat(out, o, "<b>" as *u8) 120 while p < llen { if line[p] == (32 as u8) { break } o = vr_echar(out, o, line[p] as i64); p = p + 1 } 121 o = vr_cat(out, o, "</b>" as *u8) 122 if p < llen { 123 o = vr_cat(out, o, " &mdash; " as *u8) 124 p = p + 1 125 while p < llen { o = vr_echar(out, o, line[p] as i64); p = p + 1 } 126 } 127 } else { 128 var p2: i64 = kwlen 129 while p2 < llen { o = vr_echar(out, o, line[p2] as i64); p2 = p2 + 1 } 130 } 131 o = vr_cat(out, o, "</li>\n" as *u8) 132 return o 133} 134 135// fork the blessed relate engine `brief <prefix> <contacts> <today>`, stdout -> outpath 136func vr_run_brief(prefix: *u8, contacts: *u8, today: *u8, outpath: *u8) -> i64 { 137 let pid: i64 = sys_fork() 138 if pid == 0 { 139 let ofd: i64 = sys_openat_wr(outpath, 0x1a4) 140 if ofd >= 0 { sys_dup3(ofd, 1, 0); sys_dup3(ofd, 2, 0) } 141 let argv: *i64 = sys_mmap(64) as *i64 142 argv[0] = "_offc/nx_vizsla_relate.elf" as *u8 as i64 143 argv[1] = "brief" as *u8 as i64 144 argv[2] = prefix as i64 145 argv[3] = contacts as i64 146 argv[4] = today as i64 147 argv[5] = 0 148 let envp: *i64 = sys_mmap(16) as *i64 149 envp[0] = 0 150 sys_execve("_offc/nx_vizsla_relate.elf" as *u8, argv, envp) 151 sys_exit(127) 152 } 153 let st: *i64 = sys_mmap(16) as *i64 154 sys_wait4(pid, st, 0) 155 return (st[0] >> 8) & 0xff 156} 157 158// coord item: the WHOLE line after the marker, HTML-escaped -- these are key=value machine lines 159// (a venue's contact= field must NOT trigger the relate-brief contact= humanization of vr_item) 160func vr_item_raw(line: *u8, llen: i64, kwlen: i64, out: *u8, off: i64) -> i64 { 161 var o: i64 = off 162 o = vr_cat(out, o, "<li>" as *u8) 163 var p: i64 = kwlen 164 while p < llen { o = vr_echar(out, o, line[p] as i64); p = p + 1 } 165 o = vr_cat(out, o, "</li>\n" as *u8) 166 return o 167} 168 169// fork the blessed digest `digest <conf> <today>`, stdout -> outpath 170func vr_run_digest(conf: *u8, today: *u8, outpath: *u8) -> i64 { 171 let pid: i64 = sys_fork() 172 if pid == 0 { 173 let ofd: i64 = sys_openat_wr(outpath, 0x1a4) 174 if ofd >= 0 { sys_dup3(ofd, 1, 0); sys_dup3(ofd, 2, 0) } 175 let argv: *i64 = sys_mmap(64) as *i64 176 argv[0] = "_offc/nx_vizsla_digest.elf" as *u8 as i64 177 argv[1] = "digest" as *u8 as i64 178 argv[2] = conf as i64 179 argv[3] = today as i64 180 argv[4] = 0 181 let envp: *i64 = sys_mmap(16) as *i64 182 envp[0] = 0 183 sys_execve("_offc/nx_vizsla_digest.elf" as *u8, argv, envp) 184 sys_exit(127) 185 } 186 let st: *i64 = sys_mmap(16) as *i64 187 sys_wait4(pid, st, 0) 188 return (st[0] >> 8) & 0xff 189} 190 191func vr_emit_section(page: *u8, o0: i64, title: *u8, items: *u8, nitems: i64, empty: *u8) -> i64 { 192 var o: i64 = o0 193 o = vr_cat(page, o, "<section><h2>" as *u8) 194 o = vr_cat(page, o, title) 195 o = vr_cat(page, o, "</h2>" as *u8) 196 if nitems > 0 { 197 o = vr_cat(page, o, "<ul>" as *u8) 198 o = vr_cat(page, o, items) 199 o = vr_cat(page, o, "</ul>" as *u8) 200 } else { 201 o = vr_cat(page, o, "<p class=empty>" as *u8) 202 o = vr_cat(page, o, empty) 203 o = vr_cat(page, o, "</p>" as *u8) 204 } 205 o = vr_cat(page, o, "</section>\n" as *u8) 206 return o 207} 208 209func vr_cmd_page(argc: i64, argv: *i64) -> i64 { 210 if argc < 6 { vr_p("VIZSLA-RENDER page needs <base> <tid> <today> <outfile> -- fail loud\n" as *u8); return 1 } 211 let base: *u8 = argv[2] as *u8 212 let tid: *u8 = argv[3] as *u8 213 let today: *u8 = argv[4] as *u8 214 let outpath: *u8 = argv[5] as *u8 215 216 let prefix: *u8 = sys_mmap(K_MAGIC_1024) 217 var po: i64 = 0 218 po = vr_cat(prefix, po, base); po = vr_cat(prefix, po, tid); po = vr_cat(prefix, po, ".relate-" as *u8); prefix[po] = 0 as u8 219 let contacts: *u8 = sys_mmap(K_MAGIC_1024) 220 var co: i64 = 0 221 co = vr_cat(contacts, co, base); co = vr_cat(contacts, co, tid); co = vr_cat(contacts, co, ".contacts.txt" as *u8); contacts[co] = 0 as u8 222 223 let tmp: *u8 = sys_mmap(256) 224 var to: i64 = 0 225 to = vr_cat(tmp, to, "/tmp/vr_brief_" as *u8); to = vr_catn(tmp, to, sys_now_us()); to = vr_cat(tmp, to, ".txt" as *u8); tmp[to] = 0 as u8 226 vr_run_brief(prefix, contacts, today, tmp) 227 228 let szp: *i64 = sys_mmap(16) as *i64 229 let bb: *u8 = vr_readall(tmp, szp) 230 let bn: i64 = szp[0] 231 if bn <= 0 { vr_p("VIZSLA-RENDER brief produced no output (tenant missing/empty?) -- fail loud\n" as *u8); return 1 } 232 233 let s_reach: *u8 = sys_mmap(K_MAGIC_65536); var n_reach: i64 = 0; var o_reach: i64 = 0 234 let s_bday: *u8 = sys_mmap(K_MAGIC_65536); var n_bday: i64 = 0; var o_bday: i64 = 0 235 let s_thx: *u8 = sys_mmap(K_MAGIC_65536); var n_thx: i64 = 0; var o_thx: i64 = 0 236 let s_owed: *u8 = sys_mmap(K_MAGIC_65536); var n_owed: i64 = 0; var o_owed: i64 = 0 237 238 var i: i64 = 0 239 while i < bn { 240 var e: i64 = i 241 var go: i64 = 1 242 while go == 1 { if e >= bn { go = 0 } else { if bb[e] == (10 as u8) { go = 0 } else { e = e + 1 } } } 243 let line: *u8 = (bb as i64 + i) as *u8 244 let llen: i64 = e - i 245 var off: i64 = 0 246 while off < llen { if line[off] == (32 as u8) { off = off + 1 } else { break } } 247 if vr_starts(line, llen, off, "FOLLOWUP" as *u8) == 1 { o_reach = vr_item(line, llen, off + 8, s_reach, o_reach); n_reach = n_reach + 1 } 248 if vr_starts(line, llen, off, "BIRTHDAY" as *u8) == 1 { o_bday = vr_item(line, llen, off + 8, s_bday, o_bday); n_bday = n_bday + 1 } 249 if vr_starts(line, llen, off, "THANKYOU" as *u8) == 1 { o_thx = vr_item(line, llen, off + 8, s_thx, o_thx); n_thx = n_thx + 1 } 250 if vr_starts(line, llen, off, "OBLIGATION" as *u8) == 1 { o_owed = vr_item(line, llen, off + 10, s_owed, o_owed); n_owed = n_owed + 1 } 251 i = e + 1 252 } 253 s_reach[o_reach] = 0 as u8; s_bday[o_bday] = 0 as u8; s_thx[o_thx] = 0 as u8; s_owed[o_owed] = 0 as u8 254 255 let page: *u8 = sys_mmap(K_MAGIC_524288) 256 var o: i64 = 0 257 o = vr_cat(page, o, "<!DOCTYPE html>\n<html lang=en><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Nishi Vizsla &middot; " as *u8) 258 o = vr_cat(page, o, tid) 259 o = vr_cat(page, o, "</title><style>\nbody{font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;margin:0;background:#f6f7f9;color:#1a1d21}\nheader{background:#0f172a;color:#fff;padding:24px 28px}\nheader h1{margin:0;font-size:22px;letter-spacing:.3px}\nheader p{margin:6px 0 0;opacity:.82;font-size:14px}\n.badge{display:inline-block;margin-top:12px;background:#16a34a;color:#fff;padding:4px 12px;border-radius:999px;font-size:12px;font-weight:600}\nmain{max-width:760px;margin:0 auto;padding:20px}\nsection{background:#fff;border:1px solid #e5e7eb;border-radius:12px;margin:16px 0;padding:14px 20px}\nsection h2{margin:0 0 8px;font-size:16px;color:#0f172a}\nul{margin:0;padding:0;list-style:none}\nli{padding:9px 0;border-top:1px solid #f1f5f9}\nli:first-child{border-top:none}\nli b{color:#0f172a}\n.empty{color:#64748b;font-style:italic;margin:4px 0}\nfooter{max-width:760px;margin:0 auto;padding:18px 20px 40px;color:#475569;font-size:13px;text-align:center}\n.lock{color:#16a34a;font-weight:700}\nform p{margin:7px 0}\ninput,select{font:14px system-ui;padding:7px 9px;border:1px solid #cbd5e1;border-radius:7px;margin:2px 4px 2px 0}\nbutton{font:14px system-ui;font-weight:600;padding:7px 16px;border:0;border-radius:7px;background:#0f172a;color:#fff;cursor:pointer}\n</style></head>\n<body>\n<header><h1>Nishi Vizsla</h1><p>Your relationships &middot; " as *u8) 260 o = vr_cat(page, o, tid) 261 o = vr_cat(page, o, " &middot; " as *u8) 262 o = vr_cat(page, o, today) 263 o = vr_cat(page, o, "</p><span class=badge>Private &middot; on-device &middot; never uploaded</span></header>\n<main>\n" as *u8) 264 o = vr_emit_section(page, o, "Reach out today" as *u8, s_reach, n_reach, "Everyone you keep up with has been in touch lately." as *u8) 265 o = vr_emit_section(page, o, "Birthdays coming up" as *u8, s_bday, n_bday, "No birthdays in your window." as *u8) 266 o = vr_emit_section(page, o, "Thank-yous to send" as *u8, s_thx, n_thx, "No thank-yous outstanding." as *u8) 267 o = vr_emit_section(page, o, "What is owed (both ways)" as *u8, s_owed, n_owed, "No open obligations." as *u8) 268 o = vr_cat(page, o, "<section><h2>Add someone</h2><form method=post action=/v/submit><input type=hidden name=action value=add-contact><input type=hidden name=tid value=" as *u8) 269 o = vr_cat(page, o, tid) 270 o = vr_cat(page, o, "><p><input name=id placeholder=\"handle e.g. mom\" required> <input name=name placeholder=\"Display name\" required></p><p><select name=tier><option>inner</option><option>close</option><option>network</option></select> <input name=bday placeholder=\"MM-DD optional\"> <button>Add</button></p></form></section>\n<section><h2>Log a catch-up</h2><form method=post action=/v/submit><input type=hidden name=action value=touch><input type=hidden name=tid value=" as *u8) 271 o = vr_cat(page, o, tid) 272 o = vr_cat(page, o, "><p><input name=id placeholder=\"who (handle)\" required> <input name=date placeholder=\"YYYY-MM-DD\" required> <input name=note placeholder=\"note\"> <button>Log</button></p></form></section>\n" as *u8) 273 o = vr_cat(page, o, "</main>\n<footer>Your relationships are <span class=lock>yours</span>. Nishi keeps this only on your hardware &mdash; never uploaded, sold, or profiled. This page loaded <b>zero</b> third-party code.</footer>\n</body></html>\n" as *u8) 274 275 // ===== FAIL-CLOSED SOVEREIGNTY: prove no JS / no third-party loads in our OWN output ===== 276 var bad: i64 = 0 277 if vr_has(page, o, "<script" as *u8) == 1 { bad = 1 } 278 if vr_has(page, o, "http" as *u8) == 1 { bad = 1 } 279 if vr_has(page, o, "<link" as *u8) == 1 { bad = 1 } 280 if vr_has(page, o, "@import" as *u8) == 1 { bad = 1 } 281 if bad == 1 { vr_p("VIZSLA-RENDER NON-SOVEREIGN output (script/http/link/@import present) -- REFUSING\n" as *u8); return 1 } 282 283 let fd: i64 = sys_openat_wr(outpath, 0x1a4) 284 if fd < 0 { vr_p("VIZSLA-RENDER cannot write outfile -- fail loud\n" as *u8); return 1 } 285 sys_write(fd, page, o) 286 sys_close(fd) 287 288 let rep: *u8 = sys_mmap(512) 289 var ro: i64 = 0 290 ro = vr_cat(rep, ro, "VIZSLA-RENDER tenant=" as *u8); ro = vr_cat(rep, ro, tid) 291 ro = vr_cat(rep, ro, " reach=" as *u8); ro = vr_catn(rep, ro, n_reach) 292 ro = vr_cat(rep, ro, " bday=" as *u8); ro = vr_catn(rep, ro, n_bday) 293 ro = vr_cat(rep, ro, " thanks=" as *u8); ro = vr_catn(rep, ro, n_thx) 294 ro = vr_cat(rep, ro, " owed=" as *u8); ro = vr_catn(rep, ro, n_owed) 295 ro = vr_cat(rep, ro, " bytes=" as *u8); ro = vr_catn(rep, ro, o) 296 ro = vr_cat(rep, ro, " sovereign=1 -> " as *u8); ro = vr_cat(rep, ro, outpath); ro = vr_cat(rep, ro, "\n" as *u8) 297 sys_write(1, rep, ro) 298 return 0 299} 300 301// ---------------- COORD (the engagement-partner page) ---------------- 302func vr_cmd_coord(argc: i64, argv: *i64) -> i64 { 303 if argc < 5 { vr_p("VIZSLA-RENDER coord needs <digest.conf> <today> <outfile> -- fail loud\n" as *u8); return 1 } 304 let conf: *u8 = argv[2] as *u8 305 let today: *u8 = argv[3] as *u8 306 let outpath: *u8 = argv[4] as *u8 307 308 let tmp: *u8 = sys_mmap(256) 309 var to: i64 = 0 310 to = vr_cat(tmp, to, "/tmp/vr_coord_" as *u8); to = vr_catn(tmp, to, sys_now_us()); to = vr_cat(tmp, to, ".txt" as *u8); tmp[to] = 0 as u8 311 let rc: i64 = vr_run_digest(conf, today, tmp) 312 if rc != 0 { vr_p("VIZSLA-RENDER digest FAILED -- fail loud\n" as *u8); return 1 } 313 314 let szp: *i64 = sys_mmap(16) as *i64 315 let bb: *u8 = vr_readall(tmp, szp) 316 let bn: i64 = szp[0] 317 if bn <= 0 { vr_p("VIZSLA-RENDER digest produced no output -- fail loud\n" as *u8); return 1 } 318 319 let s_today: *u8 = sys_mmap(K_MAGIC_65536); var n_today: i64 = 0; var o_today: i64 = 0 320 let s_rem: *u8 = sys_mmap(K_MAGIC_65536); var n_rem: i64 = 0; var o_rem: i64 = 0 321 let s_plan: *u8 = sys_mmap(K_MAGIC_65536); var n_plan: i64 = 0; var o_plan: i64 = 0 322 let s_ven: *u8 = sys_mmap(K_MAGIC_65536); var n_ven: i64 = 0; var o_ven: i64 = 0 323 let s_verd: *u8 = sys_mmap(K_MAGIC_8192); var o_verd: i64 = 0 324 325 var i: i64 = 0 326 while i < bn { 327 var e: i64 = i 328 var go: i64 = 1 329 while go == 1 { if e >= bn { go = 0 } else { if bb[e] == (10 as u8) { go = 0 } else { e = e + 1 } } } 330 let line: *u8 = (bb as i64 + i) as *u8 331 let llen: i64 = e - i 332 var off: i64 = 0 333 while off < llen { if line[off] == (32 as u8) { off = off + 1 } else { break } } 334 if vr_starts(line, llen, off, "VIZSLA-CAL-EVENT" as *u8) == 1 { o_today = vr_item_raw(line, llen, off + 16, s_today, o_today); n_today = n_today + 1 } 335 if vr_starts(line, llen, off, "VIZSLA-REM-DUE" as *u8) == 1 { o_rem = vr_item_raw(line, llen, off + 14, s_rem, o_rem); n_rem = n_rem + 1 } 336 if vr_starts(line, llen, off, "VIZSLA-PLAN-TASK" as *u8) == 1 { o_plan = vr_item_raw(line, llen, off + 16, s_plan, o_plan); n_plan = n_plan + 1 } 337 if vr_starts(line, llen, off, "VIZSLA-PLAN-CRITICAL" as *u8) == 1 { o_plan = vr_item_raw(line, llen, off + 20, s_plan, o_plan); n_plan = n_plan + 1 } 338 if vr_starts(line, llen, off, "VIZSLA-VEN-CAND" as *u8) == 1 { o_ven = vr_item_raw(line, llen, off + 15, s_ven, o_ven); n_ven = n_ven + 1 } 339 if vr_starts(line, llen, off, "VIZSLA-VEN-BOOKED" as *u8) == 1 { o_ven = vr_item_raw(line, llen, off + 17, s_ven, o_ven); n_ven = n_ven + 1 } 340 if vr_starts(line, llen, off, "VIZSLA-DIGEST-VERDICT" as *u8) == 1 { 341 var p: i64 = off 342 while p < llen { o_verd = vr_echar(s_verd, o_verd, line[p] as i64); p = p + 1 } 343 } 344 i = e + 1 345 } 346 s_today[o_today] = 0 as u8; s_rem[o_rem] = 0 as u8; s_plan[o_plan] = 0 as u8; s_ven[o_ven] = 0 as u8; s_verd[o_verd] = 0 as u8 347 348 let page: *u8 = sys_mmap(K_MAGIC_524288) 349 var o: i64 = 0 350 o = vr_cat(page, o, "<!DOCTYPE html>\n<html lang=en><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Nishi Vizsla &middot; Coordination</title><style>\nbody{font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;margin:0;background:#f6f7f9;color:#1a1d21}\nheader{background:#0f172a;color:#fff;padding:24px 28px}\nheader h1{margin:0;font-size:22px;letter-spacing:.3px}\nheader p{margin:6px 0 0;opacity:.82;font-size:14px}\n.badge{display:inline-block;margin-top:12px;background:#16a34a;color:#fff;padding:4px 12px;border-radius:999px;font-size:12px;font-weight:600}\nmain{max-width:760px;margin:0 auto;padding:20px}\nsection{background:#fff;border:1px solid #e5e7eb;border-radius:12px;margin:16px 0;padding:14px 20px}\nsection h2{margin:0 0 8px;font-size:16px;color:#0f172a}\nul{margin:0;padding:0;list-style:none}\nli{padding:9px 0;border-top:1px solid #f1f5f9;font-size:14px}\nli:first-child{border-top:none}\nli b{color:#0f172a}\n.empty{color:#64748b;font-style:italic;margin:4px 0}\n.verd{color:#334155;font-size:13px;margin:4px 0;word-break:break-word}\nfooter{max-width:760px;margin:0 auto;padding:18px 20px 40px;color:#475569;font-size:13px;text-align:center}\n.lock{color:#16a34a;font-weight:700}\n</style></head>\n<body>\n<header><h1>Nishi Vizsla</h1><p>Coordination &middot; " as *u8) 351 o = vr_cat(page, o, today) 352 o = vr_cat(page, o, "</p><span class=badge>Private &middot; on-device &middot; never uploaded</span></header>\n<main>\n" as *u8) 353 if o_verd > 0 { 354 o = vr_cat(page, o, "<section><h2>Summary</h2><p class=verd>" as *u8) 355 o = vr_cat(page, o, s_verd) 356 o = vr_cat(page, o, "</p></section>\n" as *u8) 357 } 358 o = vr_emit_section(page, o, "Today" as *u8, s_today, n_today, "No events today." as *u8) 359 o = vr_emit_section(page, o, "Reminders due (birthdays + events)" as *u8, s_rem, n_rem, "Nothing due at your lead times." as *u8) 360 o = vr_emit_section(page, o, "Plan" as *u8, s_plan, n_plan, "No open plan items." as *u8) 361 o = vr_emit_section(page, o, "Venue hunt" as *u8, s_ven, n_ven, "No venue pipeline running." as *u8) 362 o = vr_cat(page, o, "</main>\n<footer>Your coordination lives on <span class=lock>your hardware</span> &mdash; never uploaded, sold, or profiled. This page loaded <b>zero</b> third-party code.</footer>\n</body></html>\n" as *u8) 363 364 // ===== FAIL-CLOSED SOVEREIGNTY (same law as page mode) ===== 365 var bad: i64 = 0 366 if vr_has(page, o, "<script" as *u8) == 1 { bad = 1 } 367 if vr_has(page, o, "http" as *u8) == 1 { bad = 1 } 368 if vr_has(page, o, "<link" as *u8) == 1 { bad = 1 } 369 if vr_has(page, o, "@import" as *u8) == 1 { bad = 1 } 370 if bad == 1 { vr_p("VIZSLA-RENDER NON-SOVEREIGN output (script/http/link/@import present) -- REFUSING\n" as *u8); return 1 } 371 372 let fd: i64 = sys_openat_wr(outpath, 0x1a4) 373 if fd < 0 { vr_p("VIZSLA-RENDER cannot write outfile -- fail loud\n" as *u8); return 1 } 374 sys_write(fd, page, o) 375 sys_close(fd) 376 377 let rep: *u8 = sys_mmap(512) 378 var ro: i64 = 0 379 ro = vr_cat(rep, ro, "VIZSLA-RENDER-COORD today=" as *u8); ro = vr_cat(rep, ro, today) 380 ro = vr_cat(rep, ro, " cal=" as *u8); ro = vr_catn(rep, ro, n_today) 381 ro = vr_cat(rep, ro, " rem=" as *u8); ro = vr_catn(rep, ro, n_rem) 382 ro = vr_cat(rep, ro, " plan=" as *u8); ro = vr_catn(rep, ro, n_plan) 383 ro = vr_cat(rep, ro, " venue=" as *u8); ro = vr_catn(rep, ro, n_ven) 384 ro = vr_cat(rep, ro, " bytes=" as *u8); ro = vr_catn(rep, ro, o) 385 ro = vr_cat(rep, ro, " sovereign=1 -> " as *u8); ro = vr_cat(rep, ro, outpath); ro = vr_cat(rep, ro, "\n" as *u8) 386 sys_write(1, rep, ro) 387 return 0 388} 389 390func main(argc: i64, argv: *i64) -> i64 { 391 if argc < 2 { vr_p("VIZSLA-RENDER usage: page <base> <tenant-id> <today> <outfile> | coord <digest.conf> <today> <outfile> -- fail loud\n" as *u8); return 1 } 392 let cmd: *u8 = argv[1] as *u8 393 if vr_eq_cmd(cmd, "page" as *u8) == 1 { return vr_cmd_page(argc, argv) } 394 if vr_eq_cmd(cmd, "coord" as *u8) == 1 { return vr_cmd_coord(argc, argv) } 395 vr_p("VIZSLA-RENDER unknown command (page|coord) -- fail loud\n" as *u8) 396 return 1 397}