omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / core / rsi / om / reuse-eval / receipt.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note receipt.om (lane EvalStats, spark-rsi-mv #73): the REUSE-1 receipt of contract section 7.5 with |
| 3 | note the identity fields of spark-rsi docs/RECEIPT-V2.md, an evaluation-budget record and an |
| 4 | note explicit UNSIGNED status (no .om P-256 signer exists; the #67 signer is Rust). Needs the units |
| 5 | note sha256, stats and turing (st* files and output, tusha, tub/tule). Names: rc*, RC*. |
| 6 | note |
| 7 | note CLI (argv[1] is the dispatcher's subcommand): |
| 8 | note receipt SPLITDIR RUNDIR STATSDIR CONTRACT CANDCOMMIT MANSHA OUTFILE |
| 9 | note SPLITDIR = the FINAL split (index); RUNDIR = the FINAL run (acq-1-R.mansha, R = 0..2, the |
| 10 | note evaluator's rebuilds of the TRAIN library); STATSDIR holds stats.sum; CONTRACT = the REUSE-1 |
| 11 | note contract file (policy digest = SHA-256 of its bytes); CANDCOMMIT = the candidate-freeze commit |
| 12 | note (40 lowercase hex); MANSHA = the frozen manifest SHA-256 (64 lowercase hex), which must equal |
| 13 | note every acq-1-R.mansha (section 7.4: otherwise BLOCKED, not reproducible). OUTFILE receives |
| 14 | note the receipt (also on stdout). |
| 15 | note |
| 16 | note Receipt lines, in this order (key=value): |
| 17 | note receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED |
| 18 | note signature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust) |
| 19 | note subject_commit=<40 hex> the candidate-freeze commit |
| 20 | note subject_mansha=<64 hex> MANSHA (binding.subject_sha256 of RECEIPT-V2) |
| 21 | note holdout_set_sha256=<64 hex> FINAL index words 7..10 (each word's bytes big endian) |
| 22 | note policy_sha256=<64 hex> SHA-256 of the contract bytes |
| 23 | note evaluator_binary_sha256=<64 hex> SHA-256 of /proc/self/exe (the running evaluator) |
| 24 | note stats_summary_sha256=<64 hex> SHA-256 of stats.sum (the results this receipt states) |
| 25 | note holdouts_total=<n> holdouts_passed=<n> scored QUERY responses of arms 1..7 over every |
| 26 | note repetition, and the correct ones (stats.sum 12, 13) |
| 27 | note counts groups= sessions= requests= queries= reps= arms=8 wrong_refusals= |
| 28 | note decision=<GO|INVESTIGATE|STOP> reason_bits=<stats.sum word 3> |
| 29 | note budget split=FINAL runs_allowed=1 runs_used=1 seed=burned (a void run burns the seed) |
| 30 | note independence=UNISOLATED |
| 31 | note receipt_identity_sha256=<64 hex> |
| 32 | note receipt_identity_sha256 = SHA-256 over length-prefixed fields as RECEIPT-V2's digest writes |
| 33 | note them (u64 LE byte length, then the bytes; numbers as 8-byte LE): the string |
| 34 | note "spark-rsi.reuse1-receipt.v2-unsigned", the hex strings of subject_commit, subject_mansha, |
| 35 | note holdout_set_sha256, policy_sha256, evaluator_binary_sha256, stats_summary_sha256, then |
| 36 | note holdouts_total, holdouts_passed, decision (1 GO, 2 INVESTIGATE, 3 STOP), reason bits. It is |
| 37 | note not a RECEIPT-V2 receipt_digest (that one covers fields R1 has no value for) and it is not a |
| 38 | note signature. |
| 39 | note Exit 0 = written; 2 = refused (status=REFUSED code=N): 1 usage, 2 commit not 40 lowercase |
| 40 | note hex, 3 MANSHA not 64 lowercase hex, 4 index unreadable or invalid, 5 contract unreadable, |
| 41 | note 6 evaluator binary unreadable, 7 stats.sum missing or invalid, 8 an acq-1-R.mansha missing, |
| 42 | note 9 MANSHA differs from a rebuild (BLOCKED: not reproducible), 10 the index is not FINAL |
| 43 | note (split id 4), 11 stats.sum is not the summary of this split (its split id is not 4, its |
| 44 | note words 18..21 differ from index words 7..10, or its group, session, request or QUERY count |
| 45 | note differs from the index); 15 output failure. |
| 46 | |
| 47 | text RCK "receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED\nsignature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust)\nsubject_commit=\nsubject_mansha=\nholdout_set_sha256=\npolicy_sha256=\nevaluator_binary_sha256=\nstats_summary_sha256=\nholdouts_total=\n holdouts_passed=\ncounts groups=\n sessions=\n requests=\n queries=\n reps=\n arms=8 wrong_refusals=\ndecision=\n reason_bits=\nbudget split=FINAL runs_allowed=1 runs_used=1 seed=burned\nindependence=UNISOLATED\nreceipt_identity_sha256=\nspark-rsi.reuse1-receipt.v2-unsigned\n/proc/self/exe\nacq-1-\n.mansha\nstatus=REFUSED code=\nGO\nINVESTIGATE\nSTOP\n" |
| 48 | |
| 49 | const RKHEAD ulong 0 |
| 50 | const RKSIG ulong 1 |
| 51 | const RKCOMM ulong 2 |
| 52 | const RKMANS ulong 3 |
| 53 | const RKHOLD ulong 4 |
| 54 | const RKPOL ulong 5 |
| 55 | const RKEVAL ulong 6 |
| 56 | const RKSTAT ulong 7 |
| 57 | const RKTOT ulong 8 |
| 58 | const RKPASS ulong 9 |
| 59 | const RKCNT ulong 10 |
| 60 | const RKSESS ulong 11 |
| 61 | const RKREQS ulong 12 |
| 62 | const RKQRYS ulong 13 |
| 63 | const RKREPS ulong 14 |
| 64 | const RKARMS ulong 15 |
| 65 | const RKDECI ulong 16 |
| 66 | const RKBITS ulong 17 |
| 67 | const RKBUDG ulong 18 |
| 68 | const RKINDEP ulong 19 |
| 69 | const RKIDENT ulong 20 |
| 70 | const RKDOM ulong 21 |
| 71 | const RKEXE ulong 22 |
| 72 | const RKACQ ulong 23 |
| 73 | const RKMSH ulong 24 |
| 74 | const RKREFU ulong 25 |
| 75 | const RKGO ulong 26 |
| 76 | |
| 77 | global RCH ulong 24 |
| 78 | global RCS ulong 32 |
| 79 | |
| 80 | fn rckoff k ulong to ulong |
| 81 | i = ulong 0 |
| 82 | c = ulong 0 |
| 83 | while lt c k bound 999999 |
| 84 | if eq get RCK i 10 |
| 85 | c = add c 1 |
| 86 | end |
| 87 | i = add i 1 |
| 88 | end |
| 89 | ret i |
| 90 | end |
| 91 | |
| 92 | fn rcks k ulong to void |
| 93 | i = rckoff k |
| 94 | while ne get RCK i 10 bound 4096 |
| 95 | stoc get RCK i |
| 96 | i = add i 1 |
| 97 | end |
| 98 | end |
| 99 | |
| 100 | fn rckp k ulong to void |
| 101 | i = rckoff k |
| 102 | while ne get RCK i 10 bound 4096 |
| 103 | stpc get RCK i |
| 104 | i = add i 1 |
| 105 | end |
| 106 | end |
| 107 | |
| 108 | note slot b holds exactly n lowercase hex characters |
| 109 | fn rchex b ulong n ulong to bool |
| 110 | if ne get STBL b n |
| 111 | ret false |
| 112 | end |
| 113 | o = mul b 4096 |
| 114 | for i ulong n |
| 115 | c = get STBD add o i |
| 116 | if not or and ge c 48 le c 57 and ge c 97 le c 102 |
| 117 | ret false |
| 118 | end |
| 119 | end |
| 120 | ret true |
| 121 | end |
| 122 | |
| 123 | note TUD saved as digest d (0 holdout, 1 policy, 2 evaluator, 3 stats) in RCH |
| 124 | fn rcsave d ulong to void |
| 125 | for j ulong 4 |
| 126 | put RCH add mul d 4 j get TUD j |
| 127 | end |
| 128 | end |
| 129 | |
| 130 | note digest d as 64 hex (word j little-endian bytes, the TUD convention) |
| 131 | fn rcohd d ulong to void |
| 132 | for j ulong 4 |
| 133 | v = get RCH add mul d 4 j |
| 134 | for k ulong 8 |
| 135 | stohb and shr v mul k 8 255 |
| 136 | end |
| 137 | end |
| 138 | end |
| 139 | |
| 140 | note the holdout digest words (big-endian bytes per word) into RCH 0..3 in the TUD convention |
| 141 | fn rchold to void |
| 142 | for j ulong 4 |
| 143 | v = get STHD j |
| 144 | x = ulong 0 |
| 145 | for k ulong 8 |
| 146 | x = or x shl and shr v mul sub 7 k 8 255 mul k 8 |
| 147 | end |
| 148 | put RCH j x |
| 149 | end |
| 150 | end |
| 151 | |
| 152 | note SHA-256 of the file at STPB into RCH d; false when unreadable |
| 153 | fn rcfile d ulong to bool |
| 154 | n = stload |
| 155 | if lt n 0 |
| 156 | ret false |
| 157 | end |
| 158 | tusha 1000 1 0 ulong n |
| 159 | rcsave d |
| 160 | ret true |
| 161 | end |
| 162 | |
| 163 | note every acq-1-R.mansha equals slot 5 (64 hex then a newline); 0 ok, 8 missing, 9 differs |
| 164 | fn rcmansha to int |
| 165 | for r ulong 3 |
| 166 | stpbase 1 |
| 167 | rckp RKACQ |
| 168 | stpc uchar add r 48 |
| 169 | rckp RKMSH |
| 170 | n = stload |
| 171 | if lt n 64 |
| 172 | ret 8 |
| 173 | end |
| 174 | for i ulong 64 |
| 175 | if ne get STFB i get STBD add 20480 i |
| 176 | ret 9 |
| 177 | end |
| 178 | end |
| 179 | if gt n 64 |
| 180 | if or gt n 65 ne get STFB 64 10 |
| 181 | ret 9 |
| 182 | end |
| 183 | end |
| 184 | end |
| 185 | ret 0 |
| 186 | end |
| 187 | |
| 188 | note stats.sum into RCS (words 0..31); false when missing or not R1STS001 version 1 |
| 189 | fn rcsum to bool |
| 190 | stpbase 2 |
| 191 | stpk SKSUM |
| 192 | n = stload |
| 193 | if ne n 2048 |
| 194 | ret false |
| 195 | end |
| 196 | tusha 1000 1 0 2048 |
| 197 | rcsave 3 |
| 198 | for k ulong 32 |
| 199 | put RCS k stw mul k 8 |
| 200 | end |
| 201 | if ne get RCS 0 3544386041195737426 |
| 202 | ret false |
| 203 | end |
| 204 | ret eq get RCS 1 1 |
| 205 | end |
| 206 | |
| 207 | note one length-prefixed field from slot b (its bytes) into TUFB |
| 208 | fn rcfslot b ulong to void |
| 209 | n = get STBL b |
| 210 | tule n 8 |
| 211 | o = mul b 4096 |
| 212 | for i ulong n |
| 213 | tub ulong get STBD add o i |
| 214 | end |
| 215 | end |
| 216 | |
| 217 | note one length-prefixed 64-hex field from digest d |
| 218 | fn rcfdig d ulong to void |
| 219 | tule 64 8 |
| 220 | h = stkoff SKDIG |
| 221 | for j ulong 4 |
| 222 | v = get RCH add mul d 4 j |
| 223 | for k ulong 8 |
| 224 | b = and shr v mul k 8 255 |
| 225 | tub ulong get STK add h shr b 4 |
| 226 | tub ulong get STK add h and b 15 |
| 227 | end |
| 228 | end |
| 229 | end |
| 230 | |
| 231 | fn rcfnum v ulong to void |
| 232 | tule 8 8 |
| 233 | tule v 8 |
| 234 | end |
| 235 | |
| 236 | note receipt identity digest into RCH 16..19 |
| 237 | fn rcident to void |
| 238 | put TUFL 0 0 |
| 239 | i = rckoff RKDOM |
| 240 | n = sub rckoff add RKDOM 1 add i 1 |
| 241 | tule n 8 |
| 242 | for j ulong n |
| 243 | tub ulong get RCK add i j |
| 244 | end |
| 245 | rcfslot 4 |
| 246 | rcfslot 5 |
| 247 | for d ulong 4 |
| 248 | rcfdig d |
| 249 | end |
| 250 | rcfnum get RCS 12 |
| 251 | rcfnum get RCS 13 |
| 252 | rcfnum get RCS 2 |
| 253 | rcfnum get RCS 3 |
| 254 | tusha 1000 0 0 get TUFL 0 |
| 255 | rcsave 4 |
| 256 | end |
| 257 | |
| 258 | note slot b's bytes to the output |
| 259 | fn rcoslot b ulong to void |
| 260 | o = mul b 4096 |
| 261 | for i ulong get STBL b |
| 262 | stoc get STBD add o i |
| 263 | end |
| 264 | end |
| 265 | |
| 266 | fn rcreport to void |
| 267 | rcks RKHEAD |
| 268 | stnl |
| 269 | rcks RKSIG |
| 270 | stnl |
| 271 | rcks RKCOMM |
| 272 | rcoslot 4 |
| 273 | stnl |
| 274 | rcks RKMANS |
| 275 | rcoslot 5 |
| 276 | stnl |
| 277 | rcks RKHOLD |
| 278 | rcohd 0 |
| 279 | stnl |
| 280 | rcks RKPOL |
| 281 | rcohd 1 |
| 282 | stnl |
| 283 | rcks RKEVAL |
| 284 | rcohd 2 |
| 285 | stnl |
| 286 | rcks RKSTAT |
| 287 | rcohd 3 |
| 288 | stnl |
| 289 | rcks RKTOT |
| 290 | stou get RCS 12 |
| 291 | rcks RKPASS |
| 292 | stou get RCS 13 |
| 293 | stnl |
| 294 | rcks RKCNT |
| 295 | stou get RCS 4 |
| 296 | rcks RKSESS |
| 297 | stou get RCS 5 |
| 298 | rcks RKREQS |
| 299 | stou get RCS 6 |
| 300 | rcks RKQRYS |
| 301 | stou get RCS 7 |
| 302 | rcks RKREPS |
| 303 | stou get RCS 8 |
| 304 | rcks RKARMS |
| 305 | stou get RCS 15 |
| 306 | stnl |
| 307 | rcks RKDECI |
| 308 | d = get RCS 2 |
| 309 | if and ge d 1 le d 3 |
| 310 | rcks add RKGO sub d 1 |
| 311 | else |
| 312 | stou d |
| 313 | end |
| 314 | rcks RKBITS |
| 315 | stou get RCS 3 |
| 316 | stnl |
| 317 | rcks RKBUDG |
| 318 | stnl |
| 319 | rcks RKINDEP |
| 320 | stnl |
| 321 | rcks RKIDENT |
| 322 | rcohd 4 |
| 323 | stnl |
| 324 | end |
| 325 | |
| 326 | fn rcfail code ulong to int |
| 327 | put STOP 0 0 |
| 328 | rcks RKREFU |
| 329 | stou code |
| 330 | stnl |
| 331 | if ne get STQT 0 1 |
| 332 | r = stflush 1 |
| 333 | end |
| 334 | ret 2 |
| 335 | end |
| 336 | |
| 337 | note stats.sum describes this split: split id 4, words 18..21 = the index holdout words 7..10 |
| 338 | note (both as stored), and the group, session, request and QUERY counts equal the index's |
| 339 | fn rcsame to bool |
| 340 | if ne get RCS 9 4 |
| 341 | ret false |
| 342 | end |
| 343 | for j ulong 4 |
| 344 | if ne get RCS add 18 j get STHD j |
| 345 | ret false |
| 346 | end |
| 347 | end |
| 348 | if or ne get RCS 4 get STNG 0 ne get RCS 5 get STNS 0 |
| 349 | ret false |
| 350 | end |
| 351 | ret and eq get RCS 6 get STNR 0 eq get RCS 7 get STNQ 0 |
| 352 | end |
| 353 | |
| 354 | note the receipt on slots 0 split, 1 run, 2 stats dir, 3 contract, 4 commit, 5 MANSHA, 6 out |
| 355 | note file; stdout unless STQT is 1 |
| 356 | fn rcrun to int |
| 357 | streset |
| 358 | if not rchex 4 40 |
| 359 | ret rcfail 2 |
| 360 | end |
| 361 | if not rchex 5 64 |
| 362 | ret rcfail 3 |
| 363 | end |
| 364 | if ne stidx 0 |
| 365 | ret rcfail 4 |
| 366 | end |
| 367 | if ne get STSPL 0 4 |
| 368 | ret rcfail 10 |
| 369 | end |
| 370 | rchold |
| 371 | stpexact 3 |
| 372 | if not rcfile 1 |
| 373 | ret rcfail 5 |
| 374 | end |
| 375 | put STPL 0 0 |
| 376 | rckp RKEXE |
| 377 | if not rcfile 2 |
| 378 | ret rcfail 6 |
| 379 | end |
| 380 | if not rcsum |
| 381 | ret rcfail 7 |
| 382 | end |
| 383 | if not rcsame |
| 384 | ret rcfail 11 |
| 385 | end |
| 386 | e = rcmansha |
| 387 | if ne e 0 |
| 388 | ret rcfail ulong e |
| 389 | end |
| 390 | rcident |
| 391 | put STOP 0 0 |
| 392 | rcreport |
| 393 | if ne get STQT 0 1 |
| 394 | r = stflush 1 |
| 395 | end |
| 396 | stpexact 6 |
| 397 | if ne stwfile 0 |
| 398 | ret 15 |
| 399 | end |
| 400 | ret 0 |
| 401 | end |
| 402 | |
| 403 | fn rcmain to int |
| 404 | if lt argcnt 9 |
| 405 | ret rcfail 1 |
| 406 | end |
| 407 | for k ulong 7 |
| 408 | if eq stargb add k 2 k 0 |
| 409 | ret rcfail 1 |
| 410 | end |
| 411 | end |
| 412 | ret rcrun |
| 413 | end |