spark-rsi-mv
Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger
Brought by drakestapleton
spark-rsi-mv / tests / reuse-eval / stats-decide.om
| 1 | note units: stats |
| 2 | note SPDX-License-Identifier: Apache-2.0 |
| 3 | note stats-decide: the contract 10 decision (with K7 control outcomes) as a truth table over the |
| 4 | note globals stdecide reads. Every STOP, GO and INVESTIGATE branch and the boundary values |
| 5 | note (ppm 999999 versus 1000000, coverage exactly one half, no transfer QUERY) are covered, plus |
| 6 | note a missing (control, sub-case) pair (not run), K17 failed processes (END failure, nonzero |
| 7 | note exit: wrong refusal, STOP; echo is not scored) and the controls.log record checks |
| 8 | note (unknown sub-case and repeated pair refused with code 13). |
| 9 | note Return value of stdecide: 1 GO, 2 INVESTIGATE, 3 STOP; STDEC 1 holds the reason bits. |
| 10 | note Exit 0 = pass; otherwise the failing case number. |
| 11 | |
| 12 | note the GO state: every bound below 1, coverage 5 of 10, C1..C11 detected, C12 reported, every |
| 13 | note required sub-case present |
| 14 | fn tdbase to void |
| 15 | streset |
| 16 | for s ulong 13 |
| 17 | put STLO s 500000 |
| 18 | put STHI s 500000 |
| 19 | end |
| 20 | stcadd 4 17 10 |
| 21 | stcadd 4 18 5 |
| 22 | for c ulong 14 |
| 23 | b = mul add c 1 8 |
| 24 | put STCT b 1 |
| 25 | put STCT add b 6 stcreq add c 1 |
| 26 | if eq c 13 |
| 27 | put STCT add b 3 1 |
| 28 | else |
| 29 | put STCT add b 1 1 |
| 30 | end |
| 31 | end |
| 32 | end |
| 33 | |
| 34 | note controls.log record k in STFB: control c, sub-case s, outcome o |
| 35 | fn tdrec k ulong c ulong s ulong o ulong to void |
| 36 | v = new ulong 8 0 |
| 37 | put v 0 c |
| 38 | put v 1 s |
| 39 | put v 2 o |
| 40 | for w ulong 8 |
| 41 | tdword add mul k 64 mul w 8 get v w |
| 42 | end |
| 43 | end |
| 44 | |
| 45 | note one little-endian word at byte p of STFB |
| 46 | fn tdword p ulong x ulong to void |
| 47 | for b ulong 8 |
| 48 | put STFB add p b uchar and shr x mul b 8 255 |
| 49 | end |
| 50 | end |
| 51 | |
| 52 | note stctl1 on record 0 = (c, s, 1) after streset; returns STRF 2 when refused (13), 9 when |
| 53 | note accepted, 99 on another code |
| 54 | fn tdone c ulong s ulong to ulong |
| 55 | streset |
| 56 | tdrec 0 c s 1 |
| 57 | e = stctl1 0 |
| 58 | if eq e 0 |
| 59 | ret 9 |
| 60 | end |
| 61 | if ne e 13 |
| 62 | ret 99 |
| 63 | end |
| 64 | ret get STRF 2 |
| 65 | end |
| 66 | |
| 67 | note the 36 (control, sub-case) pairs of EvalJudge's controls run (controls-dev2/controls.log, |
| 68 | note confirmed by EvalJudge), written here independently of stcreq as control*10 + sub-case |
| 69 | text TDL "10 11 20 21 30 40 41 50 51 60 70 71 72 73 74 75 80 81 82 90 91 101 102 103 104 105 106 107 108 109 110 111 120 121 130 140 " |
| 70 | |
| 71 | note every listed pair is accepted, no pair is missing, and there are exactly 36 |
| 72 | fn tdlist to int |
| 73 | streset |
| 74 | k = ulong 0 |
| 75 | v = ulong 0 |
| 76 | for i ulong len TDL |
| 77 | c = get TDL i |
| 78 | if eq c 32 |
| 79 | tdrec k div v 10 rem v 10 1 |
| 80 | k = add k 1 |
| 81 | v = 0 |
| 82 | else |
| 83 | v = add mul v 10 ulong sub c 48 |
| 84 | end |
| 85 | end |
| 86 | if ne k 36 |
| 87 | ret 50 |
| 88 | end |
| 89 | for j ulong k |
| 90 | if ne stctl1 j 0 |
| 91 | ret 51 |
| 92 | end |
| 93 | end |
| 94 | for c ulong 14 |
| 95 | if ne stcmiss add c 1 0 |
| 96 | ret 52 |
| 97 | end |
| 98 | end |
| 99 | ret 0 |
| 100 | end |
| 101 | |
| 102 | fn tdctl to int |
| 103 | if ne tdone 3 1 2 |
| 104 | ret 30 |
| 105 | end |
| 106 | if ne tdone 10 0 2 |
| 107 | ret 31 |
| 108 | end |
| 109 | if ne tdone 10 10 2 |
| 110 | ret 32 |
| 111 | end |
| 112 | if ne tdone 7 5 9 |
| 113 | ret 33 |
| 114 | end |
| 115 | if ne tdone 10 9 9 |
| 116 | ret 34 |
| 117 | end |
| 118 | streset |
| 119 | tdrec 0 8 2 1 |
| 120 | tdrec 1 8 2 1 |
| 121 | if ne stctl1 0 0 |
| 122 | ret 35 |
| 123 | end |
| 124 | if or ne stctl1 1 13 ne get STRF 2 3 |
| 125 | ret 36 |
| 126 | end |
| 127 | if ne stcmiss 8 2 |
| 128 | ret 37 |
| 129 | end |
| 130 | if ne stcout 8 3 |
| 131 | ret 38 |
| 132 | end |
| 133 | ret 0 |
| 134 | end |
| 135 | |
| 136 | fn tdk17 to int |
| 137 | tdbase |
| 138 | stpexit 4 1024 |
| 139 | if not tdis 3 2 |
| 140 | ret 41 |
| 141 | end |
| 142 | if or ne stc 4 27 1 ne stc 4 28 1 |
| 143 | ret 42 |
| 144 | end |
| 145 | tdbase |
| 146 | stpexit 7 1 |
| 147 | if or not tdis 3 2 ne stc 7 27 0 |
| 148 | ret 43 |
| 149 | end |
| 150 | tdbase |
| 151 | stpexit 2 0 |
| 152 | if or not tdis 1 0 ne stc 2 28 0 |
| 153 | ret 44 |
| 154 | end |
| 155 | tdbase |
| 156 | stpexit 0 9 |
| 157 | if or not tdis 1 0 ne stc 0 28 1 |
| 158 | ret 45 |
| 159 | end |
| 160 | ret 0 |
| 161 | end |
| 162 | |
| 163 | fn tdis d ulong bits ulong to bool |
| 164 | r = stdecide |
| 165 | if ne r d |
| 166 | ret false |
| 167 | end |
| 168 | ret eq get STDEC 1 bits |
| 169 | end |
| 170 | |
| 171 | fn main to int |
| 172 | tdbase |
| 173 | if not tdis 1 0 |
| 174 | ret 1 |
| 175 | end |
| 176 | tdbase |
| 177 | stcadd 7 1 1 |
| 178 | if not tdis 3 1 |
| 179 | ret 2 |
| 180 | end |
| 181 | tdbase |
| 182 | stcadd 0 1 1 |
| 183 | if not tdis 1 0 |
| 184 | ret 3 |
| 185 | end |
| 186 | tdbase |
| 187 | stcadd 1 3 1 |
| 188 | if not tdis 3 2 |
| 189 | ret 4 |
| 190 | end |
| 191 | tdbase |
| 192 | put STCT 34 1 |
| 193 | if not tdis 3 4 |
| 194 | ret 5 |
| 195 | end |
| 196 | tdbase |
| 197 | put STCT 69 1 |
| 198 | if not tdis 3 8 |
| 199 | ret 6 |
| 200 | end |
| 201 | tdbase |
| 202 | put STLO 4 1000000 |
| 203 | put STHI 4 1000000 |
| 204 | if not tdis 3 48 |
| 205 | ret 7 |
| 206 | end |
| 207 | tdbase |
| 208 | put STLO 4 999999 |
| 209 | put STHI 4 1000000 |
| 210 | if not tdis 2 32 |
| 211 | ret 8 |
| 212 | end |
| 213 | tdbase |
| 214 | put STHI 4 999999 |
| 215 | if not tdis 1 0 |
| 216 | ret 9 |
| 217 | end |
| 218 | tdbase |
| 219 | put STHI 8 1000000 |
| 220 | if not tdis 2 64 |
| 221 | ret 10 |
| 222 | end |
| 223 | tdbase |
| 224 | put STHI 9 1000000 |
| 225 | if not tdis 2 128 |
| 226 | ret 11 |
| 227 | end |
| 228 | tdbase |
| 229 | put STCNT 146 4 |
| 230 | if not tdis 2 256 |
| 231 | ret 12 |
| 232 | end |
| 233 | tdbase |
| 234 | put STCNT 145 0 |
| 235 | put STCNT 146 0 |
| 236 | if not tdis 2 256 |
| 237 | ret 13 |
| 238 | end |
| 239 | tdbase |
| 240 | put STCT 44 1 |
| 241 | if not tdis 2 512 |
| 242 | ret 14 |
| 243 | end |
| 244 | tdbase |
| 245 | put STCT 48 0 |
| 246 | put STCT 49 0 |
| 247 | if not tdis 2 512 |
| 248 | ret 15 |
| 249 | end |
| 250 | tdbase |
| 251 | stcadd 5 1 1 |
| 252 | put STCT 44 1 |
| 253 | if not tdis 3 513 |
| 254 | ret 16 |
| 255 | end |
| 256 | tdbase |
| 257 | put STCT 115 0 |
| 258 | put STCT 113 1 |
| 259 | if not tdis 1 0 |
| 260 | ret 17 |
| 261 | end |
| 262 | tdbase |
| 263 | put STHI 10 1000000 |
| 264 | put STLO 10 1000000 |
| 265 | put STHI 11 1000000 |
| 266 | put STHI 12 1000000 |
| 267 | if not tdis 1 0 |
| 268 | ret 18 |
| 269 | end |
| 270 | tdbase |
| 271 | put STCT 86 1020 |
| 272 | if not tdis 2 512 |
| 273 | ret 19 |
| 274 | end |
| 275 | if ne stcmiss 10 1 |
| 276 | ret 20 |
| 277 | end |
| 278 | r = tdctl |
| 279 | if ne r 0 |
| 280 | ret r |
| 281 | end |
| 282 | r = tdlist |
| 283 | if ne r 0 |
| 284 | ret r |
| 285 | end |
| 286 | ret tdk17 |
| 287 | end |