code wiki / _hdl_build / nx_debt_hygiene.nx

nx_debt_hygiene.nx source

↩ module page · 522 lines · 26691 B

1// nx_debt_hygiene.nx -- debt-plane hygiene/stats organ (2026-07-19, sess claude_f749ee6c). 2// THE nishi debt-management tool: reads knowledge/store/debt- (mixed legacy 5-col + v2 7-col rows) 3// and emits total/open/eaten, open sev>=6 (gate-relevant), open-by-severity histogram. 4// Row schema detect: col0 all-digits & len>=8 = legacy (sev@1 status@3); else v2 (sev@2 status@3). 5// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 6import "nx_sovjson_lib.nx" 7import "nx_store_seed_lib.nx" 8import "nx_syscalls.nx" 9import "nx_tool_run.nx" 10const DH_MAGIC_65535: i64 = 65535 11const DH_MAGIC_60000: i64 = 60000 12const DH_MAGIC_65534: i64 = 65534 13const DH_MAGIC_65536: i64 = 65536 14const DH_MAGIC_2048: i64 = 2048 15 16// ★★CAP RAISED + TRUNCATION MADE VISIBLE (seq1529, 2026-07-30). This was 1048576 (1 MiB) and the debt- 17// plane had GROWN to 1447748 bytes / 1525 rows. The organ read the first 1 MiB and PRESENTED WHAT IT 18// SCANNED AS THE TOTAL: it reported total=1273 while the plane held 1525 -- 252 rows (16.5pct) invisible. 19// The dangerous part was the SEVERITY SPLIT: it reported s9=2 while `nx_debt sev 9` (a different read path) 20// returned 21, so 19 of the most severe open items sat in the unread tail and anyone triaging from this 21// summary saw a board that looked 10x calmer than it was. 22// Its own envelope already quoted "F846 scale-law: a guard that truncates its own verdict is the worst 23// case" -- and it WAS that case. ★A DECLARED CAP IN PROSE IS NOT A DECLARED CAP IN THE VERDICT. 24const DH_CAP: i64 = 33554432 25const DH_TAB: i64 = 9 26const DH_NL: i64 = 10 27 28func dh_puts(s: *u8) -> i64 { return sj_puts(s) } 29func dh_cat(d: *u8, o: i64, s: *u8) -> i64 { return sj_cat(d, o, s) } 30func dh_catn(d: *u8, o: i64, v: i64) -> i64 { return sj_catn(d, o, v) } 31func dh_le(q: *u8, i: i64, n: i64) -> i64 { var e: i64 = i; var s: i64 = 1; while s == 1 { if e >= n { s = 0 } else { if q[e] == (DH_NL as u8) { s = 0 } else { e = e + 1 } } } return e } 32func dh_col(q: *u8, ls: i64, le: i64, c: i64, out: *i64) -> i64 { 33 var col: i64 = 0 34 var p: i64 = ls 35 while col < c { 36 var s: i64 = 1 37 while s == 1 { if p >= le { return 0 } if q[p] == (DH_TAB as u8) { s = 0 } else { p = p + 1 } } 38 p = p + 1 39 col = col + 1 40 } 41 var e: i64 = p 42 var s2: i64 = 1 43 while s2 == 1 { if e >= le { s2 = 0 } else { if q[e] == (DH_TAB as u8) { s2 = 0 } else { e = e + 1 } } } 44 out[0] = p 45 out[1] = e 46 return 1 47} 48func dh_span_lit(q: *u8, s: i64, e: i64, lit: *u8) -> i64 { 49 var i: i64 = 0 50 while s + i < e { if lit[i] == (0 as u8) { return 0 } if q[s+i] != lit[i] { return 0 } i = i + 1 } 51 if lit[i] != (0 as u8) { return 0 } 52 return 1 53} 54// substring search inside a column span (used by the `stale` verb below) 55func dh_find_lit(q: *u8, s: i64, e: i64, lit: *u8) -> i64 { 56 var ll: i64 = 0 57 while lit[ll] != (0 as u8) { ll = ll + 1 } 58 if ll == 0 { return 0 } 59 var i: i64 = s 60 while i + ll <= e { 61 var k: i64 = 0 62 var ok: i64 = 1 63 while k < ll { if q[i+k] != lit[k] { ok = 0; k = ll } else { k = k + 1 } } 64 if ok == 1 { return 1 } 65 i = i + 1 66 } 67 return 0 68} 69// Which self-completion marker does this row's DESC carry? 0 = none. 70// WHY THESE AND NOT 'GREEN' (2026-08-03, debt-sweep): a row saying "the gate is NOT green" contains GREEN, 71// so a bare colour word is a false-positive machine. Each marker below is a phrase an author writes ONLY 72// about work they are reporting as finished. 73func dh_done_marker(q: *u8, s: i64, e: i64) -> i64 { 74 if dh_find_lit(q, s, e, "VERIFIED FIXED" as *u8) == 1 { return 1 } 75 if dh_find_lit(q, s, e, "DONE:" as *u8) == 1 { return 2 } 76 if dh_find_lit(q, s, e, "SHIPPED" as *u8) == 1 { return 3 } 77 if dh_find_lit(q, s, e, "PROVEN BY BEHAVIOUR" as *u8) == 1 { return 4 } 78 if dh_find_lit(q, s, e, "ship-complete" as *u8) == 1 { return 5 } 79 return 0 80} 81// Does this row ALSO declare unfinished work? MEASURED 2026-08-03 on the first run of `stale`: the very 82// highest-severity candidate (sev-9 1785453431) carries SHIPPED **and** "REMAINING AND IT IS THE ADOPTION 83// HALF: 52 writers still losing rows" -- shipped the build half, adoption still open and still severe. In 84// THIS estate a completion word usually means HALF shipped (the banked ADOPTION-GAP pattern), so a marker 85// alone is a noise machine: it flagged 117 rows including three I had filed that same hour, deliberately 86// open for their residuals. 87// ★★★★★A COMPLETION CLAIM AND A RESIDUAL CLAUSE ARE TWO DIFFERENT FACTS AND A ROW CAN HOLD BOTH -- 88// the closeable set is DONE **AND NOT** STILL-OPEN, never DONE alone. (Same two-sets shape as a detector's 89// match-set vs look-set.) This is the exclusion half; without it the verb hands over a list nobody triages. 90func dh_residual_marker(q: *u8, s: i64, e: i64) -> i64 { 91 if dh_find_lit(q, s, e, "REMAINING" as *u8) == 1 { return 1 } 92 if dh_find_lit(q, s, e, "remaining" as *u8) == 1 { return 1 } 93 if dh_find_lit(q, s, e, "NEXT:" as *u8) == 1 { return 1 } 94 if dh_find_lit(q, s, e, "NEXT (" as *u8) == 1 { return 1 } 95 if dh_find_lit(q, s, e, "OPEN:" as *u8) == 1 { return 1 } 96 if dh_find_lit(q, s, e, "still " as *u8) == 1 { return 1 } 97 if dh_find_lit(q, s, e, "NOT DONE" as *u8) == 1 { return 1 } 98 if dh_find_lit(q, s, e, "TODO" as *u8) == 1 { return 1 } 99 // 2nd calibration sample (sev-8 1785439033) was ALSO correctly open, via phrasing the first pass missed: 100 // "THE SPLIT IS THE NEXT RUNG". Residual clauses are written in prose, not in a keyword grammar. 101 if dh_find_lit(q, s, e, "NEXT RUNG" as *u8) == 1 { return 1 } 102 if dh_find_lit(q, s, e, "next rung" as *u8) == 1 { return 1 } 103 if dh_find_lit(q, s, e, "is the next" as *u8) == 1 { return 1 } 104 if dh_find_lit(q, s, e, "Until that" as *u8) == 1 { return 1 } 105 if dh_find_lit(q, s, e, "until that" as *u8) == 1 { return 1 } 106 // 3rd calibration sample (sev-8 1785445700): shipped the fix, then "NOT BUILT ... Finish with POST 107 // /api/build". Its residual was a TRANSIENT RESOURCE BLOCKER (memory floor) that had cleared -- so the 108 // row was both correctly-open AND two calls from done. These phrasings are how an author hands off. 109 if dh_find_lit(q, s, e, "NOT BUILT" as *u8) == 1 { return 1 } 110 if dh_find_lit(q, s, e, "Finish with" as *u8) == 1 { return 1 } 111 if dh_find_lit(q, s, e, "not attempted" as *u8) == 1 { return 1 } 112 if dh_find_lit(q, s, e, "unverified" as *u8) == 1 { return 1 } 113 return 0 114} 115func dh_marker_name(m: i64) -> *u8 { 116 if m == 1 { return "VERIFIED-FIXED" as *u8 } 117 if m == 2 { return "DONE:" as *u8 } 118 if m == 3 { return "SHIPPED" as *u8 } 119 if m == 4 { return "PROVEN-BY-BEHAVIOUR" as *u8 } 120 if m == 5 { return "ship-complete" as *u8 } 121 return "-" as *u8 122} 123func dh_legacy(q: *u8, s: i64, e: i64) -> i64 { 124 if e - s < 8 { return 0 } 125 var i: i64 = s 126 while i < e { let c: i64 = q[i] as i64; if c < 48 { return 0 } if c > 57 { return 0 } i = i + 1 } 127 return 1 128} 129func dh_atoi(q: *u8, s: i64, e: i64) -> i64 { var v: i64 = 0; var i: i64 = s; while i < e { let c: i64 = q[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } 130 131// ---- STALECONFIRM SUPPORT (2026-08-03, the rung 1785777238 named): join stale candidates to the 132// EXISTING confirmer instead of growing a second one (the .prev law: the primitive exists => WIRE it). 133// Debt rows carry STRUCTURED citations ("141,469 B sha f58a1706" / "254335B sha 1e038988"): parse the 134// LAST `sha <hex8+>` in the desc, the nearest nx_ token BEFORE it (the organ), and the nearest byte-count 135// BEFORE it, then fork `nx_debtconfirm check <organ>.elf <sha> <bytes>` + `scope` and report ITS ternary 136// verdict. A mis-parsed organ can only produce INCONCLUSIVE/INSUFFICIENT -- never a wrong CONFIRMED 137// (an 8-hex prefix collision across organs is the only false-positive path). READ-ONLY throughout. 138func dh_ishex(c: i64) -> i64 { 139 if c >= 48 { if c <= 57 { return 1 } } 140 if c >= 97 { if c <= 102 { return 1 } } 141 return 0 142} 143// LAST `sha[256][ =]<hex8+>` citation in [s,e); returns hex start or -1, hex len in out[0] (capped 64). 144func dh_sha_at(q: *u8, s: i64, e: i64, out: *i64) -> i64 { 145 var best: i64 = 0 - 1 146 out[0] = 0 147 var i: i64 = s 148 while i + 3 < e { 149 if q[i] == (115 as u8) { if q[i+1] == (104 as u8) { if q[i+2] == (97 as u8) { 150 var p: i64 = i + 3 151 if p + 3 <= e { if q[p] == (50 as u8) { if q[p+1] == (53 as u8) { if q[p+2] == (54 as u8) { p = p + 3 } } } } 152 var sep: i64 = 0 153 if p < e { if q[p] == (32 as u8) { sep = 1 } else { if q[p] == (61 as u8) { sep = 1 } } } 154 if sep == 1 { 155 p = p + 1 156 var h: i64 = p 157 var going: i64 = 1 158 while going == 1 { if h >= e { going = 0 } else { if dh_ishex(q[h] as i64) == 1 { h = h + 1 } else { going = 0 } } } 159 if h - p >= 8 { 160 best = p 161 var hl: i64 = h - p 162 if hl > 64 { hl = 64 } 163 out[0] = hl 164 } 165 } 166 } } } 167 i = i + 1 168 } 169 return best 170} 171// LAST word-start `nx_<ident>` token in [s,at); writes "<token>.elf" into ob. -1 if none. 172func dh_organ_before(q: *u8, s: i64, at: i64, ob: *u8) -> i64 { 173 var best: i64 = 0 - 1 174 var i: i64 = s 175 while i + 3 <= at { 176 if q[i] == (110 as u8) { if q[i+1] == (120 as u8) { if q[i+2] == (95 as u8) { 177 var pvok: i64 = 1 178 if i > s { 179 let pc: i64 = q[i-1] as i64 180 if pc >= 97 { if pc <= 122 { pvok = 0 } } 181 if pc >= 48 { if pc <= 57 { pvok = 0 } } 182 if pc == 95 { pvok = 0 } 183 } 184 if pvok == 1 { best = i } 185 } } } 186 i = i + 1 187 } 188 if best < 0 { return 0 - 1 } 189 var o: i64 = 0 190 var i2: i64 = best 191 var going2: i64 = 1 192 while going2 == 1 { 193 if i2 >= at { going2 = 0 } else { 194 let c: i64 = q[i2] as i64 195 var idc: i64 = 0 196 if c >= 97 { if c <= 122 { idc = 1 } } 197 if c >= 48 { if c <= 57 { idc = 1 } } 198 if c == 95 { idc = 1 } 199 if idc == 1 { if o < 120 { ob[o] = c as u8; o = o + 1 } i2 = i2 + 1 } else { going2 = 0 } 200 } 201 } 202 ob[o] = 46 as u8; o = o + 1 203 ob[o] = 101 as u8; o = o + 1 204 ob[o] = 108 as u8; o = o + 1 205 ob[o] = 102 as u8; o = o + 1 206 ob[o] = 0 as u8 207 return o 208} 209// LAST `<digits[,digits]>[ ]B<boundary>` before `at`; digits (commas stripped) into bb. -1 if none. 210func dh_bytes_before(q: *u8, s: i64, at: i64, bb: *u8) -> i64 { 211 var best: i64 = 0 - 1 212 var beste: i64 = 0 - 1 213 var i: i64 = s 214 while i < at { 215 let c: i64 = q[i] as i64 216 var adv: i64 = 1 217 if c >= 48 { if c <= 57 { 218 var j2: i64 = i 219 var going: i64 = 1 220 while going == 1 { 221 if j2 >= at { going = 0 } else { 222 let d: i64 = q[j2] as i64 223 var okd: i64 = 0 224 if d >= 48 { if d <= 57 { okd = 1 } } 225 if d == 44 { okd = 1 } 226 if okd == 1 { j2 = j2 + 1 } else { going = 0 } 227 } 228 } 229 var pvok: i64 = 1 230 if i > s { 231 let pc: i64 = q[i-1] as i64 232 if pc >= 97 { if pc <= 122 { pvok = 0 } } 233 if pc >= 65 { if pc <= 90 { pvok = 0 } } 234 if pc == 95 { pvok = 0 } 235 } 236 if pvok == 1 { 237 var k3: i64 = j2 238 if k3 < at { if q[k3] == (32 as u8) { k3 = k3 + 1 } } 239 if k3 < at { if q[k3] == (66 as u8) { 240 var after_ok: i64 = 1 241 if k3 + 1 < at { 242 let ac: i64 = q[k3+1] as i64 243 if ac >= 97 { if ac <= 122 { after_ok = 0 } } 244 if ac >= 65 { if ac <= 90 { after_ok = 0 } } 245 if ac >= 48 { if ac <= 57 { after_ok = 0 } } 246 } 247 if after_ok == 1 { best = i; beste = j2 } 248 } } 249 } 250 adv = j2 - i 251 if adv < 1 { adv = 1 } 252 } } 253 i = i + adv 254 } 255 if best < 0 { return 0 - 1 } 256 var o: i64 = 0 257 var i3: i64 = best 258 while i3 < beste { 259 let d2: i64 = q[i3] as i64 260 if d2 >= 48 { if d2 <= 57 { if o < 20 { bb[o] = d2 as u8; o = o + 1 } } } 261 i3 = i3 + 1 262 } 263 bb[o] = 0 as u8 264 if o == 0 { return 0 - 1 } 265 return o 266} 267func dh_dc_check(organ: *u8, sha: *u8, byt: *u8, out: *u8) -> i64 { 268 let ol: *i64 = sys_mmap(64) as *i64 269 let av: *i64 = sys_mmap(64) as *i64 270 let elf: *u8 = "nx_debtconfirm.elf\x00" as *u8 271 av[0] = elf as i64 272 av[1] = "check\x00" as *u8 as i64 273 av[2] = organ as i64 274 av[3] = sha as i64 275 av[4] = byt as i64 276 av[5] = 0 277 ol[0] = 0 278 let rc: i64 = tr_run_capture_to(elf, av, out, DH_MAGIC_65535, ol, DH_MAGIC_60000) 279 var n2: i64 = ol[0] 280 if n2 < 0 { n2 = 0 } 281 if n2 > DH_MAGIC_65534 { n2 = DH_MAGIC_65534 } 282 out[n2] = 0 as u8 283 if rc < 0 { return 0 - 1 } 284 return n2 285} 286func dh_dc_scope(rowfile: *u8, out: *u8) -> i64 { 287 let ol: *i64 = sys_mmap(64) as *i64 288 let av: *i64 = sys_mmap(64) as *i64 289 let elf: *u8 = "nx_debtconfirm.elf\x00" as *u8 290 av[0] = elf as i64 291 av[1] = "scope\x00" as *u8 as i64 292 av[2] = rowfile as i64 293 av[3] = 0 294 ol[0] = 0 295 let rc: i64 = tr_run_capture_to(elf, av, out, DH_MAGIC_65535, ol, DH_MAGIC_60000) 296 var n2: i64 = ol[0] 297 if n2 < 0 { n2 = 0 } 298 if n2 > DH_MAGIC_65534 { n2 = DH_MAGIC_65534 } 299 out[n2] = 0 as u8 300 if rc < 0 { return 0 - 1 } 301 return n2 302} 303func dh_write_tmp(q: *u8, s: i64, e: i64) -> i64 { 304 let fd: i64 = sys_openat_wr("/tmp/dh_scope_row.tmp\x00" as *u8, 0x1a4) 305 if fd < 0 { return 0 - 1 } 306 sys_write(fd, ((q as i64) + s) as *u8, e - s) 307 sys_close(fd) 308 return 0 309} 310 311func main(argc: i64, argv: *i64) -> i64 { 312 var prefix: *u8 = "knowledge/store/debt-" as *u8 313 // VERB `stale`: list OPEN rows whose OWN DESC declares the work finished (2026-08-03). 314 // WHY THIS EXISTS: nx_debtconfirm (the per-row closure confirmer) has been live since 07-31 and a corpus 315 // grep shows NOTHING CALLS IT -- the primitive existed, the SWEEP did not. Measured cost of that gap in a 316 // single session: SIX rows hand-verified as already-fixed-but-open, and one STALE row whose prescription 317 // I nearly acted on. THE ADOPTION GAP, NOT A MISSING PRIMITIVE -- so this composes the existing plane 318 // reader instead of adding a second walker. 319 // ⚠OUTPUT IS CANDIDATES, NEVER A VERDICT, and this verb is READ-ONLY: it can no more eat a row than 320 // nx_debtconfirm can. A text marker is EVIDENCE THE AUTHOR REPORTED COMPLETION, not proof the defect is 321 // gone -- the row still has to be confirmed against the artifact before anyone eats it. 322 // VERB `staleconfirm` (2026-08-03): the stale sweep PLUS a per-candidate fork of nx_debtconfirm 323 // check/scope -- the composition the 07-31 confirmer was built for and that nothing had wired. 324 // ⚠TEST BEFORE `stale`: dh_span_lit at width 5 is a PREFIX match, so "staleconfirm" also matches it. 325 var mode: i64 = 0 326 var ai: i64 = 1 327 if argc > 1 { 328 if dh_span_lit(argv[1] as *u8, 0, 12, "staleconfirm" as *u8) == 1 { mode = 2; ai = 2 } 329 if mode == 0 { if dh_span_lit(argv[1] as *u8, 0, 5, "stale" as *u8) == 1 { mode = 1; ai = 2 } } 330 } 331 var conf_eat: i64 = 0 332 var conf_inc: i64 = 0 333 var conf_ins: i64 = 0 334 var conf_scope: i64 = 0 335 if argc > ai { prefix = argv[ai] as *u8 } 336 let q: *u8 = sys_mmap(DH_CAP) 337 // sts_load returns ONLY bytes -- it cannot report what it failed to reach, so this organ was 338 // structurally incapable of noticing its own truncation. sts_load_honest fills flags[0]=declared q:n 339 // and flags[1]=rows actually found, which is what makes the check below possible at all. 340 let dhf: *i64 = sys_mmap(64) as *i64 341 let n: i64 = sts_load_honest(prefix, q, DH_CAP, dhf) 342 if n <= 0 { dh_puts("DEBT-HYGIENE store empty / unseeded\n" as *u8); sys_exit(1); return 1 } 343 let c0: *i64 = sys_mmap(16) as *i64 344 let cs: *i64 = sys_mmap(16) as *i64 345 let cc: *i64 = sys_mmap(16) as *i64 346 let hist: *i64 = sys_mmap(80) as *i64 347 var total: i64 = 0 348 var open: i64 = 0 349 var eaten: i64 = 0 350 var gating: i64 = 0 351 var stale_n: i64 = 0 352 var withres: i64 = 0 353 let cd: *i64 = sys_mmap(16) as *i64 354 let sb: *u8 = sys_mmap(DH_MAGIC_2048) 355 if mode >= 1 { dh_puts("DEBT-STALE candidates -- OPEN rows whose OWN desc reports the work finished.\nCANDIDATES, NOT VERDICTS: confirm against the artifact (nx_debtconfirm) before eating any row.\n" as *u8) } 356 var i: i64 = 0 357 while i < n { 358 let le: i64 = dh_le(q, i, n) 359 if dh_col(q, i, le, 0, c0) == 1 { 360 var sevcol: i64 = 2 361 if dh_legacy(q, c0[0], c0[1]) == 1 { sevcol = 1 } 362 if dh_col(q, i, le, 3, cs) == 1 { 363 total = total + 1 364 if dh_span_lit(q, cs[0], cs[1], "open" as *u8) == 1 { 365 open = open + 1 366 if dh_col(q, i, le, sevcol, cc) == 1 { 367 let sv: i64 = dh_atoi(q, cc[0], cc[1]) 368 if sv >= 1 { if sv <= 9 { hist[sv] = hist[sv] + 1 } } 369 if sv >= 6 { gating = gating + 1 } 370 if mode >= 1 { if dh_col(q, i, le, 4, cd) == 1 { 371 var mk: i64 = dh_done_marker(q, cd[0], cd[1]) 372 var resid: i64 = 0 373 if mk > 0 { resid = dh_residual_marker(q, cd[0], cd[1]) } 374 if resid == 1 { withres = withres + 1; mk = 0 } 375 if mk > 0 { 376 stale_n = stale_n + 1 377 let idcol: i64 = sevcol - 1 378 let ci2: *i64 = sys_mmap(16) as *i64 379 var so: i64 = dh_cat(sb, 0, "STALE-CANDIDATE id=" as *u8) 380 if dh_col(q, i, le, idcol, ci2) == 1 { 381 var k2: i64 = ci2[0] 382 while k2 < ci2[1] { sb[so] = q[k2]; so = so + 1; k2 = k2 + 1 } 383 } 384 so = dh_cat(sb, so, " sev=" as *u8) 385 so = dh_catn(sb, so, sv) 386 so = dh_cat(sb, so, " marker=" as *u8) 387 so = dh_cat(sb, so, dh_marker_name(mk)) 388 so = dh_cat(sb, so, "\n" as *u8) 389 sb[so] = 0 as u8 390 dh_puts(sb) 391 if mode == 2 { 392 let cb: *u8 = sys_mmap(DH_MAGIC_2048) 393 let dout: *u8 = sys_mmap(DH_MAGIC_65536) 394 let shal: *i64 = sys_mmap(16) as *i64 395 let shp: i64 = dh_sha_at(q, cd[0], cd[1], shal) 396 var co: i64 = dh_cat(cb, 0, " CONFIRM " as *u8) 397 if shp < 0 { 398 conf_ins = conf_ins + 1 399 co = dh_cat(cb, co, "-> INSUFFICIENT no-sha-citation-parsed (human read required)\n" as *u8) 400 cb[co] = 0 as u8 401 dh_puts(cb) 402 } else { 403 let shabuf: *u8 = sys_mmap(80) 404 var sc3: i64 = 0 405 while sc3 < shal[0] { shabuf[sc3] = q[shp + sc3]; sc3 = sc3 + 1 } 406 shabuf[sc3] = 0 as u8 407 let ob: *u8 = sys_mmap(136) 408 let on: i64 = dh_organ_before(q, cd[0], shp, ob) 409 if on < 0 { 410 conf_ins = conf_ins + 1 411 co = dh_cat(cb, co, "-> INSUFFICIENT sha-without-organ-token (human read required)\n" as *u8) 412 cb[co] = 0 as u8 413 dh_puts(cb) 414 } else { 415 let bb: *u8 = sys_mmap(24) 416 let bo: i64 = dh_bytes_before(q, cd[0], shp, bb) 417 if bo < 0 { bb[0] = 45 as u8; bb[1] = 0 as u8 } 418 let cn: i64 = dh_dc_check(ob, shabuf, bb, dout) 419 var vC: i64 = 0 420 if cn > 0 { if dh_find_lit(dout, 0, cn, "verdict=CONFIRMED" as *u8) == 1 { vC = 1 } } 421 co = dh_cat(cb, co, "organ=" as *u8) 422 co = dh_cat(cb, co, ob) 423 co = dh_cat(cb, co, " sha=" as *u8) 424 co = dh_cat(cb, co, shabuf) 425 co = dh_cat(cb, co, " bytes=" as *u8) 426 co = dh_cat(cb, co, bb) 427 if vC == 0 { 428 conf_inc = conf_inc + 1 429 co = dh_cat(cb, co, " -> INCONCLUSIVE (citation names a different/absent build -- NOT refuted; rebuilt-since-filed is the common cause)\n" as *u8) 430 cb[co] = 0 as u8 431 dh_puts(cb) 432 } else { 433 dh_write_tmp(q, cd[0], cd[1]) 434 let sn: i64 = dh_dc_scope("/tmp/dh_scope_row.tmp\x00" as *u8, dout) 435 var vS: i64 = 0 436 if sn > 0 { if dh_find_lit(dout, 0, sn, "verdict=CLEAN" as *u8) == 1 { vS = 1 } } 437 if vS == 1 { 438 conf_eat = conf_eat + 1 439 co = dh_cat(cb, co, " -> CONFIRMED+CLEAN => MECH-EATABLE (live artifact matches the citation AND no remainder marker)\n" as *u8) 440 } else { 441 conf_scope = conf_scope + 1 442 co = dh_cat(cb, co, " -> CONFIRMED but scope=REMAINDER/UNKNOWN => DO NOT EAT (shipped half, open half)\n" as *u8) 443 } 444 cb[co] = 0 as u8 445 dh_puts(cb) 446 } 447 } 448 } 449 } 450 } 451 } } 452 } 453 } else { eaten = eaten + 1 } 454 } 455 } 456 i = le + 1 457 } 458 let m: *u8 = sys_mmap(DH_MAGIC_2048) 459 var o: i64 = 0 460 // ★TRUNCATION IN THE NUMBERS, NOT THE PROSE. declared is what the plane says it holds; scanned is what 461 // this run actually parsed. When they differ the verdict is UNTRUSTWORTHY and must say so where a reader 462 // cannot miss it -- an envelope string at the end of the line is exactly what got skipped for 252 rows. 463 var rowsinbuf: i64 = 0 464 var rb: i64 = 0 465 while rb < n { if q[rb] == (DH_NL as u8) { rowsinbuf = rowsinbuf + 1 } rb = rb + 1 } 466 var trunc: i64 = 0 467 if rowsinbuf != dhf[1] { trunc = 1 } 468 if total < dhf[0] { trunc = 1 } 469 if mode >= 1 { 470 if mode == 2 { 471 var so3: i64 = dh_cat(sb, 0, "DEBT-STALECONFIRM mech_eatable=" as *u8) 472 so3 = dh_catn(sb, so3, conf_eat) 473 so3 = dh_cat(sb, so3, " inconclusive=" as *u8) 474 so3 = dh_catn(sb, so3, conf_inc) 475 so3 = dh_cat(sb, so3, " insufficient=" as *u8) 476 so3 = dh_catn(sb, so3, conf_ins) 477 so3 = dh_cat(sb, so3, " scope_blocked=" as *u8) 478 so3 = dh_catn(sb, so3, conf_scope) 479 so3 = dh_cat(sb, so3, " (READ-ONLY: nothing eaten. MECH-EATABLE = sha/bytes match the LIVE artifact AND nx_debtconfirm scope finds no remainder. INCONCLUSIVE is NOT refuted -- rebuilt organs mismatch their filed citation by construction.)\n" as *u8) 480 sb[so3] = 0 as u8 481 dh_puts(sb) 482 } 483 var so2: i64 = dh_cat(sb, 0, "DEBT-STALE candidates=" as *u8) 484 so2 = dh_catn(sb, so2, stale_n) 485 so2 = dh_cat(sb, so2, " of open=" as *u8) 486 so2 = dh_catn(sb, so2, open) 487 so2 = dh_cat(sb, so2, " excluded_with_residual=" as *u8) 488 so2 = dh_catn(sb, so2, withres) 489 so2 = dh_cat(sb, so2, " (read-only; nothing was eaten. Confirm each against its artifact first. EXCLUDED rows declare completion AND unfinished work -- half-shipped is the estate's dominant shape, not a closeable row.)\n" as *u8) 490 sb[so2] = 0 as u8 491 dh_puts(sb) 492 sys_exit(0) 493 return 0 494 } 495 o = dh_cat(m, o, "DEBT-HYGIENE truncated=" as *u8) 496 o = dh_catn(m, o, trunc) 497 o = dh_cat(m, o, " declared=" as *u8) 498 o = dh_catn(m, o, dhf[0]) 499 o = dh_cat(m, o, " scanned=" as *u8) 500 o = dh_catn(m, o, rowsinbuf) 501 o = dh_cat(m, o, " total=" as *u8) 502 o = dh_catn(m, o, total) 503 o = dh_cat(m, o, " open=" as *u8) 504 o = dh_catn(m, o, open) 505 o = dh_cat(m, o, " eaten=" as *u8) 506 o = dh_catn(m, o, eaten) 507 o = dh_cat(m, o, " gating[open,sev>=6]=" as *u8) 508 o = dh_catn(m, o, gating) 509 o = dh_cat(m, o, " open-by-sev" as *u8) 510 var s: i64 = 9 511 while s >= 1 { 512 o = dh_cat(m, o, " s" as *u8) 513 o = dh_catn(m, o, s) 514 o = dh_cat(m, o, "=" as *u8) 515 o = dh_catn(m, o, hist[s]) 516 s = s - 1 517 } 518 o = dh_cat(m, o, " envelope=plane-read-cap-32MiB-with-truncated-flag-in-the-numbers,every-loaded-row-scanned,schema-mixed-5col-legacy-plus-7col-v2 (F846 scale-law: a guard that truncates its own verdict is the worst case)\n" as *u8) 519 sys_write(1, m, o) 520 sys_exit(0) 521 return 0 522}