code wiki / _hdl_build / nx_proj_pulse.nx

nx_proj_pulse.nx source

↩ module page · 456 lines · 21497 B

1// nx_proj_pulse.nx -- NAP1: THE PUBLISHED PROJECT PULSE. One organ composes a compare domain's rank 2// artifact (nx_compare_rank's <dom>.rank), its sovereign project plane (nishi_project prj:/mem:/not: + 3// vizsla tsk:/don: records) and derives DRIFT between them, then emits ONE public page -- the team's 4// queue, board, journal (findings / recommendations / decisions) and the disagreements, visible beside 5// the compare board they serve. This is the publish leg of the Nishi Autonomous Project loop (pmdash 6// NAP1; field bar = the AI-Scientist publish-what-you-did loop, grounded our way: every claim on the 7// page comes from an artifact -- the rank file, the plane, never prose). 8// nx_proj_pulse emit <dom> <prefix> <pid> <rankfile> <outpath|-> -> compose + write the page 9// nx_proj_pulse -> selftest (unique /tmp fixtures) 10// REFUSES loud on a missing rank artifact or an empty/unknown project (abstain, never fabricate). 11// DRIFT rules (v1, detection only -- filing is NAP3): a ranked rung with no project task = UNSYNCED; 12// a task marked DONE whose rung is still OPEN on the board = EVIDENCE-DISAGREE (the contract symbol has 13// not landed, so the board refuses the claim). COMPOSES nx_project.nx (pj_gather/pj_state/pj_put) -- 14// one gatherer, one writer, no duplicate ruler. Verdict teeth are self-contained counters with the 15// canonical verdict LAST and the exit code carrying it; migration onto per-tooth gv_check is the named 16// D001 residual, not silently skipped. license_tier: ORIGINAL 17import "nx_syscalls.nx" 18import "nx_project.nx" 19 20const PP_BUF: i64 = 262144 21const PP_ROWCAP: i64 = 64 22 23func pp_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 24func pp_p(s: *u8) -> i64 { sys_write(1, s, pp_slen(s)); return 0 } 25func pp_pn(v: i64) -> i64 { let b: *u8 = sys_mmap(32); var o: i64 = pj_catn(b, 0, v); sys_write(1, b, o); return 0 } 26func pp_contains(hay: *u8, hn: i64, needle: *u8) -> i64 { 27 let nl: i64 = pp_slen(needle) 28 if nl == 0 { return 1 } 29 var i: i64 = 0 30 while i + nl <= hn { 31 var j: i64 = 0 32 var ok: i64 = 1 33 while j < nl { if hay[i+j] != needle[j] { ok = 0; j = nl } else { j = j + 1 } } 34 if ok == 1 { return 1 } 35 i = i + 1 36 } 37 return 0 38} 39// lowercase an ascii id ("G3" -> "g3") 40func pp_lower(src: *u8, dst: *u8, cap: i64) -> i64 { 41 var i: i64 = 0 42 while src[i] != (0 as u8) { 43 if i < cap - 1 { 44 var c: i64 = src[i] as i64 45 if c >= 65 { if c <= 90 { c = c + 32 } } 46 dst[i] = c as u8 47 } 48 i = i + 1 49 } 50 var n: i64 = i 51 if n > cap - 1 { n = cap - 1 } 52 dst[n] = 0 as u8 53 return n 54} 55// html-escape into dst (only < and & matter for our own text; > left alone) 56func pp_esc(dst: *u8, off: i64, s: *u8) -> i64 { 57 var o: i64 = off 58 var i: i64 = 0 59 while s[i] != (0 as u8) { 60 let c: i64 = s[i] as i64 61 if c == 60 { o = pj_cat(dst, o, "&lt;" as *u8) } 62 else { if c == 38 { o = pj_cat(dst, o, "&amp;" as *u8) } else { dst[o] = s[i]; o = o + 1 } } 63 i = i + 1 64 } 65 return o 66} 67// field n (0-based) of a pipe-row between [ls,le) -> out; returns len (0 if absent) 68func pp_pfield(b: *u8, ls: i64, le: i64, want: i64, out: *u8, cap: i64) -> i64 { 69 var f: i64 = 0 70 var i: i64 = ls 71 var fs: i64 = ls 72 var o: i64 = 0 73 out[0] = 0 as u8 74 while i <= le { 75 var atend: i64 = 0 76 if i == le { atend = 1 } else { if b[i] == (124 as u8) { atend = 1 } } 77 if atend == 1 { 78 if f == want { 79 var k: i64 = fs 80 while k < i { if o < cap - 1 { out[o] = b[k]; o = o + 1 } k = k + 1 } 81 out[o] = 0 as u8 82 return o 83 } 84 f = f + 1 85 fs = i + 1 86 } 87 i = i + 1 88 } 89 out[o] = 0 as u8 90 return 0 91} 92 93// ---- rank artifact parse: rows "rank|n|stage|id|priority|v|m|c|title|sym" -> parallel arrays ---- 94// returns row count; -1 = file missing/empty (the caller REFUSES -- absence is not an empty queue) 95func pp_rank_load(path: *u8, rids: *i64, rstage: *i64, rtitle: *i64, rsym: *i64, rprio: *i64) -> i64 { 96 let lp: *i64 = sys_mmap(16) as *i64 97 let b: *u8 = sys_read_file(path, lp) 98 if (b as i64) == 0 { return 0 - 1 } 99 let sz: i64 = lp[0] 100 if sz <= 0 { return 0 - 1 } 101 var n: i64 = 0 102 var i: i64 = 0 103 while i < sz { 104 var e: i64 = i 105 var go: i64 = 1 106 while go == 1 { if e >= sz { go = 0 } else { if b[e] == (10 as u8) { go = 0 } else { e = e + 1 } } } 107 let t0: *u8 = sys_mmap(16) 108 pp_pfield(b, i, e, 0, t0, 16) 109 if pj_eq(t0, "rank" as *u8) == 1 { if n < PP_ROWCAP { 110 let fid: *u8 = sys_mmap(32); pp_pfield(b, i, e, 3, fid, 32) 111 let fst: *u8 = sys_mmap(16); pp_pfield(b, i, e, 2, fst, 16) 112 let fpr: *u8 = sys_mmap(24); pp_pfield(b, i, e, 4, fpr, 24) 113 let ftl: *u8 = sys_mmap(160); pp_pfield(b, i, e, 8, ftl, 160) 114 let fsy: *u8 = sys_mmap(64); pp_pfield(b, i, e, 9, fsy, 64) 115 rids[n] = fid as i64 116 rstage[n] = fst as i64 117 rprio[n] = fpr as i64 118 rtitle[n] = ftl as i64 119 rsym[n] = fsy as i64 120 n = n + 1 121 } } 122 i = e + 1 123 } 124 return n 125} 126 127// find a task index by tid; -1 when absent 128func pp_task_idx(st: *i64, tid: *u8) -> i64 { 129 let tids: *i64 = st[1] as *i64 130 var i: i64 = 0 131 while i < st[0] { if pj_eq(tids[i] as *u8, tid) == 1 { return i } i = i + 1 } 132 return 0 - 1 133} 134 135// ---- THE EMITTER (the NAP1 contract symbol) ---- 136// composes rank + plane -> page at outpath ("-" = stdout only). Returns 0 ok, 1 refused. 137func pp_emit(dom: *u8, prefix: *u8, pid: *u8, rankfile: *u8, outpath: *u8) -> i64 { 138 let rids: *i64 = sys_mmap(8 * PP_ROWCAP) as *i64 139 let rstage: *i64 = sys_mmap(8 * PP_ROWCAP) as *i64 140 let rtitle: *i64 = sys_mmap(8 * PP_ROWCAP) as *i64 141 let rsym: *i64 = sys_mmap(8 * PP_ROWCAP) as *i64 142 let rprio: *i64 = sys_mmap(8 * PP_ROWCAP) as *i64 143 let nr: i64 = pp_rank_load(rankfile, rids, rstage, rtitle, rsym, rprio) 144 if nr < 0 { pp_p("NX-PROJ-PULSE REFUSED-NO-RANK rankfile missing/empty -- run nx_compare_rank first; absence is not an empty queue\n" as *u8); return 1 } 145 let st: *i64 = pj_st_new() 146 pj_gather(prefix, pid, st) 147 if st[12] == 0 { pp_p("NX-PROJ-PULSE REFUSED-NO-PROJECT prj: record absent under this prefix -- load the project first (nishi_project load)\n" as *u8); return 1 } 148 149 // task-state partition (statename strings are the contract: READY/BLOCKED/DONE) 150 var cready: i64 = 0 151 var cblocked: i64 = 0 152 var cdone: i64 = 0 153 var ti: i64 = 0 154 while ti < st[0] { 155 let sn: *u8 = pj_statename(pj_state(st, ti)) as *u8 156 if pj_eq(sn, "DONE" as *u8) == 1 { cdone = cdone + 1 } 157 else { if pj_eq(sn, "BLOCKED" as *u8) == 1 { cblocked = cblocked + 1 } else { cready = cready + 1 } } 158 ti = ti + 1 159 } 160 161 // drift: ranked-but-unsynced and done-but-still-open 162 let dbuf: *u8 = sys_mmap(8192) 163 var dof: i64 = 0 164 var dunsync: i64 = 0 165 var ddisagree: i64 = 0 166 var ri: i64 = 0 167 while ri < nr { 168 let low: *u8 = sys_mmap(32) 169 pp_lower(rids[ri] as *u8, low, 32) 170 let tix: i64 = pp_task_idx(st, low) 171 if tix < 0 { 172 dunsync = dunsync + 1 173 dof = pj_cat(dbuf, dof, "<li>UNSYNCED " as *u8) 174 dof = pp_esc(dbuf, dof, rids[ri] as *u8) 175 dof = pj_cat(dbuf, dof, " -- ranked rung has no project task (run the plan-to-project sync)</li>" as *u8) 176 } else { 177 let sn2: *u8 = pj_statename(pj_state(st, tix)) as *u8 178 if pj_eq(sn2, "DONE" as *u8) == 1 { 179 ddisagree = ddisagree + 1 180 dof = pj_cat(dbuf, dof, "<li>EVIDENCE-DISAGREE " as *u8) 181 dof = pp_esc(dbuf, dof, rids[ri] as *u8) 182 dof = pj_cat(dbuf, dof, " -- task says DONE but the rung is still OPEN on the board: the contract symbol has not landed, so the claim is refused</li>" as *u8) 183 } 184 } 185 ri = ri + 1 186 } 187 188 // ---- compose the page ---- 189 let h: *u8 = sys_mmap(PP_BUF) 190 var o: i64 = 0 191 o = pj_cat(h, o, "<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>" as *u8) 192 o = pp_esc(h, o, dom) 193 o = pj_cat(h, o, " project pulse</title><style>body{font-family:system-ui,sans-serif;background:#0b0e16;color:#e9eef8;max-width:1080px;margin:0 auto;padding:0 18px 6vh;line-height:1.5}h1{font-size:1.4rem}h2{font-size:1.02rem;letter-spacing:.06em;text-transform:uppercase;color:#96a2ba;border-bottom:1px solid #29334e;padding-bottom:6px;margin-top:26px}table{border-collapse:collapse;width:100%;font-size:.88rem}td,th{border-bottom:1px solid #1b2233;padding:5px 8px;text-align:left;vertical-align:top}a{color:#c7a3ff;text-decoration:none}.now{color:#79e0a7;font-weight:600}.later{color:#96a2ba}.st-DONE{color:#79e0a7}.st-READY{color:#7ab5ff}.st-BLOCKED{color:#ffd17a}.mut{color:#96a2ba;font-size:.8rem}ul{padding-left:18px}li{margin:5px 0}.k{font-family:ui-monospace,Consolas,monospace;font-size:.82rem}</style></head><body><p class=mut><a href=\"/compare/" as *u8) 194 o = pp_esc(h, o, dom) 195 o = pj_cat(h, o, "\">&larr; the compare board</a></p><main><h1>" as *u8) 196 o = pp_esc(h, o, dom) 197 o = pj_cat(h, o, " &mdash; project pulse</h1><p class=mut>The autonomous project loop's published face: the computed queue, the team board, the journal and the drift between them. Every row is derived from an artifact (the rank file, the project plane) -- never typed here.</p>" as *u8) 198 199 o = pj_cat(h, o, "<h2>The queue (computed, never chosen)</h2><table><tr><th>rung</th><th>stage</th><th>priority</th><th>title</th><th>contract</th></tr>" as *u8) 200 ri = 0 201 while ri < nr { 202 o = pj_cat(h, o, "<tr><td class=k>" as *u8) 203 o = pp_esc(h, o, rids[ri] as *u8) 204 o = pj_cat(h, o, "</td><td class=" as *u8) 205 if pj_eq(rstage[ri] as *u8, "later" as *u8) == 1 { o = pj_cat(h, o, "later>later" as *u8) } else { o = pj_cat(h, o, "now>NOW " as *u8); o = pp_esc(h, o, rstage[ri] as *u8) } 206 o = pj_cat(h, o, "</td><td class=k>" as *u8) 207 o = pp_esc(h, o, rprio[ri] as *u8) 208 o = pj_cat(h, o, "</td><td>" as *u8) 209 o = pp_esc(h, o, rtitle[ri] as *u8) 210 o = pj_cat(h, o, "</td><td class=k>" as *u8) 211 o = pp_esc(h, o, rsym[ri] as *u8) 212 o = pj_cat(h, o, "</td></tr>" as *u8) 213 ri = ri + 1 214 } 215 o = pj_cat(h, o, "</table>" as *u8) 216 217 o = pj_cat(h, o, "<h2>The board</h2><table><tr><th>task</th><th>state</th><th>owner</th><th>effort min</th><th>due</th><th>title</th></tr>" as *u8) 218 let tids2: *i64 = st[1] as *i64 219 let towners: *i64 = st[2] as *i64 220 let tefforts: *i64 = st[4] as *i64 221 let ttitles: *i64 = st[5] as *i64 222 let tdues: *i64 = st[21] as *i64 223 ti = 0 224 while ti < st[0] { 225 let sn3: *u8 = pj_statename(pj_state(st, ti)) as *u8 226 o = pj_cat(h, o, "<tr><td class=k>" as *u8) 227 o = pp_esc(h, o, tids2[ti] as *u8) 228 o = pj_cat(h, o, "</td><td class=st-" as *u8) 229 o = pj_cat(h, o, sn3) 230 o = pj_cat(h, o, ">" as *u8) 231 o = pj_cat(h, o, sn3) 232 o = pj_cat(h, o, "</td><td>" as *u8) 233 o = pp_esc(h, o, towners[ti] as *u8) 234 o = pj_cat(h, o, "</td><td class=k>" as *u8) 235 o = pj_catn(h, o, tefforts[ti]) 236 o = pj_cat(h, o, "</td><td class=k>" as *u8) 237 o = pp_esc(h, o, tdues[ti] as *u8) 238 o = pj_cat(h, o, "</td><td>" as *u8) 239 o = pp_esc(h, o, ttitles[ti] as *u8) 240 o = pj_cat(h, o, "</td></tr>" as *u8) 241 ti = ti + 1 242 } 243 o = pj_cat(h, o, "</table><p class=mut>partition: ready=" as *u8) 244 o = pj_catn(h, o, cready) 245 o = pj_cat(h, o, " blocked=" as *u8) 246 o = pj_catn(h, o, cblocked) 247 o = pj_cat(h, o, " done=" as *u8) 248 o = pj_catn(h, o, cdone) 249 o = pj_cat(h, o, " of " as *u8) 250 o = pj_catn(h, o, st[0]) 251 o = pj_cat(h, o, " (the parts must sum -- a partition is a claim)</p>" as *u8) 252 253 o = pj_cat(h, o, "<h2>The journal (findings, recommendations, decisions)</h2><ul>" as *u8) 254 let ntids: *i64 = st[27] as *i64 255 let npers: *i64 = st[28] as *i64 256 let ntxts: *i64 = st[29] as *i64 257 let ndates: *i64 = st[30] as *i64 258 var ni: i64 = st[26] 259 if ni == 0 { o = pj_cat(h, o, "<li class=mut>no journal entries yet</li>" as *u8) } 260 while ni > 0 { 261 ni = ni - 1 262 o = pj_cat(h, o, "<li><span class=k>" as *u8) 263 o = pp_esc(h, o, ndates[ni] as *u8) 264 o = pj_cat(h, o, " " as *u8) 265 o = pp_esc(h, o, npers[ni] as *u8) 266 o = pj_cat(h, o, " @" as *u8) 267 o = pp_esc(h, o, ntids[ni] as *u8) 268 o = pj_cat(h, o, "</span> &mdash; " as *u8) 269 o = pp_esc(h, o, ntxts[ni] as *u8) 270 o = pj_cat(h, o, "</li>" as *u8) 271 } 272 o = pj_cat(h, o, "</ul>" as *u8) 273 274 o = pj_cat(h, o, "<h2>Drift (what the loop would file)</h2><ul>" as *u8) 275 if dof == 0 { o = pj_cat(h, o, "<li class=mut>none -- the plan, the project and the board agree</li>" as *u8) } 276 dbuf[dof] = 0 as u8 277 o = pj_cat(h, o, dbuf) 278 o = pj_cat(h, o, "</ul><p class=mut>NX-DERIVED: regenerated artefact, not authored prose. emitter=nx_proj_pulse sources=rank-artifact+project-plane rank_rows=" as *u8) 279 o = pj_catn(h, o, nr) 280 o = pj_cat(h, o, " tasks=" as *u8) 281 o = pj_catn(h, o, st[0]) 282 o = pj_cat(h, o, " notes=" as *u8) 283 o = pj_catn(h, o, st[26]) 284 o = pj_cat(h, o, " drift=" as *u8) 285 o = pj_catn(h, o, dunsync + ddisagree) 286 o = pj_cat(h, o, " asof=" as *u8) 287 o = pj_catn(h, o, sys_now_realtime_sec()) 288 o = pj_cat(h, o, "</p></main></body></html>" as *u8) 289 290 var wrote: i64 = 0 291 if pj_eq(outpath, "-" as *u8) == 0 { 292 let fd: i64 = sys_openat_wr(outpath, 0x1a4) 293 if fd < 0 { pp_p("NX-PROJ-PULSE REFUSED-UNWRITABLE outpath cannot be opened for truncate-write\n" as *u8); return 1 } 294 sys_write(fd, h, o) 295 sys_close(fd) 296 wrote = o 297 } 298 pp_p("NX-PROJ-PULSE dom=" as *u8) 299 pp_p(dom) 300 pp_p(" rank_rows=" as *u8) 301 pp_pn(nr) 302 pp_p(" tasks=" as *u8) 303 pp_pn(st[0]) 304 pp_p(" ready=" as *u8) 305 pp_pn(cready) 306 pp_p(" blocked=" as *u8) 307 pp_pn(cblocked) 308 pp_p(" done=" as *u8) 309 pp_pn(cdone) 310 pp_p(" notes=" as *u8) 311 pp_pn(st[26]) 312 pp_p(" drift_unsynced=" as *u8) 313 pp_pn(dunsync) 314 pp_p(" drift_disagree=" as *u8) 315 pp_pn(ddisagree) 316 pp_p(" wrote=" as *u8) 317 pp_pn(wrote) 318 pp_p(" of=" as *u8) 319 pp_p(outpath) 320 pp_p("\n" as *u8) 321 return 0 322} 323 324// ---- selftest fixture writer: one record via the ONE shared writer (pj_put), never a second encoder ---- 325func pp_fx_rec(w: *i64, kp: *u8, keys: *i64, vals: *i64, nf: i64) -> i64 { return pj_put(keys, vals, nf, kp, w) } 326 327func pp_check(ctr: *i64, name: *u8, got: i64) -> i64 { 328 ctr[1] = ctr[1] + 1 329 if got == 1 { ctr[0] = ctr[0] + 1; pp_p("PASS " as *u8) } else { pp_p("FAIL " as *u8) } 330 pp_p(name) 331 pp_p("\n" as *u8) 332 return 0 333} 334 335func pp_selftest() -> i64 { 336 pp_p("=== NX-PROJ-PULSE GATE (unique /tmp fixtures per run -- idempotent by construction) ===\n" as *u8) 337 let ep: i64 = sys_now_us() 338 let pfx: *u8 = sys_mmap(128) 339 var po: i64 = pj_cat(pfx, 0, "/tmp/ppulse" as *u8) 340 po = pj_catn(pfx, po, ep) 341 po = pj_cat(pfx, po, "-" as *u8) 342 pfx[po] = 0 as u8 343 let rankp: *u8 = sys_mmap(128) 344 var ro: i64 = pj_cat(rankp, 0, "/tmp/ppulse" as *u8) 345 ro = pj_catn(rankp, ro, ep) 346 ro = pj_cat(rankp, ro, ".rank" as *u8) 347 rankp[ro] = 0 as u8 348 let outp: *u8 = sys_mmap(128) 349 var oo: i64 = pj_cat(outp, 0, "/tmp/ppulse" as *u8) 350 oo = pj_catn(outp, oo, ep) 351 oo = pj_cat(outp, oo, ".html" as *u8) 352 outp[oo] = 0 as u8 353 354 // rank fixture: T1 maps a DONE task (disagree), T2 maps a READY task, G7 has no task (unsynced) 355 let rfd: i64 = sys_openat_wr(rankp, 0x1a4) 356 let rtxt: *u8 = "# fixture\nrank|1|0.1|T1|900|9|1|1|first-fixture-rung|fx_one\nrank|2|0.1|T2|500|5|1|1|second-fixture-rung|fx_two\nrank|3|later|G7|100|1|1|1|ghost-rung-no-task|fx_ghost\n" as *u8 357 sys_write(rfd, rtxt, pp_slen(rtxt)) 358 sys_close(rfd) 359 360 // plane fixture through the ONE shared writer 361 let w: *i64 = sys_mmap(8 * 8) as *i64 362 w[0] = ss_begin() as i64 363 w[1] = sys_mmap(8 * 2048) 364 w[2] = 0 365 w[3] = 0 366 w[4] = 0 367 w[5] = 0 368 w[6] = pfx as i64 369 let k: *i64 = sys_mmap(8 * 12) as *i64 370 let v: *i64 = sys_mmap(8 * 12) as *i64 371 k[0] = "kind" as *u8 as i64; k[1] = "pid" as *u8 as i64; k[2] = "owner" as *u8 as i64; k[3] = "title" as *u8 as i64 372 v[0] = "prj" as *u8 as i64; v[1] = "t" as *u8 as i64; v[2] = "elder" as *u8 as i64; v[3] = "fixture-project" as *u8 as i64 373 pp_fx_rec(w, "prj:" as *u8, k, v, 4) 374 // tasks: t1 (done), t2 (ready), t3 dep t2 (blocked) 375 k[0] = "kind" as *u8 as i64; k[1] = "plan" as *u8 as i64; k[2] = "tid" as *u8 as i64; k[3] = "owner" as *u8 as i64 376 k[4] = "due" as *u8 as i64; k[5] = "effort" as *u8 as i64; k[6] = "imp" as *u8 as i64; k[7] = "dep" as *u8 as i64; k[8] = "title" as *u8 as i64 377 v[0] = "tsk" as *u8 as i64; v[1] = "t" as *u8 as i64; v[2] = "t1" as *u8 as i64; v[3] = "eng" as *u8 as i64 378 v[4] = "2026-09-01" as *u8 as i64; v[5] = "60" as *u8 as i64; v[6] = "3" as *u8 as i64; v[7] = "-" as *u8 as i64; v[8] = "first-task" as *u8 as i64 379 pp_fx_rec(w, "tsk:" as *u8, k, v, 9) 380 v[2] = "t2" as *u8 as i64; v[8] = "second-task" as *u8 as i64 381 pp_fx_rec(w, "tsk:" as *u8, k, v, 9) 382 v[2] = "t3" as *u8 as i64; v[7] = "t2" as *u8 as i64; v[8] = "third-task" as *u8 as i64 383 pp_fx_rec(w, "tsk:" as *u8, k, v, 9) 384 k[0] = "kind" as *u8 as i64; k[1] = "plan" as *u8 as i64; k[2] = "tid" as *u8 as i64; k[3] = "date" as *u8 as i64 385 v[0] = "don" as *u8 as i64; v[1] = "t" as *u8 as i64; v[2] = "t1" as *u8 as i64; v[3] = "2026-08-27" as *u8 as i64 386 pp_fx_rec(w, "don:" as *u8, k, v, 4) 387 k[0] = "kind" as *u8 as i64; k[1] = "pid" as *u8 as i64; k[2] = "tid" as *u8 as i64; k[3] = "person" as *u8 as i64 388 k[4] = "date" as *u8 as i64; k[5] = "text" as *u8 as i64 389 v[0] = "not" as *u8 as i64; v[1] = "t" as *u8 as i64; v[2] = "t1" as *u8 as i64; v[3] = "referee" as *u8 as i64 390 v[4] = "2026-08-27" as *u8 as i64; v[5] = "FINDING: fixture-journal-entry-present" as *u8 as i64 391 pp_fx_rec(w, "not:" as *u8, k, v, 6) 392 ss_commit(pfx, w[0] as *i64, ep) 393 394 let ctr: *i64 = sys_mmap(32) as *i64 395 ctr[0] = 0 396 ctr[1] = 0 397 398 // T1 the fixture REACHED the condition (assert before outcomes) 399 let st: *i64 = pj_st_new() 400 pj_gather(pfx, "t" as *u8, st) 401 var t1: i64 = 0 402 if st[12] == 1 { if st[0] == 3 { if st[26] == 1 { t1 = 1 } } } 403 pp_check(ctr, "fixture-reached-condition (prj found, 3 tasks, 1 note)" as *u8, t1) 404 405 // T2 emit runs clean on the fixture 406 let rc: i64 = pp_emit("fixture" as *u8, pfx, "t" as *u8, rankp, outp) 407 var t2: i64 = 0 408 if rc == 0 { t2 = 1 } 409 pp_check(ctr, "emit-rc0" as *u8, t2) 410 411 // read the page back (the write receipt is a claim, the artifact is the evidence) 412 let lp: *i64 = sys_mmap(16) as *i64 413 let page: *u8 = sys_read_file(outp, lp) 414 let pn: i64 = lp[0] 415 var t3: i64 = 0 416 if (page as i64) != 0 { if pn > 1500 { t3 = 1 } } 417 pp_check(ctr, "page-written-and-substantial" as *u8, t3) 418 pp_check(ctr, "queue-row-rendered" as *u8, pp_contains(page, pn, "second-fixture-rung" as *u8)) 419 pp_check(ctr, "board-state-rendered" as *u8, pp_contains(page, pn, "READY" as *u8)) 420 pp_check(ctr, "journal-note-rendered" as *u8, pp_contains(page, pn, "fixture-journal-entry-present" as *u8)) 421 pp_check(ctr, "drift-unsynced-named" as *u8, pp_contains(page, pn, "UNSYNCED G7" as *u8)) 422 pp_check(ctr, "drift-evidence-disagree-named" as *u8, pp_contains(page, pn, "EVIDENCE-DISAGREE T1" as *u8)) 423 // T9 the partition is printed AND its parts sum in the announce (ready1 blocked1 done1 of 3) 424 pp_check(ctr, "partition-sums-1-1-1-of-3" as *u8, pp_contains(page, pn, "ready=1 blocked=1 done=1 of 3" as *u8)) 425 // neg-controls: both refusals must FIRE (a guard that has only ever passed is unverified) 426 let rc2: i64 = pp_emit("fixture" as *u8, pfx, "t" as *u8, "/tmp/ppulse-no-such-rank-file" as *u8, "-" as *u8) 427 var t10: i64 = 0 428 if rc2 == 1 { t10 = 1 } 429 pp_check(ctr, "neg-control-missing-rank-refuses" as *u8, t10) 430 let rc3: i64 = pp_emit("fixture" as *u8, "/tmp/ppulse-no-such-prefix-" as *u8, "t" as *u8, rankp, "-" as *u8) 431 var t11: i64 = 0 432 if rc3 == 1 { t11 = 1 } 433 pp_check(ctr, "neg-control-empty-plane-refuses" as *u8, t11) 434 435 pp_p("NX-PROJ-PULSE-GATE passed " as *u8) 436 pp_pn(ctr[0]) 437 pp_p("/" as *u8) 438 pp_pn(ctr[1]) 439 if ctr[0] == ctr[1] { pp_p(" verdict=GREEN\n" as *u8); return 0 } 440 pp_p(" verdict=RED\n" as *u8) 441 return 1 442} 443 444func main(argc: i64, argv: *i64) -> i64 { 445 if argc < 2 { let rc: i64 = pp_selftest(); sys_exit(rc); return rc } 446 let cmd: *u8 = argv[1] as *u8 447 if pj_eq(cmd, "emit" as *u8) == 1 { 448 if argc < 7 { pp_p("usage: nx_proj_pulse emit <dom> <prefix> <pid> <rankfile> <outpath|->\n" as *u8); sys_exit(2); return 2 } 449 let rc2: i64 = pp_emit(argv[2] as *u8, argv[3] as *u8, argv[4] as *u8, argv[5] as *u8, argv[6] as *u8) 450 sys_exit(rc2) 451 return rc2 452 } 453 pp_p("usage: nx_proj_pulse emit <dom> <prefix> <pid> <rankfile> <outpath|-> | (argless = selftest)\n" as *u8) 454 sys_exit(2) 455 return 2 456}