code wiki / (root) / nx_rungclose_gate.nx

nx_rungclose_gate.nx source

↩ module page · 718 lines · 65460 B

1// nx_rungclose_gate.nx -- GATE for the close ruler v2 (nx_rungclose_lib, ecosystem EC57), driven IN-PROCESS on planted rows. 2// v2 measures every stage and signs none, so the teeth prove the EVIDENCE readers and the rules over them: the production 3// roster journal (a trial roster row never tests anything; a longer or prefix gate name is another gate; SKIP is neither 4// verdict; turns are counted only since the land), the clock's actlog rows (a process killed by a signal did not run, a 5// spawn that failed did not run, an MCP call is not a clock run, a prefix program is another program; a row planted EXACTLY as 6// clk_actlog writes it -- the forked path alone, then exit= and job= -- is witnessed by its job name, and a longer or prefix job 7// name is another clock row), the surface census row (each surface class; a prefix name is not the organ), the clock plane's 8// agent command (the LAST declaration of a name wins over a stale first one, as the scheduler applies it), every link's three states 9// and the rule that decided it, the issue classes and their ceilings (a ceiling never RAISES a stage; STALE is not 10// rework), the climb, the stage snapshot the closer diffs against (round trip, cursor wrap, prefix neg-controls), the 11// close-first worklist and the journal grammar, and THE ROSTERS (nx_rosterconf_lib, 2026-09-18): a roster is a (conf, journal) pair 12// derived from a clock plane (the runner's default pair first, then every pair a beat row runs, whatever journal it writes; a beat 13// naming no journal writes the production one; a trial row, an argless row, a PREFIX program and a line with no command add nothing; 14// a CR from another host is not part of a name); a gate is ROSTERED by any conf -- a gate only on the heavy conf is rostered BY the 15// heavy conf, the same gate against the default alone is not, and a gate on none is not; and THE CREDIT: a gate's roster GREEN is 16// read from the production journal (always) and from the journal of every pair whose conf lists it -- a gate the slow beat alone 17// runs is credited from the slow journal and green_in names it, a GREEN in a journal whose conf does NOT list the gate is never 18// credited, a trial row never credits, a journal two rosters share is read once, and a gate rostered only by a beat whose journal 19// cannot be read is UNOBSERVABLE, never HOLDS. 20// Every fixture asserts its own condition first; the neg-controls are named. 21// license_tier: ORIGINAL No hw writes (Rule 26). 22import "nx_syscalls.nx" 23import "nx_rosterconf_lib.nx" 24import "nx_rungclose_lib.nx" 25import "nx_gate_verdict.nx" 26 27const G_I64: i64 = 8 28const G_WORK_ROWS: i64 = 9 // the worklist fixture: six well-formed rows and three malformed lines 29const G_WORK_NAME_B: i64 = 8 // more than the longest domain plus rung name the fixture plants (fxx and B5) 30const G_TWICE: i64 = 2 // the duplicate-id fixture declares D1 exactly twice 31const G_WORK_NOW: i64 = 2000000 // the fixture's clock: every age is planted against it, never against the wall 32const G_PLAN: *u8 = "rung|A1|t|sym_a|n|Organ|1|-\nrung|A2|t|-|n|Organ|2|-\nrung|A3|t|sym_c|n|Organ|1|-\nrung|A4|t|sym_zz|n|Organ|1|-\nrung|A5|t|-|n|Organ|1|-\nlog|100|A1|measure|m\nlog|200|A1|land|l\nlog|250|A1|done|a note since v2, decides nothing\nlog|300|A1|retract|r\nlog|150|A2|land|l\nlog|160|A2|done|a note\nlog|50|A3|queue|q\nlog|500|A5|land|a slice\nlog|bad|A3|land|a non-integer epoch is no land\n" 33const G_MATRIX: *u8 = "# sym_a in a comment is not a row|runtime/wrong.nx|sym_a\nPrefix sibling|runtime/organ_ab.nx|_ABSENT_:sym_ab|0|0|0|0|0|n\nLabel one|runtime/organ_a.nx|_ABSENT_:sym_a|0|0|0|0|0|n\nLabel two|runtime/organ_c.nx|sym_c|0|0|0|0|0|n\n" 34const G_A1_ROWS: i64 = 4 35const G_A1_LAND: i64 = 200 36const G_A1_RETRACT: i64 = 300 37const G_A2_LAND: i64 = 150 38const G_A2_COST: i64 = 20 39// the production roster journal: epoch TAB roster TAB gate TAB VERDICT TAB exit= TAB ms= TAB lastline 40const G_GR: *u8 = "100\troster\tgx_gate\tGREEN\texit=0\tms=5\tok\n150\ttrial\tgx_gate\tRED\texit=1\tms=5\ta trial row never tests\n200\troster\tgx_gate\tRED\texit=1\tms=5\tred\n300\troster\tgx_gate\tGREEN\texit=0\tms=5\tgreen again\n310\troster\tgx_gate_x\tRED\texit=1\tms=5\ta longer name is another gate\n320\troster\tgx\tRED\texit=1\tms=5\ta prefix is another gate\n330\troster\tgy_gate\tSKIP\texit=3\tms=5\tabstained\n340\troster\tgy_gate\tRED\texit=1\tms=5\tred\nbad\troster\tgx_gate\tGREEN\texit=0\tms=5\tno epoch no row\n" 41const G_GR_INDEXED: i64 = 7 // nine lines: the trial row and the bad epoch are not production rows 42const G_GR_NOW: i64 = 1300 // inside the margin of every planted row 43// the clock's actlog rows are ASSEMBLED AT RUN TIME around the run's own clock (g_al_build): a planted epoch is a number the 44// subject could mirror, an epoch the run chose is not. Seven rows: a signal death, a failed spawn and an MCP call are not 45// clock runs, and a prefix program is another program. 46const G_AL_INDEXED: i64 = 6 47const G_AL_ROWS: i64 = 9 // the rows g_al_build writes; a tooth holds the build to it 48const G_AL_SEPS: *u8 = "\t\t\t\t\t\n" // one row's separators, spelled, so their count is read and never typed 49const G_AL_NOTE: *u8 = "clockjob lane=clock exit=" 50const G_AL_JOB: *u8 = " job=" // what the clock appends to the last field: its own row's name 51const G_AL_LONGEST_CMD: *u8 = "/volume1/x/nishihost/nx_alpha.elf" 52const G_AL_LONGEST_JOB: *u8 = "wfbeatx" 53// the command column EXACTLY as clk_actlog writes it for a clock row that runs nx_plan_run.elf <plan>: the forked path alone 54const G_AL_PLAN_PATH: *u8 = "/v/x/nishihost/nx_plan_run.elf" 55// the clock DESIRED plane: wfbeat was declared twice, and the scheduler applies the LAST declaration (the first is stale) 56const G_CLOCK: *u8 = "wfbeat\t86400\tnx_plan_run.elf stale\nwfbeat\t86400\tnx_plan_run.elf wfx\nwfbeatx\t60\tnx_other.elf\nother\t60\tnx_other.elf\n" 57const G_ES: *u8 = "nx_alpha\t1\t0\t0\t-\t0\t1\tclock\nnx_beta\t0\t0\t0\t-\t0\t1\tplan\nnx_gamma_gate\t0\t0\t0\t-\t1\t0\troster\nnx_delta\t0\t0\t0\t-\t0\t1\tactlog\nnx_eps\t0\t0\t0\t-\t0\t0\tref:nx_x\nnx_zeta\t0\t0\t0\tnx_caller\t0\t0\tfork:nx_caller\nnx_eta\t0\t0\t1\t-\t0\t0\tdaemon\n" 58// THE ROSTERS: a clock plane (name TAB interval TAB command). Five beats here -- the main, the heavy, the slow roster writing ITS 59// OWN journal, a bare beat that names no conf, the heavy again naming no journal -- and four rows that are not beats: a trial, an 60// argless run, a PREFIX program, a line with no tab. The sixth beat, a row carrying a CR from another host, is ASSEMBLED at run 61// time: the CR byte is constructed, never typed. Pairs: default/production, heavy/production, slow/slow journal, crlf/production. 62const G_RCLOCK: *u8 = "gateroster\t60\t/v/x/nishihost/nx_gate_roster_run.elf beat knowledge/gateroster.conf knowledge/status/gateroster.jrnl 9\ngaterosterheavy\t60\t/v/x/nishihost/nx_gate_roster_run.elf beat fx/heavy.conf knowledge/status/gateroster.jrnl 9\nrosterslow\t60\t/v/x/nishihost/nx_gate_roster_run.elf beat fx/slow.conf knowledge/status/gateroster_slow.jrnl 9\nrostertrial\t60\tnx_gate_roster_run.elf trial fx/trial.list\nrosterbare\t60\tnx_gate_roster_run.elf\nrosterprefix\t60\tnx_gate_roster_runner.elf beat fx/prefix.conf\nrosterdefault\t60\tnx_gate_roster_run beat\nheavyagain\t60\tnx_gate_roster_run.elf beat fx/heavy.conf\nno tab so no command nx_gate_roster_run.elf beat fx/notab.conf\n" 63const G_RCRLF_ROW: *u8 = "crlf\t60\tnx_gate_roster_run.elf beat fx/crlf.conf" 64const G_RBEATS: i64 = 6 // the main, the heavy, the slow, the bare beat, the heavy again, the CRLF beat 65const G_ROTHER: i64 = 1 // of them writing another journal: the slow roster 66const G_RCONFS: i64 = 4 // pairs: default/production, heavy/production, slow/slow journal, crlf/production 67const G_RJOINED: *u8 = "knowledge/gateroster.conf,fx/heavy.conf,fx/slow.conf,fx/crlf.conf" 68const G_RPROD: *u8 = "knowledge/status/gateroster.jrnl" 69const G_RSLOWJ: *u8 = "knowledge/status/gateroster_slow.jrnl" 70const G_RSLOW_PAIR: i64 = 2 71const G_RCRLF_PAIR: i64 = 3 72// the slow roster's conf: it lists nx_slow_gate and nx_trial_gate -- never nx_stray_gate 73const G_RSLOW: *u8 = "# the slow roster\nnx_slow_gate\nnx_trial_gate\n" 74// the production journal: nx_main_gate's GREEN, and nx_left_gate's -- a gate on no conf now, whose GREEN was earned here 75const G_RJPROD: *u8 = "100\troster\tnx_main_gate\tGREEN\texit=0\tms=5\tok\n150\troster\tnx_left_gate\tGREEN\texit=0\tms=5\tit has since left its conf\n" 76// the slow journal: nx_slow_gate's GREEN, a GREEN for nx_stray_gate (which the slow conf does NOT list), and a TRIAL GREEN for 77// nx_trial_gate (a trial never credits) 78const G_RJSLOW: *u8 = "200\troster\tnx_slow_gate\tGREEN\texit=0\tms=5\tthe slow beat ran it\n210\troster\tnx_stray_gate\tGREEN\texit=0\tms=5\tno roster listing it writes here\n220\ttrial\tnx_trial_gate\tGREEN\texit=0\tms=5\ta trial row\n" 79const G_RJ_SLOW_GREEN: i64 = 200 80const G_RJ_STRAY_GREEN: i64 = 210 81const G_RJ_LEFT_GREEN: i64 = 150 82const G_RJ_MAIN_GREEN: i64 = 100 83const G_RJPROD_ROWS: i64 = 2 // the production fixture's roster rows 84const G_RJSLOW_ROWS: i64 = 2 // the slow fixture's roster rows (its third row is a trial) 85const G_RJ_SCALE: i64 = 10 // more than either fixture's row count: two counts read as one number 86const G_RJ_CONSULT_SLOW: i64 = 2 // a gate on the slow conf alone: the production journal, then the slow one 87// a verdict and a small out-slot read as ONE number: more than any slot value a tooth reads through it (why codes stay below it) 88const G_LW_SCALE: i64 = 100 89// the conf texts, read the way the beat reads them: a comment naming a gate is not a row, leading spaces are skipped, a tab ends a 90// name, an @directive names nothing 91const G_RMAIN: *u8 = "; gateroster.conf -- the main roster\n# nx_heavy_gate named in a comment is not a row\nnx_main_gate\n nx_indented_gate\nnx_tabbed_gate\ta note\n" 92const G_RHEAVY: *u8 = "# THE HEAVY GATE ROSTER\n@dispatch_deadline_ms 9\nnx_heavy_gate\n" 93const G_RCRLF_GATE: *u8 = "nx_crlf_gate" 94const G_RNOBEAT: *u8 = "other\t60\tnx_other.elf beat fx/other.conf\n" 95 96func g_links(v0: i64, v1: i64, v2: i64, v3: i64, v4: i64, v5: i64, v6: i64) -> *i64 { 97 let l: *i64 = sys_mmap(RGC_LINKS * G_I64) as *i64 98 l[RGC_L_JOURNAL] = v0 99 l[RGC_L_BUILT] = v1 100 l[RGC_L_LIVE] = v2 101 l[RGC_L_TESTED] = v3 102 l[RGC_L_WIRED] = v4 103 l[RGC_L_OPERATED] = v5 104 l[RGC_L_PAGE] = v6 105 return l 106} 107func g_iss(red: i64, retract: i64, flaky: i64, stale: i64) -> *i64 { 108 let i: *i64 = sys_mmap(RGC_ISSUES * G_I64) as *i64 109 i[RGC_I_RED] = red 110 i[RGC_I_RETRACT] = retract 111 i[RGC_I_FLAKY] = flaky 112 i[RGC_I_STALE] = stale 113 return i 114} 115// a call's value and an out-slot it wrote, as ONE number read AFTER the call returned: an argument is evaluated before the 116// helper's body runs, so the slot read is the one this call wrote -- never a stale slot left by the previous tooth, and 117// never a question of which operand the compiler evaluates first 118func g_lw(v: i64, w: *i64) -> i64 { return v * G_LW_SCALE + w[0] } 119func g_slot(v: i64, out: *i64, k: i64, scale: i64) -> i64 { return v * scale + out[k] } 120// one actlog row at o0: epoch TAB lane TAB command TAB run TAB status TAB clockjob lane=clock exit=<code>[ job=<name>] 121// (job empty: a row written before the clock carried job=) 122func g_al_row(b: *u8, o0: i64, ep: i64, lane: *u8, cmd: *u8, status: *u8, code: *u8, job: *u8) -> i64 { 123 var o: i64 = ces_fmt_int(b, o0, ep) 124 b[o] = RGC_CH_TAB as u8 125 o = ces_cat(b, o + 1, lane) 126 b[o] = RGC_CH_TAB as u8 127 o = ces_cat(b, o + 1, cmd) 128 b[o] = RGC_CH_TAB as u8 129 o = ces_cat(b, o + 1, "run" as *u8) 130 b[o] = RGC_CH_TAB as u8 131 o = ces_cat(b, o + 1, status) 132 b[o] = RGC_CH_TAB as u8 133 o = ces_cat(b, o + 1, G_AL_NOTE) 134 o = ces_cat(b, o, code) 135 if ces_slen(job) > 0 { o = ces_cat(b, o, G_AL_JOB); o = ces_cat(b, o, job) } 136 b[o] = CES_CH_NL as u8 137 o = o + 1 138 b[o] = 0 as u8 139 return o 140} 141// the most one row can take, from its widest parts: two numbers, the longest command, the lane, the verb, the status, 142// the note, the separators and the terminator 143func g_al_row_bound() -> i64 { 144 return CES_NUM_CAP * 2 + ces_slen(G_AL_LONGEST_CMD) + ces_slen("clock" as *u8) + ces_slen("run" as *u8) + ces_slen("fail" as *u8) + ces_slen(G_AL_NOTE) + ces_slen(G_AL_JOB) + ces_slen(G_AL_LONGEST_JOB) + ces_slen(G_AL_SEPS) + 1 145} 146// the nine rows at t0 plus small offsets; rows = how many were written. The last two are written EXACTLY as clk_actlog writes a 147// run of the clock row wfbeat (and of wfbeatx): the forked path alone in the command column, then exit= and job= in the last field 148func g_al_build(b: *u8, t0: i64) -> i64 { 149 var o: i64 = g_al_row(b, 0, t0, "clock" as *u8, "nx_alpha.elf" as *u8, "ok" as *u8, "0" as *u8, "" as *u8) 150 o = g_al_row(b, o, t0 + 100, "clock" as *u8, G_AL_LONGEST_CMD, "fail" as *u8, "1" as *u8, "" as *u8) 151 o = g_al_row(b, o, t0 + 200, "clock" as *u8, "nx_alpha.elf" as *u8, "fail" as *u8, "139" as *u8, "" as *u8) 152 o = g_al_row(b, o, t0 + 250, "clock" as *u8, "nx_alpha.elf" as *u8, "fail" as *u8, "-1" as *u8, "" as *u8) 153 o = g_al_row(b, o, t0 + 300, "mcp" as *u8, "nx_alpha.elf" as *u8, "ok" as *u8, "0" as *u8, "" as *u8) 154 o = g_al_row(b, o, t0 + 400, "clock" as *u8, "nx_plan_run.elf wfx" as *u8, "ok" as *u8, "0" as *u8, "" as *u8) 155 o = g_al_row(b, o, t0 + 500, "clock" as *u8, "nx_alphabet.elf" as *u8, "ok" as *u8, "0" as *u8, "" as *u8) 156 o = g_al_row(b, o, t0 + 600, "clock" as *u8, G_AL_PLAN_PATH, "ok" as *u8, "0" as *u8, "wfbeat" as *u8) 157 o = g_al_row(b, o, t0 + 700, "clock" as *u8, G_AL_PLAN_PATH, "ok" as *u8, "0" as *u8, G_AL_LONGEST_JOB) 158 return o 159} 160// the rung field of pick i equals the literal 161func g_pick_rung_is(wb: *u8, picks: *i64, i: i64, lit: *u8, off: *i64) -> i64 { 162 let p: i64 = picks[i * RGC_PICK_STRIDE] 163 let e: i64 = picks[i * RGC_PICK_STRIDE + 1] 164 let l: i64 = ces_field(wb, p, e, RGC_WORK_F_RUNG, off) 165 return ces_span_is(wb, off[0], l, lit) 166} 167func g_streq(a: *u8, b: *u8) -> i64 { 168 let n: i64 = ces_slen(a) 169 if n != ces_slen(b) { return 0 } 170 var i: i64 = 0 171 while i < n { if a[i] != b[i] { return 0 } i = i + 1 } 172 return 1 173} 174// the haystack holds the needle somewhere 175func g_has(hay: *u8, needle: *u8) -> i64 { 176 let hn: i64 = ces_slen(hay) 177 let nn: i64 = ces_slen(needle) 178 var i: i64 = 0 179 while i + nn <= hn { if ces_span_is(hay, i, nn, needle) == 1 { return 1 } i = i + 1 } 180 return 0 181} 182// the conf (which = RCF_PART_CONF) or the journal (RCF_PART_JRNL) of roster pair k is the literal 183func g_part_is(list: *u8, n: i64, k: i64, which: i64, lit: *u8) -> i64 { 184 let o: *i64 = sys_mmap(G_I64) as *i64 185 let l: i64 = rcf_pair_part(list, n, k, which, o) 186 return ces_span_is(list, o[0], l, lit) 187} 188// some pair of the list has the literal as its conf 189func g_conf_listed(list: *u8, n: i64, lit: *u8) -> i64 { 190 let k: i64 = rcf_lines(list, n) 191 var hit: i64 = 0 192 var i: i64 = 0 193 while i < k { hit = hit + g_part_is(list, n, i, RCF_PART_CONF, lit); i = i + 1 } 194 return hit 195} 196// one journal read into the roster journal table under pair k (its own origin): the bytes, the length, the index 197func g_journal(jt: *i64, k: i64, text: *u8) -> i64 { 198 let tn: i64 = ces_slen(text) 199 let gcap: i64 = rgc_lines(text, tn) 200 let gx: *i64 = sys_mmap(gcap * RGC_GX_STRIDE * G_I64) as *i64 201 let b: i64 = k * RGC_RJ_STRIDE 202 jt[b + RGC_RJ_BUF] = text as i64 203 jt[b + RGC_RJ_LEN] = tn 204 jt[b + RGC_RJ_GX] = gx as i64 205 jt[b + RGC_RJ_GXROWS] = rgc_gx_index(text, tn, gx, gcap) 206 return jt[b + RGC_RJ_GXROWS] 207} 208// THE CREDIT, composed exactly as nx_rungclose composes it (rp_roster_evidence): which pairs' confs list the name, by the beat's 209// own row grammar, then rgc_roster_credit over the production journal and those pairs' journals 210func g_credit(jt: *i64, rt: *i64, np: i64, name: *u8, since: i64, g: *i64, out: *i64) -> i64 { 211 let lists: *i64 = sys_mmap(np * G_I64) as *i64 212 let seen: *i64 = sys_mmap(np * G_I64) as *i64 213 let gt: *i64 = sys_mmap(RGC_G_SLOTS * G_I64) as *i64 214 var i: i64 = 0 215 while i < np { 216 lists[i] = rcf_has_gate(rt[i * RCF_TEXT_STRIDE + RCF_TEXT_P] as *u8, rt[i * RCF_TEXT_STRIDE + RCF_TEXT_N], name, ces_slen(name)) 217 i = i + 1 218 } 219 return rgc_roster_credit(jt, np, lists, name, since, g, gt, seen, out) 220} 221// the list index of the roster conf holding the gate, over the first k texts 222func g_rfind(texts: *i64, k: i64, gate: *u8) -> i64 { return rcf_find(texts, k, gate, ces_slen(gate)) } 223 224func main(argc: i64, argv: *i64) -> i64 { 225 let c: *i64 = gv_ctr() 226 gv_head("nx_rungclose_gate -- the close ruler v2: the evidence readers, every link's rule, the issues and their ceilings, the climb, the snapshot the closer diffs, the worklist, the grammar" as *u8) 227 let plan: *u8 = G_PLAN 228 let pn: i64 = ces_slen(plan) 229 let mx: *u8 = G_MATRIX 230 let mn: i64 = ces_slen(mx) 231 let w: *i64 = sys_mmap(G_I64) as *i64 232 gv_check("fixture-reached-the-condition: plan, matrix, roster journal, clock plane and surface census are non-empty (the actlog is assembled below and asserts its own)" as *u8, ((pn > 0) as i64) * ((mn > 0) as i64) * ((ces_slen(G_GR) > 0) as i64) * ((ces_slen(G_CLOCK) > 0) as i64) * ((ces_slen(G_ES) > 0) as i64), c) 233 // ---- the journal facts ---- 234 let f1: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 235 gv_check_eq("journal-A1-declared" as *u8, rgc_journal(plan, pn, "A1" as *u8, f1), 1, c) 236 gv_check_eq("journal-A1-rows" as *u8, f1[RGC_F_ROWS], G_A1_ROWS, c) 237 gv_check_eq("journal-A1-newest-land" as *u8, f1[RGC_F_LAND], G_A1_LAND, c) 238 gv_check_eq("journal-A1-newest-retract" as *u8, f1[RGC_F_RETRACT], G_A1_RETRACT, c) 239 gv_check_eq("contract-A1-declared" as *u8, rgc_has_contract(plan, f1), 1, c) 240 gv_check_eq("journal-A1-the-done-row-is-still-READ-as-a-note (250) and no link takes it as an argument" as *u8, f1[RGC_F_DONE], 250, c) 241 let f2: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 242 rgc_journal(plan, pn, "A2" as *u8, f2) 243 gv_check_eq("journal-A2-land" as *u8, f2[RGC_F_LAND], G_A2_LAND, c) 244 gv_check_eq("journal-A2-no-retract-reads-NONE" as *u8, f2[RGC_F_RETRACT], CES_NONE, c) 245 gv_check_eq("contract-A2-a-dash-declares-NO-contract" as *u8, rgc_has_contract(plan, f2), 0, c) 246 gv_check_eq("journal-A2-cost-2u-is-20-deci-u" as *u8, f2[RGC_F_COST], G_A2_COST, c) 247 let f3: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 248 rgc_journal(plan, pn, "A3" as *u8, f3) 249 gv_check_eq("neg-control-journal-A3-a-non-integer-epoch-is-no-land" as *u8, f3[RGC_F_LAND], CES_NONE, c) 250 gv_check_eq("journal-A3-both-rows-counted (the bad epoch is still a journal row)" as *u8, f3[RGC_F_ROWS], 2, c) 251 let f9: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 252 gv_check_eq("neg-control-journal-an-undeclared-id-is-not-declared" as *u8, rgc_journal(plan, pn, "A9" as *u8, f9), 0, c) 253 gv_check_eq("neg-control-journal-a-PREFIX-id-is-not-the-rung (A is not A1)" as *u8, rgc_journal(plan, pn, "A" as *u8, f9), 0, c) 254 gv_check_eq("link-journal-rows-hold" as *u8, rgc_journal_link(1, w), RGC_HOLDS, c) 255 gv_check_eq("neg-control-link-journal-no-rows-fails-and-names-it" as *u8, g_lw(rgc_journal_link(0, w), w), RGC_W_NOROWS, c) 256 // ---- the matrix row that names a contract ---- 257 let o: *i64 = sys_mmap(2 * G_I64) as *i64 258 gv_check_eq("matrix-A1-found-through-the-ABSENT-form" as *u8, rgc_matrix_organ(mx, mn, plan, f1[RGC_F_SYM_O], f1[RGC_F_SYM_L], o), 1, c) 259 gv_check("neg-control-matrix-A1-is-organ_a, never the PREFIX sibling sym_ab nor the comment line" as *u8, ces_span_is(mx, o[0], o[1], "runtime/organ_a.nx" as *u8), c) 260 gv_check_eq("matrix-A3-found-through-the-bare-form" as *u8, rgc_matrix_organ(mx, mn, plan, f3[RGC_F_SYM_O], f3[RGC_F_SYM_L], o), 1, c) 261 let f4: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 262 rgc_journal(plan, pn, "A4" as *u8, f4) 263 gv_check_eq("neg-control-matrix-a-contract-no-row-names-is-NOT-found" as *u8, rgc_matrix_organ(mx, mn, plan, f4[RGC_F_SYM_O], f4[RGC_F_SYM_L], o), 0, c) 264 // ---- BUILT and LIVE ---- 265 gv_check_eq("built-no-contract-holds-by-declaration" as *u8, rgc_built(0, 0, 0, w), RGC_HOLDS, c) 266 gv_check_eq("built-an-unnamed-contract-is-UNOBSERVABLE-never-FAILS, rule no-matrix-row" as *u8, g_lw(rgc_built(1, 0, 1, w), w), RGC_UNOBS * 100 + RGC_W_NOROW, c) 267 gv_check_eq("built-symbol-present-holds" as *u8, rgc_built(1, 1, 1, w), RGC_HOLDS, c) 268 gv_check_eq("built-organ-read-and-symbol-absent-fails (the DARK contract)" as *u8, g_lw(rgc_built(1, 1, 0, w), w), RGC_W_DARK, c) 269 gv_check_eq("built-organ-unreadable-fails" as *u8, rgc_built(1, 1, 0 - 1, w), RGC_FAILS, c) 270 gv_check_eq("live-the-treat-row's-verified-tool-holds-first" as *u8, g_lw(rgc_live(0, 1, 0, 0, w), w), 100 + RGC_W_TREAT, c) 271 gv_check_eq("live-the-organ's-own-tool-on-the-allowlist-holds" as *u8, g_lw(rgc_live(1, 0, 1, 1, w), w), 100 + RGC_W_TOOL, c) 272 gv_check_eq("neg-control-live-no-contract-and-no-treat-tool-is-NO-SUBJECT" as *u8, g_lw(rgc_live(0, 0, 1, 1, w), w), RGC_W_NOCONTRACT, c) 273 gv_check_eq("neg-control-live-a-tool-off-the-allowlist-fails" as *u8, g_lw(rgc_live(1, 0, 1, 0, w), w), RGC_W_UNREGISTERED, c) 274 gv_check_eq("live-an-unreadable-allowlist-is-UNOBSERVABLE" as *u8, rgc_live(1, 0, 0, 1, w), RGC_UNOBS, c) 275 // ---- the production roster journal ---- 276 let gr: *u8 = G_GR 277 let grn: i64 = ces_slen(gr) 278 let gcap: i64 = rgc_lines(gr, grn) 279 let gx: *i64 = sys_mmap(gcap * RGC_GX_STRIDE * G_I64) as *i64 280 let grows: i64 = rgc_gx_index(gr, grn, gx, gcap) 281 gv_check_eq("roster-index-production-rows-only (the trial row and the non-integer epoch are out)" as *u8, grows, G_GR_INDEXED, c) 282 let g: *i64 = sys_mmap(RGC_G_SLOTS * G_I64) as *i64 283 gv_check_eq("roster-facts-gx_gate-three-production-rows (never gx_gate_x, never gx)" as *u8, rgc_gate_facts(gr, gx, grows, "gx_gate" as *u8, CES_NONE, g), 3, c) 284 gv_check_eq("roster-facts-newest-row" as *u8, g[RGC_G_NEWEST], 300, c) 285 gv_check_eq("roster-facts-newest-verdict-GREEN" as *u8, g[RGC_G_NEWEST_V], RGC_V_GREEN, c) 286 gv_check_eq("roster-facts-turns-GREEN-RED-GREEN-count-two" as *u8, g[RGC_G_FLIPS], 2, c) 287 gv_check_eq("roster-facts-the-last-turn" as *u8, g[RGC_G_LAST_FLIP], 300, c) 288 rgc_gate_facts(gr, gx, grows, "gx_gate" as *u8, 250, g) 289 gv_check_eq("roster-facts-since-the-land-green-at-or-after-it" as *u8, g[RGC_G_GREEN], 300, c) 290 gv_check_eq("anti-vacuity-roster-turns-before-the-land-are-not-counted" as *u8, g[RGC_G_FLIPS], 0, c) 291 rgc_gate_facts(gr, gx, grows, "gx_gate" as *u8, 301, g) 292 gv_check_eq("neg-control-roster-no-green-after-a-later-land" as *u8, g[RGC_G_GREEN], CES_NONE, c) 293 rgc_gate_facts(gr, gx, grows, "gy_gate" as *u8, CES_NONE, g) 294 gv_check_eq("roster-facts-SKIP-is-neither-verdict: gy_gate turns stay zero" as *u8, g[RGC_G_FLIPS] * 1000 + g[RGC_G_ROWS], 2, c) 295 gv_check_eq("roster-facts-gy_gate-newest-is-RED" as *u8, g[RGC_G_NEWEST_V], RGC_V_RED, c) 296 gv_check_eq("neg-control-roster-an-absent-gate-has-no-rows" as *u8, rgc_gate_facts(gr, gx, grows, "gz_gate" as *u8, CES_NONE, g), 0, c) 297 // ---- TESTED ---- 298 gv_check_eq("tested-a-green-since-the-land-holds" as *u8, g_lw(rgc_tested(1, 1, 300, 1, w), w), 100 + RGC_W_GREEN, c) 299 gv_check_eq("neg-control-tested-no-gate-resolves-fails-and-names-it" as *u8, g_lw(rgc_tested(0, 1, 300, 1, w), w), RGC_W_NOGATE, c) 300 gv_check_eq("tested-an-unreadable-roster-journal-with-no-GREEN-read-is-UNOBSERVABLE" as *u8, g_lw(rgc_tested(1, 0, CES_NONE, 1, w), w), RGC_UNOBS * G_LW_SCALE + RGC_W_UNREADABLE, c) 301 gv_check_eq("tested-a-GREEN-READ-in-one-journal-HOLDS-though-another-journal-it-consulted-was-unreadable (presence needs one witness)" as *u8, g_lw(rgc_tested(1, 0, 300, 1, w), w), RGC_HOLDS * G_LW_SCALE + RGC_W_GREEN, c) 302 gv_check_eq("neg-control-tested-rostered-and-no-green-since-land-fails" as *u8, g_lw(rgc_tested(1, 1, CES_NONE, 1, w), w), RGC_W_NOGREEN, c) 303 gv_check_eq("neg-control-tested-unrostered-with-no-green-names-the-roster" as *u8, g_lw(rgc_tested(1, 1, CES_NONE, 0, w), w), RGC_W_UNROSTERED, c) 304 // ---- the clock's actlog rows ---- 305 let t0: i64 = sys_now_realtime_sec() 306 let al: *u8 = sys_mmap(G_AL_ROWS * g_al_row_bound()) 307 let aln: i64 = g_al_build(al, t0) 308 gv_check("fixture-reached-the-condition: the assembled actlog opens at the run's own clock" as *u8, (rgc_first_epoch(al, aln) == t0) as i64, c) 309 gv_check_eq("fixture-the-build-wrote-exactly-the-rows-its-buffer-was-sized-for" as *u8, rgc_lines(al, aln) - 1, G_AL_ROWS, c) 310 let acap: i64 = rgc_lines(al, aln) 311 let ax: *i64 = sys_mmap(acap * RGC_AX_STRIDE * G_I64) as *i64 312 let arows: i64 = rgc_ax_index(al, aln, ax, acap) 313 gv_check_eq("actlog-index-clock-runs-that-EXITED (a signal death, a failed spawn and an MCP call are out)" as *u8, arows, G_AL_INDEXED, c) 314 gv_check_eq("actlog-program-read-through-a-full-path (t0+100 beats t0; t0+200 died of a signal)" as *u8, rgc_ax_newest_prog(al, ax, arows, "nx_alpha" as *u8) - t0, 100, c) 315 gv_check_eq("actlog-a-command-with-arguments and a bare forked path both name their program (the newest nx_plan_run run is t0+700)" as *u8, rgc_ax_newest_prog(al, ax, arows, "nx_plan_run" as *u8) - t0, 700, c) 316 gv_check_eq("neg-control-actlog-a-PREFIX-program-is-another-program (nx_alphabet is not nx_alpha, nx_alph is nothing)" as *u8, rgc_ax_newest_prog(al, ax, arows, "nx_alph" as *u8), CES_NONE, c) 317 let cmd: *u8 = "nx_plan_run.elf wfx" as *u8 318 gv_check_eq("actlog-the-whole-command-matches" as *u8, rgc_ax_newest_cmd(al, ax, arows, cmd, 0, ces_slen(cmd)) - t0, 400, c) 319 gv_check_eq("neg-control-actlog-a-PREFIX-command-is-another-command" as *u8, rgc_ax_newest_cmd(al, ax, arows, cmd, 0, ces_slen(cmd) - 1), CES_NONE, c) 320 // THE JOB NAME WITNESSES A CLOCK ROW: the rows at t0+600/700 are written exactly as clk_actlog writes them 321 let jag: *u8 = "wfbeat" as *u8 322 let jrun: i64 = rgc_ax_newest_job(al, ax, arows, jag, 0, ces_slen(jag)) 323 gv_check_eq("operated-the-clock's-job=-name-witnesses-the-agent (a row as clk_actlog writes it: the forked path, exit=, job=)" as *u8, jrun - t0, 600, c) 324 gv_check_eq("neg-control-operated-a-LONGER-job-name-is-another-clock-row (job=wfbeatx at t0+700 never witnesses wfbeat)" as *u8, rgc_ax_newest_job(al, ax, arows, G_AL_LONGEST_JOB, 0, ces_slen(G_AL_LONGEST_JOB)) - t0, 700, c) 325 gv_check_eq("neg-control-operated-a-PREFIX-job-name-witnesses-nothing (wfbea)" as *u8, rgc_ax_newest_job(al, ax, arows, jag, 0, ces_slen(jag) - 1), CES_NONE, c) 326 gv_check_eq("fallback-the-whole-command-match-cannot-see-a-forked-path-row (it still finds only the t0+400 row that carried arguments)" as *u8, rgc_ax_newest_cmd(al, ax, arows, cmd, 0, ces_slen(cmd)) - t0, 400, c) 327 let jbo: *i64 = sys_mmap(G_I64) as *i64 328 let jn1: *u8 = "clockjob lane=clock exit=0 subjob=wfbeat" as *u8 329 gv_check_eq("neg-control-job-a-key-that-merely-ENDS-in-job= is no job (subjob=)" as *u8, rgc_job_span(jn1, 0, ces_slen(jn1), jbo), CES_NONE, c) 330 let jn2: *u8 = "clockjob lane=clock exit=0" as *u8 331 gv_check_eq("job-a-row-written-before-the-clock-carried-job= reads NONE" as *u8, rgc_job_span(jn2, 0, ces_slen(jn2), jbo), CES_NONE, c) 332 let jn3: *u8 = "clockjob lane=clock exit=0 job=wfbeat x" as *u8 333 gv_check_eq("job-the-value-ends-at-a-separator" as *u8, rgc_job_span(jn3, 0, ces_slen(jn3), jbo), ces_slen(jag), c) 334 gv_check_eq("exit-code-parsed-with-its-sign" as *u8, rgc_exit_code("x exit=-5 y" as *u8, 0, 11), 0 - 5, c) 335 gv_check_eq("neg-control-exit-code-absent-is-NONE" as *u8, rgc_exit_code("no code here" as *u8, 0, 12), CES_NONE, c) 336 gv_check_eq("first-epoch-opens-the-window" as *u8, rgc_first_epoch(al, aln), t0, c) 337 gv_check_eq("neg-control-first-epoch-a-torn-line-is-NONE" as *u8, rgc_first_epoch("clock\t1\n" as *u8, 8), CES_NONE, c) 338 // ---- the clock plane's agent command ---- 339 let ck: *u8 = G_CLOCK 340 let ckn: i64 = ces_slen(ck) 341 let ag: *u8 = "wfbeat" as *u8 342 let cko: *i64 = sys_mmap(G_I64) as *i64 343 let ckl: i64 = rgc_clock_cmd(ck, ckn, 0, ces_slen(ag), ag, cko) 344 gv_check("clock-plane-the-agent's-command-is-the-LAST-declaration's-LAST-field" as *u8, ces_span_is(ck, cko[0], ckl, cmd), c) 345 gv_check_eq("neg-control-clock-plane-a-STALE-first-declaration-is-never-the-agent's-command (the scheduler applies the last)" as *u8, ces_span_is(ck, cko[0], ckl, "nx_plan_run.elf stale" as *u8), 0, c) 346 gv_check_eq("neg-control-clock-plane-a-PREFIX-agent-name-is-not-the-row" as *u8, rgc_clock_cmd(ck, ckn, 0, 2, ag, cko), CES_NONE, c) 347 // ---- the surface census ---- 348 let es: *u8 = G_ES 349 let esn: i64 = ces_slen(es) 350 let eo: *i64 = sys_mmap(RGC_ES_OUT_SLOTS * G_I64) as *i64 351 gv_check_eq("surface-a-direct-clock-row-is-CLOCK" as *u8, g_slot(rgc_es_class(es, esn, "nx_alpha" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_CLOCK, c) 352 gv_check_eq("surface-a-plan-step-is-unattended-and-UNWITNESSED (BLIND), never MCP though the actlog also names it" as *u8, g_slot(rgc_es_class(es, esn, "nx_beta" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_BLIND, c) 353 gv_check_eq("surface-a-roster-gate-is-ROSTER" as *u8, g_slot(rgc_es_class(es, esn, "nx_gamma_gate" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_ROSTER, c) 354 gv_check_eq("surface-an-MCP-only-organ-is-MCP" as *u8, g_slot(rgc_es_class(es, esn, "nx_delta" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_MCP, c) 355 gv_check_eq("surface-a-reference-is-NO-surface" as *u8, g_slot(rgc_es_class(es, esn, "nx_eps" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_NONE, c) 356 gv_check_eq("surface-a-fork-from-a-surfaced-caller-is-BLIND" as *u8, g_slot(rgc_es_class(es, esn, "nx_zeta" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_BLIND, c) 357 gv_check_eq("surface-a-daemon-is-BLIND" as *u8, g_slot(rgc_es_class(es, esn, "nx_eta" as *u8, eo), eo, RGC_ES_OUT_CLASS, 100), 100 + RGC_S_BLIND, c) 358 gv_check_eq("neg-control-surface-a-PREFIX-name-is-not-the-organ" as *u8, rgc_es_class(es, esn, "nx_alph" as *u8, eo), 0, c) 359 // ---- WIRED, OPERATED, PAGE ---- 360 gv_check_eq("wired-a-COMPLETE-treat-row-holds-first" as *u8, g_lw(rgc_wired(1, 0, 0, RGC_S_NONE, w), w), 100 + RGC_W_TREAT, c) 361 gv_check_eq("wired-an-unattended-surface-holds" as *u8, g_lw(rgc_wired(0, 1, 1, RGC_S_BLIND, w), w), 100 + RGC_W_SURFACE, c) 362 gv_check_eq("neg-control-wired-MCP-only-is-not-wired" as *u8, g_lw(rgc_wired(0, 1, 1, RGC_S_MCP, w), w), RGC_W_MCPONLY, c) 363 gv_check_eq("neg-control-wired-no-surface-fails" as *u8, g_lw(rgc_wired(0, 1, 1, RGC_S_NONE, w), w), RGC_W_NOSURFACE, c) 364 gv_check_eq("wired-no-census-row-is-UNOBSERVABLE" as *u8, g_lw(rgc_wired(0, 1, 0, RGC_S_NONE, w), w), RGC_UNOBS * 100 + RGC_W_NOTINCENSUS, c) 365 let now: i64 = G_WORK_NOW 366 gv_check_eq("operated-a-run-after-the-land-inside-the-margin-holds" as *u8, g_lw(rgc_operated(now - 10, now - 20, now, 1, RGC_S_CLOCK, 0, w), w), 100 + RGC_W_RUN, c) 367 gv_check_eq("neg-control-operated-a-run-BEFORE-the-land-is-not-a-run-of-this-land" as *u8, g_lw(rgc_operated(now - 30, now - 20, now, 1, RGC_S_CLOCK, 0, w), w), RGC_W_NORUN, c) 368 gv_check_eq("neg-control-operated-a-run-outside-the-margin-is-not-operating" as *u8, rgc_operated(now - rgc_margin_s() - 1, CES_NONE, now, 1, RGC_S_CLOCK, 0, w), RGC_FAILS, c) 369 gv_check_eq("operated-an-unwitnessed-surface-with-no-agent-is-UNOBSERVABLE" as *u8, g_lw(rgc_operated(CES_NONE, CES_NONE, now, 1, RGC_S_BLIND, 0, w), w), RGC_UNOBS * 100 + RGC_W_BLIND, c) 370 gv_check_eq("neg-control-operated-a-named-agent-that-never-ran-FAILS (the witness exists; its silence is evidence)" as *u8, rgc_operated(CES_NONE, CES_NONE, now, 1, RGC_S_BLIND, 1, w), RGC_FAILS, c) 371 gv_check_eq("operated-boundary-a-run-at-epoch-ZERO-is-still-a-run (the guard excludes only NONE)" as *u8, g_lw(rgc_operated(0, CES_NONE, G_GR_NOW, 1, RGC_S_CLOCK, 0, w), w), 100 + RGC_W_RUN, c) 372 gv_check_eq("operated-an-unreadable-actlog-is-UNOBSERVABLE" as *u8, rgc_operated(CES_NONE, CES_NONE, now, 0, RGC_S_CLOCK, 0, w), RGC_UNOBS, c) 373 gv_check_eq("operated-a-roster-run-counts-even-when-the-actlog-is-unreadable" as *u8, rgc_operated(now - 5, CES_NONE, now, 0, RGC_S_ROSTER, 0, w), RGC_HOLDS, c) 374 gv_check_eq("page-newer-than-the-land-holds" as *u8, rgc_page(201, G_A1_LAND, w), RGC_HOLDS, c) 375 gv_check_eq("page-the-same-second-as-the-land-holds" as *u8, rgc_page(G_A1_LAND, G_A1_LAND, w), RGC_HOLDS, c) 376 gv_check_eq("neg-control-page-older-than-the-land-fails-and-names-it" as *u8, g_lw(rgc_page(199, G_A1_LAND, w), w), RGC_W_PAGEOLD, c) 377 gv_check_eq("page-unreadable-is-UNOBSERVABLE" as *u8, rgc_page(0 - 1, G_A1_LAND, w), RGC_UNOBS, c) 378 gv_check_eq("page-with-no-land-need-only-exist" as *u8, rgc_page(999, CES_NONE, w), RGC_HOLDS, c) 379 // ---- ISSUES DEMOTE ---- 380 let iss: *i64 = sys_mmap(RGC_ISSUES * G_I64) as *i64 381 rgc_gate_facts(gr, gx, grows, "gx_gate" as *u8, CES_NONE, g) 382 gv_check_eq("issues-fixture-reached-the-condition: gx_gate turned twice" as *u8, g[RGC_G_FLIPS], RGC_FLAKY_TURNS, c) 383 gv_check_eq("issues-fixture-reached-the-condition: the last turn is the GREEN at 300" as *u8, g[RGC_G_LAST_FLIP], 300, c) 384 rgc_issues(g, CES_NONE, CES_NONE, G_GR_NOW, iss) 385 gv_check_eq("issue-FLAKY-two-turns-the-last-inside-the-margin" as *u8, iss[RGC_I_FLAKY], 1, c) 386 gv_check_eq("neg-control-issue-a-GREEN-newest-row-is-not-RED" as *u8, iss[RGC_I_RED], 0, c) 387 rgc_issues(g, CES_NONE, CES_NONE, 300 + rgc_margin_s() + 1, iss) 388 gv_check_eq("issue-FLAKY-ages-out-when-the-last-turn-leaves-the-margin" as *u8, iss[RGC_I_FLAKY], 0, c) 389 gv_check_eq("issue-STALE-when-the-roster-has-not-run-the-gate-inside-the-margin" as *u8, iss[RGC_I_STALE], 1, c) 390 rgc_gate_facts(gr, gx, grows, "gy_gate" as *u8, CES_NONE, g) 391 rgc_issues(g, CES_NONE, CES_NONE, G_GR_NOW, iss) 392 gv_check_eq("issue-RED-the-newest-roster-row" as *u8, iss[RGC_I_RED], 1, c) 393 rgc_gate_facts(gr, gx, grows, "gz_gate" as *u8, CES_NONE, g) 394 gv_check_eq("issue-RETRACT-newer-than-the-land" as *u8, g_slot(rgc_issues(g, 200, 250, G_GR_NOW, iss), iss, RGC_I_RETRACT, 10), 11, c) 395 gv_check_eq("neg-control-issue-a-land-after-the-retract-clears-it" as *u8, rgc_issues(g, 300, 250, G_GR_NOW, iss), 0, c) 396 gv_check_eq("issue-a-retract-with-no-land-at-all-stands" as *u8, rgc_issues(g, CES_NONE, 250, G_GR_NOW, iss), 1, c) 397 gv_check_eq("neg-control-issue-no-gate-rows-no-roster-issue" as *u8, rgc_issues(g, CES_NONE, CES_NONE, G_GR_NOW, iss), 0, c) 398 gv_check_eq("cap-RED-lowers-PRODUCTION-to-LIVE" as *u8, rgc_cap(RGC_ST_PRODUCTION, g_iss(1, 0, 0, 0)), RGC_ST_LIVE, c) 399 gv_check_eq("cap-RETRACT-lowers-to-LIVE" as *u8, rgc_cap(RGC_ST_BETA, g_iss(0, 1, 0, 0)), RGC_ST_LIVE, c) 400 gv_check_eq("cap-FLAKY-lowers-to-ALPHA" as *u8, rgc_cap(RGC_ST_PRODUCTION, g_iss(0, 0, 1, 0)), RGC_ST_ALPHA, c) 401 gv_check_eq("cap-STALE-lowers-to-ALPHA" as *u8, rgc_cap(RGC_ST_OPERATED, g_iss(0, 0, 0, 1)), RGC_ST_ALPHA, c) 402 gv_check_eq("cap-the-LOWEST-ceiling-wins (RED and FLAKY)" as *u8, rgc_cap(RGC_ST_PRODUCTION, g_iss(1, 0, 1, 0)), RGC_ST_LIVE, c) 403 gv_check_eq("anti-vacuity-cap-a-ceiling-NEVER-RAISES-a-stage (BUILT with RED stays BUILT)" as *u8, rgc_cap(RGC_ST_BUILT, g_iss(1, 0, 1, 1)), RGC_ST_BUILT, c) 404 gv_check_eq("rework-RED-RETRACT-and-FLAKY-are-rework" as *u8, rgc_rework(g_iss(1, 0, 0, 0)) + rgc_rework(g_iss(0, 1, 0, 0)) + rgc_rework(g_iss(0, 0, 1, 0)), 3, c) 405 gv_check_eq("neg-control-rework-STALE-alone-is-the-harness's-defect-not-the-rung's" as *u8, rgc_rework(g_iss(0, 0, 0, 1)), 0, c) 406 gv_check_eq("capping-issue-names-the-class-that-lowered-it" as *u8, rgc_capping_issue(RGC_ST_PRODUCTION, g_iss(0, 0, 1, 0)), RGC_I_FLAKY, c) 407 gv_check_eq("neg-control-capping-issue-none-when-the-ceiling-did-not-lower-it (ALPHA with FLAKY)" as *u8, rgc_capping_issue(RGC_ST_ALPHA, g_iss(0, 0, 1, 0)), CES_NONE, c) 408 let iw: *u8 = sys_mmap(rgc_issue_word_bound() + 1) 409 rgc_issue_word(g_iss(1, 0, 1, 0), iw, 0) 410 gv_check("issue-word-joins-the-present-classes" as *u8, g_streq(iw, "RED,FLAKY" as *u8), c) 411 rgc_issue_word(g_iss(0, 0, 0, 0), iw, 0) 412 gv_check("issue-word-none-is-a-dash" as *u8, g_streq(iw, "-" as *u8), c) 413 // ---- the climb ---- 414 let stop: *i64 = sys_mmap(G_I64) as *i64 415 gv_check_eq("state-every-link-holds-is-PRODUCTION" as *u8, rgc_state(1, g_links(1, 1, 1, 1, 1, 1, 1), stop), RGC_ST_PRODUCTION, c) 416 gv_check_eq("state-PRODUCTION-names-no-weakest-link" as *u8, stop[0], RGC_LINKS, c) 417 gv_check_eq("state-all-but-the-page-is-OPERATED" as *u8, rgc_state(1, g_links(1, 1, 1, 1, 1, 1, 0), stop), RGC_ST_OPERATED, c) 418 gv_check_eq("state-OPERATED-names-the-page" as *u8, stop[0], RGC_L_PAGE, c) 419 gv_check_eq("state-tested-then-not-wired-is-ALPHA" as *u8, rgc_state(1, g_links(1, 1, 1, 1, 0, 1, 1), stop), RGC_ST_ALPHA, c) 420 gv_check_eq("state-nothing-holds-is-OPEN" as *u8, rgc_state(1, g_links(0, 0, 0, 0, 0, 0, 0), stop), RGC_ST_OPEN, c) 421 gv_check_eq("anti-vacuity-a-later-link-that-holds-never-lifts-a-rung-past-an-earlier-one-that-fails" as *u8, rgc_state(1, g_links(1, 1, 1, 0, 1, 1, 1), stop), RGC_ST_LIVE, c) 422 gv_check_eq("anti-vacuity-the-weakest-link-is-the-FIRST-failure (tested), not the last" as *u8, stop[0], RGC_L_TESTED, c) 423 gv_check_eq("state-could-not-look-stops-the-climb-like-a-failure" as *u8, rgc_state(1, g_links(1, 1, 1, 1, 1, 0 - 1, 1), stop), RGC_ST_BETA, c) 424 gv_check_eq("neg-control-state-an-undeclared-rung-is-NORUNG-whatever-the-links-say" as *u8, rgc_state(0, g_links(1, 1, 1, 1, 1, 1, 1), stop), RGC_ST_NORUNG, c) 425 // ---- the words ---- 426 gv_check("name-ALPHA-BETA-OPERATED-PRODUCTION" as *u8, g_streq(rgc_state_name(RGC_ST_ALPHA), "ALPHA" as *u8) * g_streq(rgc_state_name(RGC_ST_BETA), "BETA" as *u8) * g_streq(rgc_state_name(RGC_ST_OPERATED), "OPERATED" as *u8) * g_streq(rgc_state_name(RGC_ST_PRODUCTION), "PRODUCTION" as *u8), c) 427 gv_check("name-links-tested-and-operated" as *u8, g_streq(rgc_link_name(RGC_L_TESTED), "tested" as *u8) * g_streq(rgc_link_name(RGC_L_OPERATED), "operated" as *u8), c) 428 gv_check("name-UNOBSERVABLE-is-its-own-word" as *u8, g_streq(rgc_hold_name(RGC_UNOBS), "UNOBSERVABLE" as *u8), c) 429 gv_check("weak-codes-an-issue-code-never-collides-with-a-link-or-all-hold" as *u8, (rgc_weak_issue0() > RGC_LINKS) as i64, c) 430 gv_check("weak-name-an-issue-code-names-the-issue" as *u8, g_streq(rgc_weak_name(rgc_weak_issue0() + RGC_I_FLAKY), "flaky" as *u8) * g_streq(rgc_weak_name(RGC_L_WIRED), "wired" as *u8), c) 431 var nowords: i64 = 0 432 var wk: i64 = 1 433 while wk < RGC_WHYS { if g_streq(rgc_why_word(wk), "-" as *u8) == 1 { nowords = nowords + 1 } wk = wk + 1 } 434 gv_check_eq("every-rule-has-a-word" as *u8, nowords, 0, c) 435 gv_check("every-failing-rule-names-a-remedy" as *u8, ((ces_slen(rgc_why_need(RGC_W_NOGATE)) > 1) as i64) * ((ces_slen(rgc_why_need(RGC_W_NORUN)) > 1) as i64) * ((ces_slen(rgc_why_need(RGC_W_UNREGISTERED)) > 1) as i64) * ((ces_slen(rgc_why_need(RGC_W_MCPONLY)) > 1) as i64), c) 436 gv_check("neg-control-could-not-look-has-its-OWN-remedy (an unobservable contract asks for the watch row, not for a build)" as *u8, 1 - g_streq(rgc_why_need(RGC_W_NOROW), rgc_why_need(RGC_W_DARK)), c) 437 // ---- THE STAGE SNAPSHOT the closer diffs against ---- 438 let sb: *u8 = sys_mmap(rgc_stage_head_bound() + 3 * (G_WORK_NAME_B + rgc_stage_row_fixed())) 439 var sn: i64 = rgc_stage_head(sb, 0, 400) 440 sn = rgc_stage_row(sb, sn, "fx" as *u8, "A1" as *u8, RGC_ST_BETA, g_iss(0, 0, 0, 0), 500, 0) 441 let sb_before: i64 = sn 442 sn = rgc_stage_row(sb, sn, "fx" as *u8, "A2" as *u8, RGC_ST_LIVE, g_iss(1, 0, 0, 0), 600, 1) 443 let sb_rowlen: i64 = sn - sb_before 444 sn = rgc_stage_row(sb, sn, "fy" as *u8, "A1" as *u8, RGC_ST_ALPHA, g_iss(0, 0, 0, 0), 700, 0) 445 let cur: *i64 = sys_mmap(G_I64) as *i64 446 cur[0] = 0 447 let so: *i64 = sys_mmap(RGC_SG_OUT_SLOTS * G_I64) as *i64 448 gv_check_eq("snapshot-a-row-is-found-by-domain-and-rung" as *u8, rgc_stage_find(sb, sn, "fx" as *u8, "A2" as *u8, cur, so), 1, c) 449 gv_check_eq("snapshot-round-trip-the-stage" as *u8, so[RGC_SG_OUT_STATE], RGC_ST_LIVE, c) 450 gv_check_eq("snapshot-round-trip-the-since" as *u8, so[RGC_SG_OUT_SINCE], 600, c) 451 gv_check("snapshot-round-trip-the-issues-word" as *u8, ces_span_is(sb, so[RGC_SG_OUT_IO], so[RGC_SG_OUT_IL], "RED" as *u8), c) 452 gv_check_eq("snapshot-the-cursor-WRAPS: fx A1 sits above the cursor and is still found" as *u8, g_slot(rgc_stage_find(sb, sn, "fx" as *u8, "A1" as *u8, cur, so), so, RGC_SG_OUT_STATE, 10), 10 + RGC_ST_BETA, c) 453 gv_check_eq("snapshot-another-board's-same-rung-id-is-its-own-row" as *u8, g_slot(rgc_stage_find(sb, sn, "fy" as *u8, "A1" as *u8, cur, so), so, RGC_SG_OUT_STATE, 10), 10 + RGC_ST_ALPHA, c) 454 gv_check_eq("neg-control-snapshot-a-PREFIX-rung-is-not-found" as *u8, rgc_stage_find(sb, sn, "fx" as *u8, "A" as *u8, cur, so), 0, c) 455 gv_check_eq("neg-control-snapshot-a-PREFIX-board-is-not-found" as *u8, rgc_stage_find(sb, sn, "f" as *u8, "A1" as *u8, cur, so), 0, c) 456 gv_check("snapshot-a-row-never-outgrows-its-derived-bound" as *u8, (sb_rowlen <= ces_slen("fx" as *u8) + ces_slen("A2" as *u8) + rgc_stage_row_fixed()) as i64, c) 457 let mw: *u8 = sys_mmap(G_WORK_NAME_B * 4) 458 rgc_move_word(mw, 0, RGC_ST_BETA, RGC_ST_PRODUCTION) 459 gv_check("move-word-FROM>TO" as *u8, g_streq(mw, "BETA>PRODUCTION" as *u8), c) 460 rgc_move_word(mw, 0, 0 - 1, RGC_ST_BUILT) 461 gv_check("move-word-a-rung-the-last-census-did-not-carry-is-NEW" as *u8, g_streq(mw, "NEW>BUILT" as *u8), c) 462 // ---- the close-first worklist: ONE wire, written and read by the same lib ---- 463 let cw_lp: *u8 = "rung|L1|t|-|n|Organ|1|-\nlog|100|L1|measure|m\nlog|300|L1|queue|q\nlog|200|L1|land|l\nlog|900|L2|land|other\n" as *u8 464 let cw_f: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 465 rgc_journal(cw_lp, ces_slen(cw_lp), "L1" as *u8, cw_f) 466 gv_check_eq("last-touched-is-the-newest-row-of-ANY-kind-and-never-another-rung's" as *u8, cw_f[RGC_F_LAST], 300, c) 467 let cw_act: i64 = now - 100 468 let cw_stale: i64 = now - CES_WIP_ACTIVE_S - 100 469 let cw_b: *u8 = sys_mmap(rgc_work_head_bound() + G_WORK_ROWS * (G_WORK_NAME_B + rgc_work_row_fixed())) 470 var cw_n: i64 = rgc_work_head(cw_b, 0, now - 10) 471 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_STARTED, "fx" as *u8, "S1" as *u8, RGC_L_BUILT, 0, cw_act, 0) 472 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_OPERATED, "fx" as *u8, "P2" as *u8, RGC_L_PAGE, 0, cw_stale, 0) 473 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_ALPHA, "fx" as *u8, "W3" as *u8, RGC_L_WIRED, 0, cw_act, 0) 474 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_OPERATED, "fx" as *u8, "P4" as *u8, RGC_L_PAGE, 0, cw_act, 0) 475 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_BUILT, "fxx" as *u8, "B5" as *u8, RGC_L_LIVE, 0, cw_stale, 0) 476 let cw_before: i64 = cw_n 477 cw_n = rgc_work_row(cw_b, cw_n, RGC_ST_BETA, "fx" as *u8, "A6" as *u8, rgc_weak_issue0() + RGC_I_FLAKY, 1, cw_act, 15) 478 let cw_rowlen: i64 = cw_n - cw_before 479 let cw_good: i64 = cw_n 480 cw_n = ces_cat(cw_b, cw_n, "work|9|fx|X9|page|0|1|1\nwork|8|fx|X8|page|0|1|1\nwork|3|fx|short\n" as *u8) 481 let cw_picks: *i64 = sys_mmap(G_WORK_ROWS * RGC_PICK_STRIDE * G_I64) as *i64 482 let cw_acc: *i64 = sys_mmap(RGC_W_SLOTS * G_I64) as *i64 483 let cw_off: *i64 = sys_mmap(G_I64) as *i64 484 let cw_all: i64 = rgc_work_pick(cw_b, cw_n, "*" as *u8, now, G_WORK_ROWS, cw_picks, cw_acc) 485 gv_check_eq("worklist-every-well-formed-row-is-picked-when-the-cap-allows" as *u8, cw_all, 6, c) 486 gv_check_eq("worklist-accounting-counts-the-well-formed-rows" as *u8, cw_acc[RGC_W_TOTAL], 6, c) 487 gv_check_eq("neg-control-worklist-a-PRODUCTION-row, a-non-member-state and a short row are MALFORMED: counted, never picked" as *u8, cw_acc[RGC_W_MALFORMED], 3, c) 488 gv_check("order-1-OPERATED-and-touched-this-week-comes-first (P4)" as *u8, g_pick_rung_is(cw_b, cw_picks, 0, "P4" as *u8, cw_off), c) 489 gv_check("order-2-OPERATED-and-stale-is-next (P2): nearer to production beats fresher" as *u8, g_pick_rung_is(cw_b, cw_picks, 1, "P2" as *u8, cw_off), c) 490 gv_check("order-3-BETA (A6)" as *u8, g_pick_rung_is(cw_b, cw_picks, 2, "A6" as *u8, cw_off), c) 491 gv_check("order-4-ALPHA (W3)" as *u8, g_pick_rung_is(cw_b, cw_picks, 3, "W3" as *u8, cw_off), c) 492 gv_check("order-5-BUILT-on-the-other-board (B5)" as *u8, g_pick_rung_is(cw_b, cw_picks, 4, "B5" as *u8, cw_off), c) 493 gv_check("anti-vacuity-order-the-FIRST-row-of-the-list-is-picked-LAST (S1 is only STARTED): list order never decides across stages" as *u8, g_pick_rung_is(cw_b, cw_picks, 5, "S1" as *u8, cw_off), c) 494 let cw_a6p: i64 = cw_picks[2 * RGC_PICK_STRIDE] 495 let cw_a6e: i64 = cw_picks[2 * RGC_PICK_STRIDE + 1] 496 let cw_cl: i64 = ces_field(cw_b, cw_a6p, cw_a6e, RGC_WORK_F_COST, cw_off) 497 gv_check_eq("wire-round-trip-the-LAST-field-survives (cost 15 deci-u)" as *u8, ces_parse_int(cw_b, cw_off[0], cw_cl), 15, c) 498 let cw_ul: i64 = ces_field(cw_b, cw_a6p, cw_a6e, RGC_WORK_F_UNOBS, cw_off) 499 gv_check_eq("wire-round-trip-the-unobservable-flag" as *u8, ces_parse_int(cw_b, cw_off[0], cw_ul), 1, c) 500 let cw_wl: i64 = ces_field(cw_b, cw_a6p, cw_a6e, RGC_WORK_F_WEAK, cw_off) 501 gv_check("wire-round-trip-a-capping-ISSUE-rides-the-weakest-field-BY-NAME (flaky)" as *u8, ces_span_is(cw_b, cw_off[0], cw_wl, "flaky" as *u8), c) 502 gv_check("wire-a-row-never-outgrows-its-derived-bound" as *u8, (cw_rowlen <= ces_slen("fx" as *u8) + ces_slen("A6" as *u8) + rgc_work_row_fixed()) as i64, c) 503 let cw_fx: i64 = rgc_work_pick(cw_b, cw_n, "fx" as *u8, now, G_WORK_ROWS, cw_picks, cw_acc) 504 gv_check_eq("board-filter-takes-only-that-board" as *u8, cw_fx, 5, c) 505 gv_check_eq("neg-control-board-filter-a-LONGER-board-name-never-matches (fxx is not fx)" as *u8, cw_acc[RGC_W_MATCHED], 5, c) 506 let cw_pre: i64 = rgc_work_pick(cw_b, cw_n, "f" as *u8, now, G_WORK_ROWS, cw_picks, cw_acc) 507 gv_check_eq("neg-control-board-filter-a-PREFIX-matches-nothing (f)" as *u8, cw_pre + cw_acc[RGC_W_MATCHED], 0, c) 508 let cw_cap: i64 = rgc_work_pick(cw_b, cw_n, "*" as *u8, now, 2, cw_picks, cw_acc) 509 gv_check_eq("cap-the-list-stops-at-the-cap" as *u8, cw_cap, 2, c) 510 gv_check_eq("cap-and-the-accounting-says-how-many-it-left-out (matched 6, shown 2)" as *u8, cw_acc[RGC_W_MATCHED] - cw_acc[RGC_W_SHOWN], 4, c) 511 gv_check_eq("asof-is-read-off-the-list's-own-head" as *u8, rgc_work_asof(cw_b, cw_n), now - 10, c) 512 gv_check_eq("fresh-inside-the-margin" as *u8, rgc_work_fresh(now - 10, now), RGC_WORK_FRESH, c) 513 gv_check_eq("fresh-AT-the-margin (two beats exactly)" as *u8, rgc_work_fresh(now - rgc_margin_s(), now), RGC_WORK_FRESH, c) 514 gv_check_eq("stale-one-second-past-the-margin" as *u8, rgc_work_fresh(now - rgc_margin_s() - 1, now), RGC_WORK_STALE, c) 515 gv_check_eq("neg-control-a-FUTURE-stamp-is-UNOBSERVABLE, never fresh" as *u8, rgc_work_fresh(now + 5, now), CES_NONE, c) 516 gv_check_eq("member-OPEN-PRODUCTION-and-NORUNG-are-never-on-the-list" as *u8, rgc_work_member(RGC_ST_OPEN) + rgc_work_member(RGC_ST_PRODUCTION) + rgc_work_member(RGC_ST_NORUNG), 0, c) 517 gv_check_eq("member-STARTED-through-OPERATED-are" as *u8, rgc_work_member(RGC_ST_STARTED) + rgc_work_member(RGC_ST_OPERATED), 2, c) 518 // ---- the journal row grammar (EC55 item 3): rows are written by grammar, never by hand ---- 519 let jo: *i64 = sys_mmap(G_I64) as *i64 520 gv_check_eq("kind-the-six-kinds-the-boards-render-are-accepted" as *u8, rgc_kind_ok("measure" as *u8) + rgc_kind_ok("land" as *u8) + rgc_kind_ok("retract" as *u8) + rgc_kind_ok("lesson" as *u8) + rgc_kind_ok("queue" as *u8) + rgc_kind_ok("done" as *u8), 6, c) 521 gv_check_eq("neg-control-kind-a-word-the-boards-do-not-render-is-refused (landed, the PREFIX lan, and the empty word)" as *u8, rgc_kind_ok("landed" as *u8) + rgc_kind_ok("lan" as *u8) + rgc_kind_ok("" as *u8), 0, c) 522 gv_check_eq("text-plain-text-is-ok" as *u8, rgc_text_ok("shipped nx_x sha256=ab12 bytes=10" as *u8, jo), 1, c) 523 gv_check_eq("neg-control-text-EMPTY-is-refused-as-empty" as *u8, rgc_text_ok("" as *u8, jo), 0, c) 524 gv_check_eq("neg-control-text-a-PIPE-is-refused (it would invent a field)" as *u8, rgc_text_ok("a|b" as *u8, jo), CES_NONE, c) 525 gv_check_eq("text-the-refusal-says-WHERE (byte 1)" as *u8, jo[0], 1, c) 526 let jnl: *u8 = sys_mmap(G_I64) 527 var jnn: i64 = ces_cat(jnl, 0, "a" as *u8) 528 jnl[jnn] = CES_CH_NL as u8 529 jnn = ces_cat(jnl, jnn + 1, "b" as *u8) 530 gv_check_eq("neg-control-text-a-LINE-BREAK-is-refused (it would invent a row)" as *u8, rgc_text_ok(jnl, jo), CES_NONE, c) 531 // the fixture's epoch is CHOSEN BY THE RUN (the clock at test time), never typed: a fixed value in a test can be mirrored 532 // by a constant in the subject, a value the run chose cannot 533 let jep: i64 = sys_now_realtime_sec() 534 let jbound: i64 = rgc_log_row_bound("J1" as *u8, "land" as *u8, "shipped" as *u8) 535 let jp: *u8 = sys_mmap(jbound * 2 + ces_slen("rung|J1|t|-|n|Organ|1|-\n" as *u8)) 536 let jhead: i64 = ces_cat(jp, 0, "rung|J1|t|-|n|Organ|1|-\n" as *u8) 537 let jpo: i64 = rgc_log_row(jp, jhead, 0, jep, "J1" as *u8, "land" as *u8, "shipped" as *u8) 538 let jre: i64 = jpo - 1 539 let jfo: *i64 = sys_mmap(G_I64) as *i64 540 var jshape: i64 = 0 541 if ces_nfields(jp, jhead, jre) == CES_LOG_NF { jshape = 1 } 542 let jl0: i64 = ces_field(jp, jhead, jre, 0, jfo) 543 jshape = jshape * ces_span_is(jp, jfo[0], jl0, CES_LOG_TAG) 544 let jl2: i64 = ces_field(jp, jhead, jre, CES_LOG_F_RUNG, jfo) 545 jshape = jshape * ces_span_is(jp, jfo[0], jl2, "J1" as *u8) 546 let jl3: i64 = ces_field(jp, jhead, jre, CES_LOG_F_KIND, jfo) 547 jshape = jshape * ces_span_is(jp, jfo[0], jl3, "land" as *u8) 548 let jl4: i64 = ces_field(jp, jhead, jre, CES_LOG_NF - 1, jfo) 549 jshape = jshape * ces_span_is(jp, jfo[0], jl4, "shipped" as *u8) 550 gv_check("row-is-built-by-grammar (five fields: the tag, the rung, the kind, the text LAST, and one newline closes it)" as *u8, jshape * ((jp[jre] == (CES_CH_NL as u8)) as i64), c) 551 gv_check("row-never-outgrows-its-derived-bound" as *u8, ((jpo - jhead) < jbound) as i64, c) 552 let jf: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 553 rgc_journal(jp, jpo, "J1" as *u8, jf) 554 gv_check_eq("round-trip-a-row-the-grammar-wrote-is-READ-by-the-ruler (the land at the planted epoch)" as *u8, jf[RGC_F_LAND], jep, c) 555 let jlead: *u8 = sys_mmap(jbound + 1) 556 rgc_log_row(jlead, 0, 1, jep, "J1" as *u8, "land" as *u8, "x" as *u8) 557 gv_check("row-a-file-with-no-final-newline-gets-one-FIRST (the row must start a line)" as *u8, (jlead[0] == (CES_CH_NL as u8)) as i64, c) 558 // ---- a rung id declared TWICE ---- 559 let dp: *u8 = "rung|D1|first|-|n|Organ|1|-\nrung|D2|only|-|n|Organ|1|-\nrung|D1|second|-|n|Organ|1|-\nlog|100|D1|land|whose row is this\n" as *u8 560 let df: *i64 = sys_mmap(RGC_F_SLOTS * G_I64) as *i64 561 rgc_journal(dp, ces_slen(dp), "D1" as *u8, df) 562 gv_check_eq("duplicate-id-two-rung-rows-that-share-an-id-are-COUNTED" as *u8, df[RGC_F_DECLS], G_TWICE, c) 563 rgc_journal(dp, ces_slen(dp), "D2" as *u8, df) 564 gv_check_eq("neg-control-duplicate-id-a-rung-declared-once-reads-one" as *u8, df[RGC_F_DECLS], 1, c) 565 // ---- THE ROSTER CONFS (nx_rosterconf_lib): derived from the clock plane, and a gate is rostered by ANY of them ---- 566 let rpl: i64 = ces_slen(G_RCLOCK) + ces_slen(G_RCRLF_ROW) + 3 567 let rck: *u8 = sys_mmap(rpl) 568 var rcn: i64 = ces_cat(rck, 0, G_RCLOCK) 569 rcn = ces_cat(rck, rcn, G_RCRLF_ROW) 570 rck[rcn] = RCF_CH_CR as u8 571 rck[rcn + 1] = RCF_CH_NL as u8 572 rcn = rcn + 2 573 rck[rcn] = 0 as u8 574 let rmeta: *i64 = sys_mmap(RCF_META_SLOTS * G_I64) as *i64 575 let rlist: *u8 = sys_mmap(rcf_confs_bound(rck, rcn)) 576 let rk: i64 = rcf_confs(rck, rcn, rlist, rmeta) 577 let rln: i64 = rmeta[RCF_META_BYTES] 578 let rbeats: i64 = rmeta[RCF_META_BEATS] 579 let rother: i64 = rmeta[RCF_META_OTHER] 580 gv_check_eq("roster-fixture-reached-the-condition: the plane carries six roster beats (the CRLF row was assembled)" as *u8, rbeats, G_RBEATS, c) 581 gv_check_eq("roster-pairs-the-default-and-every-pair-a-beat-runs, once each (the bare beat and the heavy-again fold into pairs already listed)" as *u8, rk, G_RCONFS, c) 582 gv_check("roster-pairs-the-runner's-default-pair-is-FIRST (its conf stays the treat judge's evidence, its journal is the production one)" as *u8, g_part_is(rlist, rln, 0, RCF_PART_CONF, "knowledge/gateroster.conf" as *u8) * g_part_is(rlist, rln, 0, RCF_PART_JRNL, G_RPROD), c) 583 gv_check("roster-pairs-the-HEAVY-beat's-conf-writes-the-production-journal" as *u8, g_part_is(rlist, rln, 1, RCF_PART_CONF, "fx/heavy.conf" as *u8) * g_part_is(rlist, rln, 1, RCF_PART_JRNL, G_RPROD), c) 584 gv_check("roster-pairs-a-beat-writing-ITS-OWN-journal-is-a-roster-paired-with-THAT-journal (its evidence is read there)" as *u8, g_part_is(rlist, rln, G_RSLOW_PAIR, RCF_PART_CONF, "fx/slow.conf" as *u8) * g_part_is(rlist, rln, G_RSLOW_PAIR, RCF_PART_JRNL, G_RSLOWJ), c) 585 gv_check_eq("roster-pairs-the-beats-off-the-production-journal-are-counted" as *u8, rother, G_ROTHER, c) 586 gv_check("roster-pairs-a-CR-a-row-carries-from-another-host-is-not-part-of-the-conf-name, and a beat naming no journal writes the production one" as *u8, g_part_is(rlist, rln, G_RCRLF_PAIR, RCF_PART_CONF, "fx/crlf.conf" as *u8) * g_part_is(rlist, rln, G_RCRLF_PAIR, RCF_PART_JRNL, G_RPROD), c) 587 gv_check_eq("neg-control-roster-pairs-a-trial-row, an-argless-row, a-PREFIX-program and a-line-with-no-command add nothing" as *u8, g_conf_listed(rlist, rln, "fx/trial.list" as *u8) + g_conf_listed(rlist, rln, "fx/prefix.conf" as *u8) + g_conf_listed(rlist, rln, "fx/notab.conf" as *u8), 0, c) 588 gv_check_eq("roster-pairs-a-journal-two-pairs-share-is-keyed-to-its-FIRST-pair (heavy's journal is the default pair's)" as *u8, rcf_pair_origin(rlist, rln, 1, RCF_PART_JRNL), 0, c) 589 gv_check_eq("roster-pairs-a-journal-only-one-pair-writes-is-its-own (the slow journal)" as *u8, rcf_pair_origin(rlist, rln, G_RSLOW_PAIR, RCF_PART_JRNL), G_RSLOW_PAIR, c) 590 let rbo: *i64 = sys_mmap(G_I64) as *i64 591 let rbare: *u8 = "nx_gate_roster_run.elf beat" as *u8 592 let rbl: i64 = rcf_beat_conf(rbare, 0, ces_slen(rbare), rbo) 593 gv_check("beat-a-beat-naming-no-conf-runs-the-DEFAULT (length 0, no offset)" as *u8, ((rbl == 0) as i64) * ((rbo[0] == RCF_NONE) as i64), c) 594 let rlong: *u8 = "/v/nx_gate_roster_runner.elf beat fx/x.conf" as *u8 595 gv_check_eq("neg-control-beat-a-LONGER-program-name-is-another-program" as *u8, rcf_beat_conf(rlong, 0, ces_slen(rlong), rbo), RCF_NOT_A_BEAT, c) 596 let rtrial: *u8 = "nx_gate_roster_run trial fx/x.list" as *u8 597 gv_check_eq("neg-control-beat-a-TRIAL-runs-candidates-never-the-roster" as *u8, rcf_beat_conf(rtrial, 0, ces_slen(rtrial), rbo), RCF_NOT_A_BEAT, c) 598 let rjc: *u8 = "nx_gate_roster_run.elf beat fx/a.conf knowledge/status/x.jrnl 9" as *u8 599 let rjl: i64 = rcf_beat_jrnl(rjc, 0, ces_slen(rjc), rbo) 600 gv_check("beat-journal-the-argument-after-the-conf-is-the-journal" as *u8, ces_span_is(rjc, rbo[0], rjl, "knowledge/status/x.jrnl" as *u8), c) 601 gv_check_eq("neg-control-beat-journal-a-journal-that-is-not-RCF_JRNL-is-not-production" as *u8, rcf_jrnl_is_prod(rjc, rbo[0], rjl), 0, c) 602 let rjn: *u8 = "nx_gate_roster_run.elf beat fx/a.conf" as *u8 603 let rjnl: i64 = rcf_beat_jrnl(rjn, 0, ces_slen(rjn), rbo) 604 gv_check("beat-journal-a-beat-naming-none-writes-the-production-journal" as *u8, ((rjnl == 0) as i64) * rcf_jrnl_is_prod(rjn, rbo[0], rjnl), c) 605 let rnb: *u8 = sys_mmap(rcf_confs_bound(G_RNOBEAT, ces_slen(G_RNOBEAT))) 606 let rnk: i64 = rcf_confs(G_RNOBEAT, ces_slen(G_RNOBEAT), rnb, rmeta) 607 gv_check("roster-pairs-a-plane-with-NO-beat-still-lists-the-default-pair (an unreadable plane costs no roster the incumbent read)" as *u8, ((rnk == 1) as i64) * g_part_is(rnb, rmeta[RCF_META_BYTES], 0, RCF_PART_CONF, "knowledge/gateroster.conf" as *u8) * g_part_is(rnb, rmeta[RCF_META_BYTES], 0, RCF_PART_JRNL, G_RPROD), c) 608 // the conf texts, in pair order 609 let rcg: i64 = ces_slen(G_RCRLF_GATE) 610 let rcrlf: *u8 = sys_mmap(rcg + 3) 611 var rco: i64 = ces_cat(rcrlf, 0, G_RCRLF_GATE) 612 rcrlf[rco] = RCF_CH_CR as u8 613 rcrlf[rco + 1] = RCF_CH_NL as u8 614 rco = rco + 2 615 rcrlf[rco] = 0 as u8 616 // sized by the larger of the derived list and the fixture: a subject that lists more pairs reads the extra as unread (0, 0) 617 // texts and empty journals, never past the array 618 var rtn: i64 = rk 619 if rtn < G_RCONFS { rtn = G_RCONFS } 620 let rt: *i64 = sys_mmap(rtn * RCF_TEXT_STRIDE * G_I64) as *i64 621 rt[RCF_TEXT_P] = G_RMAIN as i64 622 rt[RCF_TEXT_N] = ces_slen(G_RMAIN) 623 rt[RCF_TEXT_STRIDE + RCF_TEXT_P] = G_RHEAVY as i64 624 rt[RCF_TEXT_STRIDE + RCF_TEXT_N] = ces_slen(G_RHEAVY) 625 rt[G_RSLOW_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_P] = G_RSLOW as i64 626 rt[G_RSLOW_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_N] = ces_slen(G_RSLOW) 627 rt[G_RCRLF_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_P] = rcrlf as i64 628 rt[G_RCRLF_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_N] = rco 629 let rheavy_in: i64 = g_rfind(rt, rk, "nx_heavy_gate" as *u8) 630 gv_check_eq("rostered-a-gate-ONLY-on-the-HEAVY-conf-IS-rostered, by the heavy pair (index 1)" as *u8, rheavy_in, 1, c) 631 gv_check_eq("anti-vacuity-rostered-the-same-gate-against-the-DEFAULT-conf-alone-is-NOT (the comment naming it is not a row)" as *u8, g_rfind(rt, 1, "nx_heavy_gate" as *u8), RCF_NONE, c) 632 gv_check_eq("neg-control-rostered-a-gate-on-NO-conf-is-not-rostered" as *u8, g_rfind(rt, rk, "nx_none_gate" as *u8), RCF_NONE, c) 633 gv_check_eq("rostered-a-default-conf-gate-is-rostered-by-the-default (index 0)" as *u8, g_rfind(rt, rk, "nx_main_gate" as *u8), 0, c) 634 gv_check_eq("rostered-the-beat's-grammar-skips-leading-spaces" as *u8, g_rfind(rt, rk, "nx_indented_gate" as *u8), 0, c) 635 gv_check_eq("rostered-a-tab-ends-a-gate-name" as *u8, g_rfind(rt, rk, "nx_tabbed_gate" as *u8), 0, c) 636 gv_check_eq("rostered-a-gate-on-the-SLOW-conf-is-rostered-by-the-slow-pair (a beat writing its own journal IS a roster)" as *u8, g_rfind(rt, rk, "nx_slow_gate" as *u8), G_RSLOW_PAIR, c) 637 let rcrlf_in: i64 = g_rfind(rt, rk, G_RCRLF_GATE) 638 gv_check_eq("rostered-a-CRLF-row-names-its-gate (the crlf pair)" as *u8, rcrlf_in, G_RCRLF_PAIR, c) 639 gv_check_eq("neg-control-rostered-an-@directive-and-a-PREFIX-name-are-not-gates" as *u8, g_rfind(rt, rk, "@dispatch_deadline_ms" as *u8) + 1 + g_rfind(rt, rk, "nx_main" as *u8) + 1, 0, c) 640 // ---- THE CREDIT: a gate's roster evidence is read from the production journal and the journal of every roster running it ---- 641 let jt: *i64 = sys_mmap(rtn * RGC_RJ_STRIDE * G_I64) as *i64 642 var rjk: i64 = 0 643 while rjk < rtn { jt[rjk * RGC_RJ_STRIDE + RGC_RJ_ORIGIN] = rcf_pair_origin(rlist, rln, rjk, RCF_PART_JRNL); rjk = rjk + 1 } 644 let rprod_rows: i64 = g_journal(jt, 0, G_RJPROD) 645 let rslow_rows: i64 = g_journal(jt, G_RSLOW_PAIR, G_RJSLOW) 646 gv_check_eq("credit-fixture-the-journals-index-their-roster-rows-only (the slow journal's trial row is out)" as *u8, rprod_rows * G_RJ_SCALE + rslow_rows, G_RJPROD_ROWS * G_RJ_SCALE + G_RJSLOW_ROWS, c) 647 let rsb: i64 = G_RSLOW_PAIR * RGC_RJ_STRIDE 648 let rgt: *i64 = sys_mmap(RGC_G_SLOTS * G_I64) as *i64 649 rgc_gate_facts(jt[rsb + RGC_RJ_BUF] as *u8, jt[rsb + RGC_RJ_GX] as *i64, jt[rsb + RGC_RJ_GXROWS], "nx_stray_gate" as *u8, CES_NONE, rgt) 650 let rstray_there: i64 = rgt[RGC_G_GREEN] 651 rgc_gate_facts(jt[rsb + RGC_RJ_BUF] as *u8, jt[rsb + RGC_RJ_GX] as *i64, jt[rsb + RGC_RJ_GXROWS], "nx_slow_gate" as *u8, CES_NONE, rgt) 652 gv_check("credit-fixture-reached-the-condition: the slow journal holds a GREEN for nx_slow_gate AND one for nx_stray_gate, which the slow conf does not list" as *u8, ((rgt[RGC_G_GREEN] == G_RJ_SLOW_GREEN) as i64) * ((rstray_there == G_RJ_STRAY_GREEN) as i64), c) 653 let rg: *i64 = sys_mmap(RGC_G_SLOTS * G_I64) as *i64 654 let rout: *i64 = sys_mmap(RGC_RC_SLOTS * G_I64) as *i64 655 g_credit(jt, rt, rk, "nx_slow_gate" as *u8, G_RJ_LEFT_GREEN, rg, rout) 656 let rslow_green: i64 = rg[RGC_G_GREEN] 657 let rslow_in: i64 = rout[RGC_RC_GREEN_IN] 658 let rslow_consulted: i64 = rout[RGC_RC_CONSULTED] 659 gv_check_eq("credit-a-gate-rostered-ONLY-by-a-beat-writing-its-own-journal-is-CREDITED-from-THAT-journal (its GREEN since the land)" as *u8, rslow_green, G_RJ_SLOW_GREEN, c) 660 gv_check_eq("credit-green_in-names-the-journal-that-credited-it (the slow pair)" as *u8, rslow_in, G_RSLOW_PAIR, c) 661 gv_check_eq("credit-the-production-journal-and-the-slow-journal-were-consulted, each once" as *u8, rslow_consulted, G_RJ_CONSULT_SLOW, c) 662 gv_check_eq("credit-so-the-slow-rostered-gate-TESTS-HOLDS" as *u8, g_lw(rgc_tested(1, 1 - rout[RGC_RC_UNREAD], rslow_green, 1, w), w), RGC_HOLDS * G_LW_SCALE + RGC_W_GREEN, c) 663 g_credit(jt, rt, rk, "nx_stray_gate" as *u8, CES_NONE, rg, rout) 664 gv_check_eq("neg-control-credit-a-GREEN-in-a-journal-whose-conf-does-NOT-list-the-gate-is-NOT-credited" as *u8, rg[RGC_G_GREEN], CES_NONE, c) 665 gv_check_eq("neg-control-credit-and-no-journal-is-named-as-its-source" as *u8, rout[RGC_RC_GREEN_IN], CES_NONE, c) 666 g_credit(jt, rt, rk, "nx_left_gate" as *u8, CES_NONE, rg, rout) 667 gv_check_eq("credit-the-PRODUCTION-journal-is-ALWAYS-read (a GREEN earned there counts after the gate left every conf)" as *u8, rg[RGC_G_GREEN], G_RJ_LEFT_GREEN, c) 668 gv_check_eq("credit-and-green_in-names-the-production-pair" as *u8, rout[RGC_RC_GREEN_IN], 0, c) 669 g_credit(jt, rt, rk, "nx_trial_gate" as *u8, CES_NONE, rg, rout) 670 gv_check_eq("neg-control-credit-a-TRIAL-row-in-a-listed-journal-never-credits (the tag rule holds in every journal)" as *u8, g_lw(rgc_tested(1, 1 - rout[RGC_RC_UNREAD], rg[RGC_G_GREEN], 1, w), w), RGC_FAILS * G_LW_SCALE + RGC_W_NOGREEN, c) 671 g_credit(jt, rt, rk, "nx_heavy_gate" as *u8, CES_NONE, rg, rout) 672 gv_check_eq("credit-a-journal-two-rosters-share-is-read-ONCE (the heavy beat writes the production journal)" as *u8, rout[RGC_RC_CONSULTED], 1, c) 673 g_credit(jt, rt, rk, "nx_slow_gate" as *u8, G_RJ_SLOW_GREEN + 1, rg, rout) 674 gv_check_eq("neg-control-credit-a-slow-journal-GREEN-BEFORE-the-land-is-not-credited" as *u8, rg[RGC_G_GREEN], CES_NONE, c) 675 // an UNREADABLE slow journal: the gate it alone rosters reads UNOBSERVABLE, and a gate the slow conf does not list never asks it 676 jt[rsb + RGC_RJ_LEN] = RGC_RJ_UNREAD 677 g_credit(jt, rt, rk, "nx_slow_gate" as *u8, G_RJ_LEFT_GREEN, rg, rout) 678 gv_check_eq("credit-a-gate-rostered-ONLY-by-a-beat-whose-journal-is-UNREADABLE-is-FLAGGED-and-credited-nothing" as *u8, g_slot(rg[RGC_G_GREEN], rout, RGC_RC_UNREAD, G_LW_SCALE), CES_NONE * G_LW_SCALE + 1, c) 679 gv_check_eq("credit-so-TESTED-reads-UNOBSERVABLE, never HOLDS and never FAILS" as *u8, rgc_tested(1, 1 - rout[RGC_RC_UNREAD], rg[RGC_G_GREEN], 1, w), RGC_UNOBS, c) 680 g_credit(jt, rt, rk, "nx_main_gate" as *u8, CES_NONE, rg, rout) 681 gv_check_eq("neg-control-credit-a-journal-no-pair-listing-the-gate-writes-is-NEVER-asked (nx_main_gate is off the slow conf)" as *u8, g_slot(rg[RGC_G_GREEN], rout, RGC_RC_UNREAD, G_LW_SCALE), G_RJ_MAIN_GREEN * G_LW_SCALE, c) 682 jt[rsb + RGC_RJ_LEN] = ces_slen(G_RJSLOW) 683 rt[G_RCRLF_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_P] = 0 684 rt[G_RCRLF_PAIR * RCF_TEXT_STRIDE + RCF_TEXT_N] = 0 685 gv_check_eq("rostered-an-UNREAD-conf-holds-no-rows" as *u8, g_rfind(rt, rk, G_RCRLF_GATE), RCF_NONE, c) 686 let rj: *u8 = sys_mmap(rln + 1) 687 rcf_join_confs(rlist, rln, rj, 0) 688 gv_check("stale-remedy-the-printed-list-names-EVERY-roster-conf, each once" as *u8, g_streq(rj, G_RJOINED), c) 689 gv_check("stale-remedy-states-the-rule-and-points-at-the-list" as *u8, g_has(rgc_issue_need(RGC_I_STALE), "listed after this remedy" as *u8), c) 690 gv_check_eq("neg-control-stale-remedy-names-no-single-conf-by-hand (the list is derived, the prose never goes stale with it)" as *u8, g_has(rgc_issue_need(RGC_I_STALE), "gateroster" as *u8) + g_has(rgc_why_need(RGC_W_UNROSTERED), "gateroster" as *u8), 0, c) 691 gv_values_head() 692 gv_kv("roster_rows_indexed" as *u8, grows) 693 gv_kv("actlog_runs_indexed" as *u8, arows) 694 gv_kv("margin_s" as *u8, rgc_margin_s()) 695 gv_kv("weak_issue0" as *u8, rgc_weak_issue0()) 696 gv_kv("weak_codes" as *u8, rgc_weak_codes()) 697 gv_kv("cw_list_bytes" as *u8, cw_good) 698 gv_kv("cw_row_fixed" as *u8, rgc_work_row_fixed()) 699 gv_kv("stage_row_fixed" as *u8, rgc_stage_row_fixed()) 700 gv_kv("stage_row_bytes" as *u8, sb_rowlen) 701 gv_kv("a1_land" as *u8, f1[RGC_F_LAND]) 702 gv_kv("a1_retract" as *u8, f1[RGC_F_RETRACT]) 703 gv_kv("links" as *u8, RGC_LINKS) 704 gv_kv("states" as *u8, RGC_STATES) 705 gv_kv("job_witness_offset" as *u8, jrun - t0) 706 gv_kv("roster_beats" as *u8, rbeats) 707 gv_kv("roster_beats_other_journal" as *u8, rother) 708 gv_kv("roster_pairs" as *u8, rk) 709 gv_kv("roster_list_bytes" as *u8, rln) 710 gv_kv("heavy_pair_index" as *u8, rheavy_in) 711 gv_kv("crlf_pair_index" as *u8, rcrlf_in) 712 gv_kv("prod_journal_rows" as *u8, rprod_rows) 713 gv_kv("slow_journal_rows" as *u8, rslow_rows) 714 gv_kv("slow_gate_green" as *u8, rslow_green) 715 gv_kv("slow_gate_green_in" as *u8, rslow_in) 716 gv_kv("slow_gate_journals_consulted" as *u8, rslow_consulted) 717 return gv_verdict("nx_rungclose_gate" as *u8, c, "the close ruler v2 proven on planted rows" as *u8) 718}