code wiki / _hdl_build / nx_pm_board.nx

nx_pm_board.nx source

↩ module page · 697 lines · 37707 B

1// nx_pm_board.nx -- THE PM DASHBOARD (operator 2026-07-18: "the pm to give us based on my executive, 2// management, and operations layer a dashboard and feedback ... oversight into what work is happening 3// and the return on investment ... with non fake numbers but real estimates"). 4// THREE LAYERS, all DERIVED from the sovereign planes (never asserted): 5// executive : frontier done/total + open-debt posture + sev>=7 incidents + maturity permil 6// (read from the rollup's durable log; unreadable -> -1 flagged, never invented) 7// management: per RACI lane (raci- plane): open debts / open work / ready frontier rows owned by R 8// operations: mutation activity per plane (hist row counts = provenanced writes = the real work log) 9// roi : NON-FAKE BY CONSTRUCTION -- measured counts (debts closed, work closed, frontier done, 10// plane mutations) + assumption rows from the roi- plane {id metric value basis note}; 11// derived figures computed ONLY from rows whose basis != SET-ME; SET-ME rows are emitted 12// under needs_decision (feedback TO the executive) instead of being faked. 13// nx_pm_board [frontierpfx] [debtpfx] [workpfx] [racipfx] [roipfx] -> JSON on stdout 14// Debt rows are schema-aware per row (legacy epoch 5-col sev@1 vs v2 7-col sev@2/status@3/owner@4). 15// ROI rows are schema-aware the SAME way (legacy 5-col value@2/basis@3 vs v2 6-col qty@3*cents@4/basis@5). 16// Fixed 2026-08-06 per debt 1786036195: v2 rows read on the legacy ordinals parsed the src STRING as the 17// value, so this board reported the entire ROI floor as 0 while nx_pm_cockpit read the same plane right. 18// The plane holds BOTH shapes; discriminate per row by column count, never by a global assumption. 19// Fail-closed: unseeded frontier or debt plane -> error exit (no dashboard over missing data). 20// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 21import "nx_store_seed_lib.nx" 22import "nx_seg_store.nx" 23import "nx_deploy_lib.nx" 24import "nx_syscalls.nx" 25// THE COMPARE LAYER (2026-08-31, operator: "/compare boards being complete and reevaluated for gaps by 26// nishi pm gaining that functionality"). This board reads five sovereign planes and had NO compare input 27// of any kind, so the estate's 96 published boards were invisible to the surface that decides what work 28// happens next. nx_evprofile_lib is the ONE reader of the referee's own stamp -- not a second census, not 29// a re-measurement, and emphatically not a fork of nx_swcompare_evidence per domain (that costs ~20 s a 30// board and 11 minutes for the worst one; forking it 96 times from a dashboard is a resource incident, 31// not a design). 32import "nx_evprofile_lib.nx" 33// PB_SLACK_PAGE is NOT a capacity -- the capacities below are DERIVED from their input and are strict 34// upper bounds on their own. This is one page of headroom against an off-by-one, named for that and 35// nothing else, because ONE CONSTANT SERVING TWO UNRELATED PURPOSES CAN NEVER BE TUNED FOR EITHER. 36const PB_SLACK_PAGE: i64 = 4096 37const PB_ID_PUNCT: i64 = 3 // an emitted id costs at most: open quote + close quote + separating comma 38 39const PB_CAP: i64 = 33554432 // 2026-08-06 MEASURED by nx_planefit: knowledge/store/debt- loads to 4,396,892B. At the old 1 MiB this organ silently lost 3,348,316B = 76% of the board, and because AN APPEND-ONLY PLANE PAST A PREFIX CAP LOSES ITS NEWEST ROWS FIRST it was reporting on the OLDEST quarter -- degrading exactly as new work arrived. 32 MiB matches nx_debt DB_CAP sizing. Re-verify: nx_planefit knowledge/store/debt- 33554432 40const PB_OUT: i64 = 262144 41const PB_NL: i64 = 10 42const PB_TAB: i64 = 9 43const PB_MAXCOL: i64 = 16 44const PB_PAIR: i64 = 2 45const PB_SPB: i64 = 256 46const PB_STDERR: i64 = 2 47const PB_EXIT_IO: i64 = 1 48const PB_ZERO: i64 = 48 49const PB_NINE: i64 = 57 50const PB_B10: i64 = 10 51const PB_MAXLANE: i64 = 24 52const PB_INCSEV: i64 = 7 53 54func pb_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 55func pb_werr(s: *u8) -> i64 { sys_write(PB_STDERR, s, pb_slen(s)); return 0 } 56func pb_cols(q: *u8, ls: i64, le: i64, sp: *i64) -> i64 { 57 var c: i64 = 0 58 var p: i64 = ls 59 while c < PB_MAXCOL { 60 var e: i64 = p 61 var s: i64 = 1 62 while s == 1 { if e >= le { s = 0 } else { if q[e] == (PB_TAB as u8) { s = 0 } else { e = e + 1 } } } 63 sp[c*PB_PAIR] = p 64 sp[c*PB_PAIR+1] = e 65 c = c + 1 66 if e >= le { return c } 67 p = e + 1 68 } 69 return c 70} 71func pb_int(q: *u8, a: i64, b: i64) -> i64 { 72 var v: i64 = 0 73 var i: i64 = a 74 while i < b { let c: i64 = q[i]; if c >= PB_ZERO { if c <= PB_NINE { v = v * PB_B10 + (c - PB_ZERO) } } i = i + 1 } 75 return v 76} 77func pb_sl_eq(q: *u8, a: i64, b: i64, s: *u8) -> i64 { 78 let sn: i64 = pb_slen(s) 79 if b - a != sn { return 0 } 80 var i: i64 = 0 81 while i < sn { if q[a+i] != s[i] { return 0 } i = i + 1 } 82 return 1 83} 84func pb_sl_eq2(q: *u8, a: i64, b: i64, r: *u8, c: i64, d: i64) -> i64 { 85 if b - a != d - c { return 0 } 86 var i: i64 = 0 87 while a + i < b { if q[a+i] != r[c+i] { return 0 } i = i + 1 } 88 return 1 89} 90func pb_legacy(q: *u8, ls: i64, le: i64, sp: *i64) -> i64 { 91 if pb_cols(q, ls, le, sp) < 1 { return 0 } 92 if sp[1] - sp[0] < 8 { return 0 } 93 var i: i64 = sp[0] 94 while i < sp[1] { let c: i64 = q[i]; if c < PB_ZERO { return 0 } if c > PB_NINE { return 0 } i = i + 1 } 95 return 1 96} 97func pb_lines(q: *u8, n: i64) -> i64 { var k: i64 = 0; var i: i64 = 0; while i < n { if q[i] == (PB_NL as u8) { k = k + 1 } i = i + 1 } return k } 98// raw verbatim copy (for pre-quoted lists built with literal '\x22' -- must NOT be re-escaped) 99func pb_raw(d: *u8, o: i64, q: *u8, a: i64, b: i64) -> i64 { 100 var oo: i64 = o 101 var i: i64 = a 102 while i < b { d[oo] = q[i]; oo = oo + 1; i = i + 1 } 103 return oo 104} 105func pb_esc(d: *u8, o: i64, q: *u8, a: i64, b: i64) -> i64 { 106 var oo: i64 = o 107 var i: i64 = a 108 while i < b { 109 var c: i64 = q[i] 110 if c == 34 { c = 39 } 111 if c == 92 { c = 47 } 112 if c < 32 { c = 32 } 113 d[oo] = c as u8 114 oo = oo + 1 115 i = i + 1 116 } 117 return oo 118} 119// scan the durable maturity log for " = NNN permil" -> NNN; -1 if unreadable/absent (flag, never invent) 120func pb_maturity() -> i64 { 121 let b: *u8 = sys_mmap(PB_CAP) 122 let n: i64 = dp_read("knowledge/status/ecosystem_maturity.log" as *u8, b, PB_CAP - 4) 123 if n <= 0 { return 0 - 1 } 124 // The DURABLE log writes the MACHINE shape `overall_permil=<n>`; only the human stdout writes 125 // `= <n> permil`. This reader scanned for " permil", which NEVER occurs in the log (the log has 126 // "overall_permil="), so it returned -1 forever while the rollup itself measured 434 -- the same 127 // producer/consumer format drift as the roi- ordinals below. Fixed 2026-08-06, debt 1786036195. 128 // Take the LAST match = the most recent appended run. 129 let pat: *u8 = "overall_permil=" as *u8 130 let pl: i64 = pb_slen(pat) 131 var found: i64 = 0 - 1 132 var i: i64 = 0 133 while i + pl <= n { 134 var hit: i64 = 1 135 var j: i64 = 0 136 while j < pl { if b[i+j] != pat[j] { hit = 0; j = pl } else { j = j + 1 } } 137 if hit == 1 { found = i + pl } 138 i = i + 1 139 } 140 if found < 0 { return 0 - 1 } 141 var e: i64 = found 142 var sc: i64 = 1 143 while sc == 1 { 144 if e >= n { sc = 0 } else { 145 let c: i64 = b[e] 146 if c >= PB_ZERO { if c <= PB_NINE { e = e + 1 } else { sc = 0 } } else { sc = 0 } 147 } 148 } 149 if e == found { return 0 - 1 } 150 return pb_int(b, found, e) 151} 152 153// ---- THE COMPARE LAYER: re-evaluate every published board for gaps, from one artifact each ---- 154// POPULATION = THE EMITTER'S OWN SSOT. regen.list is the list nx_compare_regen actually emits from, so 155// this board and the generator cannot disagree about which domains exist. A domain that has a .matrix but 156// is missing from regen.list is the ORPHAN class the regen already censuses; it is not this reader's job 157// to invent a second population, and inventing one is how two counters of the same thing come to differ. 158// The source is PRINTED beside the count, because a population you cannot name is a number nobody can check. 159const PB_CMP_LIST: *u8 = "buildroot/knowledge/compare/regen.list" 160const PB_CMP_LISTCAP: i64 = 262144 // regen.list measures under 1 KB; brim ANNOUNCES rather than truncating 161const PB_CMP_PATHCAP: i64 = 512 162const PB_CMP_DOMCAP: i64 = 128 163const PB_CMP_BUCKETS: i64 = 11 164// Bucket ordinals. SEPARATE LISTS, NEVER ONE MERGED SCORE: claim_only needs a gate WRITTEN and 165// gate_failing needs a gate FIXED, and a single "not honest" number sends a seat at the wrong work in 166// most measured cases. A bucket named for how the reader failed rather than for what the subject IS 167// merges a real failure with a healthy pass. 168// 169// TWO OF THESE BUCKETS WERE MISNAMED AND WERE RENAMED 2026-08-31 AFTER RE-DERIVING BOTH CLAIMS: 170// * gate_failing FOLDED ABSTENTIONS INTO FAILURES. The referee counts a SKIPped gate inside ran and 171// outside green -- its own source says `gates that ABSTAINED (exit EV_RC_SKIP): counted, never 172// convicted` -- so the old `green < ran` test convicted every board that merely abstained. Live 173// witness: smallos stamps `gates=1/3 skipped=2 ... conj=GPQN`, i.e. ZERO failing gates and quorum 174// HELD, and it was published under gate_failing anyway. Now split three ways, because FIX A GATE, 175// READ WHY IT ABSTAINED and GO LOOK BECAUSE THE STAMP CANNOT SAY are three different jobs. 176// * fabricated MEASURED A STALE POINTER, NOT INVENTED EVIDENCE. Every adjudicated instance was a 177// symbol that had moved into a shared lib, or a row naming the CALLER instead of the DEFINER. 178// NAME A BUCKET FOR WHAT WAS MEASURED, NEVER FOR THE STORY YOU IMAGINE BEHIND IT -- the old name 179// accused a seat of fraud for a broken pointer. Both sibling consumers of the same predicate 180// (nx_swcompare_matrix, nx_swcompare_lib) already rendered it as UNSUPPORTED-CLAIM, and the totals 181// object below already emitted the identical quantity as ungrounded_claims: the estate had 182// converged on the honest name and this board was the lone dissenter. 183const PB_CB_CLAIM: i64 = 0 // gates_ran == 0 -> WRITE a .gates map for this domain 184const PB_CB_GATEFAIL: i64 = 1 // ran-green-skipped > 0 -> FIX the gate the map already names 185const PB_CB_UNGROUNDED: i64 = 2 // ungrounded > 0 -> REPOINT a row whose symbol is absent 186const PB_CB_FLIP: i64 = 3 // landed > 0 -> free: a pure data edit flips the cell 187const PB_CB_UNNAMED: i64 = 4 // absent_bare > 0 -> a gap that names no build contract 188const PB_CB_VACUOUS: i64 = 5 // vacuous > 0 -> a GREEN on a zero denominator 189const PB_CB_STALE: i64 = 6 // epoch older than the evidence TTL 190const PB_CB_LEAK: i64 = 7 // the stamp's AXIS partition does not sum 191const PB_CB_GATESKIP: i64 = 8 // skipped > 0 -> a gate ABSTAINED: READ why, do not fix 192const PB_CB_GATEUNK: i64 = 9 // green<ran, skipped absent -> the stamp cannot say which; go look 193const PB_CB_GATELEAK: i64 = 10 // the stamp's GATE partition does not sum (green+skipped > ran) 194 195func pb_cmp_push(b: *u8, off: *i64, cnt: *i64, k: i64, slice: i64, dom: *u8) -> i64 { 196 let base: i64 = k * slice 197 if cnt[k] > 0 { b[base + off[k]] = 44 as u8; off[k] = off[k] + 1 } 198 b[base + off[k]] = 34 as u8 199 off[k] = off[k] + 1 200 var i: i64 = 0 201 while dom[i] != (0 as u8) { b[base + off[k]] = dom[i]; off[k] = off[k] + 1; i = i + 1 } 202 b[base + off[k]] = 34 as u8 203 off[k] = off[k] + 1 204 cnt[k] = cnt[k] + 1 205 return 0 206} 207 208func pb_cmp_emit(out: *u8, o0: i64, key: *u8, b: *u8, off: *i64, k: i64, slice: i64) -> i64 { 209 var o: i64 = ss_cat(out, o0, ",\x22" as *u8) 210 o = ss_cat(out, o, key) 211 o = ss_cat(out, o, "\x22:[" as *u8) 212 o = pb_raw(out, o, b, k * slice, k * slice + off[k]) 213 o = ss_cat(out, o, "]" as *u8) 214 return o 215} 216 217func pb_compare(out: *u8, o0: i64) -> i64 { 218 var o: i64 = o0 219 let lp: *u8 = sys_mmap(PB_CMP_PATHCAP) 220 let lb: *u8 = sys_mmap(PB_CMP_LISTCAP) 221 var ln: i64 = 0 222 var found: i64 = 0 223 if ep_artifact_path(lp, PB_CMP_LIST) == 1 { found = 1; ln = evp_read(lp, lb, PB_CMP_LISTCAP) } 224 if ln < 0 { ln = 0 } 225 // FAIL-CLOSED AND SAY SO. An unreadable population is not an empty one, and a board that renders 226 // zero boards because it could not find its list would read as "nothing to do here". 227 if found == 0 { 228 return ss_cat(out, o, ",\x22compare\x22:{\x22population_src\x22:\x22UNRESOLVED\x22,\x22boards_total\x22:-1,\x22note\x22:\x22regen.list did not resolve from this working directory -- no compare gap board is available, and that is reported rather than rendered as zero gaps\x22}" as *u8) 229 } 230 // DERIVED CAPACITY, NOT A GUESSED ONE: a domain id is a disjoint substring of the list, so all ids 231 // together total at most ln, plus at most PB_ID_PUNCT punctuation bytes per line. One slice of that 232 // size per bucket is a strict upper bound no input can cross. 233 let slice: i64 = ln + PB_ID_PUNCT * pb_lines(lb, ln) + PB_SLACK_PAGE 234 let cb: *u8 = sys_mmap(slice * PB_CMP_BUCKETS) 235 let coff: *i64 = sys_mmap(8 * PB_CMP_BUCKETS) as *i64 236 let ccnt: *i64 = sys_mmap(8 * PB_CMP_BUCKETS) as *i64 237 var z: i64 = 0 238 while z < PB_CMP_BUCKETS { coff[z] = 0; ccnt[z] = 0; z = z + 1 } 239 240 let dom: *u8 = sys_mmap(PB_CMP_DOMCAP) 241 let sb: *u8 = sys_mmap(EVP_STAMP_CAP) 242 let sp2: *u8 = sys_mmap(PB_CMP_PATHCAP) 243 let fl: *i64 = sys_mmap(8 * EVP_NFLAG) as *i64 244 let f: *i64 = sys_mmap(8 * EVP_NF) as *i64 245 let now: i64 = sys_now_realtime_sec() 246 let ttl: i64 = evp_ttl_sec() 247 248 var total: i64 = 0 249 var stamped: i64 = 0 250 var unstamped: i64 = 0 251 var ambiguous: i64 = 0 252 var v2: i64 = 0 253 var v1only: i64 = 0 254 var t_land: i64 = 0 255 var t_bare: i64 = 0 256 var t_ung: i64 = 0 257 var t_vac: i64 = 0 258 var t_capped: i64 = 0 259 // THE GATE PARTITION, ACCUMULATED ACROSS EVERY STAMPED BOARD: green + skipped + failing + 260 // unresolved == ran, and it is PRINTED with a reconciles flag rather than asserted. `unresolved` 261 // is what keeps it summing: a stamp too old to carry ` skipped=` contributes its non-green gates 262 // THERE instead of silently vanishing from the total or being convicted as failures. 263 var t_ran: i64 = 0 264 var t_green: i64 = 0 265 var t_skip: i64 = 0 266 var t_fail: i64 = 0 267 var t_unres: i64 = 0 268 269 var i: i64 = 0 270 while i < ln { 271 var e: i64 = i 272 var s1: i64 = 1 273 while s1 == 1 { if e >= ln { s1 = 0 } else { if lb[e] == (PB_NL as u8) { s1 = 0 } else { e = e + 1 } } } 274 if e > i { 275 var t: i64 = 0 276 var p: i64 = i 277 while p < e { if t < PB_CMP_DOMCAP - 1 { dom[t] = lb[p]; t = t + 1 } p = p + 1 } 278 dom[t] = 0 as u8 279 if dom[0] != (35 as u8) { if dom[0] != (59 as u8) { 280 total = total + 1 281 let n: i64 = evp_load(dom, sb, EVP_STAMP_CAP, sp2, fl) 282 if n == EVP_RC_AMBIGUOUS { ambiguous = ambiguous + 1; unstamped = unstamped + 1 } else { 283 if n <= 0 { unstamped = unstamped + 1 } else { 284 stamped = stamped + 1 285 evp_parse(sb, n, f) 286 if f[EVP_F_V] == 2 { v2 = v2 + 1 } else { v1only = v1only + 1 } 287 if evp_claim_only(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_CLAIM, slice, dom) } 288 // THE SPLIT. A gate that FAILED, a gate that ABSTAINED, and a gate whose outcome 289 // this stamp cannot resolve are three buckets because they are three different 290 // jobs. Folded together, this board named boards with ZERO failing gates failing. 291 if evp_gate_failing(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_GATEFAIL, slice, dom) } 292 if evp_gate_skipped(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_GATESKIP, slice, dom) } 293 if evp_gate_unknown(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_GATEUNK, slice, dom) } 294 if evp_gates_reconcile(f) == 0 { pb_cmp_push(cb, coff, ccnt, PB_CB_GATELEAK, slice, dom) } 295 if evp_stale(f, now, ttl) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_STALE, slice, dom) } 296 // GATE TOTALS, accumulated OUTSIDE the v2 guard ON PURPOSE: gates= and skipped= 297 // are v1 keys that every stamped board carries. Each leg is guarded so an ABSENT 298 // field (-1) contributes nothing rather than subtracting one. 299 if f[EVP_F_RAN] > 0 { t_ran = t_ran + f[EVP_F_RAN] } 300 if f[EVP_F_GREEN] > 0 { t_green = t_green + f[EVP_F_GREEN] } 301 if f[EVP_F_SKIPPED] > 0 { t_skip = t_skip + f[EVP_F_SKIPPED] } 302 if evp_gate_failing_n(f) > 0 { t_fail = t_fail + evp_gate_failing_n(f) } 303 if evp_gate_unknown(f) == 1 { t_unres = t_unres + (f[EVP_F_RAN] - f[EVP_F_GREEN]) } 304 // THE PROFILE BUCKETS ONLY EXIST FOR A v2 STAMP. A v1 stamp measured none of this, and 305 // reading -1 as "zero gaps" would publish a clean board for a domain nobody profiled. 306 if f[EVP_F_V] == 2 { 307 if evp_ungrounded_claim(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_UNGROUNDED, slice, dom) } 308 if evp_flip_ready(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_FLIP, slice, dom) } 309 if evp_unnamed_gap(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_UNNAMED, slice, dom) } 310 if evp_vacuous_gate(f) == 1 { pb_cmp_push(cb, coff, ccnt, PB_CB_VACUOUS, slice, dom) } 311 if evp_reconciles(f) == 0 { pb_cmp_push(cb, coff, ccnt, PB_CB_LEAK, slice, dom) } 312 if f[EVP_F_LANDED] > 0 { t_land = t_land + f[EVP_F_LANDED] } 313 if f[EVP_F_ABSBARE] > 0 { t_bare = t_bare + f[EVP_F_ABSBARE] } 314 if f[EVP_F_UNGROUND] > 0 { t_ung = t_ung + f[EVP_F_UNGROUND] } 315 if f[EVP_F_VACUOUS] > 0 { t_vac = t_vac + f[EVP_F_VACUOUS] } 316 if f[EVP_F_MCAPPED] == 1 { t_capped = t_capped + 1 } 317 } 318 } } 319 } } 320 } 321 i = e + 1 322 } 323 324 o = ss_cat(out, o, ",\x22compare\x22:{\x22population_src\x22:\x22" as *u8) 325 o = ss_cat(out, o, PB_CMP_LIST) 326 o = ss_cat(out, o, "\x22,\x22boards_total\x22:" as *u8) 327 o = ss_catn(out, o, total) 328 o = ss_cat(out, o, ",\x22boards_stamped\x22:" as *u8) 329 o = ss_catn(out, o, stamped) 330 o = ss_cat(out, o, ",\x22boards_unstamped\x22:" as *u8) 331 o = ss_catn(out, o, unstamped) 332 o = ss_cat(out, o, ",\x22boards_ambiguous_stamp\x22:" as *u8) 333 o = ss_catn(out, o, ambiguous) 334 // THE PARTITION IS PRINTED AND CHECKED, never asserted: stamped + unstamped must equal total, and an 335 // unexplained residual is a leak while an explained one is a decision. 336 o = ss_cat(out, o, ",\x22reconciles\x22:" as *u8) 337 if stamped + unstamped == total { o = ss_cat(out, o, "true" as *u8) } else { o = ss_cat(out, o, "false" as *u8) } 338 o = ss_cat(out, o, ",\x22profile_v2\x22:" as *u8) 339 o = ss_catn(out, o, v2) 340 o = ss_cat(out, o, ",\x22profile_v1_only\x22:" as *u8) 341 o = ss_catn(out, o, v1only) 342 o = ss_cat(out, o, ",\x22matrix_read_capped\x22:" as *u8) 343 o = ss_catn(out, o, t_capped) 344 o = ss_cat(out, o, ",\x22totals\x22:{\x22landed_flips\x22:" as *u8) 345 o = ss_catn(out, o, t_land) 346 o = ss_cat(out, o, ",\x22unnamed_gap_axes\x22:" as *u8) 347 o = ss_catn(out, o, t_bare) 348 o = ss_cat(out, o, ",\x22ungrounded_claims\x22:" as *u8) 349 o = ss_catn(out, o, t_ung) 350 o = ss_cat(out, o, ",\x22vacuous_gates\x22:" as *u8) 351 o = ss_catn(out, o, t_vac) 352 // THE GATE PARTITION, PRINTED AND CHECKED RATHER THAN ASSERTED: 353 // green + skipped + failing + unresolved == ran 354 // It sums in EVERY case by construction of the four legs. A current stamp puts its non-green 355 // gates into skipped and failing; a stamp too old to carry ` skipped=` puts them into 356 // unresolved, so nothing is dropped and nothing is convicted on evidence that does not exist. 357 // THIS IS THE ARITHMETIC THAT THE OLD SINGLE gate_failing BUCKET COULD NOT STATE, because it had 358 // folded two of these four legs into one and had no name for the third. 359 o = ss_cat(out, o, ",\x22gates_ran\x22:" as *u8) 360 o = ss_catn(out, o, t_ran) 361 o = ss_cat(out, o, ",\x22gates_green\x22:" as *u8) 362 o = ss_catn(out, o, t_green) 363 o = ss_cat(out, o, ",\x22gates_skipped\x22:" as *u8) 364 o = ss_catn(out, o, t_skip) 365 o = ss_cat(out, o, ",\x22gates_failing\x22:" as *u8) 366 o = ss_catn(out, o, t_fail) 367 o = ss_cat(out, o, ",\x22gates_unresolved\x22:" as *u8) 368 o = ss_catn(out, o, t_unres) 369 o = ss_cat(out, o, ",\x22gates_reconcile\x22:" as *u8) 370 if t_green + t_skip + t_fail + t_unres == t_ran { o = ss_cat(out, o, "true" as *u8) } else { o = ss_cat(out, o, "false" as *u8) } 371 o = ss_cat(out, o, "}" as *u8) 372 // EVERY BUCKET IS AN ID LIST, NEVER A COUNT ALONE. A count without a worklist is not actionable. 373 // NAMES CHANGED 2026-08-31 (see the bucket ordinals above for the measurement behind each): 374 // fabricated -> ungrounded_claims (it measured a STALE POINTER, not invented evidence, and 375 // the totals object beside it already used this name) 376 // gate_failing -> gate_failing + gate_skipped + gate_status_unknown 377 // (an ABSTENTION is not a FAILURE) 378 // Consumer census before renaming, nx_absent over buildroot/runtime with coverage_complete=1 AND 379 // corpus_complete=1: the quoted JSON keys `fabricated\x22` and `gate_failing\x22` are 380 // ABSENT-PROVEN -- NOT ONE reader of this board's output parses either key, so the rename breaks 381 // no contract. The LIB predicate evp_fabricated does have two callers outside this lane and is 382 // therefore kept as a delegating alias rather than renamed; the two decisions differ because the 383 // evidence differs. 384 o = pb_cmp_emit(out, o, "claim_only" as *u8, cb, coff, PB_CB_CLAIM, slice) 385 o = pb_cmp_emit(out, o, "gate_failing" as *u8, cb, coff, PB_CB_GATEFAIL, slice) 386 o = pb_cmp_emit(out, o, "gate_skipped" as *u8, cb, coff, PB_CB_GATESKIP, slice) 387 o = pb_cmp_emit(out, o, "gate_status_unknown" as *u8, cb, coff, PB_CB_GATEUNK, slice) 388 o = pb_cmp_emit(out, o, "ungrounded_claims" as *u8, cb, coff, PB_CB_UNGROUNDED, slice) 389 o = pb_cmp_emit(out, o, "flip_ready" as *u8, cb, coff, PB_CB_FLIP, slice) 390 o = pb_cmp_emit(out, o, "unnamed_gaps" as *u8, cb, coff, PB_CB_UNNAMED, slice) 391 o = pb_cmp_emit(out, o, "vacuous_gates" as *u8, cb, coff, PB_CB_VACUOUS, slice) 392 o = pb_cmp_emit(out, o, "stale" as *u8, cb, coff, PB_CB_STALE, slice) 393 o = pb_cmp_emit(out, o, "partition_leak" as *u8, cb, coff, PB_CB_LEAK, slice) 394 o = pb_cmp_emit(out, o, "gate_partition_leak" as *u8, cb, coff, PB_CB_GATELEAK, slice) 395 o = ss_cat(out, o, "}" as *u8) 396 return o 397} 398 399func main(argc: i64, argv: *i64) -> i64 { 400 var fpx: *u8 = "knowledge/store/frontier-" as *u8 401 var dpx: *u8 = "knowledge/store/debt-" as *u8 402 var wpx: *u8 = "knowledge/store/work-" as *u8 403 var rpx: *u8 = "knowledge/store/raci-" as *u8 404 var opx: *u8 = "knowledge/store/roi-" as *u8 405 if argc > 1 { fpx = argv[1] as *u8 } 406 if argc > 2 { dpx = argv[2] as *u8 } 407 if argc > 3 { wpx = argv[3] as *u8 } 408 if argc > 4 { rpx = argv[4] as *u8 } 409 if argc > 5 { opx = argv[5] as *u8 } 410 411 // SELF-SIZING READS (2026-08-06). All FOUR planes were read through a fixed 1 MiB PB_CAP while 412 // knowledge/store/debt- alone measured 4,419,932B -- so this board was assembled from a PREFIX of 413 // its own inputs. And because AN APPEND-ONLY PLANE PAST A PREFIX CAP LOSES ITS NEWEST ROWS FIRST, 414 // it silently omitted the most recent work it exists to display. Measured on the sibling organ 415 // nx_dora the same day: incident_open_debts 261 -> 545 once the cap was removed. 416 // sts_load_fit chooses no number -- it grows until the read comes back STRICTLY SHORT, which is 417 // what proves completeness. ★A CAP THAT CAN BE CROSSED IN SILENCE WILL BE CROSSED AGAIN. 418 // FAIL-CLOSED: a refusal is null/-1 and is treated as no-data, never as a partial board. 419 let flen: *i64 = sys_mmap(16) as *i64 420 let fb: *u8 = sts_load_fit(fpx, flen) 421 let fn: i64 = flen[0] 422 if (fb as i64) == 0 { pb_werr("frontier plane UNREADABLE (fail-closed)\n" as *u8); sys_exit(PB_EXIT_IO); return PB_EXIT_IO } 423 if fn <= 0 { pb_werr("frontier plane unseeded (fail-closed)\n" as *u8); sys_exit(PB_EXIT_IO); return PB_EXIT_IO } 424 let dlen: *i64 = sys_mmap(16) as *i64 425 let db: *u8 = sts_load_fit(dpx, dlen) 426 let dn: i64 = dlen[0] 427 if (db as i64) == 0 { pb_werr("debt plane UNREADABLE (fail-closed)\n" as *u8); sys_exit(PB_EXIT_IO); return PB_EXIT_IO } 428 if dn <= 0 { pb_werr("debt plane unseeded (fail-closed)\n" as *u8); sys_exit(PB_EXIT_IO); return PB_EXIT_IO } 429 let wlen: *i64 = sys_mmap(16) as *i64 430 let wb: *u8 = sts_load_fit(wpx, wlen) 431 var wn: i64 = wlen[0] 432 if (wb as i64) == 0 { wn = 0 } 433 if wn < 0 { wn = 0 } 434 let rlen: *i64 = sys_mmap(16) as *i64 435 let rb: *u8 = sts_load_fit(rpx, rlen) 436 var rn: i64 = rlen[0] 437 if (rb as i64) == 0 { rn = 0 } 438 if rn < 0 { rn = 0 } 439 let ob: *u8 = sys_mmap(PB_CAP) 440 var on: i64 = sts_load(opx, ob, PB_CAP) 441 if on < 0 { on = 0 } 442 let sp: *i64 = sys_mmap(PB_SPB) as *i64 443 let out: *u8 = sys_mmap(PB_OUT) 444 445 // ---- frontier tallies (9-col: status col5, owner col4) 446 var ftot: i64 = 0 447 var fdone: i64 = 0 448 var i: i64 = 0 449 while i < fn { 450 var le: i64 = i 451 var s: i64 = 1 452 while s == 1 { if le >= fn { s = 0 } else { if fb[le] == (PB_NL as u8) { s = 0 } else { le = le + 1 } } } 453 if le > i { if pb_cols(fb, i, le, sp) >= 6 { 454 ftot = ftot + 1 455 if pb_sl_eq(fb, sp[10], sp[11], "D" as *u8) == 1 { fdone = fdone + 1 } 456 } } 457 i = le + 1 458 } 459 // ---- debt tallies (schema-aware) + incidents (open sev>=7) collected as id list 460 var dtot: i64 = 0 461 var dopen: i64 = 0 462 var dclosed: i64 = 0 463 var inc_o: i64 = 0 464 // 2026-08-16 ROOT CAUSE OF THE ZERO-BYTE BOARD (debt 1786917860). This was a FIXED 4,096-byte page 465 // while the id list it collects grows with the plane: at the estate's own measured 466 // incidents_sev7=938 it needs 938*13 = 12,194 B, a 3x overflow with no bounds check. 467 // ★THE FAILURE IS TOTAL, NOT PARTIAL: this organ builds the whole document in memory and does ONE 468 // sys_write at the very end, so a fault emits ZERO BYTES. It therefore reads as "the tool produced 469 // nothing" rather than "a buffer overran", and it survived for a long time because an overflow 470 // lands on whatever mmap put next -- it works until the neighbouring page is not mapped, which is 471 // why it broke with NO code change and a byte-identical binary. 472 // ★DERIVED, NOT RAISED: every byte written here is either an id byte -- and ids are disjoint 473 // substrings of db, so they total at most dn -- or at most PB_ID_PUNCT punctuation bytes per 474 // incident, and there is at most one incident per line. dn + PB_ID_PUNCT*lines is therefore a 475 // STRICT upper bound no input can cross. Raising a guessed ceiling would only move the guess. 476 let incb: *u8 = sys_mmap(dn + PB_ID_PUNCT * pb_lines(db, dn) + PB_SLACK_PAGE) 477 var ninc: i64 = 0 478 i = 0 479 while i < dn { 480 var le2: i64 = i 481 var s2: i64 = 1 482 while s2 == 1 { if le2 >= dn { s2 = 0 } else { if db[le2] == (PB_NL as u8) { s2 = 0 } else { le2 = le2 + 1 } } } 483 if le2 > i { 484 let nc: i64 = pb_cols(db, i, le2, sp) 485 if nc >= 4 { 486 dtot = dtot + 1 487 var sevcol: i64 = 2 488 if pb_legacy(db, i, le2, sp) == 1 { sevcol = 1 } 489 pb_cols(db, i, le2, sp) 490 var isopen: i64 = 0 491 if pb_sl_eq(db, sp[6], sp[7], "open" as *u8) == 1 { isopen = 1 } 492 if isopen == 1 { dopen = dopen + 1 } else { dclosed = dclosed + 1 } 493 if isopen == 1 { 494 let sev: i64 = pb_int(db, sp[sevcol*PB_PAIR], sp[sevcol*PB_PAIR+1]) 495 if sev >= PB_INCSEV { 496 if ninc > 0 { incb[inc_o] = 44 as u8; inc_o = inc_o + 1 } 497 incb[inc_o] = 34 as u8 498 inc_o = inc_o + 1 499 inc_o = pb_esc(incb, inc_o, db, sp[0], sp[1]) 500 incb[inc_o] = 34 as u8 501 inc_o = inc_o + 1 502 ninc = ninc + 1 503 } 504 } 505 } 506 } 507 i = le2 + 1 508 } 509 // ---- work tallies (7-col: status col3) 510 var wtot: i64 = 0 511 var wopen: i64 = 0 512 var wclosed: i64 = 0 513 i = 0 514 while i < wn { 515 var le3: i64 = i 516 var s3: i64 = 1 517 while s3 == 1 { if le3 >= wn { s3 = 0 } else { if wb[le3] == (PB_NL as u8) { s3 = 0 } else { le3 = le3 + 1 } } } 518 if le3 > i { if pb_cols(wb, i, le3, sp) >= 4 { 519 wtot = wtot + 1 520 if pb_sl_eq(wb, sp[6], sp[7], "open" as *u8) == 1 { wopen = wopen + 1 } else { wclosed = wclosed + 1 } 521 } } 522 i = le3 + 1 523 } 524 // ---- hist activity (operations layer): line counts of the mutation ledgers 525 let hb: *u8 = sys_mmap(PB_CAP) 526 let hp: *u8 = sys_mmap(256) 527 var n0: i64 = pb_slen(dpx) 528 if n0 > 0 { if dpx[n0-1] == (45 as u8) { n0 = n0 - 1 } } 529 var hh: i64 = 0 530 var t: i64 = 0 531 while t < n0 { hp[t] = dpx[t]; t = t + 1 } 532 var ho: i64 = ss_cat(hp, n0, "hist-" as *u8) 533 hp[ho] = 0 as u8 534 var dhn: i64 = sts_load(hp, hb, PB_CAP) 535 if dhn < 0 { dhn = 0 } 536 let dmut: i64 = pb_lines(hb, dhn) 537 n0 = pb_slen(wpx) 538 if n0 > 0 { if wpx[n0-1] == (45 as u8) { n0 = n0 - 1 } } 539 t = 0 540 while t < n0 { hp[t] = wpx[t]; t = t + 1 } 541 ho = ss_cat(hp, n0, "hist-" as *u8) 542 hp[ho] = 0 as u8 543 var whn: i64 = sts_load(hp, hb, PB_CAP) 544 if whn < 0 { whn = 0 } 545 let wmut: i64 = pb_lines(hb, whn) 546 if hh == 0 { hh = 0 } 547 // ---- maturity from the durable instrument log (never invented) 548 let mat: i64 = pb_maturity() 549 550 // ---- emit 551 var o: i64 = 0 552 o = ss_cat(out, o, "{\x22pm_board\x22:\x22v1\x22,\x22executive\x22:{\x22frontier_done\x22:" as *u8) 553 o = ss_catn(out, o, fdone) 554 o = ss_cat(out, o, ",\x22frontier_total\x22:" as *u8) 555 o = ss_catn(out, o, ftot) 556 o = ss_cat(out, o, ",\x22debts_open\x22:" as *u8) 557 o = ss_catn(out, o, dopen) 558 o = ss_cat(out, o, ",\x22debts_closed\x22:" as *u8) 559 o = ss_catn(out, o, dclosed) 560 o = ss_cat(out, o, ",\x22maturity_permil\x22:" as *u8) 561 if mat < 0 { o = ss_cat(out, o, "-1,\x22maturity_note\x22:\x22instrument log unreadable here -- run nx_ecosystem_maturity_rollup\x22" as *u8) } else { o = ss_catn(out, o, mat) } 562 o = ss_cat(out, o, ",\x22incidents_sev7plus\x22:[" as *u8) 563 o = pb_raw(out, o, incb, 0, inc_o) 564 o = ss_cat(out, o, "]},\x22management\x22:[" as *u8) 565 // per raci lane: {lane,R,debts_open,work_open} 566 var nlane: i64 = 0 567 i = 0 568 while i < rn { 569 var le4: i64 = i 570 var s4: i64 = 1 571 while s4 == 1 { if le4 >= rn { s4 = 0 } else { if rb[le4] == (PB_NL as u8) { s4 = 0 } else { le4 = le4 + 1 } } } 572 if le4 > i { if nlane < PB_MAXLANE { if pb_cols(rb, i, le4, sp) >= 2 { 573 let la: i64 = sp[0] 574 let lb2: i64 = sp[1] 575 let ra: i64 = sp[2] 576 let rb2: i64 = sp[3] 577 // count open debts + open work owned by R (owner col4 both planes) 578 var cd: i64 = 0 579 var cw: i64 = 0 580 var j2: i64 = 0 581 let spd: *i64 = sys_mmap(PB_SPB) as *i64 582 while j2 < dn { 583 var led: i64 = j2 584 var sd: i64 = 1 585 while sd == 1 { if led >= dn { sd = 0 } else { if db[led] == (PB_NL as u8) { sd = 0 } else { led = led + 1 } } } 586 if led > j2 { if pb_cols(db, j2, led, spd) >= 5 { 587 if pb_sl_eq(db, spd[6], spd[7], "open" as *u8) == 1 { if pb_sl_eq2(db, spd[8], spd[9], rb, ra, rb2) == 1 { cd = cd + 1 } } 588 } } 589 j2 = led + 1 590 } 591 j2 = 0 592 while j2 < wn { 593 var lew: i64 = j2 594 var sw: i64 = 1 595 while sw == 1 { if lew >= wn { sw = 0 } else { if wb[lew] == (PB_NL as u8) { sw = 0 } else { lew = lew + 1 } } } 596 if lew > j2 { if pb_cols(wb, j2, lew, spd) >= 5 { 597 if pb_sl_eq(wb, spd[6], spd[7], "open" as *u8) == 1 { if pb_sl_eq2(wb, spd[8], spd[9], rb, ra, rb2) == 1 { cw = cw + 1 } } 598 } } 599 j2 = lew + 1 600 } 601 if nlane > 0 { out[o] = 44 as u8; o = o + 1 } 602 o = ss_cat(out, o, "{\x22lane\x22:\x22" as *u8) 603 o = pb_esc(out, o, rb, la, lb2) 604 o = ss_cat(out, o, "\x22,\x22r\x22:\x22" as *u8) 605 o = pb_esc(out, o, rb, ra, rb2) 606 o = ss_cat(out, o, "\x22,\x22debts_open\x22:" as *u8) 607 o = ss_catn(out, o, cd) 608 o = ss_cat(out, o, ",\x22work_open\x22:" as *u8) 609 o = ss_catn(out, o, cw) 610 o = ss_cat(out, o, "}" as *u8) 611 nlane = nlane + 1 612 } } } 613 i = le4 + 1 614 } 615 o = ss_cat(out, o, "],\x22operations\x22:{\x22debt_mutations\x22:" as *u8) 616 o = ss_catn(out, o, dmut) 617 o = ss_cat(out, o, ",\x22work_mutations\x22:" as *u8) 618 o = ss_catn(out, o, wmut) 619 o = ss_cat(out, o, ",\x22work_open\x22:" as *u8) 620 o = ss_catn(out, o, wopen) 621 o = ss_cat(out, o, ",\x22work_closed\x22:" as *u8) 622 o = ss_catn(out, o, wclosed) 623 o = ss_cat(out, o, "},\x22roi\x22:{\x22measured\x22:{\x22debts_closed\x22:" as *u8) 624 o = ss_catn(out, o, dclosed) 625 o = ss_cat(out, o, ",\x22work_closed\x22:" as *u8) 626 o = ss_catn(out, o, wclosed) 627 o = ss_cat(out, o, ",\x22frontier_done\x22:" as *u8) 628 o = ss_catn(out, o, fdone) 629 o = ss_cat(out, o, ",\x22plane_mutations\x22:" as *u8) 630 o = ss_catn(out, o, dmut + wmut) 631 o = ss_cat(out, o, "},\x22assumptions\x22:[" as *u8) 632 // roi- rows: id metric value basis note; derived only from basis != SET-ME 633 var na: i64 = 0 634 var derived_min: i64 = 0 - 1 635 var need_o: i64 = 0 636 // SAME DEFECT, SAME REMEDY -- the SET-ME id list was the identical fixed page. A FIX THAT LIVES IN 637 // ONE SITE AND NOT ITS SIBLING IS HALF A FIX, AND THE MISSING HALF IS INVISIBLE UNTIL SOMETHING 638 // RUNS IT: this one is latent only because the roi- plane is small today. 639 let needb: *u8 = sys_mmap(on + PB_ID_PUNCT * pb_lines(ob, on) + PB_SLACK_PAGE) 640 var nneed: i64 = 0 641 i = 0 642 while i < on { 643 var le5: i64 = i 644 var s5: i64 = 1 645 while s5 == 1 { if le5 >= on { s5 = 0 } else { if ob[le5] == (PB_NL as u8) { s5 = 0 } else { le5 = le5 + 1 } } } 646 if le5 > i { let rc5: i64 = pb_cols(ob, i, le5, sp) 647 if rc5 >= 4 { 648 // roi- rows are schema-aware PER ROW, exactly as the debt reader above is: 649 // legacy 5-col id|metric|value|basis|note -> value@2 basis@3 650 // v2 6-col id|metric|src|qty|cents|basis -> value=qty*cents basis@5 651 // Reading v2 rows on the legacy ordinals parsed the src STRING as the value (-> 0) 652 // and reported qty as the basis, so every v2 row showed as worthless. 653 var vb: i64 = sp[6] 654 var ve: i64 = sp[7] 655 var vv: i64 = pb_int(ob, sp[4], sp[5]) 656 if rc5 >= 6 { vv = pb_int(ob, sp[6], sp[7]) * pb_int(ob, sp[8], sp[9]); vb = sp[10]; ve = sp[11] } 657 if na > 0 { out[o] = 44 as u8; o = o + 1 } 658 o = ss_cat(out, o, "{\x22id\x22:\x22" as *u8) 659 o = pb_esc(out, o, ob, sp[0], sp[1]) 660 o = ss_cat(out, o, "\x22,\x22metric\x22:\x22" as *u8) 661 o = pb_esc(out, o, ob, sp[2], sp[3]) 662 o = ss_cat(out, o, "\x22,\x22value\x22:" as *u8) 663 o = ss_catn(out, o, vv) 664 o = ss_cat(out, o, ",\x22basis\x22:\x22" as *u8) 665 o = pb_esc(out, o, ob, vb, ve) 666 o = ss_cat(out, o, "\x22}" as *u8) 667 na = na + 1 668 if pb_sl_eq(ob, vb, ve, "SET-ME" as *u8) == 1 { 669 if nneed > 0 { needb[need_o] = 44 as u8; need_o = need_o + 1 } 670 needb[need_o] = 34 as u8 671 need_o = need_o + 1 672 need_o = pb_esc(needb, need_o, ob, sp[0], sp[1]) 673 needb[need_o] = 34 as u8 674 need_o = need_o + 1 675 nneed = nneed + 1 676 } else { 677 if pb_sl_eq(ob, sp[2], sp[3], "manual_minutes_per_debt" as *u8) == 1 { 678 derived_min = dclosed * vv 679 } 680 } 681 } } 682 i = le5 + 1 683 } 684 o = ss_cat(out, o, "],\x22derived\x22:{\x22est_minutes_saved_debt_eating\x22:" as *u8) 685 if derived_min < 0 { o = ss_cat(out, o, "\x22AWAITING-ASSUMPTION\x22" as *u8) } else { o = ss_catn(out, o, derived_min) } 686 o = ss_cat(out, o, "},\x22needs_decision\x22:[" as *u8) 687 o = pb_raw(out, o, needb, 0, need_o) 688 o = ss_cat(out, o, "]}" as *u8) 689 // the roi object is closed; the compare layer is a sibling of it, and the outer object closes after. 690 o = pb_compare(out, o) 691 o = ss_cat(out, o, "}" as *u8) 692 out[o] = PB_NL as u8 693 o = o + 1 694 sys_write(1, out, o) 695 sys_exit(0) 696 return 0 697}