code wiki / (root) / nx_stepsolve_gate.nx

nx_stepsolve_gate.nx source

↩ module page · 292 lines · 23541 B

1// nx_stepsolve_gate.nx -- ES26 (engineshift al_steps): STEPS-TO-SOLVE proven END-TO-END on a planted journal. 2// Forks the SUBJECT ARTIFACT (the built nx_actlog, resolved from the roots the estate serves it from) with a planted 3// action journal and a planted conf and reads the JSON it prints, so the whole path -- indexed miner at gap zero, 4// closed-bigram subsumption, conf join (steps rows AND verbclass rules, a steps row winning), classification, 5// partition, per-rule tallies, ordering, worklist, spine and stamp -- is the subject, not a re-implementation. 6// Every ritual repetition lives in its OWN workstream so no cross-repeat bigram can form (the miner chains 7// successors per workstream). Seat frames are spelled tool:call and fork frames elf:run, the production journal's 8// own vocabulary (the first live beat read explained_permil=0 because a conf spelled :use could match nothing). 9// The stamp is judged through nx_gauge_lib in-process: the same ruler the /compare emitter renders it with. 10// ES27 (operator 2026-09-06: a bad one-step not rigorously evaluated is worse than a rigorous forty-step): a SECOND 11// planted journal with a failing one-step pair and a clean triple proves the QUALITY axis on the same subject -- 12// fail, fail permil, risk = support x failure permil, the risk worklist most dangerous first, the quality gauge stamp. 13// exit: 0 GREEN . 1 RED . 3 SKIP license_tier: ORIGINAL No hw writes. 14import "nx_syscalls.nx" 15import "nx_gate_verdict.nx" 16import "nx_tool_run.nx" 17import "nx_gauge_lib.nx" 18 19const SG_ROOT: *u8 = "/tmp/nx_stepsolve_gate" 20const SG_J: *u8 = "/tmp/nx_stepsolve_gate/j.jrnl" 21const SG_J_SPINE: *u8 = "/tmp/nx_stepsolve_gate/j.jrnl.stepsolve.spine" 22const SG_J_STAMP: *u8 = "/tmp/nx_stepsolve_gate/j.jrnl.stepsolve.stamp" 23const SG_EMPTY: *u8 = "/tmp/nx_stepsolve_gate/empty.jrnl" 24const SG_CONF: *u8 = "/tmp/nx_stepsolve_gate/c.conf" 25const SG_CONF_ABSENT: *u8 = "/tmp/nx_stepsolve_gate/absent.conf" 26const SG_PROD_SPINE: *u8 = "knowledge/status/stepsolve.spine" 27const SG_PROD_STAMP: *u8 = "knowledge/status/stepsolve.stamp" 28const SG_MODE_RWX: i64 = 493 29const SG_MODE_RW: i64 = 420 30const SG_TAB: i64 = 9 31const SG_NL: i64 = 10 32const SG_LINE: i64 = 512 33const SG_OUT: i64 = 262144 34const SG_NOW: i64 = 1788700000 35const SG_NOW_S: *u8 = "1788700000" 36const SG_TS0: i64 = 1788600000 37const SG_VERB_CALL: *u8 = "call" 38const SG_VERB_RUN: *u8 = "run" 39// the planted population, decided before the run: A trigram x4 (one-step verb declared), B bigram x3 (dependency), 40// C bigram x2 (reducible, verb owed), D bigram x5 (undeclared, the most common), E fork pair x3 (BY-RULE via 41// verbclass run), F fork pair x2 with its OWN steps row (the row wins over the rule) 42const SG_SUP_A: i64 = 4 43const SG_SUP_B: i64 = 3 44const SG_SUP_C: i64 = 2 45const SG_SUP_D: i64 = 5 46const SG_SUP_E: i64 = 3 47const SG_SUP_F: i64 = 2 48const SG_TOTAL: i64 = 19 49const SG_EXPLAINED_PERMIL: i64 = 736 // (4+3+2+3+2)*1000/19 50// ES27 (operator 2026-09-06: a bad one-step is worse than a rigorous long ritual): a SECOND planted journal so the 51// existing expectations stay untouched -- G a one-step pair repeated 5 times with 4 failing outcomes, H a clean 52// three-step ritual repeated 3 times; no conf row matches either, so the QUALITY axis alone must separate them 53const SG_JQ: *u8 = "/tmp/nx_stepsolve_gate/quality.jrnl" 54const SG_JQ_QSTAMP: *u8 = "/tmp/nx_stepsolve_gate/quality.jrnl.stepsolve.quality.stamp" 55const SG_SUP_G: i64 = 5 56const SG_FAIL_G: i64 = 4 57const SG_SUP_H: i64 = 3 58const SG_Q_QUALITY: i64 = 500 // 1000 - 4*1000/8: total support 8 (G 5 + H 3), failing 4 59 60func sg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 61func sg_w(fd: i64, s: *u8) -> i64 { return sys_write(fd, s, sg_slen(s)) } 62func sg_b(fd: i64, code: i64) -> i64 { let b: *u8 = sys_mmap(4); b[0] = code as u8; return sys_write(fd, b, 1) } 63func sg_n(fd: i64, v: i64) -> i64 { let b: *u8 = sys_mmap(SG_LINE); let o: i64 = sj_catn(b, 0, v); return sys_write(fd, b, o) } 64// one journal frame: ts TAB ws TAB tool TAB verb TAB outcome TAB note (real TAB bytes) 65func sg_frame(fd: i64, ts: i64, ws: *u8, tool: *u8, verb: *u8) -> i64 { 66 sg_n(fd, ts); sg_b(fd, SG_TAB); sg_w(fd, ws); sg_b(fd, SG_TAB); sg_w(fd, tool); sg_b(fd, SG_TAB); sg_w(fd, verb); sg_b(fd, SG_TAB); sg_w(fd, "ok" as *u8); sg_b(fd, SG_TAB); sg_w(fd, "planted" as *u8); sg_b(fd, SG_NL) 67 return 0 68} 69func sg_open(path: *u8) -> i64 { sys_unlinkat(path); return sys_openat_wr(path, SG_MODE_RW) } 70func sg_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 71func sg_size(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } let s: i64 = sys_lseek(fd, 0, 2); sys_close(fd); return s } 72func sg_lines(path: *u8) -> i64 { 73 let ln: *i64 = sys_mmap(16) as *i64 74 let b: *u8 = sys_read_file(path, ln) 75 if (b as i64) == 0 { return 0 - 1 } 76 var c: i64 = 0 77 var i: i64 = 0 78 while i < ln[0] { if b[i] == (SG_NL as u8) { c = c + 1 } i = i + 1 } 79 return c 80} 81func sg_find(buf: *u8, n: i64, needle: *u8) -> i64 { 82 let m: i64 = sg_slen(needle) 83 if m == 0 { return 0 } 84 var i: i64 = 0 85 while i + m <= n { var j: i64 = 0; var ok: i64 = 1; while j < m { if buf[i + j] != needle[j] { ok = 0; j = m } else { j = j + 1 } } if ok == 1 { return 1 } i = i + 1 } 86 return 0 87} 88// the subject: the built nx_actlog, from the root that serves it (the runner's CWD decides which spelling resolves) 89func sg_subject(out: *u8) -> i64 { 90 if sg_exists("_offc/nx_actlog.elf" as *u8) == 1 { sj_cat(out, 0, "_offc/nx_actlog.elf" as *u8); return 1 } 91 if sg_exists("./nx_actlog.elf" as *u8) == 1 { sj_cat(out, 0, "./nx_actlog.elf" as *u8); return 1 } 92 if sg_exists("../nx_actlog.elf" as *u8) == 1 { sj_cat(out, 0, "../nx_actlog.elf" as *u8); return 1 } 93 if sg_exists("_build/nx_actlog.sov.elf" as *u8) == 1 { sj_cat(out, 0, "_build/nx_actlog.sov.elf" as *u8); return 1 } 94 return 0 95} 96// fork `<subject> steps <journal> 2 <conf> 20 <now>` and capture its JSON; returns bytes captured or -1 97func sg_run(subject: *u8, journal: *u8, conf: *u8, out: *u8) -> i64 { 98 let av: *i64 = sys_mmap(96) as *i64 99 av[0] = subject as i64 100 av[1] = "steps" as *u8 as i64 101 av[2] = journal as i64 102 av[3] = "2" as *u8 as i64 103 av[4] = conf as i64 104 av[5] = "20" as *u8 as i64 105 av[6] = SG_NOW_S as i64 106 av[7] = 0 107 let cl: *i64 = sys_mmap(16) as *i64 108 let ex: i64 = tr_run_capture(subject, av, out, SG_OUT - 1, cl) 109 if ex != 0 { return 0 - 1 } 110 return cl[0] 111} 112// a planted pair ritual repeated `sup` times, each repetition in its own workstream `<tag><r>` 113func sg_plant_pair(fd: i64, ts0: i64, sup: i64, tag: *u8, t1: *u8, t2: *u8, verb: *u8) -> i64 { 114 var ts: i64 = ts0 115 var r: i64 = 0 116 while r < sup { 117 let ws: *u8 = sys_mmap(32); var o: i64 = sj_cat(ws, 0, tag); o = sj_catn(ws, o, r); ws[o] = 0 as u8 118 sg_frame(fd, ts, ws, t1, verb); ts = ts + 1 119 sg_frame(fd, ts, ws, t2, verb); ts = ts + 1 120 r = r + 1 121 } 122 return ts 123} 124// ES27: one frame with a caller-chosen outcome column (the planter above always writes ok) 125func sg_frame_o(fd: i64, ts: i64, ws: *u8, tool: *u8, verb: *u8, outcome: *u8) -> i64 { 126 sg_n(fd, ts); sg_b(fd, SG_TAB); sg_w(fd, ws); sg_b(fd, SG_TAB); sg_w(fd, tool); sg_b(fd, SG_TAB); sg_w(fd, verb); sg_b(fd, SG_TAB); sg_w(fd, outcome); sg_b(fd, SG_TAB); sg_w(fd, "planted" as *u8); sg_b(fd, SG_NL) 127 return 0 128} 129// ES27: a pair ritual whose first nfail repetitions END in a failing frame (the ritual ran, its outcome was bad) 130func sg_plant_pair_fail(fd: i64, ts0: i64, sup: i64, nfail: i64, tag: *u8, t1: *u8, t2: *u8, verb: *u8) -> i64 { 131 var ts: i64 = ts0 132 var r: i64 = 0 133 while r < sup { 134 let ws: *u8 = sys_mmap(32); var o: i64 = sj_cat(ws, 0, tag); o = sj_catn(ws, o, r); ws[o] = 0 as u8 135 sg_frame(fd, ts, ws, t1, verb); ts = ts + 1 136 if r < nfail { sg_frame_o(fd, ts, ws, t2, verb, "fail" as *u8) } else { sg_frame(fd, ts, ws, t2, verb) } 137 ts = ts + 1 138 r = r + 1 139 } 140 return ts 141} 142// ES27: a clean three-step ritual repeated `sup` times, each repetition in its own workstream `<tag><r>` 143func sg_plant_triple(fd: i64, ts0: i64, sup: i64, tag: *u8, t1: *u8, t2: *u8, t3: *u8, verb: *u8) -> i64 { 144 var ts: i64 = ts0 145 var r: i64 = 0 146 while r < sup { 147 let ws: *u8 = sys_mmap(32); var o: i64 = sj_cat(ws, 0, tag); o = sj_catn(ws, o, r); ws[o] = 0 as u8 148 sg_frame(fd, ts, ws, t1, verb); ts = ts + 1 149 sg_frame(fd, ts, ws, t2, verb); ts = ts + 1 150 sg_frame(fd, ts, ws, t3, verb); ts = ts + 1 151 r = r + 1 152 } 153 return ts 154} 155 156func main(argc: i64, argv: *i64) -> i64 { 157 let ctr: *i64 = gv_ctr() 158 gv_head("NX-STEPSOLVE-GATE: steps-to-solve end to end -- the partition sums, the most common ritual leads, an undeclared one never reads one-step, a verbclass rule explains the fork pair and a steps row wins over it, the stamp judges FRESH through the gauge ruler, and a failing one-step pair outranks a clean triple on the risk worklist" as *u8) 159 sys_mkdir(SG_ROOT, SG_MODE_RWX) 160 sys_unlinkat(SG_J_SPINE) 161 sys_unlinkat(SG_J_STAMP) 162 sys_unlinkat(SG_CONF_ABSENT) 163 sys_unlinkat(SG_JQ_QSTAMP) 164 // ---- the planted journal: every repetition in its own workstream ---- 165 var fd: i64 = sg_open(SG_J) 166 var ts: i64 = SG_TS0 167 ts = sg_plant_triple(fd, ts, SG_SUP_A, "wsA" as *u8, "nx_sov_build_run" as *u8, "nx_filecopy" as *u8, "nx_contentdiff" as *u8, SG_VERB_CALL) 168 ts = sg_plant_pair(fd, ts, SG_SUP_B, "wsB" as *u8, "nx_fs_write" as *u8, "nx_fs" as *u8, SG_VERB_CALL) 169 ts = sg_plant_pair(fd, ts, SG_SUP_C, "wsC" as *u8, "nx_txtscan" as *u8, "nx_fs" as *u8, SG_VERB_CALL) 170 ts = sg_plant_pair(fd, ts, SG_SUP_D, "wsD" as *u8, "nx_alpha" as *u8, "nx_beta" as *u8, SG_VERB_CALL) 171 ts = sg_plant_pair(fd, ts, SG_SUP_E, "wsE" as *u8, "nx_e1.elf" as *u8, "nx_e2.elf" as *u8, SG_VERB_RUN) 172 ts = sg_plant_pair(fd, ts, SG_SUP_F, "wsF" as *u8, "nx_f1.elf" as *u8, "nx_f2.elf" as *u8, SG_VERB_RUN) 173 sys_close(fd) 174 fd = sg_open(SG_EMPTY); sys_close(fd) 175 // ---- the planted conf: A one-step verb, B dependency, C reducible (verb owed), F its own row, two rules (run, and 176 // a harness rule no frame matches), one malformed steps row, one malformed rule, one comment ---- 177 fd = sg_open(SG_CONF) 178 sg_w(fd, "# planted\n" as *u8) 179 sg_w(fd, "steps|nx_sov_build_run:call>nx_filecopy:call>nx_contentdiff:call|1|one ship|nx_organ_ship\n" as *u8) 180 sg_w(fd, "steps|nx_fs_write:call>nx_fs:call|2|the receipt lands in the job artifact|\n" as *u8) 181 sg_w(fd, "steps|nx_txtscan:call>nx_fs:call|1|an offset-to-lines verb is owed|\n" as *u8) 182 sg_w(fd, "steps|nx_f1.elf:run>nx_f2.elf:run|1|a fork ritual with a composed verb declared|nx_fcomposed\n" as *u8) 183 sg_w(fd, "verbclass|run|each fork is one whole organ run and one step by construction\n" as *u8) 184 sg_w(fd, "verbclass|-|a harness frame is outside the sovereign surface\n" as *u8) 185 sg_w(fd, "steps|bad\n" as *u8) 186 sg_w(fd, "verbclass|onlyverb\n" as *u8) 187 sys_close(fd) 188 let subj: *u8 = sys_mmap(256) 189 if gv_need("subject nx_actlog artifact resolves from a served root" as *u8, sg_subject(subj), ctr) == 0 { return gv_verdict("nx_stepsolve_gate" as *u8, ctr, "subject artifact absent from every root" as *u8) } 190 let prod_spine_before: i64 = sg_size(SG_PROD_SPINE) 191 let prod_stamp_before: i64 = sg_size(SG_PROD_STAMP) 192 let out: *u8 = sys_mmap(SG_OUT) 193 let n: i64 = sg_run(subj, SG_J, SG_CONF, out) 194 if gv_need("subject ran and printed a document" as *u8, (n > 0) as i64, ctr) == 0 { return gv_verdict("nx_stepsolve_gate" as *u8, ctr, "subject produced nothing" as *u8) } 195 // ---- conf envelope: four steps rows, two rules, two malformed (one of each kind) ---- 196 gv_check("conf-read-four-steps-rows-two-malformed-two-rules" as *u8, sg_find(out, n, "\"conf_read\":1,\"conf_rows\":4,\"conf_malformed\":2,\"conf_rules\":2" as *u8), ctr) 197 // ---- the miner: A's bigrams are subsumed by its trigram (closed), so five closed bigrams and one trigram ---- 198 gv_check("closed-bigrams-exclude-the-trigram-halves" as *u8, sg_find(out, n, "\"bigrams_closed\":5,\"trigrams\":1" as *u8), ctr) 199 gv_check("six-recurring-signatures-in-the-population" as *u8, sg_find(out, n, "\"signatures_of\":6" as *u8), ctr) 200 // ---- the partition, support-weighted, sums to the total ---- 201 gv_check("one-step-available-support-is-A-plus-F" as *u8, sg_find(out, n, "\"ONE-STEP-AVAILABLE\":{\"support\":6,\"signatures\":2" as *u8), ctr) 202 gv_check("dependency-support-is-B" as *u8, sg_find(out, n, "\"DEPENDENCY\":{\"support\":3,\"signatures\":1" as *u8), ctr) 203 gv_check("reducible-support-is-C" as *u8, sg_find(out, n, "\"REDUCIBLE\":{\"support\":2,\"signatures\":1" as *u8), ctr) 204 gv_check("by-rule-support-is-E" as *u8, sg_find(out, n, "\"BY-RULE\":{\"support\":3,\"signatures\":1" as *u8), ctr) 205 gv_check("undeclared-support-is-D" as *u8, sg_find(out, n, "\"UNDECLARED\":{\"support\":5,\"signatures\":1" as *u8), ctr) 206 gv_check("total-support-nineteen-and-partition-sums" as *u8, sg_find(out, n, "\"total_support\":19,\"total_signatures\":6,\"partition_sums\":1" as *u8), ctr) 207 gv_check("explained-permil-is-fourteen-of-nineteen" as *u8, sg_find(out, n, "\"explained_permil\":736" as *u8), ctr) 208 // ---- the rules array: per-rule support, an unused rule reports zero and never invents support ---- 209 gv_check("rules-array-carries-the-run-rule-support-and-reason" as *u8, sg_find(out, n, "\"rules\":[{\"verb\":\"run\",\"support\":3,\"signatures\":1,\"reason\":\"each fork is one whole organ run and one step by construction\"}" as *u8), ctr) 210 gv_check("neg-control-unused-rule-reports-zero-never-invents-support" as *u8, sg_find(out, n, "{\"verb\":\"-\",\"support\":0,\"signatures\":0,\"reason\":\"a harness frame is outside the sovereign surface\"}]" as *u8), ctr) 211 // ---- rows: the declared reason travels with the count; the gap names the composed verb; every row carries its 212 // quality triple (fail, fail_permil, risk) between support and class, zero on a journal where nothing failed ---- 213 gv_check("A-row-one-step-available-gap-two-names-nx_organ_ship" as *u8, sg_find(out, n, "\"signature\":\"nx_sov_build_run:call>nx_filecopy:call>nx_contentdiff:call\",\"steps\":3,\"support\":4,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"ONE-STEP-AVAILABLE\",\"min_steps\":1,\"gap\":2,\"reason\":\"one ship\",\"one_step_verb\":\"nx_organ_ship\"" as *u8), ctr) 214 gv_check("B-row-dependency-gap-zero-with-its-reason" as *u8, sg_find(out, n, "\"signature\":\"nx_fs_write:call>nx_fs:call\",\"steps\":2,\"support\":3,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"DEPENDENCY\",\"min_steps\":2,\"gap\":0,\"reason\":\"the receipt lands in the job artifact\"" as *u8), ctr) 215 gv_check("C-row-reducible-verb-owed" as *u8, sg_find(out, n, "\"signature\":\"nx_txtscan:call>nx_fs:call\",\"steps\":2,\"support\":2,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"REDUCIBLE\",\"min_steps\":1,\"gap\":1" as *u8), ctr) 216 let d_und: i64 = sg_find(out, n, "\"signature\":\"nx_alpha:call>nx_beta:call\",\"steps\":2,\"support\":5,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"UNDECLARED\",\"min_steps\":\"UNDECLARED\"" as *u8) 217 gv_check("D-row-undeclared-never-assumed-one-step" as *u8, d_und, ctr) 218 let e_rule: i64 = sg_find(out, n, "\"signature\":\"nx_e1.elf:run>nx_e2.elf:run\",\"steps\":2,\"support\":3,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"BY-RULE\",\"min_steps\":2,\"gap\":0,\"rule_verb\":\"run\",\"reason\":\"each fork is one whole organ run and one step by construction\"" as *u8) 219 gv_check("E-row-by-rule-carries-the-rule-verb-and-reason" as *u8, e_rule, ctr) 220 gv_check("F-row-steps-row-wins-over-the-verbclass-rule" as *u8, sg_find(out, n, "\"signature\":\"nx_f1.elf:run>nx_f2.elf:run\",\"steps\":2,\"support\":2,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"ONE-STEP-AVAILABLE\",\"min_steps\":1,\"gap\":1,\"reason\":\"a fork ritual with a composed verb declared\",\"one_step_verb\":\"nx_fcomposed\"" as *u8), ctr) 221 // ---- ordering: the most common ritual leads the list; the worklist holds exactly the undeclared one ---- 222 gv_check("most-common-signature-emitted-first" as *u8, sg_find(out, n, "\"signatures\":[{\"signature\":\"nx_alpha:call>nx_beta:call\"" as *u8), ctr) 223 gv_check("worklist-is-the-undeclared-one-most-common-first-never-the-ruled-pair" as *u8, sg_find(out, n, "\"worklist_undeclared\":[{\"signature\":\"nx_alpha:call>nx_beta:call\",\"steps\":2,\"support\":5}],\"worklist_shown\":1,\"worklist_of\":1" as *u8), ctr) 224 // ---- quality on a journal where nothing failed: zero failures, quality 1000, an EMPTY risk worklist (neg-control) ---- 225 gv_check("clean-journal-total-fail-zero-quality-permil-1000" as *u8, sg_find(out, n, "\"total_fail\":0,\"quality_permil\":1000" as *u8), ctr) 226 gv_check("neg-control-clean-journal-risk-worklist-is-empty" as *u8, sg_find(out, n, "\"worklist_risk\":[],\"worklist_risk_shown\":0" as *u8), ctr) 227 // ---- spine + stamp: sidecars beside the fixture, production untouched, the stamp judges FRESH via the gauge ruler ---- 228 gv_check_eq("one-run-one-sidecar-spine-row" as *u8, sg_lines(SG_J_SPINE), 1, ctr) 229 let f: *i64 = sys_mmap(GA_F_SLOTS * GA_WORD) as *i64 230 let st: i64 = ga_judge(SG_J_STAMP, SG_NOW + 1, 0, f) 231 let g1: i64 = f[GA_F_GAUGE] 232 gv_check_eq("stamp-judges-FRESH-through-the-gauge-ruler" as *u8, st, GA_FRESH, ctr) 233 gv_check_eq("stamp-gauge-is-the-explained-permil" as *u8, g1, SG_EXPLAINED_PERMIL, ctr) 234 gv_check_eq("stamp-axes-both-known-journal-and-conf" as *u8, f[GA_F_KNOWN] * 10 + f[GA_F_TOTAL], 22, ctr) 235 gv_check("neg-control-production-spine-and-stamp-unchanged-by-the-fixture" as *u8, ((sg_size(SG_PROD_SPINE) == prod_spine_before) as i64) * ((sg_size(SG_PROD_STAMP) == prod_stamp_before) as i64), ctr) 236 // ---- a second run appends a second row (the trend is a spine, not a level) ---- 237 let out2: *u8 = sys_mmap(SG_OUT) 238 let n2: i64 = sg_run(subj, SG_J, SG_CONF, out2) 239 gv_check_eq("two-runs-two-sidecar-spine-rows" as *u8, sg_lines(SG_J_SPINE), 2, ctr) 240 // ---- an ABSENT conf is an abstaining axis: everything UNDECLARED (no rows, no rules), explained 0, BLIND never FRESH ---- 241 let out3: *u8 = sys_mmap(SG_OUT) 242 let n3: i64 = sg_run(subj, SG_J, SG_CONF_ABSENT, out3) 243 gv_check("absent-conf-reads-conf_read-zero-all-undeclared-rules-none" as *u8, sg_find(out3, n3, "\"conf_read\":0,\"conf_rows\":0,\"conf_malformed\":0,\"conf_rules\":0" as *u8) * sg_find(out3, n3, "\"UNDECLARED\":{\"support\":19,\"signatures\":6" as *u8), ctr) 244 let st3: i64 = ga_judge(SG_J_STAMP, SG_NOW + 1, 0, f) 245 gv_check_eq("absent-conf-stamp-judges-BLIND-never-fresh" as *u8, st3, GA_BLIND, ctr) 246 // ---- an empty journal writes no trend point ---- 247 let out4: *u8 = sys_mmap(SG_OUT) 248 let n4: i64 = sg_run(subj, SG_EMPTY, SG_CONF, out4) 249 gv_check("empty-journal-writes-no-spine-row" as *u8, sg_find(out4, n4, "\"spine\":\"NONE\"" as *u8), ctr) 250 // ---- bites: the one-step verb key appears on the declared row and never on the undeclared one; the rule fires on 251 // the fork pair and never promotes it to one-step ---- 252 let a_has: i64 = sg_find(out, n, "\"one_step_verb\":\"nx_organ_ship\"" as *u8) 253 let d_has_verb: i64 = sg_find(out, n, "\"nx_alpha:call>nx_beta:call\",\"steps\":2,\"support\":5,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"UNDECLARED\",\"min_steps\":\"UNDECLARED\",\"remedy\"" as *u8) 254 gv_bite("undeclared-signature-never-carries-a-one-step-verb-declared-one-does" as *u8, d_has_verb, (a_has == 0) as i64, ctr) 255 let e_one: i64 = sg_find(out, n, "\"nx_e1.elf:run>nx_e2.elf:run\",\"steps\":2,\"support\":3,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"ONE-STEP-AVAILABLE\"" as *u8) 256 // gv_bite(name, fired_on_bad, fired_on_good, ctr): the second argument is FIRED-ON-GOOD and must be 0 257 gv_bite("verbclass-rule-fires-on-the-fork-pair-and-never-reads-it-one-step-available" as *u8, e_rule, e_one, ctr) 258 // ---- ES27 QUALITY AXIS: the second planted journal -- G a one-step pair x5 whose first 4 outcomes fail, H a clean 259 // triple x3; no conf row matches either, so both are UNDECLARED and only the quality axis separates them ---- 260 fd = sg_open(SG_JQ) 261 var tq: i64 = SG_TS0 262 tq = sg_plant_pair_fail(fd, tq, SG_SUP_G, SG_FAIL_G, "wsG" as *u8, "nx_gone" as *u8, "nx_gtwo" as *u8, SG_VERB_CALL) 263 tq = sg_plant_triple(fd, tq, SG_SUP_H, "wsH" as *u8, "nx_hone" as *u8, "nx_htwo" as *u8, "nx_hthree" as *u8, SG_VERB_CALL) 264 sys_close(fd) 265 let outq: *u8 = sys_mmap(SG_OUT) 266 let nq: i64 = sg_run(subj, SG_JQ, SG_CONF, outq) 267 gv_check("quality-journal-ran-and-printed-a-document" as *u8, (nq > 0) as i64, ctr) 268 let g_bad: i64 = sg_find(outq, nq, "\"signature\":\"nx_gone:call>nx_gtwo:call\",\"steps\":2,\"support\":5,\"fail\":4,\"fail_permil\":800,\"risk\":4000,\"class\":\"UNDECLARED\"" as *u8) 269 gv_check("G-row-one-step-pair-fail-four-of-five-permil-800-risk-4000" as *u8, g_bad, ctr) 270 let h_clean: i64 = sg_find(outq, nq, "\"signature\":\"nx_hone:call>nx_htwo:call>nx_hthree:call\",\"steps\":3,\"support\":3,\"fail\":0,\"fail_permil\":0,\"risk\":0,\"class\":\"UNDECLARED\"" as *u8) 271 gv_check("H-row-clean-triple-fail-zero-risk-zero" as *u8, h_clean, ctr) 272 gv_check("undeclared-class-carries-fail-four-of-eight-permil-500" as *u8, sg_find(outq, nq, "\"UNDECLARED\":{\"support\":8,\"signatures\":2,\"permil\":1000,\"fail\":4,\"fail_permil\":500}" as *u8), ctr) 273 gv_check("totals-fail-four-quality-permil-500" as *u8, sg_find(outq, nq, "\"total_fail\":4,\"quality_permil\":500" as *u8), ctr) 274 gv_check("risk-worklist-holds-exactly-the-failing-one-step-pair-never-the-clean-triple" as *u8, sg_find(outq, nq, "\"worklist_risk\":[{\"signature\":\"nx_gone:call>nx_gtwo:call\",\"steps\":2,\"class\":\"UNDECLARED\",\"support\":5,\"fail\":4,\"fail_permil\":800,\"risk\":4000}],\"worklist_risk_shown\":1" as *u8), ctr) 275 // the quality axis must fire on the failing pair and never on the clean triple (a clean row is one carrying fail 0) 276 gv_bite("quality-axis-taints-the-failing-pair-and-never-the-clean-triple" as *u8, g_bad, (h_clean == 0) as i64, ctr) 277 let stq: i64 = ga_judge(SG_JQ_QSTAMP, SG_NOW + 1, 0, f) 278 let gq: i64 = f[GA_F_GAUGE] 279 gv_check_eq("quality-stamp-judges-FRESH-through-the-gauge-ruler" as *u8, stq, GA_FRESH, ctr) 280 gv_check_eq("quality-stamp-gauge-is-the-quality-permil" as *u8, gq, SG_Q_QUALITY, ctr) 281 gv_values_head() 282 gv_kv("doc_bytes" as *u8, n) 283 gv_kv("stamp_state" as *u8, st) 284 gv_kv("stamp_gauge" as *u8, g1) 285 gv_kv("absent_conf_stamp_state" as *u8, st3) 286 gv_kv("quality_doc_bytes" as *u8, nq) 287 gv_kv("quality_stamp_state" as *u8, stq) 288 gv_kv("quality_stamp_gauge" as *u8, gq) 289 gv_kv("prod_spine_size" as *u8, prod_spine_before) 290 gv_kv("prod_stamp_size" as *u8, prod_stamp_before) 291 return gv_verdict("nx_stepsolve_gate" as *u8, ctr, "steps-to-solve end to end: the support-weighted partition sums, the declared reason and composed verb travel with each ritual, a verbclass rule explains the fork pair with per-rule support and a steps row wins over it, the most common leads, an undeclared signature is never assumed one-step, an absent conf reads BLIND, the trend is written only beside the fixture, and the quality axis ranks a failing one-step pair above a clean triple by risk" as *u8) 292}