code wiki / _hdl_build / nx_stderronly.nx

nx_stderronly.nx source

↩ module page · 1423 lines · 68114 B

1// nx_stderronly.nx -- THE SILENT-STDERR-GUARD DETECTOR. 2// 3// THE DEFECT. A guard that detects a fault, writes its refusal ONLY to the error channel, and then 4// leaves the enclosing status function on a SUCCESS path reaches its caller as SILENCE: the caller 5// reads a success code, sees nothing, and proceeds. Measured live 2026-08-20 in nx_clockjob, where a 6// refused write was indistinguishable from a successful one. 7// 8// SCOPE, STATED PLAINLY -- THIS IS SOURCE-SHAPE ANALYSIS, NOT RUNTIME. 9// It cannot observe which channel a message actually took at run time, because the estate has no 10// fd-capture primitive: a sibling proved that nx_job_run MERGES fd1 and fd2 (one refusing write 11// appeared exactly twice in a single capture), so a runtime channel test is currently unwritable. 12// That missing primitive is filed separately as nx_fdcapture. Everything below is decided from the 13// bytes of the source with comment bodies and string bodies masked out of the code view. 14// WHAT IT THEREFORE CANNOT SEE: a verdict carried through a flag variable that is returned later; a 15// refusal whose message is built across several lines; a condition spread over several lines; a 16// caller that already holds the failure code (a reason-printer); any refusal worded outside the 17// published vocabulary; anything at all at run time. 18// 19// THE SIGNAL IS A CONJUNCTION, AND EVERY CONJUNCT IS PUBLISHED AS ITS OWN BUCKET SO THE FUNNEL CAN BE 20// AUDITED RATHER THAN TRUSTED: 21// 1. the site is an fd-2 emission -- a write whose fd argument is the literal 2 OR a file-level 22// const whose VALUE is 2 (THE SAME CONSTANT IN TWO SPELLINGS IS TWO CONSTANTS TO EVERY SCANNER: 23// the estate writes both, so resolving by value is the only complete rule), OR a call to a 24// same-file UNCONDITIONAL stderr helper 25// 2. it is NOT inside such a helper's own body (a printer is not a guard) 26// 3. its innermost enclosing block is an `if` guard, not a function body / else / loop 27// 4. the emitted literal carries a REFUSAL token from the published vocabulary 28// 5. the guard block carries NO non-zero verdict (no non-zero return, no non-zero sys_exit) 29// 6. the enclosing function PROVES IT USES EXIT CODES -- it carries a non-zero verdict SOMEWHERE 30// 7. the guard block does no other work (no assignment, so it cannot be setting a failure flag) 31// 32// CONJUNCT 6 IS THE DISCRIMINATOR AND IT WAS EARNED, NOT GUESSED. Without it the rule fires on every 33// reason-printer in the estate (nx_gunzip.gu_reason, nx_refcorpus.rc_reason: a fan of 34// `if rc == -N { emit(...) }` lines whose CALLER already holds the failure code). Such a function has 35// no non-zero verdict anywhere, so it is not a status function at all, and its silence is correct by 36// design. A FUNCTION THAT NEVER RETURNS A NON-ZERO CODE IS NOT FAILING TO REPORT -- IT WAS NEVER THE 37// REPORTER. 38// 39// CONJUNCT 7 WAS EARNED THE SAME WAY: the corpus is full of `if x < 0 { write(fd2,"-"); x = 0 - x }` 40// number formatters and `if p2 == 0 { werr("T2 ...") }` selftest teeth whose verdict lives in a 41// counter. An assignment inside the block means the block is doing something besides complaining. 42// 43// THE VOCABULARY IS DATA, NOT A CONSTANT IN THE CODE: nishi-ops/stderronly.vocab, one token per line, 44// resolved on either host by gk_ops_path. When absent the built-in list is used and the verdict SAYS 45// SO, with the token count and the path it looked at, on every single run -- A BAR NOBODY CAN SEE IS 46// A BAR THAT WAS NEVER PUBLISHED. Its derivation: tokens that assert the operation was REFUSED or 47// could not proceed. Generic outcome words (FAIL, ERROR, BAD) are DELIBERATELY EXCLUDED, and that 48// exclusion is MEASURED rather than asserted -- `dist` reports how many extra sites the loose 49// vocabulary would admit and how many of those would reach SILENT, so a reader can check the 50// exclusion instead of believing it. 51// 52// usage: 53// nx_stderronly [--dir D/] [--quiet] [--accept] [--nobaseline] [--baseline P] [--journal P] 54// scan + name-set ratchet 55// nx_stderronly dist [--dir D/] [--bucket N] publish the distribution 56// `--baseline P` exists so a GATE can ratchet against /tmp instead of the estate's real baseline -- 57// A GATE MUST NOT SHARE ITS FIXTURE WITH A PRODUCTION BEAT. 58// exit: 0 = no NEW silent guard since the baseline (or dist ok); 1 = a NEW one, named; 2 = REFUSED 59// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 60// 61// THIS ORGAN DELIBERATELY WRITES NOTHING TO FD 2. Every byte it emits goes to fd 1, so it can never 62// be its own subject, and its search literals live inside string bodies which the mask excludes from 63// the code view -- A DETECTOR THAT SCANS SOURCE WILL FIND ITS OWN FIXTURE AND ITS OWN HEADER FIRST 64// unless it is built so that it structurally cannot. 65import "nx_memplane_lib.nx" 66import "nx_gatekit_lib.nx" 67 68const SO_MAXF: i64 = 32768 // corpus is ~18,600; a smaller cap would REFUSE, never truncate 69const SO_FBUF: i64 = 4194304 70const SO_FNMAX: i64 = 2048 // functions per file 71const SO_EMMAX: i64 = 64 // unconditional stderr helpers per file 72const SO_CNMAX: i64 = 512 // file-level consts whose value is 2 73const SO_W2MAX: i64 = 8192 // fd-2 write positions per file 74const SO_SITEF: i64 = 16384 // emission sites per file 75const SO_ENCLMAX: i64 = 64 // enclosing block levels walked outward from a site 76const SO_WLB: i64 = 4194304 // per-bucket worklist buffer 77const SO_WLRES: i64 = 4096 // headroom kept free so a row is never half-written 78const SO_MSG: i64 = 65536 79const SO_KEYB: i64 = 4194304 80const SO_VOCB: i64 = 65536 81const SO_VOCMAX: i64 = 256 82const SO_PATHB: i64 = 4096 83 84const SO_NL: i64 = 10 85const SO_SP: i64 = 32 86const SO_TABCH: i64 = 9 87const SO_CR: i64 = 13 88const SO_QUOTE: i64 = 34 89const SO_HASH: i64 = 35 90const SO_BSLASH: i64 = 92 91const SO_SLASH: i64 = 47 92const SO_LBRACE: i64 = 123 93const SO_RBRACE: i64 = 125 94const SO_LPAREN: i64 = 40 95const SO_RPAREN: i64 = 41 96const SO_COMMA: i64 = 44 97const SO_EQ: i64 = 61 98const SO_BANG: i64 = 33 99const SO_LT: i64 = 60 100const SO_GT: i64 = 62 101const SO_PLUS: i64 = 43 102const SO_STAR: i64 = 42 103const SO_PCT: i64 = 37 104const SO_D0: i64 = 48 105const SO_D9: i64 = 57 106const SO_MINUS: i64 = 45 107const SO_UPA: i64 = 65 108const SO_UPZ: i64 = 90 109const SO_LOA: i64 = 97 110const SO_LOZ: i64 = 122 111const SO_USCORE: i64 = 95 112const SO_CASEGAP: i64 = 32 113const SO_BASE10: i64 = 10 114const SO_FD2VAL: i64 = 2 // the error channel; the whole subject of this organ 115 116const SO_MK_CODE: i64 = 0 117const SO_MK_CMT: i64 = 1 118const SO_MK_STR: i64 = 2 119 120// THE FUNNEL. Every emission site lands in exactly one bucket; the partition is printed with its sum. 121const SO_B_EMIT: i64 = 0 // inside an unconditional stderr helper's own body -- a printer 122const SO_B_NOGUARD: i64 = 1 // enclosing block is a function body / else / loop, not an `if` 123const SO_B_NOVOCAB: i64 = 2 // guarded, but the literal carries no refusal token 124const SO_B_CARRIES: i64 = 3 // guarded refusal, and the block carries a non-zero verdict <-- GOOD 125const SO_B_NOSTATUS: i64 = 4 // enclosing function has no non-zero verdict anywhere -- reason-printer 126const SO_B_HASWORK: i64 = 5 // block assigns something -- the verdict may live in a flag 127const SO_B_SILENT: i64 = 6 // <-- THE SIGNAL 128const SO_B_UNKNOWN: i64 = 7 // could not resolve the enclosing block / a cap was reached 129const SO_B_ELSEARM: i64 = 8 // the block is one arm of an if/else message SELECTOR, not a refusal 130const SO_B_RETZERO: i64 = 9 // the block returns/exits explicitly -- a chosen contract, not silence 131const SO_B_N: i64 = 10 132 133const SO_MODE_644: i64 = 420 134// Each of these serves EXACTLY ONE purpose, because one constant serving two unrelated purposes can 135// never be tuned for either -- SO_I64B is the width of one i64 slot in a hand-sized mmap, SO_NULRES is 136// the terminator headroom kept free at the end of a read buffer, and they are equal only by accident. 137const SO_I64B: i64 = 8 // bytes per i64 slot 138const SO_NULRES: i64 = 8 // headroom left unread so a buffer can always be NUL-terminated 139const SO_ASPAN_SLOTS: i64 = 4 // so_argspan writes out[0]=open, out[1]=past-close; slack for growth 140const SO_ESCPAIR: i64 = 2 // a backslash escape consumes the slash AND the byte it escapes 141// gk_dirscan's documented negative returns, named here so the branch reads as the condition it tests 142const SO_SCAN_ERR_CAP: i64 = 2 // returned as -2: the corpus exceeded the name-table cap 143const SO_SCAN_ERR_PATH: i64 = 3 // returned as -3: a source path exceeded the name slot 144const SO_EXIT_REFUSED: i64 = 2 // this organ REFUSED to judge; distinct from 1 = a NEW finding 145 146// Literals are bound ONCE and their lengths DERIVED. A hand-counted length beside a string literal is 147// a second copy of that literal's shape and the two drift silently. 148const SO_L_WRITE: *u8 = "sys_write(" 149const SO_L_EXIT: *u8 = "sys_exit(" 150const SO_L_RETURN: *u8 = "return " 151const SO_L_FUNC: *u8 = "func " 152const SO_L_CONST: *u8 = "const " 153const SO_L_IFSP: *u8 = "if " 154const SO_L_IFP: *u8 = "if(" 155const SO_L_ELSE: *u8 = "else" 156const SO_L_TOPLVL: *u8 = "<top-level>" 157const SO_JOURNAL: *u8 = "knowledge/status/stderronly.log" 158const SO_L_KWIF: *u8 = "if" 159const SO_L_KWWHILE: *u8 = "while" 160const SO_L_KWRETURN: *u8 = "return" 161 162func so_isid(c: i64) -> i64 { 163 if c >= SO_LOA { if c <= SO_LOZ { return 1 } } 164 if c >= SO_UPA { if c <= SO_UPZ { return 1 } } 165 if c >= SO_D0 { if c <= SO_D9 { return 1 } } 166 if c == SO_USCORE { return 1 } 167 return 0 168} 169 170func so_isdig(c: i64) -> i64 { 171 if c >= SO_D0 { if c <= SO_D9 { return 1 } } 172 return 0 173} 174 175func so_lower(c: i64) -> i64 { 176 if c >= SO_UPA { if c <= SO_UPZ { return c + SO_CASEGAP } } 177 return c 178} 179 180// literal match at p, bounded by n 181func so_at(buf: *u8, p: i64, n: i64, lit: *u8) -> i64 { 182 if p < 0 { return 0 } 183 let l: i64 = mp_len(lit) 184 if p + l > n { return 0 } 185 var i: i64 = 0 186 while i < l { if buf[p + i] != lit[i] { return 0 } i = i + 1 } 187 return 1 188} 189 190// do the `ln` bytes at buf[p..] equal the `ln` bytes at buf[q..]? 191func so_same(buf: *u8, p: i64, q: i64, ln: i64, n: i64) -> i64 { 192 if p + ln > n { return 0 } 193 var i: i64 = 0 194 while i < ln { if buf[p + i] != buf[q + i] { return 0 } i = i + 1 } 195 return 1 196} 197 198// MASK PASS. mk[i] says what buf[i] IS: code, comment body, or string body. Both quote characters stay 199// CODE so brace/paren matching still sees the statement structure. This is the whole reason this organ 200// cannot accuse its own header (a comment) or its own search literals (strings). 201// RETURNS the number of literals that reached end-of-file without a closing quote. A dialect where a 202// string may contain a LITERAL NEWLINE (this one does: `az_err("usage: ...<newline>" as *u8)` and 203// `_yt_w("<newline>" as *u8)` are both live in the corpus) means a newline CANNOT terminate a literal 204// -- v1 assumed it could, and the closing quote on the next line then read as an OPENING quote, which 205// shifted every mask after it and sent 9 real sites to UNKNOWN. An UNTERMINATED literal is a different 206// thing entirely and must make the whole file UNKNOWN, because from that point the code view is fiction. 207func so_mask(buf: *u8, n: i64, mk: *u8) -> i64 { 208 var unterm: i64 = 0 209 var z: i64 = 0 210 while z < n { mk[z] = SO_MK_CODE as u8; z = z + 1 } 211 var i: i64 = 0 212 while i < n { 213 let c: i64 = buf[i] as i64 214 var adv: i64 = 1 215 if c == SO_SLASH { 216 var isc: i64 = 0 217 if i + 1 < n { if (buf[i + 1] as i64) == SO_SLASH { isc = 1 } } 218 if isc == 1 { 219 var j: i64 = i 220 var f: i64 = 0 221 while f == 0 { 222 if j >= n { f = 1 } else { 223 if (buf[j] as i64) == SO_NL { f = 1 } else { mk[j] = SO_MK_CMT as u8; j = j + 1 } 224 } 225 } 226 adv = j - i 227 } 228 } 229 if c == SO_QUOTE { 230 var k: i64 = i + 1 231 var f2: i64 = 0 232 while f2 == 0 { 233 if k >= n { unterm = unterm + 1; f2 = 1 } else { 234 let d: i64 = buf[k] as i64 235 if d == SO_BSLASH { 236 mk[k] = SO_MK_STR as u8 237 if k + 1 < n { mk[k + 1] = SO_MK_STR as u8 } 238 k = k + SO_ESCPAIR 239 } else { 240 if d == SO_QUOTE { k = k + 1; f2 = 1 } else { mk[k] = SO_MK_STR as u8; k = k + 1 } 241 } 242 } 243 } 244 adv = k - i 245 } 246 if adv < 1 { adv = 1 } 247 i = i + adv 248 } 249 return unterm 250} 251 252// find `lit` in [s,e) at positions whose mask equals `want`; -1 if absent 253func so_find(buf: *u8, mk: *u8, s: i64, e: i64, lit: *u8, want: i64) -> i64 { 254 var i: i64 = s 255 var res: i64 = 0 - 1 256 var f: i64 = 0 257 while f == 0 { 258 if i >= e { f = 1 } else { 259 if (mk[i] as i64) == want { if so_at(buf, i, e, lit) == 1 { res = i; f = 1 } } 260 if f == 0 { i = i + 1 } 261 } 262 } 263 return res 264} 265 266// case-folded find of `lit` (length ll) in [s,e) at STRING-body positions -- the vocabulary probe 267func so_ifind(buf: *u8, mk: *u8, s: i64, e: i64, lit: *u8, ll: i64) -> i64 { 268 var i: i64 = s 269 var res: i64 = 0 - 1 270 var f: i64 = 0 271 while f == 0 { 272 if i + ll > e { f = 1 } else { 273 if (mk[i] as i64) == SO_MK_STR { 274 var k: i64 = 0 275 var same: i64 = 1 276 while k < ll { 277 if so_lower(buf[i + k] as i64) != so_lower(lit[k] as i64) { same = 0; k = ll } else { k = k + 1 } 278 } 279 if same == 1 { res = i; f = 1 } 280 } 281 if f == 0 { i = i + 1 } 282 } 283 } 284 return res 285} 286 287// forward brace match from an opening `{` at `open`; -1 if unbalanced 288func so_bmatch(buf: *u8, mk: *u8, open: i64, n: i64) -> i64 { 289 var d: i64 = 0 290 var i: i64 = open 291 var res: i64 = 0 - 1 292 var f: i64 = 0 293 while f == 0 { 294 if i >= n { f = 1 } else { 295 if (mk[i] as i64) == SO_MK_CODE { 296 let c: i64 = buf[i] as i64 297 if c == SO_LBRACE { d = d + 1 } 298 if c == SO_RBRACE { d = d - 1; if d == 0 { res = i; f = 1 } } 299 } 300 if f == 0 { i = i + 1 } 301 } 302 } 303 return res 304} 305 306// innermost enclosing `{` for position p, searching back no further than lo; -1 if unresolved 307func so_encl(buf: *u8, mk: *u8, p: i64, lo: i64) -> i64 { 308 var d: i64 = 0 309 var i: i64 = p - 1 310 var res: i64 = 0 - 1 311 var f: i64 = 0 312 while f == 0 { 313 if i < lo { f = 1 } else { 314 if (mk[i] as i64) == SO_MK_CODE { 315 let c: i64 = buf[i] as i64 316 if c == SO_RBRACE { d = d + 1 } 317 if c == SO_LBRACE { if d == 0 { res = i; f = 1 } else { d = d - 1 } } 318 } 319 if f == 0 { i = i - 1 } 320 } 321 } 322 return res 323} 324 325// Does [s,e) carry a NON-ZERO verdict? `return 0` and `sys_exit(0)` do not; a bare `return` does not; 326// anything non-literal is treated AS IF it carried one, because this rule must be wrong in the 327// direction of staying silent. 328func so_carries(buf: *u8, mk: *u8, s: i64, e: i64) -> i64 { 329 var i: i64 = s 330 var res: i64 = 0 331 var f: i64 = 0 332 while f == 0 { 333 if i >= e { f = 1 } else { 334 if (mk[i] as i64) == SO_MK_CODE { 335 var hit: i64 = 0 336 var q: i64 = 0 - 1 337 if so_at(buf, i, e, SO_L_EXIT) == 1 { hit = 1; q = i + mp_len(SO_L_EXIT) } 338 if hit == 0 { 339 if so_at(buf, i, e, SO_L_RETURN) == 1 { 340 var bnd: i64 = 1 341 if i > s { if so_isid(buf[i - 1] as i64) == 1 { bnd = 0 } } 342 if bnd == 1 { hit = 1; q = i + mp_len(SO_L_RETURN) } 343 } 344 } 345 if hit == 1 { 346 var r: i64 = q 347 var fs: i64 = 0 348 while fs == 0 { 349 if r >= e { fs = 1 } else { 350 if (buf[r] as i64) == SO_SP { r = r + 1 } else { fs = 1 } 351 } 352 } 353 if r < e { 354 let c: i64 = buf[r] as i64 355 if so_isdig(c) == 1 { 356 if c == SO_D0 { 357 // `0` alone is success; `0 - N` is a negative verdict 358 var t: i64 = r + 1 359 var ft: i64 = 0 360 while ft == 0 { 361 if t >= e { ft = 1 } else { 362 if (buf[t] as i64) == SO_SP { t = t + 1 } else { ft = 1 } 363 } 364 } 365 if t < e { if (buf[t] as i64) == SO_MINUS { res = 1; f = 1 } } 366 } else { res = 1; f = 1 } 367 } 368 // an identifier or an expression cannot be proven zero -> treat as carrying 369 if so_isdig(c) == 0 { if so_isid(c) == 1 { res = 1; f = 1 } } 370 } 371 } 372 } 373 if f == 0 { i = i + 1 } 374 } 375 } 376 return res 377} 378 379// Is there an ASSIGNMENT in [s,e)? `==`, `!=`, `<=`, `>=` and the compound forms are comparisons or 380// updates, not the plain assignment this asks about. 381func so_assigns(buf: *u8, mk: *u8, s: i64, e: i64) -> i64 { 382 var i: i64 = s 383 var res: i64 = 0 384 var f: i64 = 0 385 while f == 0 { 386 if i >= e { f = 1 } else { 387 if (mk[i] as i64) == SO_MK_CODE { 388 if (buf[i] as i64) == SO_EQ { 389 var ok: i64 = 1 390 if i + 1 < e { if (buf[i + 1] as i64) == SO_EQ { ok = 0 } } 391 if i > s { 392 let pv: i64 = buf[i - 1] as i64 393 if pv == SO_EQ { ok = 0 } 394 if pv == SO_BANG { ok = 0 } 395 if pv == SO_LT { ok = 0 } 396 if pv == SO_GT { ok = 0 } 397 if pv == SO_PLUS { ok = 0 } 398 if pv == SO_MINUS { ok = 0 } 399 if pv == SO_STAR { ok = 0 } 400 if pv == SO_SLASH { ok = 0 } 401 if pv == SO_PCT { ok = 0 } 402 } 403 if ok == 1 { res = 1; f = 1 } 404 } 405 } 406 if f == 0 { i = i + 1 } 407 } 408 } 409 return res 410} 411 412// Is the block opened at `op` an `if` guard? Look at the code on the line BEFORE the brace and take 413// the LAST of `if`/`else` -- otherwise the else-half of `if x { } else { }` reads as a guard. 414func so_isguard(buf: *u8, mk: *u8, op: i64, lo: i64) -> i64 { 415 var b: i64 = op 416 var f: i64 = 0 417 while f == 0 { 418 if b <= lo { f = 1 } else { 419 if (buf[b - 1] as i64) == SO_NL { f = 1 } else { b = b - 1 } 420 } 421 } 422 var lastif: i64 = 0 - 1 423 var lastelse: i64 = 0 - 1 424 var i: i64 = b 425 while i < op { 426 if (mk[i] as i64) == SO_MK_CODE { 427 var isif: i64 = 0 428 if so_at(buf, i, op, SO_L_IFSP) == 1 { isif = 1 } 429 if so_at(buf, i, op, SO_L_IFP) == 1 { isif = 1 } 430 if isif == 1 { 431 var bnd: i64 = 1 432 if i > b { if so_isid(buf[i - 1] as i64) == 1 { bnd = 0 } } 433 if bnd == 1 { lastif = i } 434 } 435 if so_at(buf, i, op, SO_L_ELSE) == 1 { lastelse = i } 436 } 437 i = i + 1 438 } 439 if lastif < 0 { return 0 } 440 if lastelse > lastif { return 0 } 441 return 1 442} 443 444// Is the next CODE token after the block's closing brace the keyword `else`? An `if { } else { }` 445// pair is a message SELECTOR, not a refusal decision -- both arms run on the same already-decided 446// path, so neither arm owes a verdict. MEASURED: this class supplied 3 of the first 9 raw hits 447// (nx_mkdirp's EEXIST-vs-not-created wording choice, and two selftest PASS/FAIL arms). 448func so_elsefollows(buf: *u8, mk: *u8, cl: i64, n: i64) -> i64 { 449 var i: i64 = cl + 1 450 var res: i64 = 0 451 var f: i64 = 0 452 while f == 0 { 453 if i >= n { f = 1 } else { 454 if (mk[i] as i64) == SO_MK_CODE { 455 let c: i64 = buf[i] as i64 456 var ws: i64 = 0 457 if c == SO_SP { ws = 1 } 458 if c == SO_NL { ws = 1 } 459 if c == SO_TABCH { ws = 1 } 460 if c == SO_CR { ws = 1 } 461 if ws == 0 { 462 if so_at(buf, i, n, SO_L_ELSE) == 1 { res = 1 } 463 f = 1 464 } 465 } 466 if f == 0 { i = i + 1 } 467 } 468 } 469 return res 470} 471 472// The argument span of the call starting at `site`: out[0] = its `(`, out[1] = one past its `)`. 473// THE VOCABULARY MUST BE READ FROM THE EMISSION'S OWN ARGUMENTS, NEVER FROM THE LINE. Measured: two 474// of the first nine raw hits were an `if g == 1 { lg("PASS ...") } else { lg("FAIL ... refused") }` 475// written on ONE line, where the refusal word belonged to the OTHER arm entirely. 476func so_argspan(buf: *u8, mk: *u8, site: i64, n: i64, out: *i64) -> i64 { 477 var i: i64 = site 478 var op: i64 = 0 - 1 479 var f: i64 = 0 480 while f == 0 { 481 if i >= n { f = 1 } else { 482 if (mk[i] as i64) == SO_MK_CODE { if (buf[i] as i64) == SO_LPAREN { op = i; f = 1 } } 483 if f == 0 { if (buf[i] as i64) == SO_NL { f = 1 } } 484 if f == 0 { i = i + 1 } 485 } 486 } 487 if op < 0 { return 0 } 488 var d: i64 = 0 489 var j: i64 = op 490 var cp: i64 = 0 - 1 491 var f2: i64 = 0 492 while f2 == 0 { 493 if j >= n { f2 = 1 } else { 494 if (mk[j] as i64) == SO_MK_CODE { 495 let c: i64 = buf[j] as i64 496 if c == SO_LPAREN { d = d + 1 } 497 if c == SO_RPAREN { d = d - 1; if d == 0 { cp = j; f2 = 1 } } 498 } 499 if f2 == 0 { j = j + 1 } 500 } 501 } 502 if cp < 0 { return 0 } 503 out[0] = op 504 out[1] = cp + 1 505 return 1 506} 507 508// Does [s,e) contain a call that is NOT an fd-2 emission? A block that also CALLS something is doing 509// work beyond complaining, and that call is very often the verdict mechanism itself -- MEASURED on 510// nx_parse.parse_shift, whose diagnostic block ends in nx_diag_note_error(), the compiler's actual 511// error accounting. `isemit` marks the start byte of every emission site in this file. 512func so_othercall(buf: *u8, mk: *u8, isemit: *u8, s: i64, e: i64) -> i64 { 513 var i: i64 = s 514 var res: i64 = 0 515 var f: i64 = 0 516 while f == 0 { 517 if i >= e { f = 1 } else { 518 var adv: i64 = 1 519 if (mk[i] as i64) == SO_MK_CODE { if so_isid(buf[i] as i64) == 1 { 520 var prevok: i64 = 1 521 if i > 0 { if so_isid(buf[i - 1] as i64) == 1 { prevok = 0 } } 522 if prevok == 1 { 523 var j: i64 = i 524 var f3: i64 = 0 525 while f3 == 0 { 526 if j >= e { f3 = 1 } else { if so_isid(buf[j] as i64) == 1 { j = j + 1 } else { f3 = 1 } } 527 } 528 let idl: i64 = j - i 529 var iscall: i64 = 0 530 if j < e { if (buf[j] as i64) == SO_LPAREN { iscall = 1 } } 531 if iscall == 1 { 532 var known: i64 = 0 533 if (isemit[i] as i64) == 1 { known = 1 } 534 if known == 0 { if idl == mp_len(SO_L_KWIF) { if so_at(buf, i, e, SO_L_KWIF) == 1 { known = 1 } } } 535 if known == 0 { if idl == mp_len(SO_L_KWWHILE) { if so_at(buf, i, e, SO_L_KWWHILE) == 1 { known = 1 } } } 536 if known == 0 { if idl == mp_len(SO_L_KWRETURN) { if so_at(buf, i, e, SO_L_KWRETURN) == 1 { known = 1 } } } 537 if known == 0 { res = 1; f = 1 } 538 } 539 if idl > 1 { adv = idl } 540 } 541 } } 542 if f == 0 { if adv < 1 { adv = 1 } i = i + adv } 543 } 544 } 545 return res 546} 547 548func so_lineno(buf: *u8, p: i64) -> i64 { 549 var i: i64 = 0 550 var ln: i64 = 1 551 while i < p { if (buf[i] as i64) == SO_NL { ln = ln + 1 } i = i + 1 } 552 return ln 553} 554 555// THE VOCABULARY, built into a buffer as newline-separated tokens so the conf path and the built-in 556// path share ONE parser and cannot drift. 557func so_vocab_builtin(vb: *u8) -> i64 { 558 var o: i64 = 0 559 o = mp_cat(vb, o, "REFUSED\n" as *u8) 560 o = mp_cat(vb, o, "refusing\n" as *u8) 561 o = mp_cat(vb, o, "refuses\n" as *u8) 562 o = mp_cat(vb, o, "cannot\n" as *u8) 563 o = mp_cat(vb, o, "unable to\n" as *u8) 564 o = mp_cat(vb, o, "usage:\n" as *u8) 565 o = mp_cat(vb, o, "denied\n" as *u8) 566 o = mp_cat(vb, o, "not permitted\n" as *u8) 567 o = mp_cat(vb, o, "must be\n" as *u8) 568 o = mp_cat(vb, o, "invalid\n" as *u8) 569 o = mp_cat(vb, o, "rejected\n" as *u8) 570 return o 571} 572 573// The DELIBERATELY EXCLUDED generic outcome words, kept so the exclusion can be MEASURED. 574func so_vocab_loose(vb: *u8) -> i64 { 575 var o: i64 = 0 576 o = mp_cat(vb, o, "FAIL\n" as *u8) 577 o = mp_cat(vb, o, "ERROR\n" as *u8) 578 o = mp_cat(vb, o, "BAD \n" as *u8) 579 return o 580} 581 582// index newline-separated tokens; blank lines and lines starting with the comment sigil are skipped 583func so_vindex(vb: *u8, n: i64, off: *i64, len: *i64, cap: i64) -> i64 { 584 var cnt: i64 = 0 585 var p: i64 = 0 586 while p < n { 587 var e: i64 = p 588 var f: i64 = 0 589 while f == 0 { 590 if e >= n { f = 1 } else { if (vb[e] as i64) == SO_NL { f = 1 } else { e = e + 1 } } 591 } 592 var take: i64 = 1 593 if e <= p { take = 0 } 594 if take == 1 { if (vb[p] as i64) == SO_HASH { take = 0 } } 595 if take == 1 { if cnt >= cap { take = 0 } } 596 if take == 1 { 597 var el: i64 = e 598 var f2: i64 = 0 599 while f2 == 0 { 600 if el <= p { f2 = 1 } else { 601 let lc: i64 = vb[el - 1] as i64 602 var trim: i64 = 0 603 if lc == SO_TABCH { trim = 1 } 604 if lc == SO_CR { trim = 1 } 605 if trim == 1 { el = el - 1 } else { f2 = 1 } 606 } 607 } 608 if el > p { off[cnt] = p; len[cnt] = el - p; cnt = cnt + 1 } 609 } 610 p = e + 1 611 } 612 return cnt 613} 614 615// does the emission at [s,eol) carry any vocabulary token inside a string body? 616func so_hasvocab(buf: *u8, mk: *u8, s: i64, eol: i64, vb: *u8, off: *i64, len: *i64, vn: i64) -> i64 { 617 var v: i64 = 0 618 var res: i64 = 0 619 while v < vn { 620 let lit: *u8 = ((vb as i64) + off[v]) as *u8 621 if so_ifind(buf, mk, s, eol, lit, len[v]) >= 0 { res = 1; v = vn } else { v = v + 1 } 622 } 623 return res 624} 625 626// FAIL-SOFT durable run record, appended once per scan. THE POINT OF THIS ORGAN IS THAT A REFUSAL 627// MUST NOT REACH ITS CALLER AS SILENCE, and a beat discards stdout: without this line a RED run on the 628// clock would print its finding to nobody and the only evidence would be a baseline file that did not 629// change. Shipping that would be the very defect this organ detects, wearing my name. 630// One writer, one file (a registry row pointing at a log with several writers measures a race, not a 631// subject). A write failure NEVER touches the verdict -- no permission, no record, no problem. 632// GROWTH: one line per daily run, ~110 bytes, so the estate's established status-journal budget 633// (procchurn.jrnl 1048576 bytes / 20000 lines, via nx_sizeguard) is decades away. That budget is 634// ADOPTED from its closest analogue rather than invented here. 635func so_journal(path: *u8, corpus: i64, sites: i64, silent: i64, unknown: i64, nadd: i64, green: i64) -> i64 { 636 let fd: i64 = sys_openat_append(path, SO_MODE_644) 637 if fd < 0 { return 0 } 638 let ln: *u8 = sys_mmap(SO_MSG) 639 var o: i64 = mp_catn(ln, 0, sys_now_realtime_sec()) 640 ln[o] = SO_TABCH as u8; o = o + 1 641 o = mp_cat(ln, o, "stderronly\tcorpus=" as *u8) 642 o = mp_catn(ln, o, corpus) 643 o = mp_cat(ln, o, " sites=" as *u8) 644 o = mp_catn(ln, o, sites) 645 o = mp_cat(ln, o, " silent=" as *u8) 646 o = mp_catn(ln, o, silent) 647 o = mp_cat(ln, o, " unknown=" as *u8) 648 o = mp_catn(ln, o, unknown) 649 o = mp_cat(ln, o, " new=" as *u8) 650 o = mp_catn(ln, o, nadd) 651 o = mp_cat(ln, o, " verdict=" as *u8) 652 if green == 1 { o = mp_cat(ln, o, "GREEN" as *u8) } else { o = mp_cat(ln, o, "RED" as *u8) } 653 ln[o] = SO_NL as u8; o = o + 1 654 mp_write_all(fd, ln, o) 655 sys_close(fd) 656 return 0 657} 658 659func main(argc: i64, argv: *i64) -> i64 { 660 var dir: *u8 = 0 as *u8 661 var dirset: i64 = 0 662 var quiet: i64 = 0 663 var accept: i64 = 0 664 var nobase: i64 = 0 665 var distmode: i64 = 0 666 var wantb: i64 = 0 - 1 667 // A GATE MUST NOT SHARE ITS FIXTURE WITH A PRODUCTION BEAT. Without this the only way to exercise 668 // the ratchet in both directions would be to write the estate's real baseline from a test. 669 var basearg: *u8 = 0 as *u8 670 var baseset: i64 = 0 671 var jpath: *u8 = SO_JOURNAL 672 var jset: i64 = 0 673 var a: i64 = 1 674 while a < argc { 675 let s: *u8 = argv[a] as *u8 676 if mp_streq(s, "dist" as *u8) == 1 { distmode = 1 } 677 if mp_streq(s, "--dir" as *u8) == 1 { if a + 1 < argc { dir = argv[a + 1] as *u8; dirset = 1; a = a + 1 } } 678 if mp_streq(s, "--quiet" as *u8) == 1 { quiet = 1 } 679 if mp_streq(s, "--accept" as *u8) == 1 { accept = 1 } 680 if mp_streq(s, "--nobaseline" as *u8) == 1 { nobase = 1 } 681 if mp_streq(s, "--baseline" as *u8) == 1 { if a + 1 < argc { basearg = argv[a + 1] as *u8; baseset = 1; a = a + 1 } } 682 if mp_streq(s, "--journal" as *u8) == 1 { if a + 1 < argc { jpath = argv[a + 1] as *u8; jset = 1; a = a + 1 } } 683 if mp_streq(s, "--bucket" as *u8) == 1 { 684 if a + 1 < argc { 685 let bs: *u8 = argv[a + 1] as *u8 686 var bv: i64 = 0 687 var bi: i64 = 0 688 while bs[bi] != (0 as u8) { bv = bv * SO_BASE10 + ((bs[bi] as i64) - SO_D0); bi = bi + 1 } 689 wantb = bv 690 a = a + 1 691 } 692 } 693 a = a + 1 694 } 695 696 // â›”A TEST-SCOPED RATCHET IMPLIES A TEST-SCOPED JOURNAL, BY CONSTRUCTION AND NOT BY REMEMBERING. 697 // MEASURED 2026-08-20, against myself: `--baseline` exists SOLELY so a gate can ratchet in /tmp, and 698 // my own gate duly used it -- and then the three ratchet teeth wrote their FIXTURE runs 699 // (`corpus=1 sites=2 silent=1`) straight into the production journal, because the journal path was a 700 // separate flag the gate had no argv slot left to pass. A GATE MUST NOT SHARE ITS FIXTURE WITH A 701 // PRODUCTION BEAT -- I quoted that law in this organ's own gate header while breaking it three lines 702 // of argv away. Coupling the two here makes the mistake unavailable rather than merely discouraged; 703 // an explicit `--journal` still wins, so nothing is taken away. 704 if baseset == 1 { if jset == 0 { 705 let jd: *u8 = sys_mmap(SO_PATHB) 706 var jo: i64 = mp_cat(jd, 0, basearg) 707 jo = mp_cat(jd, jo, ".journal" as *u8) 708 jd[jo] = 0 as u8 709 jpath = jd 710 } } 711 712 let msg: *u8 = sys_mmap(SO_MSG) 713 let names: *u8 = sys_mmap(SO_MAXF * MP_SLOT) 714 let fbuf: *u8 = sys_mmap(SO_FBUF) 715 let mk: *u8 = sys_mmap(SO_FBUF) 716 let keyb: *u8 = sys_mmap(SO_KEYB) 717 let dk: *u8 = sys_mmap(SO_KEYB) 718 let vb: *u8 = sys_mmap(SO_VOCB) 719 let lb: *u8 = sys_mmap(SO_VOCB) 720 let vpath: *u8 = sys_mmap(SO_PATHB) 721 let bpath: *u8 = sys_mmap(SO_PATHB) 722 let voff: *i64 = sys_mmap(SO_VOCMAX * SO_I64B) as *i64 723 let vlen: *i64 = sys_mmap(SO_VOCMAX * SO_I64B) as *i64 724 let loff: *i64 = sys_mmap(SO_VOCMAX * SO_I64B) as *i64 725 let llen: *i64 = sys_mmap(SO_VOCMAX * SO_I64B) as *i64 726 let fn_bs: *i64 = sys_mmap(SO_FNMAX * SO_I64B) as *i64 727 let fn_be: *i64 = sys_mmap(SO_FNMAX * SO_I64B) as *i64 728 let fn_ns: *i64 = sys_mmap(SO_FNMAX * SO_I64B) as *i64 729 let fn_nl: *i64 = sys_mmap(SO_FNMAX * SO_I64B) as *i64 730 let fn_st: *i64 = sys_mmap(SO_FNMAX * SO_I64B) as *i64 731 let em_ix: *i64 = sys_mmap(SO_EMMAX * SO_I64B) as *i64 732 let em_die: *i64 = sys_mmap(SO_EMMAX * SO_I64B) as *i64 733 let cn_off: *i64 = sys_mmap(SO_CNMAX * SO_I64B) as *i64 734 let cn_len: *i64 = sys_mmap(SO_CNMAX * SO_I64B) as *i64 735 let w2p: *i64 = sys_mmap(SO_W2MAX * SO_I64B) as *i64 736 let isemit: *u8 = sys_mmap(SO_FBUF) 737 let sitep: *i64 = sys_mmap(SO_SITEF * SO_I64B) as *i64 738 let siteh: *i64 = sys_mmap(SO_SITEF * SO_I64B) as *i64 739 let aspan: *i64 = sys_mmap(SO_ASPAN_SLOTS * SO_I64B) as *i64 740 let wl: *i64 = sys_mmap(SO_B_N * SO_I64B) as *i64 741 let wo: *i64 = sys_mmap(SO_B_N * SO_I64B) as *i64 742 let bkt: *i64 = sys_mmap(SO_B_N * SO_I64B) as *i64 743 var bi2: i64 = 0 744 while bi2 < SO_B_N { wl[bi2] = sys_mmap(SO_WLB) as i64; wo[bi2] = 0; bkt[bi2] = 0; bi2 = bi2 + 1 } 745 var m: i64 = 0 746 747 let LWRITE: i64 = mp_len(SO_L_WRITE) 748 let LFUNC: i64 = mp_len(SO_L_FUNC) 749 let LCONST: i64 = mp_len(SO_L_CONST) 750 751 // ---- the bar, resolved now and printed on every run ---- 752 var vsrc_conf: i64 = 0 753 var vn: i64 = 0 754 if gk_ops_path(vpath, "stderronly.vocab" as *u8) == 1 { 755 let vread: i64 = mp_readf(vpath, vb, SO_VOCB - SO_NULRES) 756 if vread > 0 { vsrc_conf = 1; vn = so_vindex(vb, vread, voff, vlen, SO_VOCMAX) } 757 } 758 if vsrc_conf == 0 { 759 let vbn: i64 = so_vocab_builtin(vb) 760 vn = so_vindex(vb, vbn, voff, vlen, SO_VOCMAX) 761 } 762 let lbn: i64 = so_vocab_loose(lb) 763 let ln2: i64 = so_vindex(lb, lbn, loff, llen, SO_VOCMAX) 764 765 // ---- the corpus ---- 766 var cnt: i64 = 0 767 if dirset == 0 { cnt = gk_corpus_scan(names, MP_SLOT, SO_MAXF) } 768 if dirset == 1 { cnt = gk_dirscan(dir, 0 as *u8, names, MP_SLOT, SO_MAXF, 0) } 769 if cnt == (0 - SO_SCAN_ERR_CAP) { 770 m = mp_cat(msg, 0, "nx_stderronly: REFUSED -- corpus exceeds SO_MAXF; a truncated scan is not a scan.\n" as *u8) 771 mp_say(msg, m) 772 return SO_EXIT_REFUSED 773 } 774 if cnt == (0 - SO_SCAN_ERR_PATH) { 775 m = mp_cat(msg, 0, "nx_stderronly: REFUSED -- a source path exceeds the name slot.\n" as *u8) 776 mp_say(msg, m) 777 return SO_EXIT_REFUSED 778 } 779 if cnt <= 0 { 780 m = mp_cat(msg, 0, "nx_stderronly: REFUSED -- could not scan the source tree.\n" as *u8) 781 mp_say(msg, m) 782 return SO_EXIT_REFUSED 783 } 784 785 var files_read: i64 = 0 786 var files_oversize: i64 = 0 787 var files_fnovf: i64 = 0 788 var files_emovf: i64 = 0 789 var files_cnovf: i64 = 0 790 var files_w2ovf: i64 = 0 791 var files_sitovf: i64 = 0 792 var files_unterm: i64 = 0 793 var sites_total: i64 = 0 794 var sites_capped: i64 = 0 795 var wl_dropped: i64 = 0 796 var keys_dropped: i64 = 0 797 var loose_extra: i64 = 0 798 var loose_extra_silent: i64 = 0 799 var ko: i64 = 0 800 801 var fi: i64 = 0 802 while fi < cnt { 803 let nm: *u8 = mp_nameptr(names, fi) 804 let n: i64 = mp_readf(nm, fbuf, SO_FBUF) 805 if n > 0 { 806 files_read = files_read + 1 807 var usable: i64 = 1 808 if n >= SO_FBUF { 809 // NO SILENT CAPS: a file that could not be read whole is REPORTED, never scanned as 810 // if it were whole -- a truncated scan invents both false negatives and false positives 811 files_oversize = files_oversize + 1 812 usable = 0 813 bkt[SO_B_UNKNOWN] = bkt[SO_B_UNKNOWN] + 1 814 let ub: *u8 = (wl[SO_B_UNKNOWN]) as *u8 815 var uo: i64 = wo[SO_B_UNKNOWN] 816 if uo < SO_WLB - SO_WLRES { 817 uo = mp_cat(ub, uo, " UNKNOWN file-exceeds-read-buffer " as *u8) 818 uo = mp_cat(ub, uo, nm) 819 ub[uo] = SO_NL as u8; uo = uo + 1 820 wo[SO_B_UNKNOWN] = uo 821 } else { wl_dropped = wl_dropped + 1 } 822 } 823 if usable == 1 { 824 if so_mask(fbuf, n, mk) > 0 { 825 // the code view is fiction from the unterminated quote onward -- REFUSE to judge 826 files_unterm = files_unterm + 1 827 usable = 0 828 sites_total = sites_total + 1 829 bkt[SO_B_UNKNOWN] = bkt[SO_B_UNKNOWN] + 1 830 let ub3: *u8 = (wl[SO_B_UNKNOWN]) as *u8 831 var uo3: i64 = wo[SO_B_UNKNOWN] 832 if uo3 < SO_WLB - SO_WLRES { 833 uo3 = mp_cat(ub3, uo3, " UNKNOWN unterminated-string-literal " as *u8) 834 uo3 = mp_cat(ub3, uo3, nm) 835 ub3[uo3] = SO_NL as u8; uo3 = uo3 + 1 836 wo[SO_B_UNKNOWN] = uo3 837 } else { wl_dropped = wl_dropped + 1 } 838 } 839 } 840 if usable == 1 { 841 842 // ---- PASS 1: file-level consts whose VALUE is 2 ---- 843 var cnn: i64 = 0 844 var covf: i64 = 0 845 var ci: i64 = 0 846 while ci < n { 847 var isline: i64 = 0 848 if ci == 0 { isline = 1 } 849 if ci > 0 { if (fbuf[ci - 1] as i64) == SO_NL { isline = 1 } } 850 if isline == 1 { if (mk[ci] as i64) == SO_MK_CODE { if so_at(fbuf, ci, n, SO_L_CONST) == 1 { 851 let ns: i64 = ci + LCONST 852 var ne: i64 = ns 853 var f: i64 = 0 854 while f == 0 { 855 if ne >= n { f = 1 } else { if so_isid(fbuf[ne] as i64) == 1 { ne = ne + 1 } else { f = 1 } } 856 } 857 var q: i64 = ne 858 var eqp: i64 = 0 - 1 859 var f2: i64 = 0 860 while f2 == 0 { 861 if q >= n { f2 = 1 } else { 862 let c2: i64 = fbuf[q] as i64 863 if c2 == SO_NL { f2 = 1 } 864 if f2 == 0 { if c2 == SO_EQ { eqp = q; f2 = 1 } } 865 if f2 == 0 { q = q + 1 } 866 } 867 } 868 if eqp > 0 { 869 var r: i64 = eqp + 1 870 var f3: i64 = 0 871 while f3 == 0 { 872 if r >= n { f3 = 1 } else { if (fbuf[r] as i64) == SO_SP { r = r + 1 } else { f3 = 1 } } 873 } 874 var val: i64 = 0 875 var nd: i64 = 0 876 var f4: i64 = 0 877 while f4 == 0 { 878 if r >= n { f4 = 1 } else { 879 let c3: i64 = fbuf[r] as i64 880 if so_isdig(c3) == 1 { val = val * SO_BASE10 + (c3 - SO_D0); nd = nd + 1; r = r + 1 } else { f4 = 1 } 881 } 882 } 883 if nd > 0 { if val == SO_FD2VAL { 884 if cnn < SO_CNMAX { cn_off[cnn] = ns; cn_len[cnn] = ne - ns; cnn = cnn + 1 } else { covf = 1 } 885 } } 886 } 887 } } } 888 ci = ci + 1 889 } 890 if covf == 1 { files_cnovf = files_cnovf + 1 } 891 892 // ---- PASS 2: every fd-2 write position, resolved ONCE ---- 893 var w2n: i64 = 0 894 var wovf: i64 = 0 895 var wi: i64 = 0 896 while wi < n { 897 var wadv: i64 = 1 898 if (mk[wi] as i64) == SO_MK_CODE { if so_at(fbuf, wi, n, SO_L_WRITE) == 1 { 899 let ap: i64 = wi + LWRITE 900 var isfd2: i64 = 0 901 if ap < n { if (fbuf[ap] as i64) == (SO_D0 + SO_FD2VAL) { 902 if ap + 1 < n { 903 let cx: i64 = fbuf[ap + 1] as i64 904 if cx == SO_COMMA { isfd2 = 1 } 905 if cx == SO_SP { isfd2 = 1 } 906 } 907 } } 908 if isfd2 == 0 { 909 var cj: i64 = 0 910 while cj < cnn { 911 if so_same(fbuf, ap, cn_off[cj], cn_len[cj], n) == 1 { 912 var bnd2: i64 = 1 913 if ap + cn_len[cj] < n { if so_isid(fbuf[ap + cn_len[cj]] as i64) == 1 { bnd2 = 0 } } 914 if bnd2 == 1 { isfd2 = 1; cj = cnn } else { cj = cj + 1 } 915 } else { cj = cj + 1 } 916 } 917 } 918 if isfd2 == 1 { 919 if w2n < SO_W2MAX { w2p[w2n] = wi; w2n = w2n + 1 } else { wovf = 1 } 920 } 921 wadv = LWRITE 922 } } 923 wi = wi + wadv 924 } 925 if wovf == 1 { files_w2ovf = files_w2ovf + 1 } 926 927 // ---- PASS 3: function table (extent + is-it-a-status-function) ---- 928 var fnn: i64 = 0 929 var ovf: i64 = 0 930 var gi: i64 = 0 931 while gi < n { 932 var isline2: i64 = 0 933 if gi == 0 { isline2 = 1 } 934 if gi > 0 { if (fbuf[gi - 1] as i64) == SO_NL { isline2 = 1 } } 935 if isline2 == 1 { if (mk[gi] as i64) == SO_MK_CODE { if so_at(fbuf, gi, n, SO_L_FUNC) == 1 { 936 let ns2: i64 = gi + LFUNC 937 var ne2: i64 = ns2 938 var f5: i64 = 0 939 while f5 == 0 { 940 if ne2 >= n { f5 = 1 } else { if so_isid(fbuf[ne2] as i64) == 1 { ne2 = ne2 + 1 } else { f5 = 1 } } 941 } 942 var ob: i64 = 0 - 1 943 var q2: i64 = ne2 944 var f6: i64 = 0 945 while f6 == 0 { 946 if q2 >= n { f6 = 1 } else { 947 if (mk[q2] as i64) == SO_MK_CODE { if (fbuf[q2] as i64) == SO_LBRACE { ob = q2; f6 = 1 } } 948 if f6 == 0 { q2 = q2 + 1 } 949 } 950 } 951 if ob > 0 { 952 let ce: i64 = so_bmatch(fbuf, mk, ob, n) 953 if ce > 0 { 954 if fnn < SO_FNMAX { 955 fn_ns[fnn] = ns2 956 fn_nl[fnn] = ne2 - ns2 957 fn_bs[fnn] = ob 958 fn_be[fnn] = ce 959 fn_st[fnn] = so_carries(fbuf, mk, ob, ce) 960 fnn = fnn + 1 961 } else { ovf = 1 } 962 gi = ce 963 } 964 } 965 } } } 966 gi = gi + 1 967 } 968 if ovf == 1 { files_fnovf = files_fnovf + 1 } 969 970 // ---- PASS 4: unconditional stderr helpers -- they emit to fd 2 and never branch ---- 971 var emn: i64 = 0 972 var eovf: i64 = 0 973 var fj: i64 = 0 974 while fj < fnn { 975 var w2 : i64 = 0 976 var wk: i64 = 0 977 while wk < w2n { 978 if w2p[wk] > fn_bs[fj] { if w2p[wk] < fn_be[fj] { w2 = 1; wk = w2n } } 979 if wk < w2n { wk = wk + 1 } 980 } 981 if w2 == 1 { 982 var branches: i64 = 0 983 if so_find(fbuf, mk, fn_bs[fj], fn_be[fj], SO_L_IFSP, SO_MK_CODE) >= 0 { branches = 1 } 984 if so_find(fbuf, mk, fn_bs[fj], fn_be[fj], SO_L_IFP, SO_MK_CODE) >= 0 { branches = 1 } 985 if branches == 0 { 986 if emn < SO_EMMAX { 987 em_ix[emn] = fj 988 // A HELPER THAT TERMINATES CARRIES THE VERDICT FOR EVERY CALLER. 989 // MEASURED: nx_syscalls.nxa_die writes to fd 2 and then sys_exit(12), 990 // so its three call sites in sys_mmap read as silent guards while the 991 // process is in fact dying with a non-zero code. 992 em_die[emn] = fn_st[fj] 993 emn = emn + 1 994 } else { eovf = 1 } 995 } 996 } 997 fj = fj + 1 998 } 999 if eovf == 1 { files_emovf = files_emovf + 1 } 1000 1001 // ---- PASS 5a: enumerate emission sites (positions only) ---- 1002 var zi: i64 = 0 1003 while zi < n { isemit[zi] = 0 as u8; zi = zi + 1 } 1004 var sn: i64 = 0 1005 var sovf: i64 = 0 1006 var i: i64 = 0 1007 while i < n { 1008 var adv: i64 = 1 1009 var site: i64 = 0 - 1 1010 var shl: i64 = 0 - 1 1011 if (mk[i] as i64) == SO_MK_CODE { 1012 var wq: i64 = 0 1013 while wq < w2n { 1014 if w2p[wq] == i { site = i; wq = w2n } else { wq = wq + 1 } 1015 } 1016 if site >= 0 { adv = LWRITE } 1017 if site < 0 { if emn > 0 { if so_isid(fbuf[i] as i64) == 1 { 1018 var prevok: i64 = 1 1019 if i > 0 { if so_isid(fbuf[i - 1] as i64) == 1 { prevok = 0 } } 1020 if prevok == 1 { 1021 var j2: i64 = i 1022 var f8: i64 = 0 1023 while f8 == 0 { 1024 if j2 >= n { f8 = 1 } else { if so_isid(fbuf[j2] as i64) == 1 { j2 = j2 + 1 } else { f8 = 1 } } 1025 } 1026 let idl: i64 = j2 - i 1027 var iscall: i64 = 0 1028 if j2 < n { if (fbuf[j2] as i64) == SO_LPAREN { iscall = 1 } } 1029 var isdef: i64 = 0 1030 if i >= LFUNC { if so_at(fbuf, i - LFUNC, n, SO_L_FUNC) == 1 { isdef = 1 } } 1031 if iscall == 1 { if isdef == 0 { 1032 var ej: i64 = 0 1033 while ej < emn { 1034 let fx: i64 = em_ix[ej] 1035 var hit2: i64 = 0 1036 if fn_nl[fx] == idl { if so_same(fbuf, i, fn_ns[fx], idl, n) == 1 { hit2 = 1 } } 1037 if hit2 == 1 { site = i; shl = ej; ej = emn } else { ej = ej + 1 } 1038 } 1039 } } 1040 if idl > 1 { adv = idl } 1041 } 1042 } } } 1043 } 1044 if site >= 0 { 1045 if sn < SO_SITEF { 1046 sitep[sn] = site 1047 siteh[sn] = shl 1048 isemit[site] = 1 as u8 1049 sn = sn + 1 1050 } else { sovf = 1 } 1051 } 1052 if adv < 1 { adv = 1 } 1053 i = i + adv 1054 } 1055 if sovf == 1 { 1056 // a per-file cap reached is REPORTED as UNKNOWN, never dropped: an unscanned site 1057 // corrupts the answer in BOTH directions 1058 files_sitovf = files_sitovf + 1 1059 sites_total = sites_total + 1 1060 sites_capped = sites_capped + 1 1061 bkt[SO_B_UNKNOWN] = bkt[SO_B_UNKNOWN] + 1 1062 let ub2: *u8 = (wl[SO_B_UNKNOWN]) as *u8 1063 var uo2: i64 = wo[SO_B_UNKNOWN] 1064 if uo2 < SO_WLB - SO_WLRES { 1065 uo2 = mp_cat(ub2, uo2, " UNKNOWN per-file-site-cap-reached " as *u8) 1066 uo2 = mp_cat(ub2, uo2, nm) 1067 ub2[uo2] = SO_NL as u8; uo2 = uo2 + 1 1068 wo[SO_B_UNKNOWN] = uo2 1069 } else { wl_dropped = wl_dropped + 1 } 1070 } 1071 1072 // ---- PASS 5b: classify every site through the published funnel ---- 1073 var si: i64 = 0 1074 while si < sn { 1075 let site: i64 = sitep[si] 1076 let shl: i64 = siteh[si] 1077 sites_total = sites_total + 1 1078 var owner: i64 = 0 - 1 1079 var fk: i64 = 0 1080 while fk < fnn { 1081 if site > fn_bs[fk] { if site < fn_be[fk] { owner = fk } } 1082 fk = fk + 1 1083 } 1084 var inhelper: i64 = 0 1085 var ek: i64 = 0 1086 while ek < emn { if em_ix[ek] == owner { inhelper = 1; ek = emn } else { ek = ek + 1 } } 1087 1088 var lo: i64 = 0 1089 if owner >= 0 { lo = fn_bs[owner] } 1090 let op: i64 = so_encl(fbuf, mk, site, lo) 1091 1092 var b: i64 = SO_B_UNKNOWN 1093 if inhelper == 1 { b = SO_B_EMIT } 1094 if inhelper == 0 { if op >= 0 { 1095 let cl: i64 = so_bmatch(fbuf, mk, op, n) 1096 if cl > 0 { 1097 if so_isguard(fbuf, mk, op, lo) == 0 { b = SO_B_NOGUARD } 1098 if b == SO_B_UNKNOWN { if so_elsefollows(fbuf, mk, cl, n) == 1 { b = SO_B_ELSEARM } } 1099 if b == SO_B_UNKNOWN { 1100 if so_argspan(fbuf, mk, site, n, aspan) == 1 { 1101 let hv: i64 = so_hasvocab(fbuf, mk, aspan[0], aspan[1], vb, voff, vlen, vn) 1102 1103 // DOES ANY ENCLOSING BLOCK STRICTLY INSIDE THE FUNCTION CARRY THE 1104 // VERDICT AFTER THE SITE? MEASURED on nx_pub_lib.pl_adopt, where an 1105 // inner reader-cap message sits inside an outer block that refuses. 1106 // The function body itself is NOT walked -- that would clear every 1107 // guard in any function that returns non-zero anywhere later. 1108 var carr: i64 = so_carries(fbuf, mk, site, cl) 1109 if carr == 0 { 1110 var cur: i64 = op 1111 var lv: i64 = 0 1112 var fo: i64 = 0 1113 while fo == 0 { 1114 if lv >= SO_ENCLMAX { fo = 1 } else { 1115 let pr: i64 = so_encl(fbuf, mk, cur, lo) 1116 if pr < 0 { fo = 1 } else { 1117 if pr <= lo { fo = 1 } else { 1118 let pc: i64 = so_bmatch(fbuf, mk, pr, n) 1119 if pc < 0 { fo = 1 } else { 1120 if so_carries(fbuf, mk, site, pc) == 1 { carr = 1; fo = 1 } 1121 cur = pr 1122 } 1123 } 1124 } 1125 lv = lv + 1 1126 } 1127 } 1128 } 1129 if carr == 0 { if shl >= 0 { if em_die[shl] == 1 { carr = 1 } } } 1130 1131 var st: i64 = 0 1132 if owner >= 0 { st = fn_st[owner] } 1133 var hasret: i64 = 0 1134 if so_find(fbuf, mk, site, cl, SO_L_EXIT, SO_MK_CODE) >= 0 { hasret = 1 } 1135 if so_find(fbuf, mk, site, cl, SO_L_RETURN, SO_MK_CODE) >= 0 { hasret = 1 } 1136 var work: i64 = 0 1137 if so_assigns(fbuf, mk, op, cl) == 1 { work = 1 } 1138 if work == 0 { if so_othercall(fbuf, mk, isemit, op, cl) == 1 { work = 1 } } 1139 1140 if hv == 1 { 1141 if carr == 1 { b = SO_B_CARRIES } 1142 if b == SO_B_UNKNOWN { if st == 0 { b = SO_B_NOSTATUS } } 1143 if b == SO_B_UNKNOWN { if hasret == 1 { b = SO_B_RETZERO } } 1144 if b == SO_B_UNKNOWN { if work == 1 { b = SO_B_HASWORK } } 1145 if b == SO_B_UNKNOWN { b = SO_B_SILENT } 1146 } 1147 if hv == 0 { 1148 b = SO_B_NOVOCAB 1149 // MEASURE the exclusion instead of asserting it: would the 1150 // generic outcome words have promoted this site to SILENT? 1151 if so_hasvocab(fbuf, mk, aspan[0], aspan[1], lb, loff, llen, ln2) == 1 { 1152 loose_extra = loose_extra + 1 1153 if carr == 0 { if st == 1 { if hasret == 0 { if work == 0 { loose_extra_silent = loose_extra_silent + 1 } } } } 1154 } 1155 } 1156 } 1157 } 1158 } 1159 } } 1160 1161 bkt[b] = bkt[b] + 1 1162 let wb: *u8 = (wl[b]) as *u8 1163 var w: i64 = wo[b] 1164 if w < SO_WLB - SO_WLRES { 1165 w = mp_cat(wb, w, " " as *u8) 1166 w = mp_cat(wb, w, nm) 1167 w = mp_cat(wb, w, ":" as *u8) 1168 w = mp_catn(wb, w, so_lineno(fbuf, site)) 1169 w = mp_cat(wb, w, " func=" as *u8) 1170 if owner >= 0 { 1171 var k4: i64 = 0 1172 while k4 < fn_nl[owner] { wb[w] = fbuf[fn_ns[owner] + k4]; w = w + 1; k4 = k4 + 1 } 1173 } else { w = mp_cat(wb, w, SO_L_TOPLVL) } 1174 wb[w] = SO_NL as u8; w = w + 1 1175 wo[b] = w 1176 } else { wl_dropped = wl_dropped + 1 } 1177 1178 if b == SO_B_SILENT { 1179 // the ratchet key is path#func -- STABLE across line shifts, so a reformat 1180 // cannot manufacture a phantom regression 1181 if ko < SO_KEYB - SO_WLRES { 1182 ko = mp_cat(keyb, ko, nm) 1183 keyb[ko] = SO_HASH as u8; ko = ko + 1 1184 if owner >= 0 { 1185 var k5: i64 = 0 1186 while k5 < fn_nl[owner] { keyb[ko] = fbuf[fn_ns[owner] + k5]; ko = ko + 1; k5 = k5 + 1 } 1187 } else { ko = mp_cat(keyb, ko, SO_L_TOPLVL) } 1188 keyb[ko] = SO_NL as u8; ko = ko + 1 1189 } else { keys_dropped = keys_dropped + 1 } 1190 } 1191 si = si + 1 1192 } 1193 } 1194 } 1195 fi = fi + 1 1196 } 1197 1198 // ---- dedupe the ratchet keys (one function can hold several silent sites) ---- 1199 var dko: i64 = 0 1200 var p2: i64 = 0 1201 while p2 < ko { 1202 var e2: i64 = p2 1203 var fa: i64 = 0 1204 while fa == 0 { 1205 if e2 >= ko { fa = 1 } else { if (keyb[e2] as i64) == SO_NL { fa = 1 } else { e2 = e2 + 1 } } 1206 } 1207 if e2 > p2 { 1208 var dup: i64 = 0 1209 var q3: i64 = 0 1210 while q3 < dko { 1211 var e3: i64 = q3 1212 var fb: i64 = 0 1213 while fb == 0 { 1214 if e3 >= dko { fb = 1 } else { if (dk[e3] as i64) == SO_NL { fb = 1 } else { e3 = e3 + 1 } } 1215 } 1216 if e3 - q3 == e2 - p2 { 1217 var same4: i64 = 1 1218 var z2: i64 = 0 1219 while z2 < e2 - p2 { if dk[q3 + z2] != keyb[p2 + z2] { same4 = 0; z2 = e2 - p2 } else { z2 = z2 + 1 } } 1220 if same4 == 1 { dup = 1; q3 = dko } 1221 } 1222 if q3 < dko { q3 = e3 + 1 } 1223 } 1224 if dup == 0 { 1225 var z3: i64 = 0 1226 while z3 < e2 - p2 { dk[dko] = keyb[p2 + z3]; dko = dko + 1; z3 = z3 + 1 } 1227 dk[dko] = SO_NL as u8; dko = dko + 1 1228 } 1229 } 1230 p2 = e2 + 1 1231 } 1232 var kc: i64 = 0 1233 var kp: i64 = 0 1234 while kp < dko { if (dk[kp] as i64) == SO_NL { kc = kc + 1 } kp = kp + 1 } 1235 1236 // ---- THE ENVELOPE AND THE BAR, PRINTED BEFORE ANY VERDICT ---- 1237 m = mp_cat(msg, 0, "nx_stderronly corpus=" as *u8) 1238 m = mp_catn(msg, m, cnt) 1239 if dirset == 0 { m = mp_cat(msg, m, " files (WHOLE compile corpus)" as *u8) } 1240 if dirset == 1 { m = mp_cat(msg, m, " files (NARROWED by --dir; NOT the whole tree)" as *u8) } 1241 m = mp_cat(msg, m, " read=" as *u8) 1242 m = mp_catn(msg, m, files_read) 1243 m = mp_cat(msg, m, "\n BAR vocab=" as *u8) 1244 if vsrc_conf == 1 { m = mp_cat(msg, m, "CONF " as *u8); m = mp_cat(msg, m, vpath) } 1245 if vsrc_conf == 0 { m = mp_cat(msg, m, "BUILTIN (conf absent at " as *u8); m = mp_cat(msg, m, vpath); m = mp_cat(msg, m, ")" as *u8) } 1246 m = mp_cat(msg, m, " tokens=" as *u8) 1247 m = mp_catn(msg, m, vn) 1248 m = mp_cat(msg, m, "\n RULE SILENT = fd2-emission AND not-in-a-stderr-helper AND inside-an-if-guard AND not-an-if-else-selector-arm AND refusal-token-in-its-OWN-args AND no-nonzero-verdict-in-this-or-any-enclosing-block-after-the-site AND helper-does-not-terminate AND enclosing-func-carries-a-nonzero-verdict-somewhere AND block-has-no-return-or-exit-at-all AND block-assigns-nothing AND block-calls-nothing-but-emissions\n" as *u8) 1249 mp_say(msg, m) 1250 1251 var sum: i64 = 0 1252 var bq: i64 = 0 1253 while bq < SO_B_N { sum = sum + bkt[bq]; bq = bq + 1 } 1254 1255 if distmode == 1 { 1256 m = mp_cat(msg, 0, " sites_total=" as *u8) 1257 m = mp_catn(msg, m, sites_total) 1258 m = mp_cat(msg, m, "\n [0] in-stderr-helper-body = " as *u8); m = mp_catn(msg, m, bkt[SO_B_EMIT]) 1259 m = mp_cat(msg, m, "\n [1] not-in-an-if-guard = " as *u8); m = mp_catn(msg, m, bkt[SO_B_NOGUARD]) 1260 m = mp_cat(msg, m, "\n [8] if-else-selector-arm = " as *u8); m = mp_catn(msg, m, bkt[SO_B_ELSEARM]) 1261 m = mp_cat(msg, m, "\n [2] guarded-no-refusal-word = " as *u8); m = mp_catn(msg, m, bkt[SO_B_NOVOCAB]) 1262 m = mp_cat(msg, m, "\n [3] guarded-refusal-CARRIES-verdict = " as *u8); m = mp_catn(msg, m, bkt[SO_B_CARRIES]) 1263 m = mp_cat(msg, m, "\n [4] enclosing-func-not-a-status-func = " as *u8); m = mp_catn(msg, m, bkt[SO_B_NOSTATUS]) 1264 m = mp_cat(msg, m, "\n [9] block-returns-or-exits-explicitly= " as *u8); m = mp_catn(msg, m, bkt[SO_B_RETZERO]) 1265 m = mp_cat(msg, m, "\n [5] block-does-other-work = " as *u8); m = mp_catn(msg, m, bkt[SO_B_HASWORK]) 1266 m = mp_cat(msg, m, "\n [6] SILENT = " as *u8); m = mp_catn(msg, m, bkt[SO_B_SILENT]) 1267 m = mp_cat(msg, m, "\n [7] UNKNOWN = " as *u8); m = mp_catn(msg, m, bkt[SO_B_UNKNOWN]) 1268 m = mp_cat(msg, m, "\n PARTITION sum=" as *u8); m = mp_catn(msg, m, sum) 1269 m = mp_cat(msg, m, " vs sites_total=" as *u8); m = mp_catn(msg, m, sites_total) 1270 if sum == sites_total { m = mp_cat(msg, m, " RECONCILES" as *u8) } else { m = mp_cat(msg, m, " DOES-NOT-RECONCILE" as *u8) } 1271 m = mp_cat(msg, m, "\n distinct silent functions (ratchet keys) = " as *u8) 1272 m = mp_catn(msg, m, kc) 1273 m = mp_cat(msg, m, "\n EXCLUSION MEASURED: admitting the generic outcome words FAIL/ERROR/BAD would add " as *u8) 1274 m = mp_catn(msg, m, loose_extra) 1275 m = mp_cat(msg, m, " guarded sites, of which " as *u8) 1276 m = mp_catn(msg, m, loose_extra_silent) 1277 m = mp_cat(msg, m, " would reach SILENT -- that is why they are excluded, and it is a measurement, not an assertion.\n caps: files_oversize=" as *u8) 1278 m = mp_catn(msg, m, files_oversize) 1279 m = mp_cat(msg, m, " func_table_overflow_files=" as *u8); m = mp_catn(msg, m, files_fnovf) 1280 m = mp_cat(msg, m, " helper_table_overflow_files=" as *u8); m = mp_catn(msg, m, files_emovf) 1281 m = mp_cat(msg, m, " const_table_overflow_files=" as *u8); m = mp_catn(msg, m, files_cnovf) 1282 m = mp_cat(msg, m, " fd2_table_overflow_files=" as *u8); m = mp_catn(msg, m, files_w2ovf) 1283 m = mp_cat(msg, m, " site_table_overflow_files=" as *u8); m = mp_catn(msg, m, files_sitovf) 1284 m = mp_cat(msg, m, " unterminated_literal_files=" as *u8); m = mp_catn(msg, m, files_unterm) 1285 m = mp_cat(msg, m, " sites_beyond_cap=" as *u8); m = mp_catn(msg, m, sites_capped) 1286 m = mp_cat(msg, m, " worklist_rows_dropped=" as *u8); m = mp_catn(msg, m, wl_dropped) 1287 m = mp_cat(msg, m, " ratchet_keys_dropped=" as *u8); m = mp_catn(msg, m, keys_dropped) 1288 m = mp_cat(msg, m, "\n" as *u8) 1289 mp_say(msg, m) 1290 if wantb >= 0 { if wantb < SO_B_N { 1291 m = mp_cat(msg, 0, " ---- FULL worklist for bucket " as *u8) 1292 m = mp_catn(msg, m, wantb) 1293 m = mp_cat(msg, m, ", " as *u8) 1294 m = mp_catn(msg, m, bkt[wantb]) 1295 m = mp_cat(msg, m, " rows ----\n" as *u8) 1296 mp_say(msg, m) 1297 mp_write_all(1, (wl[wantb]) as *u8, wo[wantb]) 1298 } } 1299 if wantb < 0 { 1300 m = mp_cat(msg, 0, " ---- FULL worklist SILENT ----\n" as *u8) 1301 mp_say(msg, m) 1302 mp_write_all(1, (wl[SO_B_SILENT]) as *u8, wo[SO_B_SILENT]) 1303 m = mp_cat(msg, 0, " ---- FULL worklist UNKNOWN ----\n" as *u8) 1304 mp_say(msg, m) 1305 mp_write_all(1, (wl[SO_B_UNKNOWN]) as *u8, wo[SO_B_UNKNOWN]) 1306 m = mp_cat(msg, 0, " every other bucket has a FULL worklist too: re-run with --bucket N\n" as *u8) 1307 mp_say(msg, m) 1308 } 1309 return 0 1310 } 1311 1312 // ---- scan mode: the name-set ratchet ---- 1313 if quiet == 0 { 1314 m = mp_cat(msg, 0, " ---- SILENT-STDERR-GUARD worklist, " as *u8) 1315 m = mp_catn(msg, m, bkt[SO_B_SILENT]) 1316 m = mp_cat(msg, m, " sites ----\n" as *u8) 1317 mp_say(msg, m) 1318 mp_write_all(1, (wl[SO_B_SILENT]) as *u8, wo[SO_B_SILENT]) 1319 if bkt[SO_B_UNKNOWN] > 0 { 1320 m = mp_cat(msg, 0, " ---- UNKNOWN, its own bucket and its own worklist ----\n" as *u8) 1321 mp_say(msg, m) 1322 mp_write_all(1, (wl[SO_B_UNKNOWN]) as *u8, wo[SO_B_UNKNOWN]) 1323 } 1324 } 1325 1326 var rc: i64 = 0 1327 var nadd: i64 = 0 1328 var bn: i64 = 0 1329 let bb: *u8 = sys_mmap(SO_KEYB) 1330 var haveb: i64 = 0 1331 if nobase == 0 { 1332 if baseset == 1 { 1333 let bo: i64 = mp_cat(bpath, 0, basearg) 1334 bpath[bo] = 0 as u8 1335 haveb = 1 1336 bn = mp_readf(bpath, bb, SO_KEYB - SO_NULRES) 1337 } 1338 if baseset == 0 { 1339 if gk_ops_path(bpath, "stderronly.baseline" as *u8) == 1 { haveb = 1; bn = mp_readf(bpath, bb, SO_KEYB - SO_NULRES) } 1340 } 1341 } 1342 if bn > 0 { 1343 var p4: i64 = 0 1344 while p4 < dko { 1345 var e4: i64 = p4 1346 var fc: i64 = 0 1347 while fc == 0 { 1348 if e4 >= dko { fc = 1 } else { if (dk[e4] as i64) == SO_NL { fc = 1 } else { e4 = e4 + 1 } } 1349 } 1350 if e4 > p4 { 1351 var seen: i64 = 0 1352 var q5: i64 = 0 1353 while q5 < bn { 1354 var e5: i64 = q5 1355 var fdd: i64 = 0 1356 while fdd == 0 { 1357 if e5 >= bn { fdd = 1 } else { if (bb[e5] as i64) == SO_NL { fdd = 1 } else { e5 = e5 + 1 } } 1358 } 1359 if e5 - q5 == e4 - p4 { 1360 var same5: i64 = 1 1361 var z5: i64 = 0 1362 while z5 < e4 - p4 { if bb[q5 + z5] != dk[p4 + z5] { same5 = 0; z5 = e4 - p4 } else { z5 = z5 + 1 } } 1363 if same5 == 1 { seen = 1; q5 = bn } 1364 } 1365 if q5 < bn { q5 = e5 + 1 } 1366 } 1367 if seen == 0 { 1368 nadd = nadd + 1 1369 m = mp_cat(msg, 0, " NEW-SILENT-STDERR-GUARD " as *u8) 1370 var z6: i64 = 0 1371 while z6 < e4 - p4 { msg[m] = dk[p4 + z6]; m = m + 1; z6 = z6 + 1 } 1372 m = mp_cat(msg, m, "\n" as *u8) 1373 mp_say(msg, m) 1374 } 1375 } 1376 p4 = e4 + 1 1377 } 1378 } 1379 1380 m = mp_cat(msg, 0, "nx_stderronly: " as *u8) 1381 m = mp_catn(msg, m, files_read) 1382 m = mp_cat(msg, m, " sources, " as *u8) 1383 m = mp_catn(msg, m, sites_total) 1384 m = mp_cat(msg, m, " fd2 emission sites, " as *u8) 1385 m = mp_catn(msg, m, bkt[SO_B_SILENT]) 1386 m = mp_cat(msg, m, " SILENT in " as *u8) 1387 m = mp_catn(msg, m, kc) 1388 m = mp_cat(msg, m, " functions, UNKNOWN=" as *u8) 1389 m = mp_catn(msg, m, bkt[SO_B_UNKNOWN]) 1390 if sum != sites_total { m = mp_cat(msg, m, " PARTITION-DOES-NOT-RECONCILE" as *u8) } 1391 if wl_dropped > 0 { m = mp_cat(msg, m, " worklist_rows_dropped=" as *u8); m = mp_catn(msg, m, wl_dropped) } 1392 if keys_dropped > 0 { m = mp_cat(msg, m, " ratchet_keys_dropped=" as *u8); m = mp_catn(msg, m, keys_dropped) } 1393 if bn <= 0 { m = mp_cat(msg, m, " no baseline yet -- recording the current set" as *u8) } 1394 if bn > 0 { 1395 if nadd > 0 { m = mp_cat(msg, m, " RED " as *u8); m = mp_catn(msg, m, nadd); m = mp_cat(msg, m, " NEW" as *u8); rc = 1 } 1396 if nadd == 0 { m = mp_cat(msg, m, " GREEN no new silent guard since the baseline" as *u8) } 1397 } 1398 m = mp_cat(msg, m, "\n" as *u8) 1399 mp_say(msg, m) 1400 1401 var green: i64 = 1 1402 if rc != 0 { green = 0 } 1403 so_journal(jpath, cnt, sites_total, bkt[SO_B_SILENT], bkt[SO_B_UNKNOWN], nadd, green) 1404 1405 if nobase == 0 { if haveb == 1 { 1406 var writeit: i64 = 0 1407 if nadd == 0 { writeit = 1 } 1408 if accept == 1 { writeit = 1 } 1409 if writeit == 1 { 1410 // the baseline ALWAYS carries a header, so a clean tree and an unarmed ratchet are 1411 // DIFFERENT FILES -- a zero-byte baseline reads back as "no baseline yet" and would 1412 // disarm the ratchet at exactly the moment the tree became clean 1413 let hdr: *u8 = sys_mmap(SO_MSG) 1414 var ho: i64 = mp_cat(hdr, 0, "# nx_stderronly baseline -- silent-stderr-guard keys, path" as *u8) 1415 hdr[ho] = SO_HASH as u8; ho = ho + 1 1416 ho = mp_cat(hdr, ho, "func\n" as *u8) 1417 let wf: i64 = sys_openat_wr(bpath, SO_MODE_644) 1418 if wf >= 0 { mp_write_all(wf, hdr, ho); mp_write_all(wf, dk, dko); sys_close(wf) } 1419 if accept == 1 { if nadd > 0 { rc = 0 } } 1420 } 1421 } } 1422 return rc 1423}