code wiki / (root) / nx_stepsolve_lib.nx

nx_stepsolve_lib.nx source

↩ module page · 354 lines · 21668 B

1// nx_stepsolve_lib.nx -- ES26 (engineshift al_steps): THE ONE RULER for STEPS-TO-SOLVE PER COMMON TASK. 2// 3// The operator's 2026-09-06 order: if a task can be solved in ONE step within logic it should be, and when it cannot 4// the estate explains why two, why three, and so on, from the most common tasks to the least, mining and evaluating 5// this efficacy continuously. The MEASURED side is the action journal's recurring tool:verb n-grams (nx_actlog's 6// indexed miner, exact support, adjacent only): a recurring bigram is a 2-step ritual, a trigram a 3-step one, and 7// its support is how common it is. The DECLARED side is knowledge/stepsolve.conf, DATA rows 8// steps|<signature>|<min_steps>|<reason>|<one_step_verb> 9// verbclass|<verb>|<reason> 10// where signature = tool:verb>tool:verb[>tool:verb] exactly as the journal spells it, min_steps is the LOGICAL 11// minimum, reason is why it cannot be fewer (a true dependency: a promote must see the sha only a finished build 12// produces) and one_step_verb names the composed verb on the CANONICAL organ that does it in one call 13// (nx_organ_ship for the build-stage-judge-promote ritual). A verbclass row is a RULE: every signature whose EVERY 14// step carries that verb is explained by the rule's reason -- the clock plane and the job lane write <elf>:run for 15// each organ fork, and a fork is one whole organ run and therefore one step by construction, so two adjacent 16// scheduled forks are two tasks and not a ritual. A steps row for a specific signature WINS over a rule, so a fork 17// ritual that does have a composed verb stays declarable. This lib joins the two and classifies every recurring 18// signature: 19// ONE-STEP-AVAILABLE min_steps 1 and a composed verb is named: the ritual is an ADOPTION gap, its support should fall 20// DEPENDENCY min_steps equals the observed steps: the count is explained, the reason travels with it 21// REDUCIBLE 1 < min_steps < observed: fewer steps are possible by declared logic 22// BY-RULE no steps row, every step's verb matches a verbclass row: explained by that rule's reason 23// UNDECLARED no row and no rule: NEVER assumed one-step; it is the worklist, most common first 24// The published figure is a PARTITION over signature support (sums to the total, printed); per-rule support is 25// tallied beside it so a rule can never hide what it absorbed; the gauge stamp is the EXPLAINED permil (declared 26// classes over all), written in the CE9 heartbeat shape so gauge_pass renders it and a stale one reads STALE never 27// zero. A row that cannot be parsed is counted as malformed, never dropped in silence. 28// license_tier: ORIGINAL No hw writes. 29import "nx_sovjson_lib.nx" 30import "nx_syscalls.nx" 31import "nx_gauge_lib.nx" 32 33const SS_CONF_PROD: *u8 = "knowledge/stepsolve.conf" 34const SS_SPINE_PROD: *u8 = "knowledge/status/stepsolve.spine" 35const SS_STAMP_PROD: *u8 = "knowledge/status/stepsolve.stamp" 36const SS_SPINE_SIDECAR: *u8 = ".stepsolve.spine" 37const SS_STAMP_SIDECAR: *u8 = ".stepsolve.stamp" 38const SS_QSTAMP_PROD: *u8 = "knowledge/status/stepsolve_quality.stamp" // ES27: the QUALITY gauge (1000 - failure permil) beside EXPLAINED 39const SS_QSTAMP_SIDECAR: *u8 = ".stepsolve.quality.stamp" 40const SS_CADENCE_S: i64 = 86400 // the daily beat that writes the stamp; max_age derives from it in the gauge lib 41const SS_AXES: i64 = 2 // the journal and the conf: an unreadable conf is an abstaining axis 42const SS_WORD: i64 = 8 43const SS_LINE: i64 = 512 44const SS_PATH: i64 = 1024 45const SS_MODE644: i64 = 420 46const SS_NL: i64 = 10 47const SS_PIPE: i64 = 124 48const SS_HASH: i64 = 35 49const SS_GT: i64 = 62 50const SS_COLON: i64 = 58 51const SS_PERMIL: i64 = 1000 52const SS_ROW_FIELDS: i64 = 5 53const SS_RULE_FIELDS: i64 = 3 54// classes 55const SS_C_UNDECLARED: i64 = 0 56const SS_C_ONE_STEP: i64 = 1 57const SS_C_DEPENDENCY: i64 = 2 58const SS_C_REDUCIBLE: i64 = 3 59const SS_C_RULE: i64 = 4 60const SS_C_N: i64 = 5 61// conf row kinds 62const SS_K_STEPS: i64 = 1 63const SS_K_RULE: i64 = 2 64// steps table slots per row (offsets into the conf buffer; the loader NUL-terminates fields in place) 65const SS_R_SIG: i64 = 0 66const SS_R_SIGLEN: i64 = 1 67const SS_R_MIN: i64 = 2 68const SS_R_REASON: i64 = 3 69const SS_R_VERB: i64 = 4 70const SS_R_HASVERB: i64 = 5 71const SS_R_SLOTS: i64 = 8 72// rule table slots per verbclass row: verb offset+len, reason offset, then the tallies the classifier accumulates 73const SS_U_VERB: i64 = 0 74const SS_U_VERBLEN: i64 = 1 75const SS_U_REASON: i64 = 2 76const SS_U_SUP: i64 = 3 77const SS_U_CNT: i64 = 4 78const SS_U_SLOTS: i64 = 8 79// totals slots: per class support sum [0..4], per class count [5..9], then 80const SS_T_SUP: i64 = 0 81const SS_T_CNT: i64 = 5 82const SS_T_TOTAL_SUP: i64 = 10 83const SS_T_TOTAL_CNT: i64 = 11 84const SS_T_CONF_ROWS: i64 = 12 85const SS_T_CONF_MALFORMED: i64 = 13 86const SS_T_CONF_READ: i64 = 14 87const SS_T_CONF_RULES: i64 = 15 88const SS_T_FAIL: i64 = 16 // per class FAILURE support [16..20]: frames of the ritual whose outcome was not ok (ES27) 89const SS_T_TOTAL_FAIL: i64 = 21 90const SS_T_SLOTS: i64 = 22 91 92func ss_capacity(q: *u8, n: i64) -> i64 { 93 var c: i64 = 1 94 var i: i64 = 0 95 while i < n { if q[i] == (SS_NL as u8) { c = c + 1 } i = i + 1 } 96 return c 97} 98func ss_vlen(s: *u8) -> i64 { return sj_vlen(s) } 99 100// load the conf: rows `steps|sig|min|reason|verb` into tab and `verbclass|verb|reason` into rt; comments (#) and 101// blanks skipped; a steps row without 5 fields or a non-numeric min, a verbclass row without 3 fields or an empty 102// verb, and any other first field are MALFORMED (counted, never dropped in silence). Returns steps rows loaded; 103// t[SS_T_CONF_*] filled (rules in SS_T_CONF_RULES). tab must hold ss_capacity(q,n) * SS_R_SLOTS words and rt 104// ss_capacity(q,n) * SS_U_SLOTS words. Fields are NUL-terminated IN PLACE (the buffer is the arena). 105func ss_conf_load(q: *u8, n: i64, tab: *i64, rt: *i64, t: *i64) -> i64 { 106 var rows: i64 = 0 107 var rules: i64 = 0 108 t[SS_T_CONF_MALFORMED] = 0 109 var i: i64 = 0 110 while i < n { 111 let le: i64 = sj_le(q, i, n) 112 if le > i { if q[i] != (SS_HASH as u8) { 113 var f: i64 = 0 114 var fs: i64 = i 115 var k: i64 = i 116 let base: i64 = rows * SS_R_SLOTS 117 let ub: i64 = rules * SS_U_SLOTS 118 var kind: i64 = 0 119 var ok: i64 = 1 120 var minv: i64 = 0 - 1 121 while k <= le { 122 var atend: i64 = 0 123 if k == le { atend = 1 } else { if q[k] == (SS_PIPE as u8) { atend = 1 } } 124 if atend == 1 { 125 if f == 0 { 126 if sj_lit_eq(q, fs, k, "steps" as *u8) == 1 { kind = SS_K_STEPS } 127 if sj_lit_eq(q, fs, k, "verbclass" as *u8) == 1 { kind = SS_K_RULE } 128 if kind == 0 { ok = 0 } 129 } 130 if kind == SS_K_STEPS { 131 if f == 1 { tab[base + SS_R_SIG] = fs; tab[base + SS_R_SIGLEN] = k - fs } 132 if f == 2 { if k > fs { minv = sj_atoi_span(q, fs, k) } } 133 if f == 3 { tab[base + SS_R_REASON] = fs } 134 if f == 4 { tab[base + SS_R_VERB] = fs; tab[base + SS_R_HASVERB] = 0; if k > fs { tab[base + SS_R_HASVERB] = 1 } } 135 } 136 if kind == SS_K_RULE { 137 if f == 1 { rt[ub + SS_U_VERB] = fs; rt[ub + SS_U_VERBLEN] = k - fs; if k <= fs { ok = 0 } } 138 if f == 2 { rt[ub + SS_U_REASON] = fs } 139 } 140 if k < le { q[k] = 0 as u8 } 141 f = f + 1 142 fs = k + 1 143 } 144 k = k + 1 145 } 146 if q[le] == (SS_NL as u8) { q[le] = 0 as u8 } 147 if kind == SS_K_STEPS { 148 if f < SS_ROW_FIELDS { ok = 0 } 149 if minv < 1 { ok = 0 } 150 if ok == 1 { tab[base + SS_R_MIN] = minv; rows = rows + 1 } 151 } 152 if kind == SS_K_RULE { 153 if f < SS_RULE_FIELDS { ok = 0 } 154 if ok == 1 { rt[ub + SS_U_SUP] = 0; rt[ub + SS_U_CNT] = 0; rules = rules + 1 } 155 } 156 if ok == 0 { t[SS_T_CONF_MALFORMED] = t[SS_T_CONF_MALFORMED] + 1 } 157 } } 158 i = le + 1 159 } 160 t[SS_T_CONF_ROWS] = rows 161 t[SS_T_CONF_RULES] = rules 162 return rows 163} 164// the conf row whose signature equals sig[0..siglen), or -1 165func ss_conf_find(q: *u8, tab: *i64, rows: i64, sig: *u8, siglen: i64) -> i64 { 166 var r: i64 = 0 167 while r < rows { 168 let b: i64 = r * SS_R_SLOTS 169 if tab[b + SS_R_SIGLEN] == siglen { 170 var m: i64 = 0 171 var eq: i64 = 1 172 while m < siglen { if q[tab[b + SS_R_SIG] + m] != sig[m] { eq = 0; m = siglen } else { m = m + 1 } } 173 if eq == 1 { return r } 174 } 175 r = r + 1 176 } 177 return 0 - 1 178} 179// the verbclass rule EVERY step of sig[0..siglen) matches (a step's verb is what follows its LAST colon), or -1; 180// a step without a colon matches no rule, and an empty signature matches none 181func ss_rule_find(q: *u8, rt: *i64, rules: i64, sig: *u8, siglen: i64) -> i64 { 182 var r: i64 = 0 183 while r < rules { 184 let ub: i64 = r * SS_U_SLOTS 185 let vo: i64 = rt[ub + SS_U_VERB] 186 let vl: i64 = rt[ub + SS_U_VERBLEN] 187 var all: i64 = 1 188 var steps: i64 = 0 189 var s: i64 = 0 190 while s < siglen { 191 var e: i64 = s 192 var hit: i64 = 0 193 while hit == 0 { if e >= siglen { hit = 1 } else { if sig[e] == (SS_GT as u8) { hit = 1 } else { e = e + 1 } } } 194 var colon: i64 = 0 - 1 195 var m: i64 = s 196 while m < e { if sig[m] == (SS_COLON as u8) { colon = m } m = m + 1 } 197 if colon < 0 { all = 0 } else { 198 let len: i64 = e - (colon + 1) 199 if len != vl { all = 0 } else { 200 var x: i64 = 0 201 while x < vl { if sig[colon + 1 + x] != q[vo + x] { all = 0 } x = x + 1 } 202 } 203 } 204 steps = steps + 1 205 s = e + 1 206 } 207 if all == 1 { if steps > 0 { return r } } 208 r = r + 1 209 } 210 return 0 - 1 211} 212// THE CLASSIFIER: observed steps vs the declared minimum 213func ss_classify(row: i64, min_steps: i64, has_verb: i64, steps: i64) -> i64 { 214 if row < 0 { return SS_C_UNDECLARED } 215 if min_steps <= 1 { if has_verb == 1 { return SS_C_ONE_STEP } } 216 if min_steps >= steps { return SS_C_DEPENDENCY } 217 if min_steps <= 1 { return SS_C_REDUCIBLE } 218 return SS_C_REDUCIBLE 219} 220// precedence: a steps row decides; else a matching rule; else UNDECLARED 221func ss_class_of(row: i64, min_steps: i64, has_verb: i64, steps: i64, rule: i64) -> i64 { 222 if row >= 0 { return ss_classify(row, min_steps, has_verb, steps) } 223 if rule >= 0 { return SS_C_RULE } 224 return SS_C_UNDECLARED 225} 226func ss_rule_add(rt: *i64, rule: i64, support: i64) -> i64 { 227 let ub: i64 = rule * SS_U_SLOTS 228 rt[ub + SS_U_SUP] = rt[ub + SS_U_SUP] + support 229 rt[ub + SS_U_CNT] = rt[ub + SS_U_CNT] + 1 230 return 0 231} 232func ss_class_name(c: i64) -> *u8 { 233 if c == SS_C_ONE_STEP { return "ONE-STEP-AVAILABLE" as *u8 } 234 if c == SS_C_DEPENDENCY { return "DEPENDENCY" as *u8 } 235 if c == SS_C_REDUCIBLE { return "REDUCIBLE" as *u8 } 236 if c == SS_C_RULE { return "BY-RULE" as *u8 } 237 return "UNDECLARED" as *u8 238} 239func ss_totals_zero(t: *i64) -> i64 { var z: i64 = 0; while z < SS_T_SLOTS { t[z] = 0; z = z + 1 } return 0 } 240func ss_totals_add(t: *i64, c: i64, support: i64, fail: i64) -> i64 { 241 t[SS_T_SUP + c] = t[SS_T_SUP + c] + support 242 t[SS_T_CNT + c] = t[SS_T_CNT + c] + 1 243 t[SS_T_FAIL + c] = t[SS_T_FAIL + c] + fail 244 t[SS_T_TOTAL_SUP] = t[SS_T_TOTAL_SUP] + support 245 t[SS_T_TOTAL_CNT] = t[SS_T_TOTAL_CNT] + 1 246 t[SS_T_TOTAL_FAIL] = t[SS_T_TOTAL_FAIL] + fail 247 return 0 248} 249func ss_permil(part: i64, whole: i64) -> i64 { if whole <= 0 { return 0 - 1 } return part * SS_PERMIL / whole } 250// the EXPLAINED permil: every declared class (steps rows and rules) over the total support; -1 when nothing recurs 251// (UNOBSERVABLE, never 0) 252func ss_explained_permil(t: *i64) -> i64 { 253 let declared: i64 = t[SS_T_SUP + SS_C_ONE_STEP] + t[SS_T_SUP + SS_C_DEPENDENCY] + t[SS_T_SUP + SS_C_REDUCIBLE] + t[SS_T_SUP + SS_C_RULE] 254 return ss_permil(declared, t[SS_T_TOTAL_SUP]) 255} 256// ES27 (operator 2026-09-06): a bad one-step is worse than a rigorous forty-step. QUALITY permil = 1000 - failure support over 257// total support (a frame whose journal outcome is not ok taints every ritual it closes); -1 when nothing recurs. RISK orders the 258// worklist: support x failure permil, so a common bad one-step outranks a rare rigorous long one. 259func ss_fail_permil(support: i64, fail: i64) -> i64 { return ss_permil(fail, support) } 260func ss_quality_permil(t: *i64) -> i64 { let fp: i64 = ss_permil(t[SS_T_TOTAL_FAIL], t[SS_T_TOTAL_SUP]); if fp < 0 { return 0 - 1 } return SS_PERMIL - fp } 261func ss_risk(support: i64, fail: i64) -> i64 { let fp: i64 = ss_fail_permil(support, fail); if fp < 0 { return 0 } return support * fp } 262// the JSON totals object at d[p0..]: the partition by class, support-weighted, with counts and the sum printed 263func ss_emit_totals(d: *u8, p0: i64, t: *i64) -> i64 { 264 var p: i64 = p0 265 d[p] = 123 as u8; p = p + 1 266 var c: i64 = 0 267 while c < SS_C_N { 268 if c > 0 { d[p] = 44 as u8; p = p + 1 } 269 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, ss_class_name(c)); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1 270 d[p] = 123 as u8; p = p + 1 271 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "support" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_SUP + c]); d[p] = 44 as u8; p = p + 1 272 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "signatures" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_CNT + c]); d[p] = 44 as u8; p = p + 1 273 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "permil" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, ss_permil(t[SS_T_SUP + c], t[SS_T_TOTAL_SUP])); d[p] = 44 as u8; p = p + 1 274 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "fail" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_FAIL + c]); d[p] = 44 as u8; p = p + 1 275 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "fail_permil" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, ss_fail_permil(t[SS_T_SUP + c], t[SS_T_FAIL + c])) 276 d[p] = 125 as u8; p = p + 1 277 c = c + 1 278 } 279 d[p] = 44 as u8; p = p + 1 280 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "total_support" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_TOTAL_SUP]); d[p] = 44 as u8; p = p + 1 281 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "total_signatures" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_TOTAL_CNT]); d[p] = 44 as u8; p = p + 1 282 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "partition_sums" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1 283 var sum: i64 = 0 284 var sc: i64 = 0 285 while sc < SS_C_N { sum = sum + t[SS_T_SUP + sc]; sc = sc + 1 } 286 var ps: i64 = 0 287 if sum == t[SS_T_TOTAL_SUP] { ps = 1 } 288 p = sj_catn(d, p, ps); d[p] = 44 as u8; p = p + 1 289 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "explained_permil" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, ss_explained_permil(t)); d[p] = 44 as u8; p = p + 1 290 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "total_fail" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, t[SS_T_TOTAL_FAIL]); d[p] = 44 as u8; p = p + 1 291 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "quality_permil" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, ss_quality_permil(t)) 292 d[p] = 125 as u8; p = p + 1 293 return p 294} 295// spine + stamp, derived paths: production iff the journal IS the live journal, else sidecars beside the source 296func ss_is_prod(journal: *u8) -> i64 { 297 return sj_lit_eq(journal, 0, sj_vlen(journal), "knowledge/status/actlog.jrnl" as *u8) 298} 299func ss_side_path(journal: *u8, sfx: *u8, out: *u8) -> i64 { let o: i64 = sj_cat(out, 0, journal); return sj_cat(out, o, sfx) } 300// one spine row per measured run + the gauge stamp (the EXPLAINED permil, axes = journal + conf), announced in the JSON 301func ss_publish_json(d: *u8, p0: i64, journal: *u8, now: i64, t: *i64) -> i64 { 302 var p: i64 = p0 303 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "publish" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1 304 d[p] = 123 as u8; p = p + 1 305 if t[SS_T_TOTAL_CNT] <= 0 { 306 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "spine" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1 307 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "NONE" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 44 as u8; p = p + 1 308 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "reason" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1 309 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "no recurring signature: an unobservable run writes no trend point and no stamp" as *u8); d[p] = 34 as u8; p = p + 1 310 d[p] = 125 as u8; p = p + 1 311 return p 312 } 313 let spine: *u8 = sys_mmap(SS_PATH) 314 let stamp: *u8 = sys_mmap(SS_PATH) 315 if ss_is_prod(journal) == 1 { sj_cat(spine, 0, SS_SPINE_PROD); sj_cat(stamp, 0, SS_STAMP_PROD) } else { ss_side_path(journal, SS_SPINE_SIDECAR, spine); ss_side_path(journal, SS_STAMP_SIDECAR, stamp) } 316 let row: *u8 = sys_mmap(SS_LINE) 317 var o: i64 = sj_catn(row, 0, now) 318 o = sj_cat(row, o, "|signatures=" as *u8); o = sj_catn(row, o, t[SS_T_TOTAL_CNT]) 319 o = sj_cat(row, o, "|support=" as *u8); o = sj_catn(row, o, t[SS_T_TOTAL_SUP]) 320 o = sj_cat(row, o, "|one_step_available=" as *u8); o = sj_catn(row, o, t[SS_T_SUP + SS_C_ONE_STEP]) 321 o = sj_cat(row, o, "|dependency=" as *u8); o = sj_catn(row, o, t[SS_T_SUP + SS_C_DEPENDENCY]) 322 o = sj_cat(row, o, "|reducible=" as *u8); o = sj_catn(row, o, t[SS_T_SUP + SS_C_REDUCIBLE]) 323 o = sj_cat(row, o, "|by_rule=" as *u8); o = sj_catn(row, o, t[SS_T_SUP + SS_C_RULE]) 324 o = sj_cat(row, o, "|undeclared=" as *u8); o = sj_catn(row, o, t[SS_T_SUP + SS_C_UNDECLARED]) 325 o = sj_cat(row, o, "|explained_permil=" as *u8); o = sj_catn(row, o, ss_explained_permil(t)) 326 o = sj_cat(row, o, "|fail=" as *u8); o = sj_catn(row, o, t[SS_T_TOTAL_FAIL]) 327 o = sj_cat(row, o, "|quality_permil=" as *u8); o = sj_catn(row, o, ss_quality_permil(t)) 328 o = sj_cat(row, o, "|conf_rows=" as *u8); o = sj_catn(row, o, t[SS_T_CONF_ROWS]) 329 o = sj_cat(row, o, "|conf_rules=" as *u8); o = sj_catn(row, o, t[SS_T_CONF_RULES]) 330 o = sj_cat(row, o, "|conf_malformed=" as *u8); o = sj_catn(row, o, t[SS_T_CONF_MALFORMED]) 331 row[o] = SS_NL as u8; o = o + 1; row[o] = 0 as u8 332 let fd: i64 = sys_openat_append(spine, SS_MODE644) 333 var wrote: i64 = 0 - 1 334 if fd >= 0 { wrote = sys_write(fd, row, o); sys_close(fd) } 335 // the gauge stamp: EXPLAINED permil; axes known = journal (always, we are here) + conf (read or not) 336 var known: i64 = 1 337 if t[SS_T_CONF_READ] == 1 { known = 2 } 338 let sw: i64 = ga_stamp_write(stamp, now, ss_explained_permil(t), known, SS_AXES, SS_CADENCE_S) 339 // ES27: the QUALITY stamp beside it, same axes, same cadence -- rendered by gauge_pass as a second gauge row 340 let qstamp: *u8 = sys_mmap(SS_PATH) 341 if ss_is_prod(journal) == 1 { sj_cat(qstamp, 0, SS_QSTAMP_PROD) } else { ss_side_path(journal, SS_QSTAMP_SIDECAR, qstamp) } 342 let qw: i64 = ga_stamp_write(qstamp, now, ss_quality_permil(t), known, SS_AXES, SS_CADENCE_S) 343 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "spine" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, spine); d[p] = 34 as u8; p = p + 1; d[p] = 44 as u8; p = p + 1 344 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "spine_wrote" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, wrote); d[p] = 44 as u8; p = p + 1 345 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "stamp" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, stamp); d[p] = 34 as u8; p = p + 1; d[p] = 44 as u8; p = p + 1 346 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "stamp_wrote" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, sw); d[p] = 44 as u8; p = p + 1 347 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "quality_stamp" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, qstamp); d[p] = 34 as u8; p = p + 1; d[p] = 44 as u8; p = p + 1 348 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "quality_stamp_wrote" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, qw); d[p] = 44 as u8; p = p + 1 349 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "quality_permil" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, ss_quality_permil(t)); d[p] = 44 as u8; p = p + 1 350 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "axes_known" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, known); d[p] = 44 as u8; p = p + 1 351 d[p] = 34 as u8; p = p + 1; p = sj_cat(d, p, "axes_total" as *u8); d[p] = 34 as u8; p = p + 1; d[p] = 58 as u8; p = p + 1; p = sj_catn(d, p, SS_AXES) 352 d[p] = 125 as u8; p = p + 1 353 return p 354}