spark-rsi-mv
Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger
Brought by drakestapleton
GitHub aien-dev/spark-rsi-mv#74 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/spark-rsi-mv/patches/ab18081699624cac.bundle -o ab18081699624cac.bundle git fetch ab18081699624cac.bundle refs/pull/74/head
Provenance
github-import 1
aien-dev/spark-rsi-mv
74
ceadf008bb9a8f47388a328feac2da07284d8baf
{"kind":"github-import","owner":"aien-dev","repo":"spark-rsi-mv","number":74,"url":"https://github.com/aien-dev/spark-rsi-mv/pull/74","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:24Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/docs/reuse-eval/README.md b/docs/reuse-eval/README.md new file mode 100644 index 0000000..de3d684 --- /dev/null +++ b/docs/reuse-eval/README.md @@ -0,0 +1,114 @@ +# REUSE-1 evaluator: judge + +`om/reuse-eval/judge.om` is the REUSE-1 judge for spark-rsi-mv #73, written in seeded `.om`. It works from the frozen contract (omega-mv `d6edaad1`, `docs/reuse/REUSE-1.md`, sha256 `71a6da13...5deb`), the evaluator formats, the candidate `drive.om` CLI and built binaries. It reads no candidate source. + +## Units and binary + +Units are concatenated in this order, with no imports: + +| Unit | File | Owner | +|---|---|---| +| sha256 | `om/reuse-eval/sha256.om` | byte copy of omega-mv main `acb3f15c` `om/sha256/sha256.om`, pinned in `sha256.pin` | +| ref | `om/reuse-eval/ref.om` | EvalGen | +| stats, turing, receipt | `om/reuse-eval/{stats,turing,receipt}.om` | EvalStats | +| judge | `om/reuse-eval/judge.om` | EvalJudge (prefix jd, JD, JW, JM) | +| main | `om/reuse-eval/main.om` | EvalJudge | + +The single evaluator binary is `sha256 ref stats turing receipt judge main`. `main` sends `stats`, `turing` and `receipt` to the EvalStats entries and every other subcommand to `jdmain`. + +## Commands + +Paths are relative to the current directory unless stated. Run every measured command as `nice -n 10`. The judge puts each arm on a CPU with `/usr/bin/taskset -c CPU`; the contract places the evaluator on CPU 18 and the arms on CPU 19. A CPU of `-` means no taskset (tests only). + +``` +judge run SPLIT OUT REPS SEED ARMS BASE ALLOW LIB MAN LIBP MANP CPU +judge tap SPLIT BASE TAPFILE SPLITARG CPU +judge calib CALIBSPLIT RUNDIR REPS OUTFILE +judge build DRIVE OMEGADIR OMC ALLOW CALIB OUTLIB ACQDIR LIBID REP [DRIVE OPTIONS AND EXP FILES...] +judge recheck MANSHAFILE PINHEX +judge controls DEV BASE DRIVE OMEGADIR OMC ALLOW NOG3 C4 OUT CPU +``` + +- `run`: `ARMS` is a digit string of arm ids, for example `01234567`. `SEED` is the 64-hex FINAL seed (the arm-order seed is bytes 16..23, little endian) or a decimal seed for public splits. `LIB` and `MAN` are the TRAIN library and its MANSHA, used by method, delta and select. `LIBP` and `MANP` are the TRAINP library and its MANSHA, used by deltap. An unused pair is `- -`. Before each repetition R, the judge copies each library to `OUT/lib-R-1` and `OUT/lib-R-2`, so every repetition starts from a fresh copy. Arm configurations: + - echo, full, cache: `BASE ARM - - - - -` + - method, delta, select: `BASE ARM OUT/lib-R-1 MAN ALLOW - -`. Select reads the calibration that `drive build` baked into the library (integrator ruling). + - idelta: `BASE delta - - ALLOW - -` + - deltap: `BASE delta OUT/lib-R-2 MANP ALLOW - -` + + In each group and repetition, the base arm list is permuted with splitmix64 by Fisher-Yates (i = n-1 down to 1, j = next mod (i+1)). The seed state carries over across groups and repetitions in run order. Each arm process runs one group. The judge sends each request, waits up to 10 s for it, reads the whole response and times the round trip with `monons`. After the last request it sends STATS, reads `/proc/PID/stat` and `/proc/PID/status`, sends END and reaps the arm. A short read or end of file, a bad q (q above 32 or not the expected q), a timeout or a failed write is a protocol violation. The judge logs that request as wrong, kills the arm and records every remaining request of the group as not sent. It then goes on to the next group. `stdout` gets one `arm=A wrong=W violations=V` line per arm. `run` refuses to start if `OUT/proc.log` already exists. +- `tap`: runs one B process over every group of the split, in order, as `BASE tap - - - TAPFILE SPLITARG` (clarification K9). `TAPFILE` must not exist. `SPLITARG` is `1` for TRAIN and TRAINP, `2` for CALIB and `3` for DEV. `tap` prints `tap_sha256=`, `tap_bytes=`, `queries=`, `wrong=` and `violations=`. It exits 0 only when there is no wrong answer, the arm exits 0 and the file is not empty. Experience files are admitted by adding `<sha256> AUTHORIZED <label>` to ALLOW, which the operator does. +- `calib`: reads the CALIB split and the raw logs in `RUNDIR` of arms full (1), method (3) and delta (4), repetitions 0..REPS-1, and writes `OUTFILE` (R1CAL001, 200 words; `OUTFILE` must not exist). Sessions carry the family and n class. The change class of a QUERY is the number of accepted changes since the previous QUERY or BEGIN: SET, INS, DEL, SWAP and PROGRAM count 1, and BATCH counts m. Only QUERYs scored correct (word 15 = 1) enter the cells. Bind cells use method BEGIN round trips, excluding each process's first request (start-to-ready), minus the p50 of the full BEGIN round trips in the same family and n class, with a floor of 1. E_q x 1000 = floor(1000 x QUERY count / session count). Percentiles are nearest rank: index ceil(p n / 100) - 1 of the ascending values. The same rule is used in stats. +- `build`: runs `DRIVE build OMC ALLOW CALIB OUTLIB [options] EXP...` as a child process with cwd = `OMEGADIR`, and the judge's stdout captures the child's output. Elapsed time is `monons` around fork and reap. cutime and cstime are the deltas of the judge's own `/proc/self/stat` fields, which include drive and its omc children. The child is killed after 1 hour. `ACQDIR/acq.log` gets one 8-word record appended. The `manifest_sha256=` value is written to `ACQDIR/acq-LIBID-REP.mansha`. The exit status is drive's own (`drive_exit=` is printed). +- `recheck`: contract 7.4. It compares the first line of `MANSHAFILE` with `PINHEX`. A match prints `REBUILD MATCH` and exits 0. A mismatch prints `BLOCKED rebuild ... pinned ...` and exits 3. A mismatch is BLOCKED. +- `controls`: contract section 9 with clarifications K7, K10, K13 and K15. `OUT` holds private copies only, and the original ALLOW and libraries are never changed. See below. + +Exit codes: 0 ok, 2 usage, 3 judge error (the `judge error N` line on stderr names the step), 4 `tap` failure or a STOP control in `controls`. + +## Files written (EVAL-FORMATS) + +All values are u64 little-endian words. R is 0-based, NN is the group number in 2 digits and A is the arm id. + +- `OUT/arm-A-rep-R-gNN.log`: 16 words per request: + - 0: group, 1: repetition, 2: arm, 3: request index, 4: op + - 5: status got (2^64-1 marks the request that broke the protocol; 2^64-2 marks a request not sent after a kill) + - 6: r0 got, 7: r1 got, 8: route got (QUERY only, otherwise 0) + - 9..11: expected status, r0, r1 + - 12: round-trip ns, 13: cold flag, 14: session ordinal + - 15: correctness: 1 ok; 0 wrong; 2 not scored, which means echo, or a non-QUERY whose status matched +- `OUT/proc.log`: 16 words per arm process, in execution order: + - 0: arm, 1: group, 2: repetition + - 3: start-to-ready, from `monons` just before fork to the end of the first response; this includes request 0's round trip + - 4..7: utime, stime, cutime, cstime (ticks) + - 8: VmHWM, 9: VmRSS (kB) + - 10: exit word: the exit code, 256 + signal when killed by a signal, 512 + violation code when the judge killed the arm (1 short or end of file, 2 bad q, 3 timeout, 4 write; 5..8 the same four failures at END), 1023 when reaping failed. K17: 1024 is added when END itself failed (a response other than status 0, q 0, or any of codes 5..8). A nonzero exit after a good END keeps the plain exit code. Any nonzero word 10 is a failed process. + - 11: requests sent, 12: sum of round-trip ns (END excluded), 13: CPU, 14: loadavg x 100, 15: END round-trip ns (K17; until failure when END failed) +- `OUT/stats-A-R-gNN.ctr` (K14): 34 words: STATS status, q, then q counters zero-padded to 32. Diagnostic only and not timed. The status word is 2^64-1 if STATS failed. +- `ACQDIR/acq.log`: 8 words per build: + - 0: library id (1 TRAIN, 2 TRAINP, 3 EMPTY, 9 control), 1: repetition + - 2: elapsed ns, 3: cutime, 4: cstime + - 5: drive exit word, 6: LIBDIR regular-file bytes, 7: 0 + + `ACQDIR/acq-L-R.mansha` holds 64 hex characters and a newline. +- `OUT/controls.log` (K7): 8 words per control: id, sub-case, outcome (1 detected, 0 undetected, 2 reported, 3 not run), served-tampered flag, 0, 0, 0, 0. + +## Controls + +The control workloads are derived from DEV. The ancestor is the first AGG BEGIN of DEV, and its first constant feeds the control program. The judge builds its own TRAIN-like experience with the tap arm of BASE: an ADD shape at wl 8 and an ADD shape at wl 16, each with 8 QUERYs. That gives a pair of shapes that differ only in wl, and wl-16 lane values of 256 and above. It authorizes that experience in a private copy of ALLOW and builds an honest wl-16 library, which serves as the reference for C3 and C6..C11. Every control workload is scored against `ref.om` (`rfreq`), never against candidate output. The ids are those of K7. + +| K7 id | Contract | Sub-cases | Detected when | +|---|---|---|---| +| 1 | C1 | 0 `mutant:c1` with a wl-8 library, served wl 16; 1 the same plus `unit:check=NOG3` | 0: route 5 on every QUERY (G3) or wrong answers (K10; the printed `5=` and `wrong=` counts show which); 1: wrong answers | +| 2 | C1b | 0 `mutant:c1b`; 1 plus NOG3 | 0: route 5, no wrong answer; 1: wrong answers | +| 3 | C1c | 0 `mutant:c1c` | route 5, no wrong answer | +| 4 | C2 | 0 one byte of the magic; 1 one byte of the program digest (both copies re-authorized) | drive exit 10 | +| 5 | C3 | 0 sample outputs swapped; 1 diagnostic costs (word 7) rotated across records | 0: drive exit 10; 1: gen-G.om and gen-G.elf byte-identical, manifest word 4 and words 56..183 equal (K13) | +| 6 | C4 | 0 `unit:delta=C4` | wrong answers | +| 7 | C5 | per wl 8 and 16: full; delta with the library; idelta. Lanes 2^wl - 1 with MUL and SHL, values 2^wl | reference values, status 3, no wrong answer | +| 8 | C6 | 0 one ELF byte; 1 one manifest byte; 2 coherent replacement (new ELF, manifest and CURRENT consistent, MANSHA still the honest one) | every QUERY route 5 | +| 9 | C7 | 0 REVOKED appended before start; 1 REVOKED appended before request 2 | 0: route 5 throughout; 1: method or delta routes before, route 5 on every later QUERY | +| 10 | C8 | K = 1..9 `crashafter:K` over a copy of the honest generation P (K15) | exit 97; CURRENT, gen-G.man and gen-G.elf are self-consistent and load with their own MANSHA; no wrong answer, and method or delta routes served | +| 11 | C9 | 0 compiler SHA-256; 1 profile version (manifest, self-check, CURRENT and MANSHA rewritten coherently) | route 5 | +| 12 | C10 | 0 manifest truncated to 777 bytes; 1 CURRENT truncated to 17 bytes | route 5 | +| 13 | C11 | SIGKILL after request 3, then a fresh arm | the kill is observed (exit word 265); CURRENT and MANSHA are unchanged; the fresh arm answers with no wrong answer | +| 14 | C12 | reported (outcome 2); scored by `run` with arms 5 and 6 | ablation | + +A control that cannot be set up (a failed build, a missing CURRENT) is recorded as 3 (not run), never as passed. `controls` exits 4 if any outcome is 0 or any served-tampered flag is set (STOP), exits 3 if a control was not run, and exits 0 otherwise. + +## Holdout: running FINAL once (contract 7.3) + +1. Evaluator freeze: commit and push this tree, together with `evidence/REUSE-73/final-commitment.txt` (SHA-256 of the secret). +2. Candidate freeze: omega-mv commit with the TRAIN and CALIB library and its MANSHA. +3. `judge build` rebuilds the TRAIN library from the admitted experience with the frozen drive, three times (REP 0..2), and `judge recheck` checks each result against the frozen MANSHA. A mismatch is BLOCKED, and the run stops there. +4. The operator reveals the secret. FINAL seed = SHA-256(secret || candidate commit || evaluator commit). +5. `gen FINAL OUTDIR SEEDHEX`, then once: `nice -n 10 taskset -c 18 eval judge run FINALDIR RUNDIR 3 SEEDHEX 01234567 BASE ALLOW LIB MAN LIBP MANP 19`. +6. Run `stats`, `turing` and `receipt` on that run directory. A void run burns the seed, and any later run needs a new secret and a recorded reason. + +## Tests + +From the repo root: `OMC < tests/reuse-eval/run.om > run.elf`, then `run.elf OMC [PREFIX]`. + +- The first line of a test is `note units: ...`. An optional second line `note needs: gen|eval|arm|drive|omc ...` builds those binaries once and passes their paths as argv[2..]; argv[1] is a fresh scratch directory. +- A line `note fixture:` marks a helper program, which is compiled for `needs` and never run as a test. +- Each test may run for at most 120 s. The runner prints `PASS` or `FAIL name rc=N`, with 2048 + rc for a compile failure, and then `TOTAL`. + +`judge-arm.om` is a fake arm built on `ref.om`. Its mode comes from the ARM word: full; wrong (r0 + 1); echo; badq; short; stall (sleeps 10.1 s); tap (writes R1EXP001 records); endbad (END answered q 1), endst (END status 3), endeof (no END answer), endexit (good END, exit 7). `judge-drive.om` is a fake drive. The fakes check only the judge's protocol, logs and fail-closed behaviour. They are not the candidate. `judge-end.om` also pins the arm order: for splitmix64 seed 0 over arms 01234567, the first two permutations are 2,5,0,3,4,6,1,7 and 3,7,0,5,6,2,1,4 (computed outside the judge from the standard splitmix64 constants). diff --git a/evidence/REUSE-73/final-commitment.txt b/evidence/REUSE-73/final-commitment.txt new file mode 100644 index 0000000..94d1023 --- /dev/null +++ b/evidence/REUSE-73/final-commitment.txt @@ -0,0 +1,11 @@ +REUSE-1 FINAL holdout commitment (spark-rsi-mv #73; contract omega-mv d6edaad1 docs/reuse/REUSE-1.md section 7.3) + +secret_commitment_sha256=cc6cbc60cc5417c8de406a11261738805d7e4d99490794b566893a2fc8a99878 +secret_definition=32 bytes from the Linux getrandom pool, stored only in the operator's TPM vault (atlas-vault name REUSE73_FINAL_SECRET) as 64 lowercase hex characters +commitment_definition=SHA-256 of the 32 raw secret bytes +final_seed_definition=SHA-256(32 raw secret bytes || candidate-freeze commit id as 40 ASCII hex || evaluator-freeze commit id as 40 ASCII hex) +seed_use=bytes 0..7 LE bootstrap; bytes 8..15 LE FINAL generator; bytes 16..23 LE arm order +order=this commitment pushed; evaluator freeze pushed (spark-rsi-mv); candidate freeze pushed (omega-mv); reveal; one FINAL run +void_rule=a void run burns the seed; a new run needs a new secret, a new commitment and a recorded reason +independence=UNISOLATED: one operator account holds both sides; non-access is procedural and auditable by commit order +created_utc=2026-10-25 diff --git a/evidence/REUSE-73/final/README.md b/evidence/REUSE-73/final/README.md new file mode 100644 index 0000000..7902e07 --- /dev/null +++ b/evidence/REUSE-73/final/README.md @@ -0,0 +1,82 @@ +# REUSE-1 FINAL evaluation (spark-rsi-mv #73) + +Decision: **STOP** (contract REUSE-1 v1.0 section 10: the lower bound of rho(delta) is at least 1). +Correctness: 0 wrong answers and 0 wrong refusals in 189,504 scored requests across 7 scored arms +and 3 repetitions. Every negative control was detected (36 of 36 required cases; C12 is reported only). + +## Pins + +| Item | Value | +|---|---| +| Contract | omega-mv `d6edaad1` `docs/reuse/REUSE-1.md`, sha256 `71a6da13...5deb`; clarifications K1..K8 frozen with the candidate; K9..K17 written after FINAL (omega-mv `feat/742-reuse-r1`) to record decisions already in the frozen code, no rule changed | +| Evaluator freeze | spark-rsi-mv `4345eda9e58fe625a4d9b8e9175305160369f760` (pushed 2026-10-25T16:20:47Z), evaluator ELF sha256 `b550ad7e...46cf` | +| Candidate freeze | omega-mv `6ad09bff0c544bf73ceb3c63b349ba0cd6998e52` (pushed 2026-10-25T16:21:52Z), source `2b25e1bf`, base ELF `bf7dd018...2568`, drive ELF `ade1c049...9825` | +| Compiler | omc sha256 `734f0a39...6b61` | +| TRAIN library | MANSHA `05f163f8...7cf6`, 16 templates, calibration `c7971e77...6ab0` | +| TRAINP library | MANSHA `b15f71dc...4c61` | +| FINAL | seed commitment pushed 2026-10-25T15:10:36Z; seed revealed in `seed-reveal.txt`; holdout digest `1ce74aa2...8f04`; 24 groups, 192 sessions, 17,952 requests, 9,024 QUERYs per arm and repetition | +| Run | 2026-10-25, 16:22:12Z to 16:22:26Z UTC, judge on CPU 18 and arms on CPU 19 (X925), nice 10, load average 7.1 (shared host with live model services) | + +## Results (95 % cluster bootstrap over 24 groups, 10,000 resamples) + +| Arm | rho (point) | 95 % interval | +|---|---|---| +| full | 1.000 | 1.000 to 1.000 | +| echo (pipe-overhead control) | 0.521 | 0.459 to 0.598 | +| cache | 3.179 | 2.805 to 3.603 | +| method | 1.219 | 1.091 to 1.363 | +| delta (primary) | 1.164 | 1.040 to 1.307 | +| idelta (delta, empty library) | 0.751 | 0.650 to 0.867 | +| delta' (shape-permuted library) | 1.011 | 0.895 to 1.143 | +| select | 1.001 | 0.887 to 1.127 | + +Ratios: delta/cache 0.366 (0.304 to 0.440); delta/idelta 1.551 (1.406 to 1.737); select/delta +0.859 (0.759 to 0.957); delta/method 0.955 (0.854 to 1.079). Transfer coverage of delta: 100 % +(5,616 of 5,616 transfer QUERYs served by a method). + +The full per-arm, per-category latency quantiles (cold and warm p50, p95 and p99), memory, Cbar +terms, payback and regime tables are in `stats.txt`. + +Turing (`turing.txt`): B and both library models code D (9,024 symbols) to identical lengths +(60 bytes, rANS and range, H1 PASS), so T = minus the library charge. T(delta) = -8,192 bits +(P1), -80,952 bits (P2); T(select) = -20,544 bits (P1). No positive T exists in this profile. + +Receipt (`receipt.txt`): UNSIGNED (no `.om` P-256 signer; the #67 signer is Rust). +Independence: UNISOLATED. + +## Reproduce + +From the two freeze commits, with the pinned omc: + +``` +OMC=<omc 734f0a39...> +# candidate (omega-mv 6ad09bff): build the test runner, drive and the baseline router +$OMC < tests/reuse/run.om > run.elf && run.elf compose $OMC om/reuse/drive.om drive.elf +drive.elf base $OMC base +# evaluator (spark-rsi-mv 4345eda9) +cat om/reuse-eval/{sha256,ref,stats,turing,receipt,judge,main}.om | $OMC > eval.elf +cat om/reuse-eval/{sha256,ref,gen}.om | $OMC > gen.elf +gen.elf FINAL splits/FINAL <final_seed from seed-reveal.txt> +eval.elf build drive.elf <omega checkout> $OMC allow.txt calib.r1cal lib-T acq 1 0 exp-TRAIN.bin +eval.elf run splits/FINAL finalrun 3 <final_seed> 01234567 base/base.elf allow.txt lib-T <MANSHA T> lib-P <MANSHA P> 19 +eval.elf controls splits/DEV base/base.elf drive.elf <omega checkout> $OMC ctl-allow.txt tests/reuse/mutants/nog3-check.om tests/reuse/mutants/c4-delta.om finalctl 19 +eval.elf stats splits/FINAL finalrun finalctl <final_seed> finalstats +eval.elf turing splits/FINAL calibration/profiles/Turing-profile-REUSE-v1.0.toml lib-T lib-P base/base.om <turing-coder> finalturing +eval.elf receipt splits/FINAL finalrun finalstats docs/reuse/REUSE-1.md 6ad09bff... <MANSHA T> receipt.txt +``` + +Experience files, `allow.txt`, `calib.r1cal` and the library sources are in omega-mv +`evidence/REUSE-742/freeze/`. Raw evidence here: `finalrun.tar.xz` (raw logs, proc, STATS +counters, acquisition), `finalctl.tar.xz` (controls), `final-split.tar.xz` (the FINAL requests and +expectations), `calibrun.tar.xz`, `finalturing.tar.xz` (TPS1 and coded streams). +`SHA256SUMS` lists every file. + +## Verdicts by evidence class + +| Class | Verdict | +|---|---| +| Source | PASS after independent review: candidate and evaluator reviewed by separate read-only reviewers; 2 + 4 findings fixed and verified, plus 1 regression fixed | +| Host (Spark CPU) | Correctness PASS; controls PASS; lifecycle cost decision STOP | +| Simulator | NOT_RUN | +| Physical (GB10) | NOT_RUN | +| Energy | NOT_MEASURED | diff --git a/evidence/REUSE-73/final/SHA256SUMS b/evidence/REUSE-73/final/SHA256SUMS new file mode 100644 index 0000000..d1542b8 --- /dev/null +++ b/evidence/REUSE-73/final/SHA256SUMS @@ -0,0 +1,16 @@ +eb74485355a887b41482f8a1d1b2b52e73973399fa0b57b3816280c220dd6aad README.md +1b06bffb0a978bc60350700743e63dcf70a749af3b00a10cc7a402e197bf2596 calibrun.tar.xz +50cdad1f7eb49bc1bf241444f915157e7c2387bd52f896d6522a471c88c18676 ended.txt +c23c0553181de8e3bc1cc4d957c5f5098e2ff3ad77eb37658c9f362f8836f5bc final-gen.txt +57a86ad5239856108a3ab6ed4799cf52f6facc0945c8837a1f63cc0bf178fcdd final-split.tar.xz +9777039291816f76b6d1074f2791e7f069cd9846b52c06568519c9c2d404194f finalctl.tar.xz +eda7987a5d2b1e52961e5b1738726d34e4f03a3ae98b032ef25e76b6e3c1eca7 finalrun.tar.xz +707d27e1552d543201170565c6fa0f93ae0f868cae7e58943df80b49f7c45221 finalturing.tar.xz +6ae4a311b73dc94622cc390caa6b6e57ae36d6d5a857b1ffff73865ee9ec884f load-end.txt +7bfbf896098ed18a13615867757d4030cd4eda47750576b6565f3d49cac346b4 load-start.txt +5e4a9c23d8fa4b39d0e4d0ec7c3602702216afb5910b8a18193a40c0ee2e0115 receipt.txt +7939c103b02e9d3891a2a8533b5870cf5603334205b37e107d63a668c62ac616 seed-reveal.txt +734e579edd1199cd2f14316f128070330bdf641da4a020b6ec4e6259aeb22e92 started.txt +b8b13625864efb5e123e6d4aa532eb089b529dee44820966c10281225abec41a stats.sum +6cb1b6633ab19fc6bb811f8e3fd6003089c283a08670cd7c1625de2d9b4f9a5b stats.txt +018b0d77ea7d572d7fee492e49e9ad3bfbfa3833476ddb7e228050d1573e0867 turing.txt diff --git a/evidence/REUSE-73/final/calibrun.tar.xz b/evidence/REUSE-73/final/calibrun.tar.xz new file mode 100644 index 0000000..d9b47c8 Binary files /dev/null and b/evidence/REUSE-73/final/calibrun.tar.xz differ diff --git a/evidence/REUSE-73/final/ended.txt b/evidence/REUSE-73/final/ended.txt new file mode 100644 index 0000000..adebf5c --- /dev/null +++ b/evidence/REUSE-73/final/ended.txt @@ -0,0 +1 @@ +2026-10-25T16:22:26Z diff --git a/evidence/REUSE-73/final/final-gen.txt b/evidence/REUSE-73/final/final-gen.txt new file mode 100644 index 0000000..4ad41c9 --- /dev/null +++ b/evidence/REUSE-73/final/final-gen.txt @@ -0,0 +1 @@ +spl=4 grp=24 ses=192 req=17952 qry=9024 mnx=7 dgs=1ce74aa2f9057af27fb66513d11ad7b5af0326093526198c1b69c10cd6f78f04 diff --git a/evidence/REUSE-73/final/final-split.tar.xz b/evidence/REUSE-73/final/final-split.tar.xz new file mode 100644 index 0000000..340e38b Binary files /dev/null and b/evidence/REUSE-73/final/final-split.tar.xz differ diff --git a/evidence/REUSE-73/final/finalctl.tar.xz b/evidence/REUSE-73/final/finalctl.tar.xz new file mode 100644 index 0000000..8426a53 Binary files /dev/null and b/evidence/REUSE-73/final/finalctl.tar.xz differ diff --git a/evidence/REUSE-73/final/finalrun.tar.xz b/evidence/REUSE-73/final/finalrun.tar.xz new file mode 100644 index 0000000..3e98321 Binary files /dev/null and b/evidence/REUSE-73/final/finalrun.tar.xz differ diff --git a/evidence/REUSE-73/final/finalturing.tar.xz b/evidence/REUSE-73/final/finalturing.tar.xz new file mode 100644 index 0000000..cc35f0c Binary files /dev/null and b/evidence/REUSE-73/final/finalturing.tar.xz differ diff --git a/evidence/REUSE-73/final/load-end.txt b/evidence/REUSE-73/final/load-end.txt new file mode 100644 index 0000000..d9839f6 --- /dev/null +++ b/evidence/REUSE-73/final/load-end.txt @@ -0,0 +1 @@ + 11:22:26 up 4 days 17:02, 4 users, load average: 6.90, 6.32, 6.83 diff --git a/evidence/REUSE-73/final/load-start.txt b/evidence/REUSE-73/final/load-start.txt new file mode 100644 index 0000000..fadf3d1 --- /dev/null +++ b/evidence/REUSE-73/final/load-start.txt @@ -0,0 +1 @@ + 11:22:12 up 4 days 17:02, 4 users, load average: 7.10, 6.32, 6.84 diff --git a/evidence/REUSE-73/final/receipt.txt b/evidence/REUSE-73/final/receipt.txt new file mode 100644 index 0000000..07dc46b --- /dev/null +++ b/evidence/REUSE-73/final/receipt.txt @@ -0,0 +1,14 @@ +receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED +signature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust) +subject_commit=6ad09bff0c544bf73ceb3c63b349ba0cd6998e52 +subject_mansha=05f163f8301ecaa40f43a30a6bebcdc253b65688aa384e209c83eba9dfaa7cf6 +holdout_set_sha256=1ce74aa2f9057af27fb66513d11ad7b5af0326093526198c1b69c10cd6f78f04 +policy_sha256=71a6da1338116a88ccdcf37bece933105bbed4653d9a766d30d7ecd7225e5deb +evaluator_binary_sha256=b550ad7e5fed2a91381c7a11599979860eff5f10859de44020e5d65d42ec46cf +stats_summary_sha256=b8b13625864efb5e123e6d4aa532eb089b529dee44820966c10281225abec41a +holdouts_total=189504 holdouts_passed=189504 +counts groups=24 sessions=192 requests=17952 queries=9024 reps=3 arms=8 wrong_refusals=0 +decision=STOP reason_bits=176 +budget split=FINAL runs_allowed=1 runs_used=1 seed=burned +independence=UNISOLATED +receipt_identity_sha256=ff32e5e11d268e0ecbf7a30abbcd338041e3d84c7ef3fa322c229c895153c44f diff --git a/evidence/REUSE-73/final/seed-reveal.txt b/evidence/REUSE-73/final/seed-reveal.txt new file mode 100644 index 0000000..6367549 --- /dev/null +++ b/evidence/REUSE-73/final/seed-reveal.txt @@ -0,0 +1,7 @@ +REUSE-1 FINAL seed reveal (after the single FINAL run; the seed is burned) +secret_hex=427dae3c806a340914c80b4dafe03b4a3392936f2bf5d410b043da78f26a31b3 +secret_commitment_sha256=cc6cbc60cc5417c8de406a11261738805d7e4d99490794b566893a2fc8a99878 (equals evidence/REUSE-73/final-commitment.txt, pushed 2026-10-25T15:10:36Z) +evaluator_freeze_commit=4345eda9e58fe625a4d9b8e9175305160369f760 (pushed 2026-10-25T16:20:47Z) +candidate_freeze_commit=6ad09bff0c544bf73ceb3c63b349ba0cd6998e52 (omega-mv, pushed 2026-10-25T16:21:52Z) +final_seed=ef613f1636bda74dc828f6f2a5e28fe291960197afa321b3625735d28738d72c = SHA-256(secret bytes || candidate commit ASCII || evaluator commit ASCII) +check: printf %s SECRET_HEX | xxd -r -p | sha256sum ; { printf %s SECRET_HEX | xxd -r -p; printf %s CAND EVAL; } | sha256sum diff --git a/evidence/REUSE-73/final/started.txt b/evidence/REUSE-73/final/started.txt new file mode 100644 index 0000000..3abfd86 --- /dev/null +++ b/evidence/REUSE-73/final/started.txt @@ -0,0 +1 @@ +2026-10-25T16:22:12Z diff --git a/evidence/REUSE-73/final/stats.sum b/evidence/REUSE-73/final/stats.sum new file mode 100644 index 0000000..8ae7312 Binary files /dev/null and b/evidence/REUSE-73/final/stats.sum differ diff --git a/evidence/REUSE-73/final/stats.txt b/evidence/REUSE-73/final/stats.txt new file mode 100644 index 0000000..1b3a4ce --- /dev/null +++ b/evidence/REUSE-73/final/stats.txt @@ -0,0 +1,565 @@ +report=reuse1-stats version=1 contract=REUSE-1 v1.0 +input split=4 groups=24 sessions=192 requests=17952 queries=9024 reps=3 +bootstrap resamples=10000 seed=5595649102030266863 rank_lo=249 rank_hi=9749 +total arm=echo rt_ns=439454916 ready_ns=66987815 end_ns=3525183 acq_ns=0 total_ns=451463603 +total arm=full rt_ns=854179317 ready_ns=64946324 end_ns=4264361 acq_ns=0 total_ns=866944174 +total arm=cache rt_ns=2742471767 ready_ns=64242898 end_ns=5367732 acq_ns=0 total_ns=2755721613 +total arm=method rt_ns=823938219 ready_ns=133580930 end_ns=2640775 acq_ns=222383635 total_ns=1057084880 +total arm=delta rt_ns=776959224 ready_ns=135765632 end_ns=1818542 acq_ns=222383635 total_ns=1009501250 +total arm=idelta rt_ns=637845620 ready_ns=62069269 end_ns=4506807 acq_ns=0 total_ns=650828667 +total arm=deltap rt_ns=658515159 ready_ns=121207147 end_ns=2510823 acq_ns=207481668 total_ns=876569227 +total arm=select rt_ns=634499013 ready_ns=131146894 end_ns=1744897 acq_ns=222383635 total_ns=867562224 +rho arm=echo point_ppm=520752 lo_ppm=458989 hi_ppm=597980 +rho arm=full point_ppm=1000000 lo_ppm=1000000 hi_ppm=1000000 +rho arm=cache point_ppm=3178660 lo_ppm=2804736 hi_ppm=3603236 +rho arm=method point_ppm=1219322 lo_ppm=1090819 hi_ppm=1362898 +rho arm=delta point_ppm=1164436 lo_ppm=1039892 hi_ppm=1306773 +rho arm=idelta point_ppm=750715 lo_ppm=650013 hi_ppm=867141 +rho arm=deltap point_ppm=1011102 lo_ppm=895444 hi_ppm=1143011 +rho arm=select point_ppm=1000712 lo_ppm=887200 hi_ppm=1127408 +ratio name=delta/cache point_ppm=366329 lo_ppm=303655 hi_ppm=440085 +ratio name=delta/idelta point_ppm=1551101 lo_ppm=1406231 hi_ppm=1737375 +ratio name=select/delta point_ppm=859396 lo_ppm=758743 hi_ppm=956712 +ratio name=delta/method point_ppm=954985 lo_ppm=854391 hi_ppm=1078713 +ratio name=idelta/full point_ppm=750715 lo_ppm=650013 hi_ppm=867141 +correct arm=echo query_ok=0 query_wrong=0 change_ok=0 change_wrong=0 unscored=53856 log_inconsistent=0 proc_failed=0 +correct arm=full query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=cache query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=method query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=delta query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=idelta query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=deltap query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +correct arm=select query_ok=27072 query_wrong=0 change_ok=26784 change_wrong=0 unscored=0 log_inconsistent=0 proc_failed=0 +routes arm=echo r0=27072 r1=0 r2=0 r3=0 r4=0 r5=0 other=0 fallback_ppm=0 +routes arm=full r0=0 r1=27072 r2=0 r3=0 r4=0 r5=0 other=0 fallback_ppm=0 +routes arm=cache r0=0 r1=21054 r2=6018 r3=0 r4=0 r5=0 other=0 fallback_ppm=0 +routes arm=method r0=0 r1=6360 r2=0 r3=20712 r4=0 r5=0 other=0 fallback_ppm=0 +routes arm=delta r0=0 r1=0 r2=0 r3=0 r4=27072 r5=0 other=0 fallback_ppm=0 +routes arm=idelta r0=0 r1=0 r2=0 r3=0 r4=27072 r5=0 other=0 fallback_ppm=0 +routes arm=deltap r0=0 r1=0 r2=0 r3=0 r4=27072 r5=0 other=0 fallback_ppm=0 +routes arm=select r0=0 r1=3939 r2=0 r3=78 r4=23055 r5=0 other=0 fallback_ppm=0 +coverage arm=delta class=transfer queries=5616 method_served=5616 coverage_ppm=1000000 +memory arm=echo procs=72 hwm_max_kb=232 hwm_mean_kb=217 rss_max_kb=232 cpu_ticks=0 exit_nonzero=0 end_failed=0 +memory arm=full procs=72 hwm_max_kb=232 hwm_mean_kb=218 rss_max_kb=232 cpu_ticks=5 exit_nonzero=0 end_failed=0 +memory arm=cache procs=72 hwm_max_kb=292 hwm_mean_kb=274 rss_max_kb=292 cpu_ticks=163 exit_nonzero=0 end_failed=0 +memory arm=method procs=72 hwm_max_kb=292 hwm_mean_kb=278 rss_max_kb=292 cpu_ticks=2 exit_nonzero=0 end_failed=0 +memory arm=delta procs=72 hwm_max_kb=832 hwm_mean_kb=397 rss_max_kb=832 cpu_ticks=3 exit_nonzero=0 end_failed=0 +memory arm=idelta procs=72 hwm_max_kb=776 hwm_mean_kb=344 rss_max_kb=776 cpu_ticks=5 exit_nonzero=0 end_failed=0 +memory arm=deltap procs=72 hwm_max_kb=820 hwm_mean_kb=392 rss_max_kb=820 cpu_ticks=0 exit_nonzero=0 end_failed=0 +memory arm=select procs=72 hwm_max_kb=832 hwm_mean_kb=399 rss_max_kb=832 cpu_ticks=0 exit_nonzero=0 end_failed=0 +acq lib=1 builds=3 elapsed_ns=222383635 cpu_ticks=10 libdir_bytes_max=222144 drive_nonzero=0 +acq lib=2 builds=3 elapsed_ns=207481668 cpu_ticks=9 libdir_bytes_max=219991 drive_nonzero=0 +payback arm=cache queries=69 +payback arm=method queries=none +payback arm=delta queries=none +payback arm=idelta queries=0 +payback arm=deltap queries=none +payback arm=select queries=none +cbar arm=cache r_ppm=299465 q_ppm=777703 e_ppm=1755113 k_units_ppm=0 n=27072 cbar_ppm=1467324 observed_ppm=4028417 +cbar arm=method r_ppm=299465 q_ppm=234929 e_ppm=241065 k_units_ppm=10242429762 n=27072 cbar_ppm=1097165 observed_ppm=1044399 +cbar arm=delta r_ppm=299465 q_ppm=0 e_ppm=58862 k_units_ppm=10242429762 n=27072 cbar_ppm=736667 observed_ppm=736643 +cbar arm=idelta r_ppm=299465 q_ppm=0 e_ppm=31273 k_units_ppm=0 n=27072 cbar_ppm=330738 observed_ppm=330738 +cbar arm=deltap r_ppm=299465 q_ppm=0 e_ppm=47209 k_units_ppm=9556082719 n=27072 cbar_ppm=699661 observed_ppm=699659 +cbar arm=select r_ppm=299465 q_ppm=145500 e_ppm=11929 k_units_ppm=10242429762 n=27072 cbar_ppm=833498 observed_ppm=691138 +echo_sub arm=echo ppm=0 +echo_sub arm=cache ppm=5546006 +echo_sub arm=method ppm=1457640 +echo_sub arm=delta ppm=1343113 +echo_sub arm=idelta ppm=479842 +echo_sub arm=deltap ppm=1023166 +echo_sub arm=select ppm=1001487 +cat_rho arm=echo cat=type:Z ppm=372896 +cat_rho arm=echo cat=type:S ppm=564804 +cat_rho arm=echo cat=type:D ppm=714616 +cat_rho arm=echo cat=type:R ppm=474755 +cat_rho arm=echo cat=type:I ppm=498727 +cat_rho arm=echo cat=type:A ppm=464520 +cat_rho arm=echo cat=type:P ppm=581683 +cat_rho arm=echo cat=type:C ppm=549454 +cat_rho arm=echo cat=nov:recall ppm=409490 +cat_rho arm=echo cat=nov:transfer ppm=499862 +cat_rho arm=echo cat=nov:novel ppm=442627 +cat_rho arm=echo cat=nov:fsm_recall ppm=533939 +cat_rho arm=echo cat=nov:fsm_new ppm=621002 +cat_rho arm=echo cat=fam:AGG ppm=459898 +cat_rho arm=echo cat=fam:FSM ppm=584486 +cat_rho arm=echo cat=n:64 ppm=1046282 +cat_rho arm=echo cat=n:512 ppm=751348 +cat_rho arm=echo cat=n:4096 ppm=284830 +cat_rho arm=full cat=type:Z ppm=1000000 +cat_rho arm=full cat=type:S ppm=1000000 +cat_rho arm=full cat=type:D ppm=1000000 +cat_rho arm=full cat=type:R ppm=1000000 +cat_rho arm=full cat=type:I ppm=1000000 +cat_rho arm=full cat=type:A ppm=1000000 +cat_rho arm=full cat=type:P ppm=1000000 +cat_rho arm=full cat=type:C ppm=1000000 +cat_rho arm=full cat=nov:recall ppm=1000000 +cat_rho arm=full cat=nov:transfer ppm=1000000 +cat_rho arm=full cat=nov:novel ppm=1000000 +cat_rho arm=full cat=nov:fsm_recall ppm=1000000 +cat_rho arm=full cat=nov:fsm_new ppm=1000000 +cat_rho arm=full cat=fam:AGG ppm=1000000 +cat_rho arm=full cat=fam:FSM ppm=1000000 +cat_rho arm=full cat=n:64 ppm=1000000 +cat_rho arm=full cat=n:512 ppm=1000000 +cat_rho arm=full cat=n:4096 ppm=1000000 +cat_rho arm=cache cat=type:Z ppm=553527 +cat_rho arm=cache cat=type:S ppm=4018014 +cat_rho arm=cache cat=type:D ppm=1950885 +cat_rho arm=cache cat=type:R ppm=3635403 +cat_rho arm=cache cat=type:I ppm=3407113 +cat_rho arm=cache cat=type:A ppm=3172864 +cat_rho arm=cache cat=type:P ppm=1800376 +cat_rho arm=cache cat=type:C ppm=4056071 +cat_rho arm=cache cat=nov:recall ppm=2845493 +cat_rho arm=cache cat=nov:transfer ppm=2796733 +cat_rho arm=cache cat=nov:novel ppm=3025449 +cat_rho arm=cache cat=nov:fsm_recall ppm=3373285 +cat_rho arm=cache cat=nov:fsm_new ppm=3801988 +cat_rho arm=cache cat=fam:AGG ppm=2889832 +cat_rho arm=cache cat=fam:FSM ppm=3622181 +cat_rho arm=cache cat=n:64 ppm=1524633 +cat_rho arm=cache cat=n:512 ppm=2297119 +cat_rho arm=cache cat=n:4096 ppm=3992941 +cat_rho arm=method cat=type:Z ppm=772049 +cat_rho arm=method cat=type:S ppm=903568 +cat_rho arm=method cat=type:D ppm=959690 +cat_rho arm=method cat=type:R ppm=930165 +cat_rho arm=method cat=type:I ppm=883327 +cat_rho arm=method cat=type:A ppm=698128 +cat_rho arm=method cat=type:P ppm=3049658 +cat_rho arm=method cat=type:C ppm=1042587 +cat_rho arm=method cat=nov:recall ppm=1092874 +cat_rho arm=method cat=nov:transfer ppm=1076402 +cat_rho arm=method cat=nov:novel ppm=1127343 +cat_rho arm=method cat=nov:fsm_recall ppm=825462 +cat_rho arm=method cat=nov:fsm_new ppm=769623 +cat_rho arm=method cat=fam:AGG ppm=1098334 +cat_rho arm=method cat=fam:FSM ppm=793043 +cat_rho arm=method cat=n:64 ppm=1370558 +cat_rho arm=method cat=n:512 ppm=1227809 +cat_rho arm=method cat=n:4096 ppm=761806 +cat_rho arm=delta cat=type:Z ppm=603613 +cat_rho arm=delta cat=type:S ppm=777606 +cat_rho arm=delta cat=type:D ppm=2336417 +cat_rho arm=delta cat=type:R ppm=717119 +cat_rho arm=delta cat=type:I ppm=715366 +cat_rho arm=delta cat=type:A ppm=726053 +cat_rho arm=delta cat=type:P ppm=2887807 +cat_rho arm=delta cat=type:C ppm=699311 +cat_rho arm=delta cat=nov:recall ppm=862112 +cat_rho arm=delta cat=nov:transfer ppm=984821 +cat_rho arm=delta cat=nov:novel ppm=614895 +cat_rho arm=delta cat=nov:fsm_recall ppm=1123612 +cat_rho arm=delta cat=nov:fsm_new ppm=942131 +cat_rho arm=delta cat=fam:AGG ppm=824895 +cat_rho arm=delta cat=fam:FSM ppm=1018248 +cat_rho arm=delta cat=n:64 ppm=1584991 +cat_rho arm=delta cat=n:512 ppm=1401758 +cat_rho arm=delta cat=n:4096 ppm=554118 +cat_rho arm=idelta cat=type:Z ppm=372763 +cat_rho arm=idelta cat=type:S ppm=713146 +cat_rho arm=idelta cat=type:D ppm=2409242 +cat_rho arm=idelta cat=type:R ppm=553008 +cat_rho arm=idelta cat=type:I ppm=550043 +cat_rho arm=idelta cat=type:A ppm=827013 +cat_rho arm=idelta cat=type:P ppm=783587 +cat_rho arm=idelta cat=type:C ppm=549827 +cat_rho arm=idelta cat=nov:recall ppm=457240 +cat_rho arm=idelta cat=nov:transfer ppm=647918 +cat_rho arm=idelta cat=nov:novel ppm=507400 +cat_rho arm=idelta cat=nov:fsm_recall ppm=1250461 +cat_rho arm=idelta cat=nov:fsm_new ppm=803247 +cat_rho arm=idelta cat=fam:AGG ppm=556453 +cat_rho arm=idelta cat=fam:FSM ppm=990818 +cat_rho arm=idelta cat=n:64 ppm=1094264 +cat_rho arm=idelta cat=n:512 ppm=1179967 +cat_rho arm=idelta cat=n:4096 ppm=503776 +cat_rho arm=deltap cat=type:Z ppm=664522 +cat_rho arm=deltap cat=type:S ppm=514252 +cat_rho arm=deltap cat=type:D ppm=2024544 +cat_rho arm=deltap cat=type:R ppm=644128 +cat_rho arm=deltap cat=type:I ppm=744985 +cat_rho arm=deltap cat=type:A ppm=684882 +cat_rho arm=deltap cat=type:P ppm=1177578 +cat_rho arm=deltap cat=type:C ppm=679231 +cat_rho arm=deltap cat=nov:recall ppm=463483 +cat_rho arm=deltap cat=nov:transfer ppm=576166 +cat_rho arm=deltap cat=nov:novel ppm=597373 +cat_rho arm=deltap cat=nov:fsm_recall ppm=1252796 +cat_rho arm=deltap cat=nov:fsm_new ppm=889289 +cat_rho arm=deltap cat=fam:AGG ppm=559809 +cat_rho arm=deltap cat=fam:FSM ppm=1041751 +cat_rho arm=deltap cat=n:64 ppm=1218659 +cat_rho arm=deltap cat=n:512 ppm=1273289 +cat_rho arm=deltap cat=n:4096 ppm=476536 +cat_rho arm=select cat=type:Z ppm=526838 +cat_rho arm=select cat=type:S ppm=554017 +cat_rho arm=select cat=type:D ppm=1195876 +cat_rho arm=select cat=type:R ppm=764351 +cat_rho arm=select cat=type:I ppm=666468 +cat_rho arm=select cat=type:A ppm=677749 +cat_rho arm=select cat=type:P ppm=1884003 +cat_rho arm=select cat=type:C ppm=687084 +cat_rho arm=select cat=nov:recall ppm=618570 +cat_rho arm=select cat=nov:transfer ppm=742090 +cat_rho arm=select cat=nov:novel ppm=625651 +cat_rho arm=select cat=nov:fsm_recall ppm=932121 +cat_rho arm=select cat=nov:fsm_new ppm=758878 +cat_rho arm=select cat=fam:AGG ppm=673650 +cat_rho arm=select cat=fam:FSM ppm=831540 +cat_rho arm=select cat=n:64 ppm=1243059 +cat_rho arm=select cat=n:512 ppm=1011282 +cat_rho arm=select cat=n:4096 ppm=511571 +regime cat=type:Z delta_over_method_ppm=781832 idelta_over_full_ppm=372763 +regime cat=type:S delta_over_method_ppm=860594 idelta_over_full_ppm=713146 +regime cat=type:D delta_over_method_ppm=2434553 idelta_over_full_ppm=2409242 +regime cat=type:R delta_over_method_ppm=770958 idelta_over_full_ppm=553008 +regime cat=type:I delta_over_method_ppm=809853 idelta_over_full_ppm=550043 +regime cat=type:A delta_over_method_ppm=1039999 idelta_over_full_ppm=827013 +regime cat=type:P delta_over_method_ppm=946927 idelta_over_full_ppm=783587 +regime cat=type:C delta_over_method_ppm=670746 idelta_over_full_ppm=549827 +quant arm=echo temp=cold cat=all count=864 p50_ns=5520 p95_ns=7632 p99_ns=15600 +quant arm=echo temp=cold cat=type:Z count=72 p50_ns=5536 p95_ns=9136 p99_ns=15600 +quant arm=echo temp=cold cat=type:S count=72 p50_ns=5536 p95_ns=7152 p99_ns=991530 +quant arm=echo temp=cold cat=type:D count=72 p50_ns=5520 p95_ns=6993 p99_ns=40401 +quant arm=echo temp=cold cat=type:R count=72 p50_ns=5632 p95_ns=10176 p99_ns=33856 +quant arm=echo temp=cold cat=type:I count=72 p50_ns=5552 p95_ns=7328 p99_ns=7664 +quant arm=echo temp=cold cat=type:A count=72 p50_ns=5472 p95_ns=6224 p99_ns=76209 +quant arm=echo temp=cold cat=type:P count=360 p50_ns=5504 p95_ns=7120 p99_ns=10880 +quant arm=echo temp=cold cat=type:C count=72 p50_ns=5568 p95_ns=7888 p99_ns=14288 +quant arm=echo temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=echo temp=cold cat=nov:recall count=99 p50_ns=5552 p95_ns=6480 p99_ns=7969 +quant arm=echo temp=cold cat=nov:transfer count=198 p50_ns=5536 p95_ns=7472 p99_ns=40401 +quant arm=echo temp=cold cat=nov:novel count=135 p50_ns=5488 p95_ns=7568 p99_ns=11712 +quant arm=echo temp=cold cat=nov:fsm_recall count=198 p50_ns=5520 p95_ns=9968 p99_ns=39952 +quant arm=echo temp=cold cat=nov:fsm_new count=234 p50_ns=5504 p95_ns=7808 p99_ns=15600 +quant arm=echo temp=cold cat=fam:AGG count=432 p50_ns=5521 p95_ns=7232 p99_ns=11376 +quant arm=echo temp=cold cat=fam:FSM count=432 p50_ns=5504 p95_ns=8432 p99_ns=16512 +quant arm=echo temp=cold cat=n:64 count=288 p50_ns=5536 p95_ns=7824 p99_ns=33856 +quant arm=echo temp=cold cat=n:512 count=288 p50_ns=5488 p95_ns=7248 p99_ns=12880 +quant arm=echo temp=cold cat=n:4096 count=288 p50_ns=5536 p95_ns=7472 p99_ns=39952 +quant arm=echo temp=warm cat=all count=26208 p50_ns=5504 p95_ns=6512 p99_ns=13456 +quant arm=echo temp=warm cat=type:Z count=2232 p50_ns=5488 p95_ns=6672 p99_ns=17488 +quant arm=echo temp=warm cat=type:S count=4536 p50_ns=5504 p95_ns=6561 p99_ns=16288 +quant arm=echo temp=warm cat=type:D count=504 p50_ns=5536 p95_ns=6928 p99_ns=15616 +quant arm=echo temp=warm cat=type:R count=4536 p50_ns=5504 p95_ns=6624 p99_ns=12512 +quant arm=echo temp=warm cat=type:I count=4536 p50_ns=5488 p95_ns=6096 p99_ns=11425 +quant arm=echo temp=warm cat=type:A count=4536 p50_ns=5488 p95_ns=6016 p99_ns=9728 +quant arm=echo temp=warm cat=type:P count=792 p50_ns=5504 p95_ns=6192 p99_ns=8672 +quant arm=echo temp=warm cat=type:C count=4536 p50_ns=5504 p95_ns=7888 p99_ns=18704 +quant arm=echo temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=echo temp=warm cat=nov:recall count=2709 p50_ns=5552 p95_ns=7744 p99_ns=16608 +quant arm=echo temp=warm cat=nov:transfer count=5418 p50_ns=5488 p95_ns=6032 p99_ns=10304 +quant arm=echo temp=warm cat=nov:novel count=4977 p50_ns=5488 p95_ns=6032 p99_ns=11904 +quant arm=echo temp=warm cat=nov:fsm_recall count=5418 p50_ns=5488 p95_ns=5968 p99_ns=10256 +quant arm=echo temp=warm cat=nov:fsm_new count=7686 p50_ns=5520 p95_ns=7264 p99_ns=20256 +quant arm=echo temp=warm cat=fam:AGG count=13104 p50_ns=5488 p95_ns=6512 p99_ns=12097 +quant arm=echo temp=warm cat=fam:FSM count=13104 p50_ns=5504 p95_ns=6512 p99_ns=15217 +quant arm=echo temp=warm cat=n:64 count=8736 p50_ns=5520 p95_ns=7104 p99_ns=20640 +quant arm=echo temp=warm cat=n:512 count=8736 p50_ns=5488 p95_ns=6240 p99_ns=11360 +quant arm=echo temp=warm cat=n:4096 count=8736 p50_ns=5504 p95_ns=6416 p99_ns=11105 +quant arm=full temp=cold cat=all count=864 p50_ns=10368 p95_ns=62144 p99_ns=74368 +quant arm=full temp=cold cat=type:Z count=72 p50_ns=8896 p95_ns=72369 p99_ns=89057 +quant arm=full temp=cold cat=type:S count=72 p50_ns=9824 p95_ns=66160 p99_ns=77121 +quant arm=full temp=cold cat=type:D count=72 p50_ns=9968 p95_ns=63441 p99_ns=68848 +quant arm=full temp=cold cat=type:R count=72 p50_ns=11728 p95_ns=64609 p99_ns=86945 +quant arm=full temp=cold cat=type:I count=72 p50_ns=10208 p95_ns=68337 p99_ns=74784 +quant arm=full temp=cold cat=type:A count=72 p50_ns=11760 p95_ns=54785 p99_ns=63681 +quant arm=full temp=cold cat=type:P count=360 p50_ns=10368 p95_ns=54017 p99_ns=63696 +quant arm=full temp=cold cat=type:C count=72 p50_ns=10544 p95_ns=62145 p99_ns=62881 +quant arm=full temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=full temp=cold cat=nov:recall count=99 p50_ns=10608 p95_ns=68337 p99_ns=86945 +quant arm=full temp=cold cat=nov:transfer count=198 p50_ns=11984 p95_ns=65201 p99_ns=87681 +quant arm=full temp=cold cat=nov:novel count=135 p50_ns=9649 p95_ns=55009 p99_ns=72257 +quant arm=full temp=cold cat=nov:fsm_recall count=198 p50_ns=9889 p95_ns=54849 p99_ns=60913 +quant arm=full temp=cold cat=nov:fsm_new count=234 p50_ns=9968 p95_ns=62529 p99_ns=68049 +quant arm=full temp=cold cat=fam:AGG count=432 p50_ns=10608 p95_ns=63441 p99_ns=84753 +quant arm=full temp=cold cat=fam:FSM count=432 p50_ns=9968 p95_ns=57425 p99_ns=64144 +quant arm=full temp=cold cat=n:64 count=288 p50_ns=6305 p95_ns=9232 p99_ns=12624 +quant arm=full temp=cold cat=n:512 count=288 p50_ns=10289 p95_ns=17616 p99_ns=55249 +quant arm=full temp=cold cat=n:4096 count=288 p50_ns=45281 p95_ns=68337 p99_ns=86945 +quant arm=full temp=warm cat=all count=26208 p50_ns=9488 p95_ns=62337 p99_ns=86785 +quant arm=full temp=warm cat=type:Z count=2232 p50_ns=9168 p95_ns=65617 p99_ns=89009 +quant arm=full temp=warm cat=type:S count=4536 p50_ns=9488 p95_ns=63888 p99_ns=70608 +quant arm=full temp=warm cat=type:D count=504 p50_ns=9505 p95_ns=63057 p99_ns=67904 +quant arm=full temp=warm cat=type:R count=4536 p50_ns=9217 p95_ns=54368 p99_ns=88769 +quant arm=full temp=warm cat=type:I count=4536 p50_ns=9296 p95_ns=61136 p99_ns=72017 +quant arm=full temp=warm cat=type:A count=4536 p50_ns=10224 p95_ns=58481 p99_ns=64161 +quant arm=full temp=warm cat=type:P count=792 p50_ns=10080 p95_ns=53312 p99_ns=62353 +quant arm=full temp=warm cat=type:C count=4536 p50_ns=8704 p95_ns=56144 p99_ns=64048 +quant arm=full temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=full temp=warm cat=nov:recall count=2709 p50_ns=10544 p95_ns=86209 p99_ns=90049 +quant arm=full temp=warm cat=nov:transfer count=5418 p50_ns=11536 p95_ns=70592 p99_ns=87425 +quant arm=full temp=warm cat=nov:novel count=4977 p50_ns=10176 p95_ns=56384 p99_ns=71041 +quant arm=full temp=warm cat=nov:fsm_recall count=5418 p50_ns=9168 p95_ns=47472 p99_ns=52608 +quant arm=full temp=warm cat=nov:fsm_new count=7686 p50_ns=8209 p95_ns=54289 p99_ns=64065 +quant arm=full temp=warm cat=fam:AGG count=13104 p50_ns=11232 p95_ns=65809 p99_ns=88113 +quant arm=full temp=warm cat=fam:FSM count=13104 p50_ns=8688 p95_ns=50048 p99_ns=63553 +quant arm=full temp=warm cat=n:64 count=8736 p50_ns=6080 p95_ns=6912 p99_ns=17440 +quant arm=full temp=warm cat=n:512 count=8736 p50_ns=9377 p95_ns=15408 p99_ns=21184 +quant arm=full temp=warm cat=n:4096 count=8736 p50_ns=44000 p95_ns=71377 p99_ns=92097 +quant arm=cache temp=cold cat=all count=864 p50_ns=33168 p95_ns=241506 p99_ns=548565 +quant arm=cache temp=cold cat=type:Z count=72 p50_ns=35088 p95_ns=262866 p99_ns=271570 +quant arm=cache temp=cold cat=type:S count=72 p50_ns=35232 p95_ns=255395 p99_ns=335683 +quant arm=cache temp=cold cat=type:D count=72 p50_ns=35472 p95_ns=250322 p99_ns=1005225 +quant arm=cache temp=cold cat=type:R count=72 p50_ns=38192 p95_ns=258034 p99_ns=337523 +quant arm=cache temp=cold cat=type:I count=72 p50_ns=36224 p95_ns=255571 p99_ns=597717 +quant arm=cache temp=cold cat=type:A count=72 p50_ns=37600 p95_ns=286947 p99_ns=1174699 +quant arm=cache temp=cold cat=type:P count=360 p50_ns=13648 p95_ns=204674 p99_ns=955929 +quant arm=cache temp=cold cat=type:C count=72 p50_ns=36080 p95_ns=236770 p99_ns=1011161 +quant arm=cache temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=cache temp=cold cat=nov:recall count=99 p50_ns=35744 p95_ns=259219 p99_ns=1174699 +quant arm=cache temp=cold cat=nov:transfer count=198 p50_ns=29632 p95_ns=255395 p99_ns=335683 +quant arm=cache temp=cold cat=nov:novel count=135 p50_ns=29216 p95_ns=235810 p99_ns=247762 +quant arm=cache temp=cold cat=nov:fsm_recall count=198 p50_ns=34672 p95_ns=250322 p99_ns=1029194 +quant arm=cache temp=cold cat=nov:fsm_new count=234 p50_ns=33025 p95_ns=237426 p99_ns=342340 +quant arm=cache temp=cold cat=fam:AGG count=432 p50_ns=30225 p95_ns=241523 p99_ns=335683 +quant arm=cache temp=cold cat=fam:FSM count=432 p50_ns=33168 p95_ns=239250 p99_ns=955929 +quant arm=cache temp=cold cat=n:64 count=288 p50_ns=12960 p95_ns=15408 p99_ns=27472 +quant arm=cache temp=cold cat=n:512 count=288 p50_ns=34832 p95_ns=42641 p99_ns=177281 +quant arm=cache temp=cold cat=n:4096 count=288 p50_ns=211522 p95_ns=324995 p99_ns=1012554 +quant arm=cache temp=warm cat=all count=26208 p50_ns=33808 p95_ns=246211 p99_ns=388932 +quant arm=cache temp=warm cat=type:Z count=2232 p50_ns=7920 p95_ns=8944 p99_ns=16465 +quant arm=cache temp=warm cat=type:S count=4536 p50_ns=34801 p95_ns=306627 p99_ns=457492 +quant arm=cache temp=warm cat=type:D count=504 p50_ns=35105 p95_ns=240290 p99_ns=576822 +quant arm=cache temp=warm cat=type:R count=4536 p50_ns=34480 p95_ns=269778 p99_ns=376340 +quant arm=cache temp=warm cat=type:I count=4536 p50_ns=34993 p95_ns=245346 p99_ns=362003 +quant arm=cache temp=warm cat=type:A count=4536 p50_ns=35297 p95_ns=236866 p99_ns=420068 +quant arm=cache temp=warm cat=type:P count=792 p50_ns=7968 p95_ns=9616 p99_ns=989689 +quant arm=cache temp=warm cat=type:C count=4536 p50_ns=34048 p95_ns=240914 p99_ns=447637 +quant arm=cache temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=cache temp=warm cat=nov:recall count=2709 p50_ns=35489 p95_ns=261411 p99_ns=382772 +quant arm=cache temp=warm cat=nov:transfer count=5418 p50_ns=35648 p95_ns=246706 p99_ns=476837 +quant arm=cache temp=warm cat=nov:novel count=4977 p50_ns=34784 p95_ns=247043 p99_ns=355524 +quant arm=cache temp=warm cat=nov:fsm_recall count=5418 p50_ns=33392 p95_ns=223650 p99_ns=339348 +quant arm=cache temp=warm cat=nov:fsm_new count=7686 p50_ns=32544 p95_ns=271171 p99_ns=444020 +quant arm=cache temp=warm cat=fam:AGG count=13104 p50_ns=35392 p95_ns=248483 p99_ns=384836 +quant arm=cache temp=warm cat=fam:FSM count=13104 p50_ns=32656 p95_ns=236979 p99_ns=409220 +quant arm=cache temp=warm cat=n:64 count=8736 p50_ns=12944 p95_ns=14288 p99_ns=22288 +quant arm=cache temp=warm cat=n:512 count=8736 p50_ns=34369 p95_ns=40704 p99_ns=59040 +quant arm=cache temp=warm cat=n:4096 count=8736 p50_ns=218130 p95_ns=337731 p99_ns=644326 +quant arm=method temp=cold cat=all count=864 p50_ns=8400 p95_ns=28449 p99_ns=55680 +quant arm=method temp=cold cat=type:Z count=72 p50_ns=8768 p95_ns=37249 p99_ns=125457 +quant arm=method temp=cold cat=type:S count=72 p50_ns=10833 p95_ns=25872 p99_ns=76464 +quant arm=method temp=cold cat=type:D count=72 p50_ns=8240 p95_ns=28305 p99_ns=51329 +quant arm=method temp=cold cat=type:R count=72 p50_ns=8304 p95_ns=27313 p99_ns=55088 +quant arm=method temp=cold cat=type:I count=72 p50_ns=8144 p95_ns=30736 p99_ns=54241 +quant arm=method temp=cold cat=type:A count=72 p50_ns=8144 p95_ns=31632 p99_ns=54913 +quant arm=method temp=cold cat=type:P count=360 p50_ns=8305 p95_ns=27681 p99_ns=55680 +quant arm=method temp=cold cat=type:C count=72 p50_ns=8928 p95_ns=53696 p99_ns=3506305 +quant arm=method temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=method temp=cold cat=nov:recall count=99 p50_ns=8512 p95_ns=27313 p99_ns=125457 +quant arm=method temp=cold cat=nov:transfer count=198 p50_ns=8576 p95_ns=28320 p99_ns=55680 +quant arm=method temp=cold cat=nov:novel count=135 p50_ns=10288 p95_ns=54913 p99_ns=76464 +quant arm=method temp=cold cat=nov:fsm_recall count=198 p50_ns=7216 p95_ns=17520 p99_ns=23728 +quant arm=method temp=cold cat=nov:fsm_new count=234 p50_ns=7104 p95_ns=15744 p99_ns=30736 +quant arm=method temp=cold cat=fam:AGG count=432 p50_ns=9136 p95_ns=53136 p99_ns=75089 +quant arm=method temp=cold cat=fam:FSM count=432 p50_ns=7152 p95_ns=16433 p99_ns=23728 +quant arm=method temp=cold cat=n:64 count=288 p50_ns=6352 p95_ns=10544 p99_ns=19008 +quant arm=method temp=cold cat=n:512 count=288 p50_ns=8209 p95_ns=15232 p99_ns=125457 +quant arm=method temp=cold cat=n:4096 count=288 p50_ns=23920 p95_ns=53696 p99_ns=75089 +quant arm=method temp=warm cat=all count=26208 p50_ns=8176 p95_ns=48401 p99_ns=64801 +quant arm=method temp=warm cat=type:Z count=2232 p50_ns=8192 p95_ns=34544 p99_ns=42784 +quant arm=method temp=warm cat=type:S count=4536 p50_ns=10016 p95_ns=26129 p99_ns=73232 +quant arm=method temp=warm cat=type:D count=504 p50_ns=8256 p95_ns=27088 p99_ns=28337 +quant arm=method temp=warm cat=type:R count=4536 p50_ns=8112 p95_ns=32016 p99_ns=54545 +quant arm=method temp=warm cat=type:I count=4536 p50_ns=7969 p95_ns=28352 p99_ns=53857 +quant arm=method temp=warm cat=type:A count=4536 p50_ns=8081 p95_ns=26865 p99_ns=55840 +quant arm=method temp=warm cat=type:P count=792 p50_ns=8144 p95_ns=27168 p99_ns=42497 +quant arm=method temp=warm cat=type:C count=4536 p50_ns=8544 p95_ns=52929 p99_ns=54512 +quant arm=method temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=method temp=warm cat=nov:recall count=2709 p50_ns=8480 p95_ns=25280 p99_ns=32016 +quant arm=method temp=warm cat=nov:transfer count=5418 p50_ns=8401 p95_ns=25344 p99_ns=29760 +quant arm=method temp=warm cat=nov:novel count=4977 p50_ns=10848 p95_ns=57984 p99_ns=74273 +quant arm=method temp=warm cat=nov:fsm_recall count=5418 p50_ns=7024 p95_ns=14832 p99_ns=20800 +quant arm=method temp=warm cat=nov:fsm_new count=7686 p50_ns=6960 p95_ns=14480 p99_ns=18561 +quant arm=method temp=warm cat=fam:AGG count=13104 p50_ns=8832 p95_ns=53393 p99_ns=72497 +quant arm=method temp=warm cat=fam:FSM count=13104 p50_ns=6992 p95_ns=14560 p99_ns=19296 +quant arm=method temp=warm cat=n:64 count=8736 p50_ns=6240 p95_ns=8016 p99_ns=16256 +quant arm=method temp=warm cat=n:512 count=8736 p50_ns=8064 p95_ns=14256 p99_ns=19776 +quant arm=method temp=warm cat=n:4096 count=8736 p50_ns=23536 p95_ns=54129 p99_ns=73185 +quant arm=delta temp=cold cat=all count=864 p50_ns=6048 p95_ns=9840 p99_ns=32337 +quant arm=delta temp=cold cat=type:Z count=72 p50_ns=6256 p95_ns=11952 p99_ns=103569 +quant arm=delta temp=cold cat=type:S count=72 p50_ns=6032 p95_ns=11904 p99_ns=1224988 +quant arm=delta temp=cold cat=type:D count=72 p50_ns=6064 p95_ns=9104 p99_ns=2014659 +quant arm=delta temp=cold cat=type:R count=72 p50_ns=6128 p95_ns=8449 p99_ns=8560 +quant arm=delta temp=cold cat=type:I count=72 p50_ns=6064 p95_ns=7681 p99_ns=32337 +quant arm=delta temp=cold cat=type:A count=72 p50_ns=5952 p95_ns=6784 p99_ns=9840 +quant arm=delta temp=cold cat=type:P count=360 p50_ns=6032 p95_ns=10448 p99_ns=43568 +quant arm=delta temp=cold cat=type:C count=72 p50_ns=6096 p95_ns=11920 p99_ns=128657 +quant arm=delta temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=delta temp=cold cat=nov:recall count=99 p50_ns=6113 p95_ns=9104 p99_ns=16352 +quant arm=delta temp=cold cat=nov:transfer count=198 p50_ns=6064 p95_ns=10657 p99_ns=62401 +quant arm=delta temp=cold cat=nov:novel count=135 p50_ns=6080 p95_ns=8016 p99_ns=9488 +quant arm=delta temp=cold cat=nov:fsm_recall count=198 p50_ns=6048 p95_ns=11297 p99_ns=103569 +quant arm=delta temp=cold cat=nov:fsm_new count=234 p50_ns=6000 p95_ns=10176 p99_ns=32337 +quant arm=delta temp=cold cat=fam:AGG count=432 p50_ns=6080 p95_ns=9120 p99_ns=23120 +quant arm=delta temp=cold cat=fam:FSM count=432 p50_ns=6016 p95_ns=10512 p99_ns=97153 +quant arm=delta temp=cold cat=n:64 count=288 p50_ns=6032 p95_ns=9457 p99_ns=18961 +quant arm=delta temp=cold cat=n:512 count=288 p50_ns=6048 p95_ns=9728 p99_ns=30416 +quant arm=delta temp=cold cat=n:4096 count=288 p50_ns=6080 p95_ns=10448 p99_ns=97153 +quant arm=delta temp=warm cat=all count=26208 p50_ns=5936 p95_ns=7968 p99_ns=20960 +quant arm=delta temp=warm cat=type:Z count=2232 p50_ns=5968 p95_ns=8384 p99_ns=19840 +quant arm=delta temp=warm cat=type:S count=4536 p50_ns=5936 p95_ns=9104 p99_ns=26368 +quant arm=delta temp=warm cat=type:D count=504 p50_ns=6064 p95_ns=9568 p99_ns=897705 +quant arm=delta temp=warm cat=type:R count=4536 p50_ns=5920 p95_ns=7808 p99_ns=19937 +quant arm=delta temp=warm cat=type:I count=4536 p50_ns=5936 p95_ns=8817 p99_ns=22352 +quant arm=delta temp=warm cat=type:A count=4536 p50_ns=5920 p95_ns=6833 p99_ns=16704 +quant arm=delta temp=warm cat=type:P count=792 p50_ns=5936 p95_ns=7408 p99_ns=22784 +quant arm=delta temp=warm cat=type:C count=4536 p50_ns=5920 p95_ns=7392 p99_ns=25792 +quant arm=delta temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=delta temp=warm cat=nov:recall count=2709 p50_ns=5920 p95_ns=8352 p99_ns=26368 +quant arm=delta temp=warm cat=nov:transfer count=5418 p50_ns=5952 p95_ns=7584 p99_ns=19712 +quant arm=delta temp=warm cat=nov:novel count=4977 p50_ns=5920 p95_ns=7504 p99_ns=19616 +quant arm=delta temp=warm cat=nov:fsm_recall count=5418 p50_ns=5952 p95_ns=8624 p99_ns=26512 +quant arm=delta temp=warm cat=nov:fsm_new count=7686 p50_ns=5936 p95_ns=7632 p99_ns=21313 +quant arm=delta temp=warm cat=fam:AGG count=13104 p50_ns=5936 p95_ns=7776 p99_ns=19984 +quant arm=delta temp=warm cat=fam:FSM count=13104 p50_ns=5936 p95_ns=8096 p99_ns=22784 +quant arm=delta temp=warm cat=n:64 count=8736 p50_ns=5952 p95_ns=8384 p99_ns=22352 +quant arm=delta temp=warm cat=n:512 count=8736 p50_ns=5920 p95_ns=7728 p99_ns=19456 +quant arm=delta temp=warm cat=n:4096 count=8736 p50_ns=5936 p95_ns=7840 p99_ns=23216 +quant arm=idelta temp=cold cat=all count=864 p50_ns=5600 p95_ns=9792 p99_ns=17313 +quant arm=idelta temp=cold cat=type:Z count=72 p50_ns=5600 p95_ns=10544 p99_ns=203938 +quant arm=idelta temp=cold cat=type:S count=72 p50_ns=5601 p95_ns=11665 p99_ns=1005994 +quant arm=idelta temp=cold cat=type:D count=72 p50_ns=5680 p95_ns=17313 p99_ns=989273 +quant arm=idelta temp=cold cat=type:R count=72 p50_ns=5664 p95_ns=12096 p99_ns=13120 +quant arm=idelta temp=cold cat=type:I count=72 p50_ns=5616 p95_ns=8961 p99_ns=15904 +quant arm=idelta temp=cold cat=type:A count=72 p50_ns=5536 p95_ns=7104 p99_ns=12928 +quant arm=idelta temp=cold cat=type:P count=360 p50_ns=5568 p95_ns=8928 p99_ns=12880 +quant arm=idelta temp=cold cat=type:C count=72 p50_ns=5616 p95_ns=9361 p99_ns=17472 +quant arm=idelta temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=idelta temp=cold cat=nov:recall count=99 p50_ns=5584 p95_ns=12112 p99_ns=36801 +quant arm=idelta temp=cold cat=nov:transfer count=198 p50_ns=5632 p95_ns=8816 p99_ns=12032 +quant arm=idelta temp=cold cat=nov:novel count=135 p50_ns=5632 p95_ns=9120 p99_ns=11088 +quant arm=idelta temp=cold cat=nov:fsm_recall count=198 p50_ns=5600 p95_ns=10785 p99_ns=218306 +quant arm=idelta temp=cold cat=nov:fsm_new count=234 p50_ns=5568 p95_ns=9952 p99_ns=17472 +quant arm=idelta temp=cold cat=fam:AGG count=432 p50_ns=5616 p95_ns=8961 p99_ns=12304 +quant arm=idelta temp=cold cat=fam:FSM count=432 p50_ns=5584 p95_ns=10288 p99_ns=21008 +quant arm=idelta temp=cold cat=n:64 count=288 p50_ns=5552 p95_ns=8928 p99_ns=14145 +quant arm=idelta temp=cold cat=n:512 count=288 p50_ns=5600 p95_ns=10032 p99_ns=36801 +quant arm=idelta temp=cold cat=n:4096 count=288 p50_ns=5632 p95_ns=10016 p99_ns=21008 +quant arm=idelta temp=warm cat=all count=26208 p50_ns=5520 p95_ns=6864 p99_ns=15456 +quant arm=idelta temp=warm cat=type:Z count=2232 p50_ns=5536 p95_ns=6928 p99_ns=14304 +quant arm=idelta temp=warm cat=type:S count=4536 p50_ns=5520 p95_ns=6816 p99_ns=17329 +quant arm=idelta temp=warm cat=type:D count=504 p50_ns=5648 p95_ns=7056 p99_ns=999897 +quant arm=idelta temp=warm cat=type:R count=4536 p50_ns=5520 p95_ns=7408 p99_ns=15104 +quant arm=idelta temp=warm cat=type:I count=4536 p50_ns=5536 p95_ns=6992 p99_ns=16960 +quant arm=idelta temp=warm cat=type:A count=4536 p50_ns=5504 p95_ns=6849 p99_ns=13984 +quant arm=idelta temp=warm cat=type:P count=792 p50_ns=5520 p95_ns=6656 p99_ns=12001 +quant arm=idelta temp=warm cat=type:C count=4536 p50_ns=5536 p95_ns=6144 p99_ns=13264 +quant arm=idelta temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=idelta temp=warm cat=nov:recall count=2709 p50_ns=5552 p95_ns=6976 p99_ns=11520 +quant arm=idelta temp=warm cat=nov:transfer count=5418 p50_ns=5520 p95_ns=7072 p99_ns=18849 +quant arm=idelta temp=warm cat=nov:novel count=4977 p50_ns=5520 p95_ns=6544 p99_ns=16528 +quant arm=idelta temp=warm cat=nov:fsm_recall count=5418 p50_ns=5504 p95_ns=6464 p99_ns=12880 +quant arm=idelta temp=warm cat=nov:fsm_new count=7686 p50_ns=5536 p95_ns=7008 p99_ns=16832 +quant arm=idelta temp=warm cat=fam:AGG count=13104 p50_ns=5520 p95_ns=6912 p99_ns=16352 +quant arm=idelta temp=warm cat=fam:FSM count=13104 p50_ns=5520 p95_ns=6769 p99_ns=14448 +quant arm=idelta temp=warm cat=n:64 count=8736 p50_ns=5520 p95_ns=6336 p99_ns=13473 +quant arm=idelta temp=warm cat=n:512 count=8736 p50_ns=5536 p95_ns=7184 p99_ns=16625 +quant arm=idelta temp=warm cat=n:4096 count=8736 p50_ns=5520 p95_ns=6896 p99_ns=15456 +quant arm=deltap temp=cold cat=all count=864 p50_ns=6016 p95_ns=9184 p99_ns=23984 +quant arm=deltap temp=cold cat=type:Z count=72 p50_ns=6064 p95_ns=11600 p99_ns=919817 +quant arm=deltap temp=cold cat=type:S count=72 p50_ns=5969 p95_ns=8336 p99_ns=24144 +quant arm=deltap temp=cold cat=type:D count=72 p50_ns=6048 p95_ns=7216 p99_ns=165362 +quant arm=deltap temp=cold cat=type:R count=72 p50_ns=6080 p95_ns=8784 p99_ns=62336 +quant arm=deltap temp=cold cat=type:I count=72 p50_ns=6096 p95_ns=8464 p99_ns=25872 +quant arm=deltap temp=cold cat=type:A count=72 p50_ns=5952 p95_ns=7280 p99_ns=102992 +quant arm=deltap temp=cold cat=type:P count=360 p50_ns=5968 p95_ns=7312 p99_ns=12752 +quant arm=deltap temp=cold cat=type:C count=72 p50_ns=6128 p95_ns=10752 p99_ns=24256 +quant arm=deltap temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=deltap temp=cold cat=nov:recall count=99 p50_ns=5968 p95_ns=7760 p99_ns=10336 +quant arm=deltap temp=cold cat=nov:transfer count=198 p50_ns=5985 p95_ns=8000 p99_ns=11904 +quant arm=deltap temp=cold cat=nov:novel count=135 p50_ns=6064 p95_ns=8752 p99_ns=165362 +quant arm=deltap temp=cold cat=nov:fsm_recall count=198 p50_ns=6032 p95_ns=10736 p99_ns=62336 +quant arm=deltap temp=cold cat=nov:fsm_new count=234 p50_ns=5984 p95_ns=10416 p99_ns=24256 +quant arm=deltap temp=cold cat=fam:AGG count=432 p50_ns=6000 p95_ns=8304 p99_ns=18352 +quant arm=deltap temp=cold cat=fam:FSM count=432 p50_ns=6016 p95_ns=10416 p99_ns=24256 +quant arm=deltap temp=cold cat=n:64 count=288 p50_ns=5984 p95_ns=9441 p99_ns=23984 +quant arm=deltap temp=cold cat=n:512 count=288 p50_ns=6016 p95_ns=8784 p99_ns=25872 +quant arm=deltap temp=cold cat=n:4096 count=288 p50_ns=6032 p95_ns=9728 p99_ns=18352 +quant arm=deltap temp=warm cat=all count=26208 p50_ns=5936 p95_ns=6560 p99_ns=14128 +quant arm=deltap temp=warm cat=type:Z count=2232 p50_ns=5952 p95_ns=9872 p99_ns=103729 +quant arm=deltap temp=warm cat=type:S count=4536 p50_ns=5920 p95_ns=6416 p99_ns=9568 +quant arm=deltap temp=warm cat=type:D count=504 p50_ns=6080 p95_ns=7184 p99_ns=23968 +quant arm=deltap temp=warm cat=type:R count=4536 p50_ns=5937 p95_ns=6464 p99_ns=13665 +quant arm=deltap temp=warm cat=type:I count=4536 p50_ns=5920 p95_ns=6432 p99_ns=22192 +quant arm=deltap temp=warm cat=type:A count=4536 p50_ns=5920 p95_ns=6464 p99_ns=12032 +quant arm=deltap temp=warm cat=type:P count=792 p50_ns=5920 p95_ns=6497 p99_ns=13216 +quant arm=deltap temp=warm cat=type:C count=4536 p50_ns=5920 p95_ns=6560 p99_ns=10560 +quant arm=deltap temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=deltap temp=warm cat=nov:recall count=2709 p50_ns=5936 p95_ns=6496 p99_ns=12112 +quant arm=deltap temp=warm cat=nov:transfer count=5418 p50_ns=5904 p95_ns=6384 p99_ns=9009 +quant arm=deltap temp=warm cat=nov:novel count=4977 p50_ns=5936 p95_ns=6464 p99_ns=10688 +quant arm=deltap temp=warm cat=nov:fsm_recall count=5418 p50_ns=5952 p95_ns=6800 p99_ns=77424 +quant arm=deltap temp=warm cat=nov:fsm_new count=7686 p50_ns=5920 p95_ns=6704 p99_ns=17376 +quant arm=deltap temp=warm cat=fam:AGG count=13104 p50_ns=5920 p95_ns=6432 p99_ns=10656 +quant arm=deltap temp=warm cat=fam:FSM count=13104 p50_ns=5936 p95_ns=6736 p99_ns=23424 +quant arm=deltap temp=warm cat=n:64 count=8736 p50_ns=5920 p95_ns=6464 p99_ns=14112 +quant arm=deltap temp=warm cat=n:512 count=8736 p50_ns=5936 p95_ns=6608 p99_ns=13056 +quant arm=deltap temp=warm cat=n:4096 count=8736 p50_ns=5936 p95_ns=6608 p99_ns=15248 +quant arm=select temp=cold cat=all count=864 p50_ns=6144 p95_ns=9248 p99_ns=19616 +quant arm=select temp=cold cat=type:Z count=72 p50_ns=6080 p95_ns=11648 p99_ns=11744 +quant arm=select temp=cold cat=type:S count=72 p50_ns=6128 p95_ns=8384 p99_ns=16112 +quant arm=select temp=cold cat=type:D count=72 p50_ns=6128 p95_ns=8064 p99_ns=9920 +quant arm=select temp=cold cat=type:R count=72 p50_ns=6224 p95_ns=15185 p99_ns=1003242 +quant arm=select temp=cold cat=type:I count=72 p50_ns=6224 p95_ns=8064 p99_ns=16928 +quant arm=select temp=cold cat=type:A count=72 p50_ns=6144 p95_ns=7457 p99_ns=18256 +quant arm=select temp=cold cat=type:P count=360 p50_ns=6096 p95_ns=9248 p99_ns=30721 +quant arm=select temp=cold cat=type:C count=72 p50_ns=6272 p95_ns=11377 p99_ns=16864 +quant arm=select temp=cold cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=select temp=cold cat=nov:recall count=99 p50_ns=6064 p95_ns=8160 p99_ns=16928 +quant arm=select temp=cold cat=nov:transfer count=198 p50_ns=6096 p95_ns=9024 p99_ns=358787 +quant arm=select temp=cold cat=nov:novel count=135 p50_ns=6177 p95_ns=8048 p99_ns=13408 +quant arm=select temp=cold cat=nov:fsm_recall count=198 p50_ns=6209 p95_ns=12976 p99_ns=36736 +quant arm=select temp=cold cat=nov:fsm_new count=234 p50_ns=6128 p95_ns=8337 p99_ns=11744 +quant arm=select temp=cold cat=fam:AGG count=432 p50_ns=6112 p95_ns=8384 p99_ns=16928 +quant arm=select temp=cold cat=fam:FSM count=432 p50_ns=6176 p95_ns=11088 p99_ns=19616 +quant arm=select temp=cold cat=n:64 count=288 p50_ns=6256 p95_ns=8688 p99_ns=16864 +quant arm=select temp=cold cat=n:512 count=288 p50_ns=6048 p95_ns=8288 p99_ns=18256 +quant arm=select temp=cold cat=n:4096 count=288 p50_ns=6160 p95_ns=11168 p99_ns=30721 +quant arm=select temp=warm cat=all count=26208 p50_ns=6016 p95_ns=7392 p99_ns=14096 +quant arm=select temp=warm cat=type:Z count=2232 p50_ns=5952 p95_ns=6464 p99_ns=9552 +quant arm=select temp=warm cat=type:S count=4536 p50_ns=6032 p95_ns=7168 p99_ns=11408 +quant arm=select temp=warm cat=type:D count=504 p50_ns=6160 p95_ns=7712 p99_ns=19808 +quant arm=select temp=warm cat=type:R count=4536 p50_ns=6032 p95_ns=7904 p99_ns=20529 +quant arm=select temp=warm cat=type:I count=4536 p50_ns=6000 p95_ns=6992 p99_ns=11632 +quant arm=select temp=warm cat=type:A count=4536 p50_ns=6048 p95_ns=8000 p99_ns=14464 +quant arm=select temp=warm cat=type:P count=792 p50_ns=5952 p95_ns=7568 p99_ns=14704 +quant arm=select temp=warm cat=type:C count=4536 p50_ns=6016 p95_ns=7712 p99_ns=15296 +quant arm=select temp=warm cat=nov:none count=0 p50_ns=na p95_ns=na p99_ns=na +quant arm=select temp=warm cat=nov:recall count=2709 p50_ns=5952 p95_ns=8160 p99_ns=13120 +quant arm=select temp=warm cat=nov:transfer count=5418 p50_ns=5968 p95_ns=6704 p99_ns=10704 +quant arm=select temp=warm cat=nov:novel count=4977 p50_ns=5968 p95_ns=6800 p99_ns=12736 +quant arm=select temp=warm cat=nov:fsm_recall count=5418 p50_ns=6096 p95_ns=7680 p99_ns=17776 +quant arm=select temp=warm cat=nov:fsm_new count=7686 p50_ns=6064 p95_ns=7665 p99_ns=14208 +quant arm=select temp=warm cat=fam:AGG count=13104 p50_ns=5968 p95_ns=7168 p99_ns=12176 +quant arm=select temp=warm cat=fam:FSM count=13104 p50_ns=6080 p95_ns=7680 p99_ns=15568 +quant arm=select temp=warm cat=n:64 count=8736 p50_ns=6160 p95_ns=7424 p99_ns=14432 +quant arm=select temp=warm cat=n:512 count=8736 p50_ns=5968 p95_ns=7232 p99_ns=12928 +quant arm=select temp=warm cat=n:4096 count=8736 p50_ns=5969 p95_ns=7664 p99_ns=14688 +full_ns_per_step=NOT_RECORDED reason=raw_logs_carry_no_reference_timing +control id=C1 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C1b records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C1c records=1 detected=1 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C2 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C3 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C4 records=1 detected=1 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C5 records=6 detected=6 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C6 records=3 detected=3 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C7 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C8 records=9 detected=9 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C9 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C10 records=2 detected=2 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C11 records=1 detected=1 undetected=0 reported=0 not_run=0 served_tampered=0 missing_pairs=0 +control id=C12 records=1 detected=0 undetected=0 reported=1 not_run=0 served_tampered=0 missing_pairs=0 +issue742 transfer_coverage_ppm=1000000 bind_failures=NOT_RECORDED route5_method=0 route5_delta=0 restart_identity=detected C1=detected C1b=detected C1c=detected C2=detected C3=detected C6=detected C7=detected C8=detected C9=detected C10=detected C11=detected +issue743 delta_over_method point_ppm=954985 lo_ppm=854391 hi_ppm=1078713 idelta_over_full point_ppm=750715 lo_ppm=650013 hi_ppm=867141 C4=detected C8=detected +issue744 select_over_delta point_ppm=859396 lo_ppm=758743 hi_ppm=956712 matched_correctness=yes verdict=helps +reason=rho_delta_lower_ge_1 +reason=rho_delta_upper_ge_1 +reason=delta_over_idelta_upper_ge_1 +decision=STOP +verdicts source=REVIEW_REQUIRED host=STOP simulator=NOT_RUN physical=NOT_RUN diff --git a/evidence/REUSE-73/final/turing.txt b/evidence/REUSE-73/final/turing.txt new file mode 100644 index 0000000..05109dc --- /dev/null +++ b/evidence/REUSE-73/final/turing.txt @@ -0,0 +1,26 @@ +report=reuse1-turing version=1 profile=Turing-profile-REUSE-v1.0 +profile_sha256=8558b4070128a86e1df6538f996b522c0db40ca8fc284f165a88c9d6372264c4 dataset_sha256=1ce74aa2f9057af27fb66513d11ad7b5af0326093526198c1b69c10cd6f78f04 n=9024 k=16 tsy1_trailer=fb95ccafea97223b54cb093c309b4dfe736a91648e51b67efc4ddeee3d9313b2 +model name=B model_sha256=ebd1d64d37e8336d67d58085f17dec8bfca2c3295e473d5be960883839610204 tps1_trailer=520c97721a5cf32c84f7e9ddef41e93acb36e3a56f6e7032f608ba5178eee635 +model name=M1 model_sha256=cf703c2f76d8e4e8ebe618d0114a5a196b092b1be9f1594fa8d5d697e70f47b4 tps1_trailer=201fca0d1bf5957d48dddd3f41acbf4de20b27c92c2cb3ab3407b0c3c7a57969 generation=1 k_templates=16 calibration=yes gen_om_bytes=111472 base_om_bytes=103401 +model name=M2 model_sha256=5614aa684c5ca4e8bce9fc20bbec3afc03730a20069e4b9cef4d9a670c81901d tps1_trailer=1d4e56979abe9b5065daba813be1220fe1d8e7037e40961057518237872eb7e2 generation=1 k_templates=16 calibration=no gen_om_bytes=111139 base_om_bytes=103401 +data ideal_ub=2977920 ub_per_symbol=330 +coded model=B coder=rans bytes=60 overhead_ub=477022080 h1=PASS +coded model=B coder=range bytes=60 overhead_ub=477022080 h1=PASS +coded model=M1 coder=rans bytes=60 overhead_ub=477022080 h1=PASS +coded model=M1 coder=range bytes=60 overhead_ub=477022080 h1=PASS +coded model=M2 coder=rans bytes=60 overhead_ub=477022080 h1=PASS +coded model=M2 coder=range bytes=60 overhead_ub=477022080 h1=PASS +h1_all=PASS +charge arm=method p1_bits=8192 p2_bits=80952 +turing arm=method t_ideal_p1_bits=-8192 t_real_p1_bits_rans=-8192 t_real_p1_bits_range=-8192 t_ideal_p2_bits=-80952 t_real_p2_bits_rans=-80952 t_real_p2_bits_range=-80952 +charge arm=delta p1_bits=8192 p2_bits=80952 +turing arm=delta t_ideal_p1_bits=-8192 t_real_p1_bits_rans=-8192 t_real_p1_bits_range=-8192 t_ideal_p2_bits=-80952 t_real_p2_bits_rans=-80952 t_real_p2_bits_range=-80952 +charge arm=select p1_bits=20544 p2_bits=80952 +turing arm=select t_ideal_p1_bits=-20544 t_real_p1_bits_rans=-20544 t_real_p1_bits_range=-20544 t_ideal_p2_bits=-80952 t_real_p2_bits_rans=-80952 t_real_p2_bits_range=-80952 +charge arm=deltap p1_bits=8192 p2_bits=78288 +turing arm=deltap t_ideal_p1_bits=-8192 t_real_p1_bits_rans=-8192 t_real_p1_bits_range=-8192 t_ideal_p2_bits=-78288 t_real_p2_bits_rans=-78288 t_real_p2_bits_range=-78288 +charge arm=idelta p1_bits=0 p2_bits=0 +turing arm=idelta t_ideal_p1_bits=0 t_real_p1_bits_rans=0 t_real_p1_bits_range=0 t_ideal_p2_bits=0 t_real_p2_bits_rans=0 t_real_p2_bits_range=0 +charge arm=cache p1_bits=0 p2_bits=0 +turing arm=cache t_ideal_p1_bits=0 t_real_p1_bits_rans=0 t_real_p1_bits_range=0 t_ideal_p2_bits=0 t_real_p2_bits_rans=0 t_real_p2_bits_range=0 +delta_t=NOT_APPLICABLE reason=one_library_generation_per_arm verdict=none diff --git a/om/reuse-eval/gen.om b/om/reuse-eval/gen.om new file mode 100644 index 0000000..e6f5c49 --- /dev/null +++ b/om/reuse-eval/gen.om @@ -0,0 +1,1503 @@ +note SPDX-License-Identifier: Apache-2.0 +note gen.om: the REUSE-1 workload generator of the evaluator (docs/reuse/REUSE-1.md v1.0 section 7, +note /tmp/reuse/EVAL-FORMATS.md layout, integrator clarifications K2, K6, K8). +note Units before it: sha256, ref. Prefix gn / GN. Holds fn main. +note +note gen SPLIT OUTDIR [SEEDHEX] +note SPLIT: TRAIN (id 1), CALIB (2), DEV (3), FINAL (4), TRAINP (5). SEEDHEX (64 hex characters, the +note 32-byte FINAL seed) is required for FINAL and refused otherwise; the FINAL generator seed is its +note bytes 8..15 read little endian. Public seeds: TRAIN 1001, TRAINP 1002, CALIB 1003, DEV 1004. +note Writes OUTDIR/index, OUTDIR/sessions, OUTDIR/gNN.req, OUTDIR/gNN.exp (OUTDIR is created when +note missing), prints one summary line. Exit 0 ok, 2 usage, 3 file error, 4 generation failure +note (a reference status other than 0, or an impossible draw such as no MIN/MAX shape for type A). +note +note Randomness: splitmix64 only. Each purpose has its own stream, seeded with +note sub(seed, tag) = mix(seed + tag * 0x9E3779B97F4A7C15) (mix = the splitmix64 finalizer): +note tag 1 shape pool, 2 TRAIN list (machines, session programs, n), 3 composition (programs and the +note dealing permutation of FINAL, DEV and CALIB), 4 data (states and changes, in request order). +note A draw below m is the next output mod m (bias below m / 2^64, at most 2^-51 here). +note +note Splits (contract 7; K8 a..h): +note - shape pool: 24 distinct AGG shapes (wl 8 or 16, f 1..6, k 1..6, ops 1..8) drawn from the +note TRAIN seed; TRAINP's 24 are drawn from 1002 and exclude TRAIN's. Pool rank r has weight +note L / (r + 1), L = lcm(1..24) = 5354228880, so the weights are exactly 1 / (rank + 1). +note - TRAIN / TRAINP: 240 sessions in generation order, session s is FSM iff s mod 6 = 5; 10 machines +note (0..4 general, 5..9 permutation machines), FSM session number f uses machine f mod 10; AGG +note session number j reuses a uniformly chosen earlier AGG program exactly iff j mod 4 = 3, else a +note pool shape by weight with new constants; n uniform in {64, 512, 4096}; BEGIN + 8 x (SET, QUERY). +note - FINAL / DEV: 2 families x 8 types x 3 n x 4 = 192 sessions, dealt into 24 groups of 8 by a +note seeded permutation. AGG types Z..P: 1 recall (a TRAIN AGG program), 2 transfer (a TRAIN pool +note shape by weight, new constants, not equal to any TRAIN program), 1 novel (a shape outside both +note pools); C: 4 novel; type A only uses f MIN or MAX (fails when TRAIN has none). FSM: 2 recall +note (TRAIN machines), 2 new; type C 4 new; type A permutation machines (recall from machines 5..9). +note Bodies: Z 32 QUERY; S and C 64 (SET, QUERY); D 8 (BATCH of 1024 SET, QUERY); R 64 (SWAP, +note QUERY); I 64 (DEL, INS alternating from DEL, QUERY); A AGG 64 (DEL of the first index whose +note mapped value is the current fold result, INS of a random value at a random index, QUERY); +note A FSM 64 (SET at index 0 to a symbol whose transition from s0 differs from the current one, +note QUERY); P 16 QUERY with a PROGRAM before QUERY 4, 8, 12, 16 (AGG same shape new constants, +note FSM same S and A new s0, lambda and rules). +note - CALIB: 2 families x 3 n x 4 change classes x 4 = 96 sessions, dealt into 12 groups of 8; each +note BEGIN + 16 x (change, QUERY), change = none (type Z), one SET (S), BATCH of 2..64 SET (D) or +note BATCH of 1024 SET (D); AGG programs = pool shapes by weight with new constants, FSM general. +note Every expected response is ref.om's (rfreq); any status other than 0 fails the run (exit 4). +note Permutation machines: S 4..8, A 4..16, the alphabet cut into 2 or 3 intervals; interval 0 is a +note rotation by 1..S-1, the others random permutations; one rule (s, lo, hi, pi(s)) per moved +note state, so every symbol's transition is a permutation of the states; s0 must have two +note different successors (redrawn otherwise), so a SET at index 0 can always change q_1. + +global GNRS ulong 4 +global GNTP ulong 24 +global GNPP ulong 24 +global GNLM ulong 640 +global GNLP ulong 15360 +global GNLF ulong 240 +global GNLN ulong 240 +global GNLA ulong 240 +global GNPG ulong 64 +global GNSP ulong 15360 +global GNSM ulong 1920 +global GNSO ulong 240 +global GNSS ulong 3840 +global GNOB uchar 16777216 +global GNEB uchar 4194304 +global GNWB uchar 65536 +global GNPA uchar 4096 +global GNAR uchar 4096 +global GNCT ulong 32 +global GNGR ulong 100 +global GNFD long 4 +text gntsess "/sessions" +text gntidx "/index" +text gnemm "gen: type A needs a MIN or MAX program and the TRAIN pool or list has none\n" +text gneus "usage: gen TRAIN|TRAINP|CALIB|DEV|FINAL OUTDIR [SEEDHEX (FINAL only)]\n" +text gneio "gen: file error\n" +text gnegen "gen: generation failure\n" + +note GNCT: 0 exit code, 1 split id, 2 session count, 3 group count, 4 OUTDIR length, 5 GNOB fill, +note 6 GNEB fill, 7 requests, 8 QUERYs, 9 request index in group, 10 session requests, +note 11 session QUERYs, 12 cold pending, 13 session ordinal, 14 seed, 15 GNWB fill, +note 16 TRAIN pool MIN/MAX shapes + +note ---- splitmix64 ---- + +fn gnmix z ulong to ulong +a = mul xor z shr z 30 13787848793156543929 +b = mul xor a shr a 27 10723151780598845931 +ret xor b shr b 31 +end + +fn gnsub seed ulong tag ulong to ulong +ret gnmix add seed mul tag 11400714819323198485 +end + +fn gnrnd k ulong to ulong +s = add get GNRS k 11400714819323198485 +put GNRS k s +ret gnmix s +end + +fn gnbelow k ulong m ulong to ulong +ret rem gnrnd k m +end + +fn gnfail code ulong to void +if eq get GNCT 0 0 +put GNCT 0 code +end +end + +note ---- shapes and programs ---- + +fn gnshape k ulong fsel ulong to ulong +wl = ulong 8 +if eq gnbelow k 2 1 +wl = 16 +end +f = ulong 0 +if eq fsel 1 +f = add 3 gnbelow k 2 +else +f = add 1 gnbelow k 6 +end +kk = add 1 gnbelow k 6 +s = add add wl mul 256 f mul 4096 kk +m = ulong 65536 +for j ulong kk +s = add s mul m add 1 gnbelow k 8 +m = mul m 16 +end +ret s +end + +fn gnfok s ulong fsel ulong to bool +if eq fsel 0 +ret true +end +f = and shr s 8 15 +ret or eq f 3 eq f 4 +end + +fn gnclrpg fam ulong to void +for i ulong 64 +put GNPG i 0 +end +put GNPG 0 3544411312749556050 +put GNPG 1 fam +end + +fn gnconst k ulong wl ulong op ulong to ulong +if ge op 7 +ret gnbelow k wl +end +ret gnbelow k shl ulong 1 wl +end + +note an AGG program of shape s with random constants into GNPG +fn gnprog s ulong k ulong to void +gnclrpg 1 +wl = and s 255 +put GNPG 2 wl +put GNPG 3 and shr s 8 15 +kk = and shr s 12 15 +put GNPG 4 kk +for j ulong kk +op = and shr s add 16 mul j 4 15 +c = gnconst k wl op +put GNPG add 5 mul j 2 op +put GNPG add 6 mul j 2 c +end +end + +fn gnrule k ulong s ulong a ulong to ulong +rs = gnbelow k s +x = gnbelow k a +y = gnbelow k a +t = gnbelow k s +if gt x y +z = x +x = y +y = z +end +ret add add rs shl x 8 add shl y 16 shl t 24 +end + +note a general FSM into GNPG; sa, aa = 0 draw S, A, otherwise keep them +fn gnmach k ulong sa ulong aa ulong to void +gnclrpg 2 +s = sa +if eq s 0 +s = add 2 gnbelow k 15 +end +a = aa +if eq a 0 +a = add 2 gnbelow k 15 +end +put GNPG 2 s +put GNPG 3 a +put GNPG 4 gnbelow k s +r = add 1 gnbelow k 24 +put GNPG 5 r +for i ulong s +put GNPG add 6 i gnbelow k 256 +end +for j ulong r +put GNPG add 22 j gnrule k s a +end +end + +fn gnaddr r ulong st ulong lo ulong hi ulong t ulong to ulong +w = add add st shl lo 8 add shl hi 16 shl t 24 +put GNPG add 22 r w +ret add r 1 +end + +note symbols lo..hi: a random permutation of the S states, one rule per moved state +fn gnpint k ulong s ulong lo ulong hi ulong r ulong to ulong +p = new ulong 16 0 +for i ulong s +put p i i +end +j = s +while gt j 1 bound 16 +u = gnbelow k j +j = sub j 1 +t = get p j +put p j get p u +put p u t +end +rr = r +for st ulong s +if ne get p st st +rr = gnaddr rr st lo hi get p st +end +end +ret rr +end + +note FSM transition of the machine in GNPG (the rule order of contract 1.2) +fn gndel s ulong a ulong to ulong +r = get GNPG 5 +for i ulong r +w = get GNPG add 22 i +if eq and w 255 s +lo = and shr w 8 255 +hi = and shr w 16 255 +if and le lo a le a hi +ret shr w 24 +end +end +end +ret s +end + +fn gnpermok to bool +s0 = get GNPG 4 +a = get GNPG 3 +i0 = gndel s0 0 +for x ulong a +if ne gndel s0 x i0 +ret true +end +end +ret false +end + +fn gnperm1 k ulong to void +gnclrpg 2 +s = add 4 gnbelow k 5 +a = add 4 gnbelow k 13 +put GNPG 2 s +put GNPG 3 a +put GNPG 4 gnbelow k s +for i ulong s +put GNPG add 6 i gnbelow k 256 +end +b1 = add 1 gnbelow k sub a 1 +b2 = a +if eq gnbelow k 2 1 +c = add 1 gnbelow k sub a 1 +while eq c b1 bound 999 +c = add 1 gnbelow k sub a 1 +end +if lt c b1 +b2 = b1 +b1 = c +else +b2 = c +end +end +rot = add 1 gnbelow k sub s 1 +r = ulong 0 +for st ulong s +r = gnaddr r st 0 sub b1 1 rem add st rot s +end +r = gnpint k s b1 sub b2 1 r +if lt b2 a +r = gnpint k s b2 sub a 1 r +end +put GNPG 5 r +end + +note a permutation machine into GNPG: 0 ok, 1 none found +fn gnperm k ulong to ulong +for t ulong 64 +gnperm1 k +if gnpermok +ret 0 +end +end +ret 1 +end + +note ---- pools and the TRAIN / TRAINP list ---- + +fn gnpget which ulong r ulong to ulong +if eq which 1 +ret get GNTP r +end +ret get GNPP r +end + +fn gnphas which ulong s ulong cnt ulong to bool +for i ulong cnt +if eq gnpget which i s +ret true +end +end +ret false +end + +fn gnpool which ulong to void +seed = ulong 1001 +if eq which 5 +seed = 1002 +end +put GNRS 0 gnsub seed 1 +i = ulong 0 +while lt i 24 bound 99999 +s = gnshape 0 0 +ok = not gnphas which s i +if eq which 5 +if gnphas 1 s 24 +ok = false +end +end +if ok +if eq which 1 +put GNTP i s +else +put GNPP i s +end +i = add i 1 +end +end +end + +note a pool shape by weight 1 / (rank + 1), restricted by fsel; 0 when none qualifies +fn gnpick which ulong fsel ulong k ulong to ulong +tot = ulong 0 +for r ulong 24 +if gnfok gnpget which r fsel +tot = add tot div 5354228880 add r 1 +end +end +if eq tot 0 +ret 0 +end +u = gnbelow k tot +for q ulong 24 +s = gnpget which q +if gnfok s fsel +w = div 5354228880 add q 1 +if lt u w +ret s +end +u = sub u w +end +end +ret 0 +end + +fn gncplm i ulong to void +for j ulong 64 +put GNLM add mul i 64 j get GNPG j +end +end + +fn gncplp s ulong to void +for j ulong 64 +put GNLP add mul s 64 j get GNPG j +end +end + +fn gnlpto d ulong s ulong to void +for j ulong 64 +put GNLP add mul d 64 j get GNLP add mul s 64 j +end +end + +fn gnlmto d ulong i ulong to void +for j ulong 64 +put GNLP add mul d 64 j get GNLM add mul i 64 j +end +end + +fn gnnsize k ulong to ulong +u = gnbelow k 3 +if eq u 0 +ret 64 +end +if eq u 1 +ret 512 +end +ret 4096 +end + +note the 240 sessions of TRAIN (which 1) or TRAINP (5) into GNLP, GNLF, GNLN; machines into GNLM +fn gnlist which ulong to void +seed = ulong 1001 +if eq which 5 +seed = 1002 +end +put GNRS 0 gnsub seed 2 +for i ulong 10 +if lt i 5 +gnmach 0 0 0 +else +if ne gnperm 0 0 +gnfail 4 +ret +end +end +gncplm i +end +na = ulong 0 +for s ulong 240 +put GNLN s gnnsize 0 +if eq rem s 6 5 +put GNLF s 2 +gnlmto s rem div s 6 10 +else +put GNLF s 1 +if eq rem na 4 3 +e = gnbelow 0 na +gnlpto s get GNLA e +else +gnprog gnpick which 0 0 0 +gncplp s +end +put GNLA na s +na = add na 1 +end +end +end + +note ---- FINAL / DEV composition ---- + +fn gnlpeq s ulong to bool +for j ulong 64 +if ne get GNPG j get GNLP add mul s 64 j +ret false +end +end +ret true +end + +fn gnlmeq i ulong to bool +for j ulong 64 +if ne get GNPG j get GNLM add mul i 64 j +ret false +end +end +ret true +end + +fn gnintr to bool +for s ulong 240 +if eq get GNLF s 1 +if gnlpeq s +ret true +end +end +end +ret false +end + +fn gninmach to bool +for i ulong 10 +if gnlmeq i +ret true +end +end +ret false +end + +note recall: a uniformly chosen TRAIN AGG session program (f filtered) into GNPG; 1 if none +fn gnrecall fsel ulong to ulong +cnt = ulong 0 +for s ulong 240 +if eq get GNLF s 1 +if gnfokf get GNLP add mul s 64 3 fsel +cnt = add cnt 1 +end +end +end +if eq cnt 0 +ret 1 +end +u = gnbelow 0 cnt +for t ulong 240 +if eq get GNLF t 1 +if gnfokf get GNLP add mul t 64 3 fsel +if eq u 0 +for j ulong 64 +put GNPG j get GNLP add mul t 64 j +end +ret 0 +end +u = sub u 1 +end +end +end +ret 1 +end + +note note: gnfok reads f from bits 8..11 of a shape id; for a PROG word 3 (f itself) use gnfokf +fn gnfokf f ulong fsel ulong to bool +if eq fsel 0 +ret true +end +ret or eq f 3 eq f 4 +end + +note shape id of the AGG program in GNLP row s (contract 1.1) +fn gnrowsh s ulong to ulong +b = mul s 64 +k = get GNLP add b 4 +v = add get GNLP add b 2 mul 256 get GNLP add b 3 +v = add v mul 4096 k +m = ulong 65536 +for j ulong k +v = add v mul m get GNLP add b add 5 mul j 2 +m = mul m 16 +end +ret v +end + +note a shape is seen when some TRAIN AGG session program has it +fn gnseen sh ulong to bool +for s ulong 240 +if eq get GNLF s 1 +if eq gnrowsh s sh +ret true +end +end +end +ret false +end + +note transfer: a TRAIN pool shape by weight that TRAIN sessions used, new constants that equal +note no TRAIN program; 1 when none is found +fn gntransf fsel ulong to ulong +for a ulong 64 +s = gnpick 1 fsel 0 +if eq s 0 +ret 1 +end +if gnseen s +for b ulong 64 +gnprog s 0 +if not gnintr +ret 0 +end +end +end +end +ret 1 +end + +fn gnnovel fsel ulong to ulong +for a ulong 99999 +s = gnshape 0 fsel +if not or gnphas 1 s 24 gnphas 5 s 24 +gnprog s 0 +ret 0 +end +end +ret 1 +end + +fn gnfsmnew adv ulong to ulong +for a ulong 999 +if eq adv 1 +if ne gnperm 0 0 +ret 1 +end +else +gnmach 0 0 0 +end +if not gninmach +ret 0 +end +end +ret 1 +end + +fn gnfsmold adv ulong to void +i = gnbelow 0 10 +if eq adv 1 +i = add 5 gnbelow 0 5 +end +for j ulong 64 +put GNPG j get GNLM add mul i 64 j +end +end + +fn gnsetsp c ulong fam ulong typ ulong nov ulong n ulong body ulong to void +for j ulong 64 +put GNSP add mul c 64 j get GNPG j +end +b = mul c 8 +put GNSM b fam +put GNSM add b 1 typ +put GNSM add b 2 nov +put GNSM add b 3 n +put GNSM add b 4 body +end + +fn gnnof i ulong to ulong +if eq i 0 +ret 64 +end +if eq i 1 +ret 512 +end +ret 4096 +end + +note one FINAL / DEV session of the composition: 0 ok, else failure +fn gncsess c ulong fam ulong typ ulong n ulong j ulong to ulong +adv = ulong 0 +if eq typ 6 +adv = 1 +end +nov = ulong 0 +st = ulong 0 +if eq fam 1 +nov = 2 +if eq j 0 +nov = 1 +end +if or eq j 3 eq typ 8 +nov = 3 +end +if eq nov 1 +st = gnrecall adv +end +if eq nov 2 +st = gntransf adv +end +if eq nov 3 +st = gnnovel adv +end +else +nov = 4 +if or ge j 2 eq typ 8 +nov = 5 +end +if eq nov 4 +gnfsmold adv +else +st = gnfsmnew adv +end +end +gnsetsp c fam typ nov n typ +ret st +end + +fn gndeal cnt ulong to void +for i ulong cnt +put GNSO i i +end +j = cnt +while gt j 1 bound 240 +u = gnbelow 0 j +j = sub j 1 +t = get GNSO j +put GNSO j get GNSO u +put GNSO u t +end +end + +fn gncomp to void +put GNRS 0 gnsub get GNCT 14 3 +for c ulong 192 +fam = add 1 div c 96 +typ = add 1 rem div c 12 8 +n = gnnof rem div c 4 3 +st = gncsess c fam typ n rem c 4 +if ne st 0 +x = write 2 gnemm 0 len gnemm +gnfail 4 +ret +end +end +gndeal 192 +put GNCT 2 192 +end + +fn gncalib to void +put GNRS 0 gnsub get GNCT 14 3 +for c ulong 96 +fam = add 1 div c 48 +n = gnnof rem div c 16 3 +cc = rem div c 4 4 +if eq fam 1 +gnprog gnpick 1 0 0 0 +else +gnmach 0 0 0 +end +typ = ulong 3 +if eq cc 0 +typ = 1 +end +if eq cc 1 +typ = 2 +end +gnsetsp c fam typ 0 n add 10 cc +end +gndeal 96 +put GNCT 2 96 +end + +fn gnfromls to void +for s ulong 240 +for j ulong 64 +put GNPG j get GNLP add mul s 64 j +end +gnsetsp s get GNLF s 2 0 get GNLN s 9 +put GNSO s s +end +put GNCT 2 240 +end + +note ---- output buffers and files ---- + +fn gnpb x ulong to void +o = get GNCT 5 +v = x +for i ulong 8 +put GNOB add o i uchar and v 255 +v = shr v 8 +end +put GNCT 5 add o 8 +end + +fn gnpe x ulong to void +o = get GNCT 6 +v = x +for i ulong 8 +put GNEB add o i uchar and v 255 +v = shr v 8 +end +put GNCT 6 add o 8 +end + +fn gnpw x ulong to void +o = get GNCT 15 +v = x +for i ulong 8 +put GNWB add o i uchar and v 255 +v = shr v 8 +end +put GNCT 15 add o 8 +end + +fn gnwrob n ulong to void +fd = int get GNFD 0 +off = ulong 0 +while lt off n bound 99999 +r = write fd GNOB off sub n off +if le r 0 +gnfail 3 +ret +end +off = add off ulong r +end +end + +fn gnwreb n ulong to void +fd = int get GNFD 1 +off = ulong 0 +while lt off n bound 99999 +r = write fd GNEB off sub n off +if le r 0 +gnfail 3 +ret +end +off = add off ulong r +end +end + +fn gnwrwb n ulong to void +fd = int get GNFD 2 +off = ulong 0 +while lt off n bound 99999 +r = write fd GNWB off sub n off +if le r 0 +gnfail 3 +ret +end +off = add off ulong r +end +end + +note request bytes: absorbed into the holdout digest (slot 1) in file order, then written +fn gnflreq to void +n = get GNCT 5 +off = ulong 0 +while lt off n bound 999 +k = sub n off +if gt k 65536 +k = 65536 +end +for i ulong k +put RFHB i get GNOB add off i +end +rfhabs 1 k +off = add off k +end +gnwrob n +put GNCT 5 0 +end + +fn gnflexp to void +gnwreb get GNCT 6 +put GNCT 6 0 +end + +fn gngpath g ulong ext ulong to ulong +l = get GNCT 4 +put GNPA l 47 +put GNPA add l 1 103 +put GNPA add l 2 uchar add 48 div g 10 +put GNPA add l 3 uchar add 48 rem g 10 +put GNPA add l 4 46 +if eq ext 0 +put GNPA add l 5 114 +put GNPA add l 6 101 +put GNPA add l 7 113 +else +put GNPA add l 5 101 +put GNPA add l 6 120 +put GNPA add l 7 112 +end +ret add l 8 +end + +fn gnopen slot ulong pl ulong to void +fd = fopen GNPA 0 pl 577 420 +if lt fd 0 +gnfail 3 +fd = -1 +end +put GNFD slot fd +end + +fn gnclose slot ulong to void +fd = int get GNFD slot +if ge fd 0 +r = fclose fd +if ne r 0 +gnfail 3 +end +end +put GNFD slot -1 +end + +note ---- requests ---- + +note send RFRQ: append the frame, run the reference, append the 8-word expected record +fn gnemit to void +op = get RFRQ 0 +w = add get RFRQ 1 2 +for i ulong w +gnpb get RFRQ i +end +st = rfreq +if ne st 0 +gnfail 4 +end +cold = ulong 0 +if eq op 2 +if eq get GNCT 12 1 +cold = 1 +put GNCT 12 0 +end +put GNCT 8 add get GNCT 8 1 +put GNCT 11 add get GNCT 11 1 +end +if or eq op 1 eq op 8 +put GNCT 12 1 +end +gnpe ulong st +gnpe get RFRS 1 +gnpe get RFRS 2 +gnpe get RFRS 3 +gnpe op +gnpe get GNCT 13 +gnpe cold +gnpe 0 +put GNCT 7 add get GNCT 7 1 +put GNCT 9 add get GNCT 9 1 +put GNCT 10 add get GNCT 10 1 +if gt get GNCT 5 16646144 +gnflreq +end +if gt get GNCT 6 4194240 +gnflexp +end +end + +fn gnq to void +put RFRQ 0 2 +put RFRQ 1 0 +gnemit +end + +fn gnc2 op ulong a ulong b ulong to void +put RFRQ 0 op +put RFRQ 1 2 +put RFRQ 2 a +put RFRQ 3 b +gnemit +end + +fn gnc1 op ulong a ulong to void +put RFRQ 0 op +put RFRQ 1 1 +put RFRQ 2 a +gnemit +end + +fn gnset to void +n = get RFN 0 +d = rfdom +i = gnbelow 1 n +gnc2 3 i gnbelow 1 d +end + +fn gnbset m ulong to void +put RFRQ 0 7 +put RFRQ 1 add 1 mul 3 m +put RFRQ 2 m +n = get RFN 0 +d = rfdom +for i ulong m +b = add 3 mul i 3 +put RFRQ b 3 +put RFRQ add b 1 gnbelow 1 n +put RFRQ add b 2 gnbelow 1 d +end +gnemit +end + +note BEGIN with the session's program (GNSP row c) and n random values of its domain +fn gnbegin c ulong n ulong to void +put RFRQ 0 1 +put RFRQ 1 add n 65 +for j ulong 64 +put RFRQ add j 2 get GNSP add mul c 64 j +end +d = get GNSP add mul c 64 3 +if eq get GNSP add mul c 64 1 1 +d = shl ulong 1 get GNSP add mul c 64 2 +end +put RFRQ 66 n +for i ulong n +put RFRQ add 67 i gnbelow 1 d +end +gnemit +end + +fn gnbs to void +for i ulong 64 +gnset +gnq +end +end + +fn gnbr to void +for i ulong 64 +n = get RFN 0 +a = gnbelow 1 n +gnc2 6 a gnbelow 1 n +gnq +end +end + +fn gnbi to void +for i ulong 64 +n = get RFN 0 +if eq rem i 2 0 +gnc1 5 gnbelow 1 n +else +a = gnbelow 1 add n 1 +gnc2 4 a gnbelow 1 rfdom +end +gnq +end +end + +fn gnextr to ulong +rffull +ex = get RFR 0 +n = get RFN 0 +for i ulong n +if eq rflane get RFX i ex +ret i +end +end +gnfail 4 +ret 0 +end + +fn gnbaagg to void +for it ulong 64 +gnc1 5 gnextr +n = get RFN 0 +a = gnbelow 1 add n 1 +gnc2 4 a gnbelow 1 rfdom +gnq +end +end + +fn gnbafsm to void +for it ulong 64 +s0 = get RFP 4 +a = get RFP 3 +cur = rfdelta s0 get RFX 0 +cnt = ulong 0 +for x ulong a +if ne rfdelta s0 x cur +cnt = add cnt 1 +end +end +if eq cnt 0 +gnfail 4 +ret +end +u = gnbelow 1 cnt +v = ulong 0 +for y ulong a +if ne rfdelta s0 y cur +if eq u 0 +v = y +end +u = sub u 1 +end +end +gnc2 3 0 v +gnq +end +end + +fn gnrfpeq to bool +for j ulong 64 +if ne get GNPG j get RFP j +ret false +end +end +ret true +end + +note a PROGRAM for rule drift into RFRQ: same shape new constants, or same S and A new rules +fn gnnewp to void +for t ulong 64 +if eq get RFP 1 1 +gnprog rfshape 1 +else +gnmach 1 get RFP 2 get RFP 3 +end +if not gnrfpeq +put RFRQ 0 8 +put RFRQ 1 64 +for j ulong 64 +put RFRQ add j 2 get GNPG j +end +gnemit +ret +end +end +gnfail 4 +end + +fn gnbp to void +for i ulong 16 +if eq rem i 4 3 +gnnewp +end +gnq +end +end + +fn gnbody body ulong fam ulong to void +if eq body 1 +for i ulong 32 +gnq +end +ret +end +if or eq body 2 eq body 8 +gnbs +ret +end +if eq body 3 +for j ulong 8 +gnbset 1024 +gnq +end +ret +end +if eq body 4 +gnbr +ret +end +if eq body 5 +gnbi +ret +end +if eq body 6 +if eq fam 1 +gnbaagg +else +gnbafsm +end +ret +end +if eq body 7 +gnbp +ret +end +if eq body 9 +for t ulong 8 +gnset +gnq +end +ret +end +for q ulong 16 +if eq body 11 +gnset +end +if eq body 12 +gnbset add 2 gnbelow 1 63 +end +if eq body 13 +gnbset 1024 +end +gnq +end +end + +fn gnsess pos ulong to void +c = get GNSO pos +b = mul c 8 +fam = get GNSM b +n = get GNSM add b 3 +put GNCT 13 pos +put GNCT 10 0 +put GNCT 11 0 +r = mul pos 16 +put GNSS r pos +put GNSS add r 14 get GNCT 9 +gnbegin c n +put GNSS add r 1 div pos 8 +put GNSS add r 2 fam +put GNSS add r 3 get GNSM add b 1 +put GNSS add r 4 get GNSM add b 2 +nc = ulong 2 +if le n 512 +nc = 1 +end +if le n 64 +nc = 0 +end +put GNSS add r 5 nc +put GNSS add r 6 n +put GNSS add r 7 rfshape +rfpdig +for j ulong 4 +put GNSS add r add 8 j get RFPD j +end +gnbody get GNSM add b 4 fam +put GNSS add r 12 get GNCT 10 +put GNSS add r 13 get GNCT 11 +put GNSS add r 15 0 +end + +fn gngroup g ulong to void +put GNCT 9 0 +gnopen 0 gngpath g 0 +gnopen 1 gngpath g 1 +if ne get GNCT 0 0 +ret +end +rfreset +for i ulong 8 +gnsess add mul g 8 i +end +gnflreq +gnflexp +gnclose 0 +gnclose 1 +put GNGR g get GNCT 9 +end + +fn gnsmall tpath ulong n ulong to void +l = get GNCT 4 +if eq tpath 0 +for i ulong len gntsess +put GNPA add l i get gntsess i +end +gnopen 2 add l len gntsess +else +for j ulong len gntidx +put GNPA add l j get gntidx j +end +gnopen 2 add l len gntidx +end +if eq get GNCT 0 0 +gnwrwb n +end +gnclose 2 +end + +fn gnwrite to void +put GNRS 1 gnsub get GNCT 14 4 +rfhini 1 +cnt = get GNCT 2 +g = div cnt 8 +put GNCT 3 g +for i ulong g +gngroup i +if ne get GNCT 0 0 +ret +end +end +rfhfin 1 +put GNCT 15 0 +for w ulong mul cnt 16 +gnpw get GNSS w +end +gnsmall 0 get GNCT 15 +put GNCT 15 0 +gnpw 3544386032354079058 +gnpw 1 +gnpw get GNCT 1 +gnpw g +gnpw cnt +gnpw get GNCT 7 +gnpw get GNCT 8 +for d ulong 4 +gnpw get RFHD d +end +for z ulong 5 +gnpw 0 +end +for k ulong g +gnpw get GNGR k +end +gnsmall 1 get GNCT 15 +end + +note ---- arguments and the summary line ---- + +fn gnhexv c ulong to ulong +if and ge c 48 le c 57 +ret sub c 48 +end +if and ge c 97 le c 102 +ret sub c 87 +end +if and ge c 65 le c 70 +ret sub c 55 +end +ret 16 +end + +note FINAL generator seed: bytes 8..15 (LE) of the 64-hex-character seed in GNAR; 16 = bad hex +fn gnseedhex n ulong to ulong +if ne n 64 +put GNCT 20 1 +ret 0 +end +for i ulong 64 +if gt gnhexv ulong get GNAR i 15 +put GNCT 20 1 +end +end +v = ulong 0 +for b ulong 8 +hi = gnhexv ulong get GNAR add 16 mul b 2 +lo = gnhexv ulong get GNAR add 17 mul b 2 +v = or v shl add mul hi 16 lo mul b 8 +end +ret v +end + +fn gnsplit n ulong to ulong +if or eq n 0 gt n 8 +ret 0 +end +v = ulong 0 +for i ulong n +v = or v shl ulong get GNAR i mul i 8 +end +if eq v 336236466772 +ret 1 +end +if eq v 284697575747 +ret 2 +end +if eq v 5653828 +ret 3 +end +if eq v 327513164102 +ret 4 +end +if eq v 88297166688852 +ret 5 +end +ret 0 +end + +fn gntxt t ulong to void +o = get GNCT 15 +put GNWB o uchar t +put GNCT 15 add o 1 +end + +fn gntnum v ulong to void +d = new uchar 24 0 +k = ulong 0 +x = v +while true bound 21 +put d k uchar add 48 rem x 10 +k = add k 1 +x = div x 10 +if eq x 0 +break +end +end +while gt k 0 bound 21 +k = sub k 1 +gntxt ulong get d k +end +end + +fn gntkey a ulong b ulong c ulong to void +if gt get GNCT 15 0 +gntxt 32 +end +gntxt a +gntxt b +gntxt c +gntxt 61 +end + +fn gnthex w ulong to void +for i ulong 16 +nib = and shr w mul sub 15 i 4 15 +if lt nib 10 +gntxt add 48 nib +else +gntxt add 87 nib +end +end +end + +note "spl=ID grp=G ses=S req=R qry=Q mnx=M dgs=HEX": split id, groups, sessions, requests, QUERYs, +note MIN/MAX shapes in the TRAIN pool, holdout digest (SHA-256 of the .req files in group order) +fn gnsummary to void +put GNCT 15 0 +gntkey 115 112 108 +gntnum get GNCT 1 +gntkey 103 114 112 +gntnum get GNCT 3 +gntkey 115 101 115 +gntnum get GNCT 2 +gntkey 114 101 113 +gntnum get GNCT 7 +gntkey 113 114 121 +gntnum get GNCT 8 +gntkey 109 110 120 +gntnum get GNCT 16 +gntkey 100 103 115 +for i ulong 4 +gnthex get RFHD i +end +gntxt 10 +x = write 1 GNWB 0 get GNCT 15 +end + +fn gnminmax to ulong +m = ulong 0 +for r ulong 24 +if gnfok get GNTP r 1 +m = add m 1 +end +end +ret m +end + +fn main to int +ac = argcnt +if or lt ac 3 gt ac 4 +x = write 2 gneus 0 len gneus +ret 2 +end +l1 = argread 1 GNAR 0 4096 +if lt l1 0 +ret 2 +end +sid = gnsplit ulong l1 +if eq sid 0 +x = write 2 gneus 0 len gneus +ret 2 +end +put GNCT 1 sid +seed = ulong 1001 +if eq sid 2 +seed = 1003 +end +if eq sid 3 +seed = 1004 +end +if eq sid 5 +seed = 1002 +end +if eq sid 4 +if ne ac 4 +x = write 2 gneus 0 len gneus +ret 2 +end +l3 = argread 3 GNAR 0 4096 +if lt l3 0 +ret 2 +end +seed = gnseedhex ulong l3 +if ne get GNCT 20 0 +x = write 2 gneus 0 len gneus +ret 2 +end +else +if ne ac 3 +x = write 2 gneus 0 len gneus +ret 2 +end +end +put GNCT 14 seed +l2 = argread 2 GNPA 0 3900 +if le l2 0 +ret 2 +end +put GNCT 4 ulong l2 +md = makedir GNPA 0 ulong l2 493 +if and lt md 0 ne md -17 +x = write 2 gneio 0 len gneio +ret 3 +end +gnpool 1 +gnpool 5 +put GNCT 16 gnminmax +if eq sid 1 +gnlist 1 +gnfromls +end +if eq sid 5 +gnlist 5 +gnfromls +end +if eq sid 2 +gncalib +end +if or eq sid 3 eq sid 4 +gnlist 1 +gncomp +end +if eq get GNCT 0 0 +gnwrite +end +e = get GNCT 0 +if eq e 3 +x = write 2 gneio 0 len gneio +end +if eq e 4 +x = write 2 gnegen 0 len gnegen +end +if eq e 0 +gnsummary +end +ret int e +end diff --git a/om/reuse-eval/judge.om b/om/reuse-eval/judge.om new file mode 100644 index 0000000..bc52171 --- /dev/null +++ b/om/reuse-eval/judge.om @@ -0,0 +1,3560 @@ +note SPDX-License-Identifier: Apache-2.0 +note judge.om: the REUSE-1 judge (spark-rsi-mv #73, lane EvalJudge), written from the frozen +note contract (omega-mv d6edaad1 docs/reuse/REUSE-1.md), the evaluator formats and the drive.om +note CLI only; no candidate source is read. Units before it: sha256 ref. Prefix jd / JD / JW / JM. +note Entry: jdmain (argv[1] = run, tap, calib, build, recheck, controls); see docs/reuse-eval/README.md. +note +note String registers: JDS holds 32 byte strings of up to 4095 bytes (register r at r * 4096), +note lengths in JDSL. Register map: 0..2 scratch, 3 split dir, 4 output dir, 5 base ELF, +note 6 ALLOW (run), 7 cpu, 8 arm name, 9 LIBDIR (process), 10 MANSHA (process), 11 ALLOW (process), +note 12 TAPFILE, 13 SPLIT, 14 TRAIN lib, 15 TRAIN mansha, 16 TRAINP lib, 17 TRAINP mansha, +note 18 drive, 19 omega-mv checkout, 20 omc, 21 calibration file, 22 control dir, 23 nog3 unit path, +note 24 c4 unit path, 25 DEV split dir, 26..29 control scratch, 30 acquisition dir, 31 jdabs only. +note Word memory JDM: JMIX index, JMSE sessions, JMEX group .exp, JMRQ group .req, JMOF request +note offsets, JMRT per-request results (route, r0, r1, status), JMSC scratch. +text JDW "/usr/bin/taskset-c-echofullcachemethoddeltaselecttap/proc//stat/status/proc/loadavg/proc/self/statVmHWM:VmRSS:arm--rep--g.logproc.logacq.logacq-.manshaindexsessions.req.expCURRENTgen-.man.elf.om.calmanifest_sha256=build AUTHORIZED REVOKED mutant:c1mutant:c1bmutant:c1cunit:check=unit:delta=crashafter:controls.loglib-c0123456789abcdef.tmpctrlarm= wrong= violations=tap_sha256= tap_bytes=drive_exit= elapsed_ns=REBUILD MATCH BLOCKED rebuild pinned usage: judge run|tap|calib|build|recheck|controls (docs/reuse-eval/README.md) queries=cal_sha256=judge error unit:mutant:" +const JWTASK ulong 0 +const JWDC ulong 16 +const JWDASH ulong 18 +const JWECHO ulong 19 +const JWFULL ulong 23 +const JWCACHE ulong 27 +const JWMETH ulong 32 +const JWDELTA ulong 38 +const JWSEL ulong 43 +const JWTAP ulong 49 +const JWPROC ulong 52 +const JWSTAT ulong 58 +const JWSTATUS ulong 63 +const JWLOADAV ulong 70 +const JWSELF ulong 83 +const JWHWM ulong 98 +const JWRSS ulong 104 +const JWARM ulong 110 +const JWREP ulong 114 +const JWG ulong 119 +const JWLOG ulong 121 +const JWPLOG ulong 125 +const JWACQ ulong 133 +const JWACQ2 ulong 140 +const JWMANS ulong 144 +const JWINDEX ulong 151 +const JWSESS ulong 156 +const JWREQ ulong 164 +const JWEXP ulong 168 +const JWCUR ulong 172 +const JWGEN ulong 179 +const JWMAN ulong 183 +const JWELF ulong 187 +const JWOM ulong 191 +const JWCAL ulong 194 +const JWMSHA ulong 198 +const JWBUILD ulong 214 +const JWAUTH ulong 219 +const JWREVK ulong 231 +const JWMC1 ulong 240 +const JWMC1B ulong 249 +const JWMC1C ulong 259 +const JWUCHK ulong 269 +const JWUDEL ulong 280 +const JWCRASH ulong 291 +const JWCLOG ulong 302 +const JWLIB ulong 314 +const JWCTL ulong 318 +const JWHEX ulong 319 +const JWTMP ulong 335 +const JWCTRL ulong 339 +const JWAEQ ulong 343 +const JWWRONG ulong 347 +const JWVIOL ulong 354 +const JWTSHA ulong 366 +const JWTBYT ulong 377 +const JWDEX ulong 388 +const JWELNS ulong 399 +const JWMATCH ulong 411 +const JWBLK ulong 425 +const JWPIN ulong 441 +const JWUSAGE ulong 449 +const JWQRY ulong 526 +const JWCSHA ulong 535 +const JWERR ulong 546 +const JWUNIT ulong 558 +const JWMUT ulong 563 +const JMIX ulong 0 +const JMSE ulong 4096 +const JMEX ulong 1048576 +const JMRQ ulong 2097152 +const JMOF ulong 8388608 +const JMPRC ulong 9437150 +const JMEND ulong 9437180 +const JMRT ulong 9437184 +const JMSC ulong 10485760 +const JDNONE ulong 18446744073709551615 +global JDS uchar 131072 +global JDSL ulong 32 +global JDM ulong 16777216 +global JDF uchar 16777216 +global JDLB uchar 8388608 +global JDIO uchar 65536 +global JDWB uchar 65536 +global JDPK uchar 4096 +global JDPKN ulong 2 +global JDPF uchar 16 +global JDWS uchar 4 +global JDST uchar 128 +global JDRS ulong 40 +global JDSM ulong 1 +global JDC ulong 64 +global JDA ulong 64 +global JDH ulong 4 +global JDT ulong 8 +global JDXA uchar 16384 +global JDXL ulong 130 +global JDQ ulong 8 + +note ---- string registers ---- + +fn jdsclr r ulong to void +put JDSL r 0 +end + +fn jdsc r ulong c uchar to void +n = get JDSL r +if ge n 4095 +trap 3 +end +put JDS add mul r 4096 n c +put JDSL r add n 1 +end + +fn jdsw r ulong off ulong n ulong to void +for i ulong n +jdsc r get JDW add off i +end +end + +fn jdsr r ulong s ulong to void +n = get JDSL s +b = mul s 4096 +for i ulong n +jdsc r get JDS add b i +end +end + +fn jdscp r ulong s ulong to void +if eq r s +ret +end +jdsclr r +jdsr r s +end + +fn jdsnum r ulong v ulong w ulong to void +d = new uchar 24 0 +k = ulong 0 +x = v +while true bound 24 +put d k uchar add rem x 10 48 +k = add k 1 +x = div x 10 +if and eq x 0 ge k w +break +end +end +while gt k 0 bound 24 +k = sub k 1 +jdsc r get d k +end +end + +fn jdshex r ulong v ulong to void +for i ulong 16 +sh = mul sub 15 i 4 +jdsc r get JDW add JWHEX and shr v sh 15 +end +end + +fn jdsarg r ulong i ulong to bool +n = argread i JDS mul r 4096 4095 +if lt n 0 +put JDSL r 0 +ret false +end +put JDSL r ulong n +ret true +end + +fn jdseq r ulong s ulong to bool +n = get JDSL r +if ne n get JDSL s +ret false +end +a = mul r 4096 +b = mul s 4096 +for i ulong n +if ne get JDS add a i get JDS add b i +ret false +end +end +ret true +end + +fn jdsdash r ulong to bool +if ne get JDSL r 1 +ret false +end +ret eq get JDS mul r 4096 45 +end + +fn jdsdsh r ulong to void +jdsclr r +jdsc r 45 +end + +fn jdsval r ulong to ulong +n = get JDSL r +if or eq n 0 gt n 20 +ret JDNONE +end +b = mul r 4096 +v = ulong 0 +for i ulong n +c = ulong get JDS add b i +if or lt c 48 gt c 57 +ret JDNONE +end +v = add mul v 10 sub c 48 +end +ret v +end + +fn jdspack r ulong to ulong +n = get JDSL r +if gt n 8 +ret 0 +end +b = mul r 4096 +v = ulong 0 +for i ulong n +v = or v shl ulong get JDS add b i mul i 8 +end +ret v +end + +note byte i of register r, 256 past the end +fn jdsb r ulong i ulong to ulong +if ge i get JDSL r +ret 256 +end +ret ulong get JDS add mul r 4096 i +end + +note true if register r starts with the JDW bytes off..off+n +fn jdspre r ulong off ulong n ulong to bool +if lt get JDSL r n +ret false +end +b = mul r 4096 +for i ulong n +if ne get JDS add b i get JDW add off i +ret false +end +end +ret true +end + +fn jdhexd c ulong to ulong +if and ge c 48 le c 57 +ret sub c 48 +end +if and ge c 97 le c 102 +ret sub c 87 +end +if and ge c 65 le c 70 +ret sub c 55 +end +ret 16 +end + +note the byte k of a hex string in register r (2 hex digits), 256 if bad +fn jdshexb r ulong k ulong to ulong +hi = jdhexd jdsb r mul k 2 +lo = jdhexd jdsb r add mul k 2 1 +if or gt hi 15 gt lo 15 +ret 256 +end +ret add mul hi 16 lo +end + +fn jdsout r ulong to void +jdsc r 10 +n = write 1 JDS mul r 4096 get JDSL r +put JDSL r sub get JDSL r 1 +end + +note append the string form of an 8-word path: dir r, "/", then JDW off..off+n +fn jdspath r ulong d ulong off ulong n ulong to void +jdscp r d +jdsc r 47 +jdsw r off n +end + +note ---- little-endian words in byte pools ---- + +fn jdgfw off ulong to ulong +v = ulong 0 +i = ulong 8 +while gt i 0 bound 8 +i = sub i 1 +v = or shl v 8 ulong get JDF add off i +end +ret v +end + +fn jdpfw off ulong v ulong to void +x = v +for i ulong 8 +put JDF add off i uchar and x 255 +x = shr x 8 +end +end + +fn jdgiw off ulong to ulong +v = ulong 0 +i = ulong 8 +while gt i 0 bound 8 +i = sub i 1 +v = or shl v 8 ulong get JDIO add off i +end +ret v +end + +fn jdpiw off ulong v ulong to void +x = v +for i ulong 8 +put JDIO add off i uchar and x 255 +x = shr x 8 +end +end + +fn jdpww off ulong v ulong to void +x = v +for i ulong 8 +put JDWB add off i uchar and x 255 +x = shr x 8 +end +end + +fn jdplw off ulong v ulong to void +x = v +for i ulong 8 +put JDLB add off i uchar and x 255 +x = shr x 8 +end +end + +fn jdbswap x ulong to ulong +v = ulong 0 +y = x +for i ulong 8 +v = or shl v 8 and y 255 +y = shr y 8 +end +ret v +end + +note ---- files ---- + +fn jdopen r ulong flags int to long +ret fopen JDS mul r 4096 get JDSL r flags 420 +end + +fn jdexists r ulong to bool +x = faccess JDS mul r 4096 get JDSL r 0 +ret eq x 0 +end + +fn jdmkdir r ulong mode int to long +ret makedir JDS mul r 4096 get JDSL r mode +end + +note whole file of register r into JDF; byte count, -1 open/read error, -2 too big +fn jdldf r ulong to long +x = jdopen r 0 +if lt x 0 +ret -1 +end +fd = int x +tot = ulong 0 +while true bound 999999 +if ge tot 16777216 +c = fclose fd +ret -2 +end +k = read fd JDF tot sub 16777216 tot +if lt k 0 +c = fclose fd +ret -1 +end +if eq k 0 +break +end +tot = add tot ulong k +end +c = fclose fd +ret long tot +end + +note JDF[0..n) to the file of register r with open flags (577 truncate, 1089 append, 705 new) +fn jdwrf r ulong n ulong flags int to long +x = jdopen r flags +if lt x 0 +ret x +end +fd = int x +off = ulong 0 +while lt off n bound 999999 +k = write fd JDF off sub n off +if le k 0 +c = fclose fd +ret -1 +end +off = add off ulong k +end +c = fsync fd +c = fclose fd +ret 0 +end + +note words of file r into JDM[base..); word count, or negative +fn jdldw r ulong base ulong maxw ulong to long +n = jdldf r +if lt n 0 +ret n +end +nb = ulong n +if ne and nb 7 0 +ret -3 +end +nw = shr nb 3 +if gt nw maxw +ret -2 +end +for i ulong nw +put JDM add base i jdgfw shl i 3 +end +ret long nw +end + +fn jdw2wb b ulong k ulong to void +for i ulong k +v = get JDM add b i +jdpww shl i 3 v +end +end + +note JDM[base..base+nw) to file r (flags as jdwrf) +fn jdstw r ulong base ulong nw ulong flags int to long +x = jdopen r flags +if lt x 0 +ret x +end +fd = int x +done = ulong 0 +while lt done nw bound 999999 +k = sub nw done +if gt k 8192 +k = 8192 +end +jdw2wb add base done k +w = write fd JDWB 0 shl k 3 +if ne w long shl k 3 +c = fclose fd +ret -1 +end +done = add done k +end +c = fsync fd +c = fclose fd +ret 0 +end + +note small file (at most 65535 bytes) of register r into JDWB; bytes or negative +fn jdldsm r ulong to long +x = jdopen r 0 +if lt x 0 +ret x +end +fd = int x +k = read fd JDWB 0 65535 +c = fclose fd +ret k +end + +note file size of register r, -1 if missing +fn jdfsize r ulong to long +x = stat JDS mul r 4096 get JDSL r JDST 0 128 +if ne x 0 +ret -1 +end +v = ulong 0 +i = ulong 8 +while gt i 0 bound 8 +i = sub i 1 +v = or shl v 8 ulong get JDST add 48 i +end +ret long v +end + +note mode bits of register r (st_mode), 0 if missing +fn jdfmode r ulong to ulong +x = stat JDS mul r 4096 get JDSL r JDST 0 128 +if ne x 0 +ret 0 +end +v = or ulong get JDST 16 shl ulong get JDST 17 8 +v = or v shl ulong get JDST 18 16 +ret v +end + +note copy file register s to register d (new file, same permission bits) +fn jdcpf s ulong d ulong to int +m = jdfmode s +if ne and m 61440 32768 +ret 1 +end +n = jdldf s +if lt n 0 +ret 2 +end +x = jdopen d 705 +if lt x 0 +ret 3 +end +fd = int x +c = fchmod fd int and m 4095 +off = ulong 0 +nb = ulong n +while lt off nb bound 999999 +k = write fd JDF off sub nb off +if le k 0 +c = fclose fd +ret 4 +end +off = add off ulong k +end +c = fsync fd +c = fclose fd +ret 0 +end + +fn jdu16 off ulong to ulong +ret or ulong get JDWB off shl ulong get JDWB add off 1 8 +end + +note the name of the getdents64 record at pos appended to register r +fn jddname pos ulong r ulong to void +k = add pos 19 +while ne get JDWB k 0 bound 256 +jdsc r get JDWB k +k = add k 1 +end +end + +note one directory record: copy (mode 1, s -> d) or size (mode 0); names in registers 0 and 1 +fn jddent pos ulong s ulong d ulong mode ulong to ulong +jdscp 0 s +jdsc 0 47 +jddname pos 0 +m = jdfmode 0 +if ne and m 61440 32768 +ret 0 +end +if eq mode 0 +z = jdfsize 0 +if gt z 0 +ret ulong z +end +ret 0 +end +jdscp 1 d +jdsc 1 47 +jddname pos 1 +c = jdcpf 0 1 +if ne c 0 +ret add 10 ulong c +end +ret 0 +end + +note walk directory register s: mode 1 copies regular files into d (error code back), mode 0 sums sizes +fn jdwalk s ulong d ulong mode ulong to ulong +x = jdopen s 0 +if lt x 0 +ret JDNONE +end +fd = int x +acc = ulong 0 +while true bound 100000 +n = getdnts fd JDWB 0 65536 +if le n 0 +break +end +pos = ulong 0 +while lt pos ulong n bound 100000 +v = jddent pos s d mode +if eq mode 0 +acc = add acc v +else +if ne v 0 +acc = v +end +end +pos = add pos jdu16 add pos 16 +end +end +c = fclose fd +ret acc +end + +note copy every regular file of directory register s into a new directory register d (mode 0700) +fn jdcpdir s ulong d ulong to int +r = jdmkdir d 448 +if ne r 0 +ret 1 +end +e = jdwalk s d 1 +if ne e 0 +ret 2 +end +ret 0 +end + +note sum of st_size of the regular files of directory register s +fn jddirb s ulong to ulong +v = jdwalk s s 0 +if eq v JDNONE +ret 0 +end +ret v +end + +note make register r absolute against the current directory (register 31 is scratch) +fn jdabs r ulong to void +if eq jdsb r 0 47 +ret +end +n = cwd JDWB 0 4096 +if le n 1 +ret +end +jdsclr 31 +for i ulong sub ulong n 1 +jdsc 31 get JDWB i +end +jdsc 31 47 +jdsr 31 r +jdscp r 31 +end + +note ---- SHA-256 (sha256 unit, omsha) ---- + +fn jdhput w view ulong 64 to void +for i ulong 4 +put JDH i jdbswap get w i +end +end + +note SHA-256 of the file of register r into JDH (big-endian words); size or -1 +fn jdhfile r ulong to long +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +omsha c b 0 0 w b8 +x = jdopen r 0 +if lt x 0 +ret -1 +end +fd = int x +tot = ulong 0 +while true bound 999999 +k = read fd b 0 4096 +if lt k 0 +y = fclose fd +ret -1 +end +if eq k 0 +break +end +omsha c b ulong k 1 w b8 +tot = add tot ulong k +end +y = fclose fd +omsha c b 0 2 w b8 +jdhput w +ret long tot +end + +fn jdhcpf b edit uchar 4096 off ulong k ulong to void +for j ulong k +put b j get JDF add off j +end +end + +note SHA-256 of JDF[off..off+n) into JDH +fn jdhjdf off ulong n ulong to void +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +omsha c b 0 0 w b8 +d = ulong 0 +while lt d n bound 999999 +k = sub n d +if gt k 4096 +k = 4096 +end +jdhcpf b add off d k +omsha c b k 1 w b8 +d = add d k +end +omsha c b 0 2 w b8 +jdhput w +end + +note the 64 hex digits of JDH appended to register r +fn jdshash r ulong to void +for i ulong 4 +jdshex r get JDH i +end +end + +note ---- splitmix64 ---- + +fn jdsmix to ulong +s = add get JDSM 0 11400714819323198485 +put JDSM 0 s +z = mul xor s shr s 30 13787848793156543929 +z = mul xor z shr z 27 10723151780598845931 +ret xor z shr z 31 +end + +note ---- argument packets for execprog ---- + +fn jdpk0 to void +put JDPKN 0 2 +put JDPKN 1 0 +end + +fn jdpkb c uchar to void +n = get JDPKN 0 +if ge n 4096 +trap 3 +end +put JDPK n c +put JDPKN 0 add n 1 +end + +fn jdpkr r ulong to void +n = get JDSL r +jdpkb uchar and n 255 +jdpkb uchar shr n 8 +b = mul r 4096 +for i ulong n +jdpkb get JDS add b i +end +put JDPKN 1 add get JDPKN 1 1 +end + +note extra-argument list JDXA / JDXL (0 count, 1 + 2i offset, 2 + 2i length) +fn jdx0 to void +put JDXL 0 0 +end + +fn jdxadd r ulong to void +k = get JDXL 0 +if ge k 64 +trap 3 +end +off = ulong 0 +if gt k 0 +off = add get JDXL sub mul k 2 1 get JDXL mul k 2 +end +n = get JDSL r +if gt add off n 16384 +trap 3 +end +b = mul r 4096 +for i ulong n +put JDXA add off i get JDS add b i +end +put JDXL add mul k 2 1 off +put JDXL add mul k 2 2 n +put JDXL 0 add k 1 +end + +note list item i into register r +fn jdxget r ulong i ulong to void +jdsclr r +off = get JDXL add mul i 2 1 +n = get JDXL add mul i 2 2 +for j ulong n +jdsc r get JDXA add off j +end +end + +fn jdpkfin to void +c = get JDPKN 1 +put JDPK 0 uchar and c 255 +put JDPK 1 uchar shr c 8 +end + +note ---- /proc readings ---- + +note /proc/PID/stat (or /proc/self/stat for pid 0) fields into JDT: 0 utime 1 stime 2 cutime +note 3 cstime 4 processor; 0 ok +fn jdprocst pid ulong to int +jdsclr 0 +if eq pid 0 +jdsw 0 JWSELF 15 +else +jdsw 0 JWPROC 6 +jdsnum 0 pid 1 +jdsw 0 JWSTAT 5 +end +n = jdldsm 0 +if le n 0 +ret 1 +end +nb = ulong n +p = ulong 0 +for i ulong nb +if eq get JDWB i 41 +p = i +end +end +tok = ulong 0 +v = ulong 0 +i = add p 2 +while lt i nb bound 65536 +c = ulong get JDWB i +if or eq c 32 eq c 10 +jdstok tok v +tok = add tok 1 +v = 0 +else +if and ge c 48 le c 57 +v = add mul v 10 sub c 48 +end +end +i = add i 1 +end +ret 0 +end + +fn jdstok tok ulong v ulong to void +if and ge tok 11 le tok 14 +put JDT sub tok 11 v +end +if eq tok 36 +put JDT 4 v +end +end + +note index of JDW[off..off+wn) in JDWB[0..n), or n +fn jdfindw n ulong off ulong wn ulong to ulong +if lt n wn +ret n +end +for i ulong add sub n wn 1 +k = ulong 0 +while lt k wn bound 64 +if ne get JDWB add i k get JDW add off k +break +end +k = add k 1 +end +if eq k wn +ret i +end +end +ret n +end + +note first decimal number in JDWB at or after p (stops at a newline after digits) +fn jdnumat p ulong n ulong to ulong +v = ulong 0 +seen = false +i = p +while lt i n bound 65536 +c = ulong get JDWB i +if and ge c 48 le c 57 +v = add mul v 10 sub c 48 +seen = true +else +if seen +break +end +end +i = add i 1 +end +ret v +end + +note VmHWM and VmRSS kB of pid into JDT 5, 6 +fn jdprocmem pid ulong to void +put JDT 5 0 +put JDT 6 0 +jdsclr 0 +jdsw 0 JWPROC 6 +jdsnum 0 pid 1 +jdsw 0 JWSTATUS 7 +n = jdldsm 0 +if le n 0 +ret +end +nb = ulong n +p = jdfindw nb JWHWM 6 +if lt p nb +put JDT 5 jdnumat p nb +end +p = jdfindw nb JWRSS 6 +if lt p nb +put JDT 6 jdnumat p nb +end +end + +note first /proc/loadavg value x 100 +fn jdloadav to ulong +jdsclr 0 +jdsw 0 JWLOADAV 13 +n = jdldsm 0 +if le n 0 +ret 0 +end +v = ulong 0 +fr = ulong 0 +dig = ulong 0 +dot = false +for i ulong ulong n +c = ulong get JDWB i +if eq c 32 +break +end +if eq c 46 +dot = true +continue +end +if and ge c 48 le c 57 +if dot +if lt dig 2 +fr = add mul fr 10 sub c 48 +dig = add dig 1 +end +else +v = add mul v 10 sub c 48 +end +end +end +while lt dig 2 bound 2 +fr = mul fr 10 +dig = add dig 1 +end +ret add mul v 100 fr +end + +note ---- arm processes ---- +note JDC: 0 pid, 1 write fd, 2 read fd, 3 kept stdin read end, 4 t0, 5 start-to-ready, 6 sum rt, +note 7 requests sent, 8 alive, 9 violation code, 10 arm id, 11 group, 12 repetition, 13 loadavg, +note 14 log bytes in JDLB, 15 requests done by this process, 16 revoke-at request, 17 kill-at +note request, 18 exit status, 19 log enabled, 20 utime, 21 stime, 22 cutime, 23 cstime, 24 cpu, +note 25 hwm, 26 rss, 27 proc read done. +note JDA counters: 0 QUERYs, 1 wrong (correctness 0), 2..7 QUERY routes 0..5, 8 other routes, +note 10 QUERYs after revoke, 11 route 3/4 after, 12 route 5 after, 13 route 3/4 before, 14 wrong +note QUERYs, 15 violations. + +fn jdfdw off ulong to int +x = ulong 0 +for i ulong 4 +v = ulong get JDPF add off i +x = or x shl v mul i 8 +end +ret int x +end + +fn jdspawn to long +r = pipefds JDPF 0 8 524288 +if ne r 0 +ret -1 +end +r = pipefds JDPF 8 8 524288 +if ne r 0 +ret -1 +end +a0 = jdfdw 0 +a1 = jdfdw 4 +b0 = jdfdw 8 +b1 = jdfdw 12 +pid = fork +if lt pid 0 +ret -1 +end +if eq pid 0 +d = dupfd a0 0 0 +d = dupfd b1 1 0 +e = execprog JDPK 0 get JDPKN 0 +exit 127 +end +c = fclose b1 +put JDC 0 ulong pid +put JDC 1 ulong a1 +put JDC 2 ulong b0 +put JDC 3 ulong a0 +ret pid +end + +fn jdarmname r ulong a ulong to void +jdsclr r +if eq a 0 +jdsw r JWECHO 4 +end +if eq a 1 +jdsw r JWFULL 4 +end +if eq a 2 +jdsw r JWCACHE 5 +end +if eq a 3 +jdsw r JWMETH 6 +end +if and ge a 4 le a 6 +jdsw r JWDELTA 5 +end +if eq a 7 +jdsw r JWSEL 6 +end +if eq a 8 +jdsw r JWTAP 3 +end +end + +note packet: [taskset -c CPU] BASE ARM LIBDIR MANSHA ALLOW TAPFILE SPLIT +fn jdarmpk to void +jdpk0 +if not jdsdash 7 +jdsclr 0 +jdsw 0 JWTASK 16 +jdpkr 0 +jdsclr 0 +jdsw 0 JWDC 2 +jdpkr 0 +jdpkr 7 +end +jdpkr 5 +jdpkr 8 +jdpkr 9 +jdpkr 10 +jdpkr 11 +jdpkr 12 +jdpkr 13 +jdpkfin +end + +fn jdpstart to int +jdarmpk +put JDC 13 jdloadav +t0 = monons +pid = jdspawn +if lt pid 0 +ret 1 +end +put JDC 4 ulong t0 +put JDC 5 0 +put JDC 6 0 +put JDC 7 0 +put JDC 8 1 +put JDC 9 0 +put JDC 15 0 +put JDC 18 0 +put JDC 27 0 +put JDC 28 0 +for i ulong 5 +put JDT i 0 +end +put JDT 5 0 +put JDT 6 0 +ret 0 +end + +note write a frame JDM[off..off+nw) to the arm before deadline dl; 0 ok, 3 timeout, 4 write failure +fn jdsend off ulong nw ulong dl long to int +fd = int get JDC 1 +nb = shl nw 3 +if gt nb 65536 +ret 4 +end +for i ulong nw +jdpiw shl i 3 get JDM add off i +end +done = ulong 0 +while lt done nb bound 999999 +left = sub dl monons +if le left 0 +ret 3 +end +e = waitio fd 4 left +if eq e 0 +ret 3 +end +if or lt e 0 eq and e 4 0 +ret 4 +end +k = sub nb done +if gt k 4096 +k = 4096 +end +w = write fd JDIO done k +if le w 0 +ret 4 +end +done = add done ulong w +end +ret 0 +end + +note read exactly n bytes into JDIO[off..) before deadline dl; 0 ok, 1 end of file, 3 timeout +fn jdrdn fd int off ulong n ulong dl long to int +got = ulong 0 +while lt got n bound 999999 +left = sub dl monons +if le left 0 +ret 3 +end +e = waitio fd 1 left +if lt e 0 +ret 1 +end +if eq e 0 +ret 3 +end +k = read fd JDIO add off got sub n got +if le k 0 +ret 1 +end +got = add got ulong k +end +ret 0 +end + +note response into JDRS (0 status, 1 q, 2.. words); 0 ok, 1 short, 2 bad q, 3 timeout +fn jdrecv dl long to int +fd = int get JDC 2 +e = jdrdn fd 0 16 dl +if ne e 0 +ret e +end +put JDRS 0 jdgiw 0 +q = jdgiw 8 +put JDRS 1 q +if gt q 32 +ret 2 +end +e = jdrdn fd 16 shl q 3 dl +if ne e 0 +ret e +end +for i ulong q +put JDRS add 2 i jdgiw add 16 shl i 3 +end +ret 0 +end + +note read /proc of the live arm once (before END or a kill) +fn jdpread to void +if ne get JDC 27 0 +ret +end +pid = get JDC 0 +r = jdprocst pid +put JDC 20 get JDT 0 +put JDC 21 get JDT 1 +put JDC 22 get JDT 2 +put JDC 23 get JDT 3 +put JDC 24 get JDT 4 +jdprocmem pid +put JDC 25 get JDT 5 +put JDC 26 get JDT 6 +put JDC 27 1 +end + +fn jdclosefd to void +c = fclose int get JDC 1 +c = fclose int get JDC 2 +c = fclose int get JDC 3 +end + +note wait status in JDWS to the proc.log exit word +fn jdwstat to ulong +sig = and ulong get JDWS 0 127 +if ne sig 0 +ret add 256 sig +end +ret ulong get JDWS 1 +end + +note reap the arm within 10 s, killing it after that +fn jdreap to void +pid = int get JDC 0 +dl = add monons 10000000000 +while true bound 999999 +r = waitpid pid JDWS 0 4 1 +if eq r long pid +put JDC 18 jdwstat +ret +end +if lt r 0 +put JDC 18 1023 +ret +end +if gt monons dl +k = killpid pid 9 +r = waitpid pid JDWS 0 4 0 +put JDC 18 jdwstat +ret +end +s = sleepns 1000000 +end +end + +note kill the arm (protocol violation or a C11 kill); code 0 = deliberate kill +fn jdpkill code ulong to void +if eq get JDC 8 0 +ret +end +jdpread +pid = int get JDC 0 +k = killpid pid 9 +r = waitpid pid JDWS 0 4 0 +if eq code 0 +put JDC 18 jdwstat +else +put JDC 18 add 512 code +end +put JDC 8 0 +jdclosefd +end + +note send END, require status 0 and q 0, reap; K17: END round trip into JDC 28, and 1024 added to +note the exit word when END itself failed (bad status or q, end of file, timeout, write failure; +note the low bits then hold the exit status, or 512 + 4 + code when the judge had to kill the arm) +fn jdpfin to void +if eq get JDC 8 0 +ret +end +if eq get JDC 19 1 +jdpstats +end +jdpread +put JDM JMEND 10 +put JDM add JMEND 1 0 +t1 = monons +dl = add t1 10000000000 +e = jdsend JMEND 2 dl +if eq e 0 +e = jdrecv dl +end +put JDC 28 ulong sub monons t1 +if ne e 0 +jdpkill add 4 ulong e +put JDC 18 add get JDC 18 1024 +ret +end +bad = or ne get JDRS 0 0 ne get JDRS 1 0 +jdreap +if bad +put JDC 18 add get JDC 18 1024 +end +put JDC 8 0 +jdclosefd +end + +note K14: diagnostic STATS, excluded from every latency sum, padded to 32 counter words. +fn jdpstats to void +for i ulong 34 +put JDM add 9437000 i 0 +end +put JDM JMEND 9 +put JDM add JMEND 1 0 +dl = add monons 10000000000 +e = jdsend JMEND 2 dl +if eq e 0 +e = jdrecv dl +end +if eq e 0 +put JDM 9437000 get JDRS 0 +put JDM 9437001 get JDRS 1 +for i ulong get JDRS 1 +put JDM add 9437002 i get JDRS add i 2 +end +else +put JDM 9437000 JDNONE +end +jdscp 0 4 +jdsc 0 47 +jdsc 0 115 +jdsc 0 116 +jdsc 0 97 +jdsc 0 116 +jdsc 0 115 +jdsc 0 45 +jdsnum 0 get JDC 10 1 +jdsc 0 45 +jdsnum 0 get JDC 12 1 +jdsw 0 JWG 2 +jdsnum 0 get JDC 11 2 +jdsc 0 46 +jdsc 0 99 +jdsc 0 116 +jdsc 0 114 +x = jdstw 0 9437000 34 705 +end + +note status, r0, r1, route of the response as logged, into JDQ 0..3 +fn jdlogval op ulong code ulong to void +put JDQ 0 get JDRS 0 +put JDQ 1 0 +put JDQ 2 0 +put JDQ 3 0 +if and eq op 2 ge get JDRS 1 3 +put JDQ 1 get JDRS 2 +put JDQ 2 get JDRS 3 +put JDQ 3 get JDRS 4 +end +if ne code 0 +put JDQ 1 0 +put JDQ 2 0 +put JDQ 3 0 +end +if eq code 1 +put JDQ 0 JDNONE +end +if eq code 2 +put JDQ 0 sub JDNONE 1 +end +end + +note one 16-word raw record for request j into JDLB, counters into JDA +fn jdlogrec j ulong code ulong rt ulong to void +off = get JDM add JMOF j +op = get JDM add JMRQ off +ex = add JMEX shl j 3 +jdlogval op code +co = jdcorr op code get JDQ 0 get JDQ 1 get JDQ 2 ex +jdcount j op code co get JDQ 3 +if eq get JDC 19 0 +ret +end +jdlogw j op ex rt co +end + +fn jdlogw j ulong op ulong ex ulong rt ulong co ulong to void +b = get JDC 14 +if gt add b 128 8388608 +trap 3 +end +jdplw b get JDC 11 +jdplw add b 8 get JDC 12 +jdplw add b 16 get JDC 10 +jdplw add b 24 j +jdplw add b 32 op +jdplw add b 40 get JDQ 0 +jdplw add b 48 get JDQ 1 +jdplw add b 56 get JDQ 2 +jdplw add b 64 get JDQ 3 +jdplw add b 72 get JDM ex +jdplw add b 80 get JDM add ex 2 +jdplw add b 88 get JDM add ex 3 +jdplw add b 96 rt +jdplw add b 104 get JDM add ex 6 +jdplw add b 112 get JDM add ex 5 +jdplw add b 120 co +put JDC 14 add b 128 +end + +note correctness word: code 0 answered, 1 violation, 2 not sent +fn jdcorr op ulong code ulong st ulong r0 ulong r1 ulong ex ulong to ulong +if ne code 0 +ret 0 +end +if eq get JDC 10 0 +ret 2 +end +if ne st get JDM ex +ret 0 +end +if ne op 2 +ret 2 +end +if ne st 0 +ret 1 +end +e0 = get JDM add ex 2 +if ne r0 e0 +ret 0 +end +e1 = get JDM add ex 3 +if ne r1 e1 +ret 0 +end +ret 1 +end + +fn jdcount j ulong op ulong code ulong co ulong ro ulong to void +rt = add JMRT shl j 2 +put JDM rt ro +put JDM add rt 1 code +put JDM add rt 2 co +if eq co 0 +put JDA 1 add get JDA 1 1 +end +if eq code 1 +put JDA 15 add get JDA 15 1 +end +if ne op 2 +ret +end +put JDM add rt 3 1 +put JDA 0 add get JDA 0 1 +if eq co 0 +put JDA 14 add get JDA 14 1 +end +if ne code 0 +ret +end +if le ro 5 +put JDA add 2 ro add get JDA add 2 ro 1 +else +put JDA 8 add get JDA 8 1 +end +m = or eq ro 3 eq ro 4 +rv = get JDC 16 +if and ne rv JDNONE ge j rv +put JDA 10 add get JDA 10 1 +if m +put JDA 11 add get JDA 11 1 +end +if eq ro 5 +put JDA 12 add get JDA 12 1 +end +else +if m +put JDA 13 add get JDA 13 1 +end +end +end + +fn jdcnt0 to void +for i ulong 64 +put JDA i 0 +end +end + +note send request j and read its response; logs it +fn jdpreq j ulong to void +if eq get JDC 8 0 +jdlogrec j 2 0 +ret +end +if eq j get JDC 16 +jdrevoke +end +off = get JDM add JMOF j +nw = add get JDM add add JMRQ off 1 2 +t1 = monons +dl = add t1 10000000000 +e = jdsend add JMRQ off nw dl +if eq e 0 +e = jdrecv dl +end +t2 = monons +if eq e 0 +eq1 = get JDM add add JMEX shl j 3 1 +if ne get JDRS 1 eq1 +e = 2 +end +end +rt = ulong sub t2 t1 +if eq get JDC 15 0 +put JDC 5 ulong sub t2 long get JDC 4 +end +put JDC 15 add get JDC 15 1 +put JDC 6 add get JDC 6 rt +put JDC 7 add get JDC 7 1 +if ne e 0 +put JDC 9 ulong e +jdlogrec j 1 rt +jdpkill ulong e +ret +end +jdlogrec j 0 rt +end + +note C7 mid-session revocation: append the line of register 29 to the ALLOW copy of register 28 +fn jdrevoke to void +if eq get JDSL 28 0 +ret +end +x = jdopen 28 1089 +if lt x 0 +ret +end +fd = int x +w = write fd JDS 118784 get JDSL 29 +c = fsync fd +c = fclose fd +end + +note the proc.log record (16 words at JMPRC) appended to <dir 4>/proc.log +fn jdproclog to int +p = JMPRC +put JDM p get JDC 10 +put JDM add p 1 get JDC 11 +put JDM add p 2 get JDC 12 +put JDM add p 3 get JDC 5 +put JDM add p 4 get JDC 20 +put JDM add p 5 get JDC 21 +put JDM add p 6 get JDC 22 +put JDM add p 7 get JDC 23 +put JDM add p 8 get JDC 25 +put JDM add p 9 get JDC 26 +put JDM add p 10 get JDC 18 +put JDM add p 11 get JDC 7 +put JDM add p 12 get JDC 6 +put JDM add p 13 get JDC 24 +put JDM add p 14 get JDC 13 +put JDM add p 15 get JDC 28 +jdspath 0 4 JWPLOG 8 +x = jdstw 0 p 16 1089 +if lt x 0 +ret 1 +end +ret 0 +end + +note <dir 4>/arm-A-rep-R-gNN.log from JDLB (a new file; never overwritten) +fn jdrawlog to int +jdscp 0 4 +jdsc 0 47 +jdsw 0 JWARM 4 +jdsnum 0 get JDC 10 1 +jdsw 0 JWREP 5 +jdsnum 0 get JDC 12 1 +jdsw 0 JWG 2 +jdsnum 0 get JDC 11 2 +jdsw 0 JWLOG 4 +x = jdopen 0 705 +if lt x 0 +ret 1 +end +fd = int x +n = get JDC 14 +off = ulong 0 +while lt off n bound 999999 +k = write fd JDLB off sub n off +if le k 0 +c = fclose fd +ret 2 +end +off = add off ulong k +end +c = fsync fd +c = fclose fd +ret 0 +end + +note one arm process over requests j0..j1 of the loaded group; arm config in registers 5, 7..13, +note JDC 10..12; writes the raw log and proc.log when JDC 19 = 1. 0 ok, nonzero judge failure. +fn jdpgroup j0 ulong j1 ulong to int +put JDC 14 0 +r = jdpstart +if ne r 0 +ret 1 +end +j = j0 +while lt j j1 bound 999999 +if eq j get JDC 17 +jdpkill 0 +end +jdpreq j +j = add j 1 +end +jdpfin +if eq get JDC 19 0 +ret 0 +end +r = jdrawlog +if ne r 0 +ret 2 +end +r = jdproclog +if ne r 0 +ret 3 +end +ret 0 +end + +note ---- split directories ---- + +note index and sessions of the split in register 3; group count or negative +fn jdsload to long +jdspath 0 3 JWINDEX 5 +n = jdldw 0 JMIX 4096 +if lt n 16 +ret -1 +end +if ne get JDM JMIX 3544386032354079058 +ret -2 +end +if ne get JDM add JMIX 1 1 +ret -2 +end +g = get JDM add JMIX 3 +if or gt g 100 ne ulong n add 16 g +ret -3 +end +jdspath 0 3 JWSESS 8 +s = jdldw 0 JMSE 1044480 +if lt s 0 +ret -4 +end +if ne ulong s mul 16 get JDM add JMIX 4 +ret -5 +end +ret long g +end + +fn jdgpath r ulong d ulong g ulong ext ulong to void +jdscp r d +jdsc r 47 +jdsc r 103 +jdsnum r g 2 +jdsw r ext 4 +end + +note group g of the split in register 3 into JMRQ / JMOF / JMEX; request count or negative +fn jdgload g ulong to long +jdgpath 0 3 g JWREQ +nw = jdldw 0 JMRQ 6291456 +if lt nw 0 +ret -1 +end +off = ulong 0 +j = ulong 0 +while lt off ulong nw bound 999999 +if ge j 1048576 +ret -2 +end +put JDM add JMOF j off +off = add off add get JDM add add JMRQ off 1 2 +j = add j 1 +end +if ne off ulong nw +ret -3 +end +if ne j get JDM add add JMIX 16 g +ret -4 +end +jdgpath 0 3 g JWEXP +ne8 = jdldw 0 JMEX 1048576 +if ne ulong ne8 shl j 3 +ret -5 +end +for i ulong j +if not jdopok i +ret -6 +end +end +ret long j +end + +fn jdopok i ulong to bool +o = get JDM add JMOF i +op = get JDM add JMRQ o +eo = get JDM add add JMEX shl i 3 4 +ret eq op eo +end + +fn jdusage to int +jdsclr 0 +jdsw 0 JWUSAGE 77 +jdsc 0 10 +n = write 2 JDS 0 get JDSL 0 +ret 2 +end + +fn jderr code ulong to int +jdsclr 0 +jdsw 0 JWERR 12 +jdsnum 0 code 1 +jdsc 0 10 +n = write 2 JDS 0 get JDSL 0 +ret 3 +end + +note ---- run ---- + +note arm-order seed: a 64-hex FINAL seed gives bytes 16..23 little endian; else a decimal value +fn jdseed r ulong to ulong +if eq get JDSL r 64 +v = ulong 0 +for k ulong 8 +b = jdshexb r add 16 k +if gt b 255 +ret JDNONE +end +v = or v shl b mul k 8 +end +ret v +end +ret jdsval r +end + +note arm digits of register r into JDM JMSC..; count, 0 when invalid +fn jdarms r ulong to ulong +n = get JDSL r +if or eq n 0 gt n 8 +ret 0 +end +for i ulong n +c = jdsb r i +if or lt c 48 gt c 55 +ret 0 +end +a = sub c 48 +for k ulong i +if eq get JDM add JMSC k a +ret 0 +end +end +put JDM add JMSC i a +end +ret n +end + +note fresh copy of the base arm list at JMSC + 16, Fisher-Yates with splitmix64 (i = n-1 .. 1) +fn jdperm n ulong to void +b = add JMSC 16 +for i ulong n +put JDM add b i get JDM add JMSC i +end +i = sub n 1 +while gt i 0 bound 8 +j = rem jdsmix add i 1 +t = get JDM add b i +put JDM add b i get JDM add b j +put JDM add b j t +i = sub i 1 +end +end + +fn jdlibdir r ulong rep ulong lib ulong to void +jdscp r 4 +jdsc r 47 +jdsw r JWLIB 4 +jdsnum r rep 1 +jdsc r 45 +jdsnum r lib 1 +end + +note process registers 8..13 and JDC 10, 12 for arm a in repetition rep of a run +fn jdarmcfg a ulong rep ulong to void +jdarmname 8 a +jdsdsh 9 +jdsdsh 10 +jdsdsh 11 +jdsdsh 12 +jdsdsh 13 +if or eq a 3 or eq a 4 eq a 7 +jdlibdir 9 rep 1 +jdscp 10 15 +jdscp 11 6 +end +if eq a 5 +jdscp 11 6 +end +if eq a 6 +jdlibdir 9 rep 2 +jdscp 10 17 +jdscp 11 6 +end +put JDC 10 a +put JDC 12 rep +end + +fn jdaddm i ulong d ulong to void +put JDM i add get JDM i d +end + +fn jdneed n ulong lib ulong to bool +for i ulong n +a = get JDM add JMSC i +if and eq lib 1 or eq a 3 or eq a 4 eq a 7 +ret true +end +if and eq lib 2 eq a 6 +ret true +end +end +ret false +end + +fn jdsummary n ulong to void +for i ulong n +a = get JDM add JMSC i +jdsclr 0 +jdsw 0 JWAEQ 4 +jdsnum 0 a 1 +jdsw 0 JWWRONG 7 +jdsnum 0 get JDM add add JMSC 32 a 1 +jdsw 0 JWVIOL 12 +jdsnum 0 get JDM add add JMSC 48 a 1 +jdsout 0 +end +end + +note all arms of the base list over one loaded group g, repetition rep +fn jdrungrp na ulong g ulong rep ulong nreq ulong to int +jdperm na +for k ulong na +a = get JDM add add JMSC 16 k +jdarmcfg a rep +put JDC 11 g +w0 = get JDA 1 +v0 = get JDA 15 +e = jdpgroup 0 nreq +if ne e 0 +ret add 40 e +end +dw = sub get JDA 1 w0 +jdaddm add add JMSC 32 a dw +dv = sub get JDA 15 v0 +jdaddm add add JMSC 48 a dv +end +ret 0 +end + +note judge run SPLIT OUT REPS SEED ARMS BASE ALLOW LIB MAN LIBP MANP CPU +fn jdrun to int +if ne argcnt 14 +ret jdusage +end +b = jdsarg 3 2 +b = jdsarg 4 3 +b = jdsarg 0 4 +b = jdsarg 1 5 +b = jdsarg 2 6 +b = jdsarg 5 7 +b = jdsarg 6 8 +b = jdsarg 14 9 +b = jdsarg 15 10 +b = jdsarg 16 11 +b = jdsarg 17 12 +b = jdsarg 7 13 +reps = jdsval 0 +seed = jdseed 1 +na = jdarms 2 +if or or eq reps JDNONE or eq reps 0 gt reps 99 or eq seed JDNONE eq na 0 +ret jdusage +end +n1 = jdneed na 1 +n2 = jdneed na 2 +if and n1 or jdsdash 14 jdsdash 15 +ret jdusage +end +if and n2 or jdsdash 16 jdsdash 17 +ret jdusage +end +g = jdsload +if lt g 0 +ret jderr 10 +end +r = jdmkdir 4 493 +jdspath 0 4 JWPLOG 8 +if jdexists 0 +ret jderr 11 +end +for i ulong 32 +put JDM add add JMSC 32 i 0 +end +put JDSM 0 seed +e = jdrunloop reps na n1 n2 ulong g +if ne e 0 +ret jderr e +end +jdsummary na +ret 0 +end + + +fn jdrunloop reps ulong na ulong n1 bool n2 bool g ulong to ulong +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 1 +jdcnt0 +for rep ulong reps +if n1 +jdlibdir 26 rep 1 +c = jdcpdir 14 26 +if ne c 0 +ret 12 +end +end +if n2 +jdlibdir 26 rep 2 +c = jdcpdir 16 26 +if ne c 0 +ret 13 +end +end +for gi ulong g +nreq = jdgload gi +if lt nreq 0 +ret 20 +end +e = jdrungrp na gi rep ulong nreq +if ne e 0 +ret ulong e +end +end +end +ret 0 +end + +note ---- tap ---- + +note judge tap SPLIT BASE TAPFILE SPLITARG CPU: one B process over every group in order +fn jdtap to int +if ne argcnt 7 +ret jdusage +end +b = jdsarg 3 2 +b = jdsarg 5 3 +b = jdsarg 12 4 +b = jdsarg 13 5 +b = jdsarg 7 6 +g = jdsload +if lt g 0 +ret jderr 10 +end +if jdexists 12 +ret jderr 14 +end +jdarmname 8 8 +jdsdsh 9 +jdsdsh 10 +jdsdsh 11 +put JDC 10 1 +put JDC 11 0 +put JDC 12 0 +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 0 +jdcnt0 +r = jdpstart +if ne r 0 +ret jderr 15 +end +for gi ulong ulong g +nreq = jdgload gi +if lt nreq 0 +jdpkill 0 +ret jderr 16 +end +for j ulong ulong nreq +jdpreq j +end +end +jdpfin +z = jdhfile 12 +jdsclr 0 +jdsw 0 JWTSHA 11 +jdshash 0 +jdsw 0 JWTBYT 11 +if gt z 0 +jdsnum 0 ulong z 1 +else +jdsc 0 48 +end +jdsw 0 JWQRY 9 +jdsnum 0 get JDA 0 1 +jdsw 0 JWWRONG 7 +jdsnum 0 get JDA 1 1 +jdsw 0 JWVIOL 12 +jdsnum 0 get JDA 15 1 +jdsout 0 +if or ne get JDA 1 0 ne get JDC 18 0 +ret 4 +end +if le z 0 +ret 4 +end +ret 0 +end + +note ---- calib ---- +note pairs (key, ns) at JMSC, sort area at JMSC + 2097152, logs at JMSC + 3145728; change class +note of QUERY j at JMRT + j, per-session change counts at JMRT + 524288 + ordinal. + +const JDPAIR ulong 10485760 +const JDSORT ulong 12582912 +const JDLOGW ulong 13631488 + +fn jdccls c ulong to ulong +if eq c 0 +ret 0 +end +if eq c 1 +ret 1 +end +if le c 64 +ret 2 +end +ret 3 +end + +fn jdcchg nreq ulong to void +cb = add JMRT 524288 +for j ulong nreq +o = get JDM add JMOF j +op = get JDM add JMRQ o +ex = add JMEX shl j 3 +s = get JDM add ex 5 +ok = eq get JDM ex 0 +si = add cb s +put JDM add JMRT j 9 +if and eq op 1 ok +put JDM si 0 +end +if and ok and ge op 3 le op 6 +jdaddm si 1 +end +if and ok eq op 8 +jdaddm si 1 +end +if and ok eq op 7 +m = get JDM add add JMRQ o 2 +jdaddm si m +end +if eq op 2 +put JDM add JMRT j jdccls get JDM si +put JDM si 0 +end +end +end + +fn jdpair k ulong v ulong np ulong to ulong +if ge np 1048576 +ret np +end +put JDM add JDPAIR shl np 1 k +put JDM add add JDPAIR shl np 1 1 v +ret add np 1 +end + +note pairs of one arm log (already at JDLOGW) for a loaded group of nreq requests +fn jdcpairs a ulong nreq ulong np ulong to ulong +n = np +path = ulong 2 +if eq a 1 +path = 0 +end +if eq a 3 +path = 1 +end +for j ulong nreq +n = jdcpone a path j n +end +ret n +end + +fn jdsfld s ulong w ulong to ulong +ret get JDM add add JMSE shl s 4 w +end + +fn jdcpone a ulong path ulong j ulong np ulong to ulong +rec = add JDLOGW shl j 4 +fam = jdsfld get JDM add rec 14 2 +ncl = jdsfld get JDM add rec 14 5 +if or or lt fam 1 gt fam 2 gt ncl 2 +ret np +end +k = add mul sub fam 1 3 ncl +n = jdcpq path j k np +if jdcbind get JDM add rec 4 rec j a +kb = add k 100 +if eq a 1 +kb = add k 200 +end +n = jdpair kb get JDM add rec 12 n +end +ret n +end + +note QUERY pair of record j; k = (family - 1) * 3 + nclass +fn jdcpq path ulong j ulong k ulong np ulong to ulong +rec = add JDLOGW shl j 4 +if or ne get JDM add rec 4 2 ne get JDM add rec 15 1 +ret np +end +f0 = div k 3 +ncl = rem k 3 +c = jdcell f0 path ncl get JDM add JMRT j +ret jdpair c get JDM add rec 12 np +end + +fn jdcell f0 ulong path ulong ncl ulong cc ulong to ulong +x = mul add mul f0 4 path 12 +ret add add x mul ncl 4 cc +end + +fn jdcbind op ulong rec ulong j ulong a ulong to bool +if or ne op 1 eq j 0 +ret false +end +if eq a 4 +ret false +end +ret and eq get JDM add rec 5 0 eq get JDM add rec 9 0 +end + +note values of key k gathered into JDSORT and sorted; count +fn jdgather k ulong np ulong to ulong +n = ulong 0 +for i ulong np +if eq get JDM add JDPAIR shl i 1 k +put JDM add JDSORT n get JDM add add JDPAIR shl i 1 1 +n = add n 1 +end +end +jdhsort JDSORT n +ret n +end + +fn jdsift b ulong st ulong n ulong to void +root = st +while true bound 64 +ch = add mul root 2 1 +if ge ch n +break +end +sw = root +if gt get JDM add b ch get JDM add b sw +sw = ch +end +c2 = add ch 1 +if lt c2 n +if gt get JDM add b c2 get JDM add b sw +sw = c2 +end +end +if eq sw root +break +end +t = get JDM add b root +put JDM add b root get JDM add b sw +put JDM add b sw t +root = sw +end +end + +fn jdhsort b ulong n ulong to void +if lt n 2 +ret +end +st = add div sub n 2 2 1 +while gt st 0 bound 999999 +st = sub st 1 +jdsift b st n +end +e = sub n 1 +while gt e 0 bound 999999 +t = get JDM b +put JDM b get JDM add b e +put JDM add b e t +jdsift b 0 e +e = sub e 1 +end +end + +note nearest-rank percentile p of the n sorted values at JDSORT: index ceil(p n / 100) - 1 +fn jdpct n ulong p ulong to ulong +i = div add mul p n 99 100 +if eq i 0 +i = 1 +end +ret get JDM add JDSORT sub i 1 +end + +fn jdfloor1 a ulong b ulong to ulong +if le a b +ret 1 +end +d = sub a b +if lt d 1 +ret 1 +end +ret d +end + +note the calibration words into JMEX[0..200) +fn jdcalout np ulong eqv ulong to void +for i ulong 200 +put JDM add JMEX i 0 +end +put JDM JMEX 3544386010811150674 +put JDM add JMEX 1 1 +put JDM add JMEX 2 eqv +for c ulong 96 +if eq rem div c 12 4 3 +continue +end +n = jdgather c np +if gt n 0 +put JDM add add JMEX 8 shl c 1 jdpct n 50 +put JDM add add JMEX 9 shl c 1 jdpct n 90 +end +end +for f0 ulong 2 +for ncl ulong 3 +jdcalbind f0 ncl np +end +end +end + +fn jdcalbind f0 ulong ncl ulong np ulong to void +k = add mul f0 3 ncl +nf = jdgather add k 200 np +if eq nf 0 +ret +end +fp = jdpct nf 50 +nm = jdgather add k 100 np +if eq nm 0 +ret +end +c = add mul add mul f0 4 3 12 mul ncl 4 +put JDM add add JMEX 8 shl c 1 jdfloor1 jdpct nm 50 fp +put JDM add add JMEX 9 shl c 1 jdfloor1 jdpct nm 90 fp +end + +note judge calib CALIBDIR RUNDIR REPS OUTFILE +fn jdcalib to int +if ne argcnt 6 +ret jdusage +end +b = jdsarg 3 2 +b = jdsarg 4 3 +b = jdsarg 0 4 +b = jdsarg 21 5 +reps = jdsval 0 +if or eq reps JDNONE eq reps 0 +ret jdusage +end +g = jdsload +if lt g 0 +ret jderr 10 +end +ns = get JDM add JMIX 4 +if eq ns 0 +ret jderr 17 +end +eqv = div mul get JDM add JMIX 6 1000 ns +np = jdcalloop reps ulong g +if eq np JDNONE +ret jderr 18 +end +jdcalout np eqv +x = jdstw 21 JMEX 200 705 +if lt x 0 +ret jderr 19 +end +z = jdhfile 21 +jdsclr 0 +jdsw 0 JWCSHA 11 +jdshash 0 +jdsout 0 +ret 0 +end + +fn jdcalloop reps ulong g ulong to ulong +np = ulong 0 +for rep ulong reps +for gi ulong g +x = jdgload gi +if lt x 0 +ret JDNONE +end +nreq = ulong x +jdcchg nreq +np = jdcal3 rep gi nreq np +if eq np JDNONE +ret JDNONE +end +end +end +ret np +end + +fn jdcal3 rep ulong gi ulong nreq ulong np ulong to ulong +n = np +for t ulong 3 +a = add t 2 +if eq t 0 +a = 1 +end +if eq t 2 +a = 4 +end +x = jdcload a rep gi +if ne x mul nreq 16 +ret JDNONE +end +n = jdcpairs a nreq n +end +ret n +end + +note raw log arm a, repetition rep, group g of the run dir in register 4 into JDLOGW; words +fn jdcload a ulong rep ulong g ulong to ulong +jdscp 0 4 +jdsc 0 47 +jdsw 0 JWARM 4 +jdsnum 0 a 1 +jdsw 0 JWREP 5 +jdsnum 0 rep 1 +jdsw 0 JWG 2 +jdsnum 0 g 2 +jdsw 0 JWLOG 4 +x = jdldw 0 JDLOGW 3145728 +if lt x 0 +ret JDNONE +end +ret ulong x +end + +note ---- build ---- + +note index of JDW[off..off+wn) in JDF[0..n), or n +fn jdfindf n ulong off ulong wn ulong to ulong +if lt n wn +ret n +end +for i ulong add sub n wn 1 +k = ulong 0 +while lt k wn bound 64 +if ne get JDF add i k get JDW add off k +break +end +k = add k 1 +end +if eq k wn +ret i +end +end +ret n +end + +note register r written to the file of register p (flags), with a final newline +fn jdwreg r ulong p ulong flags int to long +x = jdopen p flags +if lt x 0 +ret x +end +fd = int x +jdsc r 10 +w = write fd JDS mul r 4096 get JDSL r +put JDSL r sub get JDSL r 1 +c = fsync fd +c = fclose fd +ret 0 +end + +note drive child: chdir into register 19, stdout onto the pipe, exec the packet +fn jddchild wr int to void +c = chdir JDS 77824 get JDSL 19 +if ne c 0 +exit 126 +end +d = dupfd wr 1 0 +e = execprog JDPK 0 get JDPKN 0 +exit 127 +end + +note read the child's stdout into JDF until end of file; bytes +fn jddread rd int dl long to ulong +n = ulong 0 +while true bound 999999 +left = sub dl monons +if le left 0 +break +end +e = waitio rd 1 left +if le e 0 +break +end +if ge n 16777216 +break +end +k = read rd JDF n sub 16777216 n +if le k 0 +break +end +n = add n ulong k +end +ret n +end + +note run drive build: registers 18 drive, 19 checkout (cwd of drive), 20 omc, 11 ALLOW, 21 CALIB, +note 9 OUTLIB, 30 acquisition dir, JDXA extra arguments. acq.log record, acq-L-R.mansha; the +note manifest hex is left in register 10 (empty if none). Returns the drive exit word. +fn jdbuild lib ulong rep ulong to ulong +jdbpk +r = jdprocst 0 +put JDC 40 get JDT 2 +put JDC 41 get JDT 3 +ex = jdbrun +r = jdprocst 0 +el = get JDC 42 +n = get JDC 43 +cu = sub get JDT 2 get JDC 40 +cs = sub get JDT 3 get JDC 41 +jdacqrec lib rep el cu cs ex +jdmansha lib rep n +w = write 1 JDF 0 n +jdsclr 0 +jdsw 0 JWDEX 11 +jdsnum 0 ex 1 +jdsw 0 JWELNS 12 +jdsnum 0 el 1 +jdsout 0 +ret ex +end + +fn jdbpk to void +jdpk0 +jdpkr 18 +jdsclr 0 +jdsw 0 JWBUILD 5 +jdpkr 0 +jdpkr 20 +jdpkr 11 +jdpkr 21 +jdpkr 9 +for i ulong get JDXL 0 +jdxget 0 i +jdpkr 0 +end +jdpkfin +end + +note fork and exec the drive packet; exit word; JDC 42 elapsed ns, JDC 43 output bytes in JDF +fn jdbrun to ulong +put JDC 42 0 +put JDC 43 0 +pr = pipefds JDPF 0 8 524288 +if ne pr 0 +ret 1001 +end +rd = jdfdw 0 +wr = jdfdw 4 +t0 = monons +pid = fork +if lt pid 0 +ret 1002 +end +if eq pid 0 +jddchild wr +end +c = fclose wr +dl = add t0 3600000000000 +n = jddread rd dl +if gt monons dl +k = killpid int pid 9 +end +w = waitpid int pid JDWS 0 4 0 +t1 = monons +c = fclose rd +put JDC 42 ulong sub t1 t0 +put JDC 43 n +ret jdwstat +end + +fn jdacqrec lib ulong rep ulong el ulong cu ulong cs ulong ex ulong to void +p = JMPRC +put JDM p lib +put JDM add p 1 rep +put JDM add p 2 el +put JDM add p 3 cu +put JDM add p 4 cs +put JDM add p 5 ex +put JDM add p 6 jddirb 9 +put JDM add p 7 0 +jdspath 0 30 JWACQ 7 +x = jdstw 0 p 8 1089 +end + +note manifest_sha256=<64 hex> of the drive output into register 10 and acq-L-R.mansha +fn jdmansha lib ulong rep ulong n ulong to void +jdsclr 10 +p = jdfindf n JWMSHA 16 +if ge add p 80 add n 1 +ret +end +b = add p 16 +for i ulong 64 +jdsc 10 get JDF add b i +end +jdscp 0 30 +jdsc 0 47 +jdsw 0 JWACQ2 4 +jdsnum 0 lib 1 +jdsc 0 45 +jdsnum 0 rep 1 +jdsw 0 JWMANS 7 +x = jdwreg 10 0 577 +end + +fn jdxpre r ulong to bool +if jdspre r JWUNIT 5 +ret true +end +if jdspre r JWMUT 7 +ret true +end +ret jdspre r JWCRASH 11 +end + +note judge build DRIVE OMEGADIR OMC ALLOW CALIB OUTLIB ACQDIR LIBID REP [DRIVE ARGS...] +fn jdbuildc to int +if lt argcnt 11 +ret jdusage +end +b = jdsarg 18 2 +b = jdsarg 19 3 +b = jdsarg 20 4 +b = jdsarg 11 5 +b = jdsarg 21 6 +b = jdsarg 9 7 +b = jdsarg 30 8 +b = jdsarg 0 9 +lib = jdsval 0 +b = jdsarg 0 10 +rep = jdsval 0 +if or eq lib JDNONE eq rep JDNONE +ret jdusage +end +jdabs 18 +jdabs 20 +if not jdsdash 11 +jdabs 11 +end +if not jdsdash 21 +jdabs 21 +end +jdabs 9 +jdx0 +i = ulong 11 +while lt i ulong argcnt bound 64 +b = jdsarg 0 i +if not jdxpre 0 +jdabs 0 +end +jdxadd 0 +i = add i 1 +end +ex = jdbuild lib rep +if gt ex 255 +ret 255 +end +ret int ex +end + +note ---- recheck (contract 7.4) ---- + +note judge recheck MANSHAFILE PINHEX: 0 REBUILD MATCH, 3 BLOCKED +fn jdrecheck to int +if ne argcnt 4 +ret jdusage +end +b = jdsarg 1 2 +b = jdsarg 2 3 +n = jdldsm 1 +jdsclr 0 +if gt n 0 +for i ulong ulong n +c = get JDWB i +if eq c 10 +break +end +jdsc 0 c +end +end +if and eq get JDSL 2 64 jdseq 0 2 +jdsclr 1 +jdsw 1 JWMATCH 14 +jdsr 1 0 +jdsout 1 +ret 0 +end +jdsclr 1 +jdsw 1 JWBLK 16 +jdsr 1 0 +jdsw 1 JWPIN 8 +jdsr 1 2 +jdsout 1 +ret 3 +end + +note ---- entry ---- + +fn jdmain to int +if lt argcnt 2 +ret jdusage +end +b = jdsarg 0 1 +k = jdspack 0 +if eq k 7239026 +ret jdrun +end +if eq k 7364980 +ret jdtap +end +if eq k 422675505507 +ret jdcalib +end +if eq k 431315580258 +ret jdbuildc +end +if eq k 30227109702231410 +ret jdrecheck +end +if eq k 8317145149216812899 +ret jdcontrols +end +ret jdusage +end + +note ---- controls (contract 9; K7 outcome words, K10 mutants) ---- + +note JDK: 0 synthetic request count, 1 request word cursor, 2 synthetic session ordinal, +note 3 cold flag, 4 outcome undetected count, 5 not-run count, 6 experience byte size, +note 7 last drive exit, 8 synthetic wl, 9 synthetic shape mode, 10 stored generation. +global JDK ulong 64 +global JDCP ulong 64 + +note Control paths: <control dir>/cID-SUFFIX, no collisions/overwrites. +fn jdctpath r ulong id ulong suffix ulong to void +jdscp r 22 +jdsc r 47 +jdsc r 99 +jdsnum r id 1 +jdsc r 45 +jdsnum r suffix 1 +end + +note controls.log: id, subcase, detected (1), undetected (0), reported (2) or not-run (3), +note served-tampered flag, four reserved zero words. Each observation also printed to stdout. +fn jdctl id ulong subc ulong outcome ulong served ulong to void +for i ulong 8 +put JDM add JMPRC i 0 +end +put JDM JMPRC id +put JDM add JMPRC 1 subc +put JDM add JMPRC 2 outcome +put JDM add JMPRC 3 served +jdspath 0 22 JWCLOG 12 +x = jdstw 0 JMPRC 8 1089 +if or eq outcome 0 ne served 0 +jdaddk 4 1 +end +if eq outcome 3 +jdaddk 5 1 +end +jdsclr 0 +jdsc 0 67 +jdsnum 0 id 1 +jdsc 0 47 +jdsnum 0 subc 1 +jdsc 0 61 +jdsnum 0 outcome 1 +jdsw 0 JWWRONG 7 +jdsnum 0 get JDA 1 1 +jdsw 0 JWVIOL 12 +jdsnum 0 get JDA 15 1 +jdsc 0 32 +jdsc 0 53 +jdsc 0 61 +jdsnum 0 get JDA 7 1 +jdsc 0 32 +jdsc 0 77 +jdsc 0 61 +jdsnum 0 add get JDA 5 get JDA 6 1 +jdsout 0 +end + +fn jdaddk i ulong v ulong to void +put JDK i add get JDK i v +end + +fn jdctlbool id ulong subc ulong yes bool served ulong to void +o = ulong 0 +if yes +o = 1 +end +jdctl id subc o served +end + +note load the first valid AGG BEGIN of DEV as the ancestor of the control programs. +fn jdctancestor to bool +jdscp 3 25 +g = jdsload +if lt g 0 +ret false +end +for gi ulong ulong g +nr = jdgload gi +if lt nr 0 +ret false +end +if jdctfind ulong nr +ret true +end +end +ret false +end + +fn jdctfind nr ulong to bool +for j ulong nr +o = add JMRQ get JDM add JMOF j +if ne get JDM o 1 +continue +end +if ne get JDM add o 3 1 +continue +end +for k ulong 64 +put JDCP k get JDM add add o 2 k +end +ret true +end +ret false +end + +note emit RFRQ as the next synthetic request, compare with the independent reference. +fn jdctemit to void +j = get JDK 0 +o = get JDK 1 +nw = add get RFRQ 1 2 +put JDM add JMOF j o +for k ulong nw +put JDM add JMRQ add o k get RFRQ k +end +st = rfreq +ex = add JMEX shl j 3 +for k ulong 8 +put JDM add ex k 0 +end +put JDM ex get RFRS 0 +put JDM add ex 1 get RFRS 1 +put JDM add ex 2 get RFRS 2 +put JDM add ex 3 get RFRS 3 +put JDM add ex 4 get RFRQ 0 +put JDM add ex 5 get JDK 2 +if eq get RFRQ 0 2 +put JDM add ex 6 get JDK 3 +put JDK 3 0 +end +if or eq get RFRQ 0 1 eq get RFRQ 0 8 +put JDK 3 1 +end +put JDK 0 add j 1 +put JDK 1 add o nw +end + +note derive a valid AGG program from DEV, with the same family/fold and its first constant, +note keeping just ADD at the selected width. These deliberate shapes isolate the mutants. +fn jdctprog wl ulong c ulong to void +for k ulong 64 +put RFRQ add 2 k 0 +end +put RFRQ 2 3544411312749556050 +put RFRQ 3 1 +put RFRQ 4 wl +put RFRQ 5 1 +put RFRQ 6 1 +put RFRQ 7 1 +put RFRQ 8 c +end + +note build a synthetic workload: mode 0, train (8 QUERYs); 1, drift + boundary refusals; +note 2, MUL/SHL boundary KATs. It is independently scored by rfreq, not candidate responses. +fn jdctsyn wl ulong mode ulong to void +rfreset +put JDK 0 0 +put JDK 1 0 +put JDK 2 0 +put JDK 3 1 +put JDK 8 wl +put JDK 9 mode +jdctprog wl and get JDCP 6 7 +put RFRQ 0 1 +put RFRQ 1 69 +put RFRQ 66 4 +put RFRQ 67 0 +put RFRQ 68 1 +put RFRQ 69 sub shl ulong 1 wl 1 +put RFRQ 70 2 +if eq wl 16 +put RFRQ 68 256 +end +jdctemit +for i ulong 8 +put RFRQ 0 2 +put RFRQ 1 0 +jdctemit +end +if eq mode 1 +jdctprog wl 9 +put RFRQ 0 8 +put RFRQ 1 64 +jdctemit +put RFRQ 0 2 +put RFRQ 1 0 +jdctemit +put RFRQ 0 3 +put RFRQ 1 2 +put RFRQ 2 0 +put RFRQ 3 shl ulong 1 wl +jdctemit +put RFRQ 0 2 +put RFRQ 1 0 +jdctemit +end +if eq mode 2 +jdctbound wl 3 +jdctbound wl 7 +end +end + +fn jdctbound wl ulong op ulong to void +jdctprog wl 1 +put RFRQ 7 op +put RFRQ 8 sub wl 1 +if eq op 3 +put RFRQ 8 sub shl ulong 1 wl 1 +end +put RFRQ 0 8 +put RFRQ 1 64 +jdctemit +put RFRQ 0 2 +put RFRQ 1 0 +jdctemit +put RFRQ 0 3 +put RFRQ 1 2 +put RFRQ 2 0 +put RFRQ 3 shl ulong 1 wl +jdctemit +put RFRQ 0 2 +put RFRQ 1 0 +jdctemit +end + +note authorize the current digest JDH in ALLOW register 11 (copies of ALLOW are always private). +fn jdctauth to bool +jdsclr 0 +jdshash 0 +jdsw 0 JWAUTH 12 +jdsw 0 JWCTRL 4 +x = jdwreg 0 11 1089 +ret eq x 0 +end + +note tap the current synthetic workload to fresh experience register ep, then authorize it. +fn jdcttap ep ulong to bool +jdarmname 8 8 +jdsdsh 9 +jdsdsh 10 +jdsdsh 11 +jdscp 12 ep +jdsclr 13 +jdsc 13 49 +put JDC 10 1 +put JDC 11 0 +put JDC 12 0 +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 0 +jdcnt0 +e = jdpgroup 0 get JDK 0 +if or ne e 0 ne get JDA 1 0 +ret false +end +if ne get JDC 18 0 +ret false +end +z = jdhfile ep +if le z 0 +ret false +end +jdscp 11 6 +ret jdctauth +end + +note build a library from experience ep, optional mutant kind (0 none, 1 c1, 2 c1b, 3 c1c), +note optional unit mutant kind (0 none, 1 nog3, 2 c4). Destination register 9. +fn jdctbuild ep ulong mut ulong unit ulong rep ulong to ulong +jdx0 +if ne mut 0 +jdsclr 0 +if eq mut 1 +jdsw 0 JWMC1 9 +end +if eq mut 2 +jdsw 0 JWMC1B 10 +end +if eq mut 3 +jdsw 0 JWMC1C 10 +end +jdxadd 0 +end +if ne unit 0 +jdsclr 0 +if eq unit 1 +jdsw 0 JWUCHK 11 +jdsr 0 23 +end +if eq unit 2 +jdsw 0 JWUDEL 11 +jdsr 0 24 +end +jdxadd 0 +end +jdxadd ep +jdscp 11 6 +jdsdsh 21 +ex = jdbuild 9 rep +put JDK 7 ex +ret ex +end + +note run a synthetic workload against the current library (9/10), arm a; no raw measurement log. +fn jdctserve a ulong to bool +jdarmname 8 a +jdscp 11 6 +jdsdsh 12 +jdsdsh 13 +put JDC 10 a +put JDC 11 0 +put JDC 12 0 +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 0 +jdcnt0 +e = jdpgroup 0 get JDK 0 +ret and eq e 0 eq get JDA 15 0 +end + +note G3 refusal means every successful QUERY was route 5 with correct values, no protocol failure. +fn jdctrefused to bool +if eq get JDA 0 0 +ret false +end +if ne get JDA 1 0 +ret false +end +if ne get JDA 15 0 +ret false +end +ret eq get JDA 7 get JDA 0 +end + +note mutant library build + independently scored synthetic workload (id 1/2/3/6). +fn jdctmut id ulong subc ulong mut ulong unit ulong ep ulong to void +jdctpath 9 id subc +ex = jdctbuild ep mut unit add mul id 100 subc +if or ne ex 0 ne get JDSL 10 64 +jdctl id subc 3 0 +ret +end +wl = ulong 16 +jdctsyn wl 1 +ok = jdctserve 4 +if not ok +jdctl id subc 0 0 +ret +end +if or eq unit 1 eq unit 2 +jdctlbool id subc gt get JDA 14 0 0 +else +yes = jdctrefused +if eq id 1 +yes = or yes gt get JDA 14 0 +end +jdctlbool id subc yes 0 +end +end + +note C2/C3 tampered experience helpers. ep -> private copy at register 2; re-authorize its new hash. +fn jdctexcopy ep ulong id ulong subc ulong to bool +jdctpath 2 id add 100 subc +c = jdcpf ep 2 +if ne c 0 +ret false +end +ret true +end + +note tamper variant 0 magic byte, 1 program digest, 2 sample output, 3 permute diagnostic costs. +note Valid admitted records are 1024 bytes, sample slots at words 16..47, costs at word 7. +fn jdctexmut ep ulong id ulong subc ulong kind ulong to void +if not jdctexcopy ep id subc +jdctl id subc 3 0 +ret +end +n = jdldf 2 +if lt n 1024 +jdctl id subc 3 0 +ret +end +if eq kind 0 +put JDF 0 xor get JDF 0 1 +end +if eq kind 1 +put JDF 416 xor get JDF 416 1 +end +if eq kind 2 +x = jdgfw 136 +y = jdgfw 152 +jdpfw 136 y +jdpfw 152 x +end +if eq kind 3 +jdctcost ulong n +end +x = jdwrf 2 ulong n 577 +z = jdhfile 2 +jdscp 11 6 +if not jdctauth +jdctl id subc 3 0 +ret +end +jdctpath 9 id subc +ex = jdctbuild 2 0 0 add mul id 100 subc +if eq kind 3 +if ne ex 0 +jdctl id subc 0 0 +ret +end +jdctsame id subc +else +jdctlbool id subc eq ex 10 0 +end +end + +fn jdctcost n ulong to void +nr = div n 1024 +if lt nr 2 +ret +end +first = jdgfw 56 +for i ulong sub nr 1 +next = jdgfw add mul add i 1 1024 56 +jdpfw add mul i 1024 56 next +end +jdpfw add mul sub nr 1 1024 56 first +end + +note K13 C3 equality: code/ELF byte-identical, manifest count/entries identical; lineage differs. +fn jdctsame id ulong subc ulong to void +ok = jdctcmpdir 14 9 +jdctlbool id subc ok 0 +end + +fn jdctcmpfile to bool +x = jdhfile 0 +for i ulong 4 +put JDT i get JDH i +end +y = jdhfile 1 +if or ne x y lt x 0 +ret false +end +for i ulong 4 +if ne get JDT i get JDH i +ret false +end +end +ret true +end + +fn jdctcmpdir a ulong b ulong to bool +jdspath 0 a JWCUR 7 +x = jdldf 0 +if ne x 40 +ret false +end +ga = jdgfw 0 +jdspath 0 b JWCUR 7 +x = jdldf 0 +if ne x 40 +ret false +end +gb = jdgfw 0 +for e ulong 2 +ext = JWOM +if eq e 1 +ext = JWELF +end +jdgenpath 0 a ga ext +jdgenpath 1 b gb ext +if not jdctcmpfile +ret false +end +end +jdgenpath 0 a ga JWMAN +x = jdldw 0 add JMSC 1024 256 +if ne x 256 +ret false +end +jdgenpath 0 b gb JWMAN +x = jdldf 0 +if ne x 2048 +ret false +end +if ne get JDM add JMSC 1028 jdgfw 32 +ret false +end +for i ulong 128 +pos = add i 56 +if ne get JDM add add JMSC 1024 pos jdgfw mul pos 8 +ret false +end +end +ret true +end + +fn jdgenpath r ulong d ulong g ulong ext ulong to void +jdspath r d JWGEN 4 +jdsnum r g 1 +n = ulong 4 +if eq ext JWOM +n = 3 +end +jdsw r ext n +end + +note mutate CURRENT's named file in library 9; 0 ELF byte, 1 manifest byte, 2 coherent ELF, +note 3 compiler digest, 4 profile version, 5 truncated manifest, 6 truncated CURRENT. +fn jdctart kind ulong to bool +jdspath 0 9 JWCUR 7 +n = jdldf 0 +if ne n 40 +ret false +end +g = jdgfw 0 +put JDK 10 g +if eq kind 6 +x = truncate JDS 0 get JDSL 0 17 +ret eq x 0 +end +if or eq kind 0 eq kind 2 +jdgenpath 0 9 g JWELF +n = jdldf 0 +if le n 256 +ret false +end +p = sub ulong n 1 +put JDF p xor get JDF p 1 +x = jdwrf 0 ulong n 577 +if eq kind 0 +ret eq x 0 +end +z = jdhfile 0 +for i ulong 4 +put JDK add 16 i get JDH i +end +end +jdgenpath 0 9 g JWMAN +n = jdldf 0 +if ne n 2048 +ret false +end +if eq kind 5 +x = truncate JDS 0 get JDSL 0 777 +ret eq x 0 +end +if eq kind 1 +put JDF 101 xor get JDF 101 1 +end +if eq kind 2 +for i ulong 4 +jdpfw mul add 10 i 8 get JDK add 16 i +end +end +if eq kind 3 +put JDF 112 xor get JDF 112 1 +end +if eq kind 4 +jdpfw 144 2 +end +if ne kind 1 +jdctfnv +end +x = jdwrf 0 2048 577 +z = jdhfile 0 +jdspath 0 9 JWCUR 7 +jdpfw 0 g +for i ulong 4 +jdpfw mul add i 1 8 jdbswap get JDH i +end +x = jdwrf 0 40 577 +note K7 C9 must pass the mutated manifest as MANSHA so the compiler/profile check itself is tested. +if or eq kind 3 eq kind 4 +jdsclr 10 +jdshash 10 +end +ret eq x 0 +end + +fn jdctfnv to void +h = ulong 14695981039346656037 +for i ulong 2040 +h = mul xor h ulong get JDF i 1099511628211 +end +jdpfw 2040 h +end + +note artifact load-refusal controls use the private honest library 14/15. +fn jdctartifact id ulong subc ulong kind ulong to void +jdctpath 9 id subc +x = jdcpdir 14 9 +if ne x 0 +jdctl id subc 3 0 +ret +end +jdscp 10 15 +if not jdctart kind +jdctl id subc 3 0 +ret +end +jdctsyn 16 1 +ok = jdctserve 4 +served = ulong 0 +if gt add get JDA 5 get JDA 6 0 +served = 1 +end +jdctlbool id subc and ok jdctrefused served +end + +note create a private ALLOW and append a REVOKED line for the control experience register 27. +fn jdctrevprep subc ulong to bool +jdctpath 28 9 add 100 subc +x = jdcpf 6 28 +if ne x 0 +ret false +end +z = jdhfile 27 +if lt z 0 +ret false +end +jdsclr 29 +jdshash 29 +jdsw 29 JWREVK 9 +jdsw 29 JWCTRL 4 +jdsc 29 10 +ret true +end + +fn jdctrevoke subc ulong to void +if not jdctrevprep subc +jdctl 9 subc 3 0 +ret +end +jdctsyn 16 1 +jdarmname 8 4 +jdscp 9 14 +jdscp 10 15 +jdscp 11 28 +jdsdsh 12 +jdsdsh 13 +put JDC 10 4 +put JDC 11 0 +put JDC 12 0 +put JDC 16 JDNONE +if eq subc 0 +jdrevoke +else +put JDC 16 2 +end +put JDC 17 JDNONE +put JDC 19 0 +jdcnt0 +e = jdpgroup 0 get JDK 0 +served = ulong 0 +ok = false +if eq subc 0 +if gt add get JDA 5 get JDA 6 0 +served = 1 +end +ok = jdctrefused +else +if gt get JDA 11 0 +served = 1 +end +ok = jdctrevmid +end +ok = and ok eq e 0 +ok = and ok eq get JDA 1 0 +jdctlbool 9 subc ok served +put JDC 16 JDNONE +jdsclr 28 +jdsclr 29 +end + +fn jdctrevmid to bool +if eq get JDA 13 0 +ret false +end +if eq get JDA 10 0 +ret false +end +ret eq get JDA 10 get JDA 12 +end + +note C8 steps: seed the directory with an honest complete generation, then invoke crashafter:K; +note read CURRENT and check its manifest/ELF SHA-256, pin it, serve and score with the reference. +fn jdctcrash step ulong to void +jdctpath 9 10 step +x = jdcpdir 14 9 +if ne x 0 +jdctl 10 step 3 0 +ret +end +jdx0 +jdsclr 0 +jdsw 0 JWCRASH 11 +jdsnum 0 step 1 +jdxadd 0 +jdxadd 27 +jdscp 11 6 +jdsdsh 21 +ex = jdbuild 9 add 1000 step +if ne ex 97 +jdctl 10 step 0 0 +ret +end +if not jdctcurrent +jdctl 10 step 0 0 +ret +end +jdctsyn 16 1 +ok = jdctserve 4 +ok = and ok eq get JDA 1 0 +m = add get JDA 5 get JDA 6 +ok = and ok gt m 0 +jdctlbool 10 step ok 0 +end + +note validate complete CURRENT files independently; use its manifest digest as MANSHA (register 10). +fn jdctcurrent to bool +jdspath 0 9 JWCUR 7 +n = jdldf 0 +if ne n 40 +ret false +end +g = jdgfw 0 +for i ulong 4 +put JDK add 16 i jdbswap jdgfw mul add i 1 8 +end +jdgenpath 0 9 g JWMAN +n = jdhfile 0 +if ne n 2048 +ret false +end +for i ulong 4 +if ne get JDH i get JDK add 16 i +ret false +end +end +jdsclr 10 +jdshash 10 +n = jdldf 0 +if ne n 2048 +ret false +end +for i ulong 4 +put JDK add 16 i jdgfw mul add 10 i 8 +end +jdgenpath 0 9 g JWELF +n = jdhfile 0 +if le n 0 +ret false +end +for i ulong 4 +if ne get JDH i get JDK add 16 i +ret false +end +end +jdgenpath 0 9 g JWOM +ret gt jdfsize 0 0 +end + +note C11: identity before/after a real SIGKILL mid-session, fresh process byte-identical responses. +fn jdctrestart to void +jdctsyn 16 1 +jdscp 9 14 +jdscp 10 15 +ok = jdctserve 4 +if or not ok ne get JDA 1 0 +jdctl 13 0 0 0 +ret +end +for i ulong 4 +put JDK add 24 i get JDM add add JMRT 4 i +end +if not jdctcurrent +jdctl 13 0 0 0 +ret +end +jdctsyn 16 1 +jdarmname 8 4 +jdscp 11 6 +jdsdsh 12 +jdsdsh 13 +put JDC 17 3 +put JDC 16 JDNONE +put JDC 19 0 +jdcnt0 +e = jdpgroup 0 get JDK 0 +killed = eq get JDC 18 265 +put JDC 17 JDNONE +jdscp 9 14 +if not jdctcurrent +jdctl 13 0 0 0 +ret +end +jdctsyn 16 1 +ok = jdctserve 4 +same = jdseq 10 15 +jdctlbool 13 0 and killed and same and ok eq get JDA 1 0 0 +end + +note C5 is scored both at widths 8 and 16, full and delta (with/without a library). +fn jdctkat wl ulong a ulong subc ulong to void +jdctsyn wl 2 +if eq a 1 +jdsdsh 9 +jdsdsh 10 +else +jdscp 9 14 +jdscp 10 15 +end +ok = jdctserve a +jdctlbool 7 subc and ok eq get JDA 1 0 0 +end + +note controls DEV BASE DRIVE OMEGADIR OMC ALLOW NOG3 C4 OUT CPU +note Builds its own honest control experiences and libraries; no FINAL data or vault access. +fn jdcontrols to int +if ne argcnt 12 +ret jdusage +end +b = jdsarg 25 2 +b = jdsarg 5 3 +b = jdsarg 18 4 +b = jdsarg 19 5 +b = jdsarg 20 6 +b = jdsarg 1 7 +b = jdsarg 23 8 +b = jdsarg 24 9 +b = jdsarg 22 10 +b = jdsarg 7 11 +jdabs 18 +jdabs 20 +jdabs 23 +jdabs 24 +r = jdmkdir 22 448 +jdabs 22 +jdscp 30 22 +jdctpath 6 0 0 +c = jdcpf 1 6 +if ne c 0 +ret jderr 70 +end +jdctpath 26 0 8 +jdctpath 27 0 16 +if not jdctancestor +ret jderr 71 +end +put JDK 4 0 +put JDK 5 0 +jdctsyn 8 0 +if not jdcttap 26 +ret jderr 72 +end +jdctsyn 16 0 +if not jdcttap 27 +ret jderr 73 +end +note Honest rebuild for C3 costs and all artifact/lifecycle controls. +jdctpath 9 0 1 +ex = jdctbuild 27 0 0 1 +if ne ex 0 +ret jderr 74 +end +jdscp 14 9 +jdscp 15 10 +jdctmut 1 0 1 0 26 +jdctmut 1 1 1 1 26 +jdctmut 2 0 2 0 27 +jdctmut 2 1 2 1 27 +jdctmut 3 0 3 0 27 +jdctexmut 27 4 0 0 +jdctexmut 27 4 1 1 +jdctexmut 27 5 0 2 +jdctexmut 27 5 1 3 +jdctmut 6 0 0 2 27 +for w ulong 2 +wl = add mul w 8 8 +jdctkat wl 1 mul w 3 +jdctkat wl 4 add mul w 3 1 +jdctsyn wl 2 +jdsdsh 9 +jdsdsh 10 +ok = jdctserve 4 +jdctlbool 7 add mul w 3 2 and ok eq get JDA 1 0 0 +end +for k ulong 3 +jdctartifact 8 k k +end +jdctrevoke 0 +jdctrevoke 1 +for k ulong 9 +jdctcrash add k 1 +end +jdctartifact 11 0 3 +jdctartifact 11 1 4 +jdctartifact 12 0 5 +jdctartifact 12 1 6 +jdctrestart +note C12 is an ablation report, not a guard detection; run independently via judge run with arms 56. +jdctl 14 0 2 0 +if gt get JDK 4 0 +ret 4 +end +if gt get JDK 5 0 +ret 3 +end +ret 0 +end diff --git a/om/reuse-eval/main.om b/om/reuse-eval/main.om new file mode 100644 index 0000000..809e29d --- /dev/null +++ b/om/reuse-eval/main.om @@ -0,0 +1,19 @@ +note SPDX-License-Identifier: Apache-2.0 +note One evaluator binary: sha256 ref stats turing receipt judge main, in that order. +fn main to int +if lt argcnt 2 +ret jdusage +end +b = jdsarg 0 1 +k = jdspack 0 +if eq k 495873782899 +ret stmain +end +if eq k 113723913172340 +ret tumain +end +if eq k 32774695273325938 +ret rcmain +end +ret jdmain +end diff --git a/om/reuse-eval/receipt.om b/om/reuse-eval/receipt.om new file mode 100644 index 0000000..543ce98 --- /dev/null +++ b/om/reuse-eval/receipt.om @@ -0,0 +1,413 @@ +note SPDX-License-Identifier: Apache-2.0 +note receipt.om (lane EvalStats, spark-rsi-mv #73): the REUSE-1 receipt of contract section 7.5 with +note the identity fields of spark-rsi docs/RECEIPT-V2.md, an evaluation-budget record and an +note explicit UNSIGNED status (no .om P-256 signer exists; the #67 signer is Rust). Needs the units +note sha256, stats and turing (st* files and output, tusha, tub/tule). Names: rc*, RC*. +note +note CLI (argv[1] is the dispatcher's subcommand): +note receipt SPLITDIR RUNDIR STATSDIR CONTRACT CANDCOMMIT MANSHA OUTFILE +note SPLITDIR = the FINAL split (index); RUNDIR = the FINAL run (acq-1-R.mansha, R = 0..2, the +note evaluator's rebuilds of the TRAIN library); STATSDIR holds stats.sum; CONTRACT = the REUSE-1 +note contract file (policy digest = SHA-256 of its bytes); CANDCOMMIT = the candidate-freeze commit +note (40 lowercase hex); MANSHA = the frozen manifest SHA-256 (64 lowercase hex), which must equal +note every acq-1-R.mansha (section 7.4: otherwise BLOCKED, not reproducible). OUTFILE receives +note the receipt (also on stdout). +note +note Receipt lines, in this order (key=value): +note receipt=REUSE-1 format_version=2 kind=evaluation status=UNSIGNED +note signature=UNSIGNED reason=no_om_p256_signer (REUSE-1 7.5, spark-rsi #67 signer is Rust) +note subject_commit=<40 hex> the candidate-freeze commit +note subject_mansha=<64 hex> MANSHA (binding.subject_sha256 of RECEIPT-V2) +note holdout_set_sha256=<64 hex> FINAL index words 7..10 (each word's bytes big endian) +note policy_sha256=<64 hex> SHA-256 of the contract bytes +note evaluator_binary_sha256=<64 hex> SHA-256 of /proc/self/exe (the running evaluator) +note stats_summary_sha256=<64 hex> SHA-256 of stats.sum (the results this receipt states) +note holdouts_total=<n> holdouts_passed=<n> scored QUERY responses of arms 1..7 over every +note repetition, and the correct ones (stats.sum 12, 13) +note counts groups= sessions= requests= queries= reps= arms=8 wrong_refusals= +note decision=<GO|INVESTIGATE|STOP> reason_bits=<stats.sum word 3> +note budget split=FINAL runs_allowed=1 runs_used=1 seed=burned (a void run burns the seed) +note independence=UNISOLATED +note receipt_identity_sha256=<64 hex> +note receipt_identity_sha256 = SHA-256 over length-prefixed fields as RECEIPT-V2's digest writes +note them (u64 LE byte length, then the bytes; numbers as 8-byte LE): the string +note "spark-rsi.reuse1-receipt.v2-unsigned", the hex strings of subject_commit, subject_mansha, +note holdout_set_sha256, policy_sha256, evaluator_binary_sha256, stats_summary_sha256, then +note holdouts_total, holdouts_passed, decision (1 GO, 2 INVESTIGATE, 3 STOP), reason bits. It is +note not a RECEIPT-V2 receipt_digest (that one covers fields R1 has no value for) and it is not a +note signature. +note Exit 0 = written; 2 = refused (status=REFUSED code=N): 1 usage, 2 commit not 40 lowercase +note hex, 3 MANSHA not 64 lowercase hex, 4 index unreadable or invalid, 5 contract unreadable, +note 6 evaluator binary unreadable, 7 stats.sum missing or invalid, 8 an acq-1-R.mansha missing, +note 9 MANSHA differs from a rebuild (BLOCKED: not reproducible), 10 the index is not FINAL +note (split id 4), 11 stats.sum is not the summary of this split (its split id is not 4, its +note words 18..21 differ from index words 7..10, or its group, session, request or QUERY count +note differs from the index); 15 output failure. + +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" + +const RKHEAD ulong 0 +const RKSIG ulong 1 +const RKCOMM ulong 2 +const RKMANS ulong 3 +const RKHOLD ulong 4 +const RKPOL ulong 5 +const RKEVAL ulong 6 +const RKSTAT ulong 7 +const RKTOT ulong 8 +const RKPASS ulong 9 +const RKCNT ulong 10 +const RKSESS ulong 11 +const RKREQS ulong 12 +const RKQRYS ulong 13 +const RKREPS ulong 14 +const RKARMS ulong 15 +const RKDECI ulong 16 +const RKBITS ulong 17 +const RKBUDG ulong 18 +const RKINDEP ulong 19 +const RKIDENT ulong 20 +const RKDOM ulong 21 +const RKEXE ulong 22 +const RKACQ ulong 23 +const RKMSH ulong 24 +const RKREFU ulong 25 +const RKGO ulong 26 + +global RCH ulong 24 +global RCS ulong 32 + +fn rckoff k ulong to ulong +i = ulong 0 +c = ulong 0 +while lt c k bound 999999 +if eq get RCK i 10 +c = add c 1 +end +i = add i 1 +end +ret i +end + +fn rcks k ulong to void +i = rckoff k +while ne get RCK i 10 bound 4096 +stoc get RCK i +i = add i 1 +end +end + +fn rckp k ulong to void +i = rckoff k +while ne get RCK i 10 bound 4096 +stpc get RCK i +i = add i 1 +end +end + +note slot b holds exactly n lowercase hex characters +fn rchex b ulong n ulong to bool +if ne get STBL b n +ret false +end +o = mul b 4096 +for i ulong n +c = get STBD add o i +if not or and ge c 48 le c 57 and ge c 97 le c 102 +ret false +end +end +ret true +end + +note TUD saved as digest d (0 holdout, 1 policy, 2 evaluator, 3 stats) in RCH +fn rcsave d ulong to void +for j ulong 4 +put RCH add mul d 4 j get TUD j +end +end + +note digest d as 64 hex (word j little-endian bytes, the TUD convention) +fn rcohd d ulong to void +for j ulong 4 +v = get RCH add mul d 4 j +for k ulong 8 +stohb and shr v mul k 8 255 +end +end +end + +note the holdout digest words (big-endian bytes per word) into RCH 0..3 in the TUD convention +fn rchold to void +for j ulong 4 +v = get STHD j +x = ulong 0 +for k ulong 8 +x = or x shl and shr v mul sub 7 k 8 255 mul k 8 +end +put RCH j x +end +end + +note SHA-256 of the file at STPB into RCH d; false when unreadable +fn rcfile d ulong to bool +n = stload +if lt n 0 +ret false +end +tusha 1000 1 0 ulong n +rcsave d +ret true +end + +note every acq-1-R.mansha equals slot 5 (64 hex then a newline); 0 ok, 8 missing, 9 differs +fn rcmansha to int +for r ulong 3 +stpbase 1 +rckp RKACQ +stpc uchar add r 48 +rckp RKMSH +n = stload +if lt n 64 +ret 8 +end +for i ulong 64 +if ne get STFB i get STBD add 20480 i +ret 9 +end +end +if gt n 64 +if or gt n 65 ne get STFB 64 10 +ret 9 +end +end +end +ret 0 +end + +note stats.sum into RCS (words 0..31); false when missing or not R1STS001 version 1 +fn rcsum to bool +stpbase 2 +stpk SKSUM +n = stload +if ne n 2048 +ret false +end +tusha 1000 1 0 2048 +rcsave 3 +for k ulong 32 +put RCS k stw mul k 8 +end +if ne get RCS 0 3544386041195737426 +ret false +end +ret eq get RCS 1 1 +end + +note one length-prefixed field from slot b (its bytes) into TUFB +fn rcfslot b ulong to void +n = get STBL b +tule n 8 +o = mul b 4096 +for i ulong n +tub ulong get STBD add o i +end +end + +note one length-prefixed 64-hex field from digest d +fn rcfdig d ulong to void +tule 64 8 +h = stkoff SKDIG +for j ulong 4 +v = get RCH add mul d 4 j +for k ulong 8 +b = and shr v mul k 8 255 +tub ulong get STK add h shr b 4 +tub ulong get STK add h and b 15 +end +end +end + +fn rcfnum v ulong to void +tule 8 8 +tule v 8 +end + +note receipt identity digest into RCH 16..19 +fn rcident to void +put TUFL 0 0 +i = rckoff RKDOM +n = sub rckoff add RKDOM 1 add i 1 +tule n 8 +for j ulong n +tub ulong get RCK add i j +end +rcfslot 4 +rcfslot 5 +for d ulong 4 +rcfdig d +end +rcfnum get RCS 12 +rcfnum get RCS 13 +rcfnum get RCS 2 +rcfnum get RCS 3 +tusha 1000 0 0 get TUFL 0 +rcsave 4 +end + +note slot b's bytes to the output +fn rcoslot b ulong to void +o = mul b 4096 +for i ulong get STBL b +stoc get STBD add o i +end +end + +fn rcreport to void +rcks RKHEAD +stnl +rcks RKSIG +stnl +rcks RKCOMM +rcoslot 4 +stnl +rcks RKMANS +rcoslot 5 +stnl +rcks RKHOLD +rcohd 0 +stnl +rcks RKPOL +rcohd 1 +stnl +rcks RKEVAL +rcohd 2 +stnl +rcks RKSTAT +rcohd 3 +stnl +rcks RKTOT +stou get RCS 12 +rcks RKPASS +stou get RCS 13 +stnl +rcks RKCNT +stou get RCS 4 +rcks RKSESS +stou get RCS 5 +rcks RKREQS +stou get RCS 6 +rcks RKQRYS +stou get RCS 7 +rcks RKREPS +stou get RCS 8 +rcks RKARMS +stou get RCS 15 +stnl +rcks RKDECI +d = get RCS 2 +if and ge d 1 le d 3 +rcks add RKGO sub d 1 +else +stou d +end +rcks RKBITS +stou get RCS 3 +stnl +rcks RKBUDG +stnl +rcks RKINDEP +stnl +rcks RKIDENT +rcohd 4 +stnl +end + +fn rcfail code ulong to int +put STOP 0 0 +rcks RKREFU +stou code +stnl +if ne get STQT 0 1 +r = stflush 1 +end +ret 2 +end + +note stats.sum describes this split: split id 4, words 18..21 = the index holdout words 7..10 +note (both as stored), and the group, session, request and QUERY counts equal the index's +fn rcsame to bool +if ne get RCS 9 4 +ret false +end +for j ulong 4 +if ne get RCS add 18 j get STHD j +ret false +end +end +if or ne get RCS 4 get STNG 0 ne get RCS 5 get STNS 0 +ret false +end +ret and eq get RCS 6 get STNR 0 eq get RCS 7 get STNQ 0 +end + +note the receipt on slots 0 split, 1 run, 2 stats dir, 3 contract, 4 commit, 5 MANSHA, 6 out +note file; stdout unless STQT is 1 +fn rcrun to int +streset +if not rchex 4 40 +ret rcfail 2 +end +if not rchex 5 64 +ret rcfail 3 +end +if ne stidx 0 +ret rcfail 4 +end +if ne get STSPL 0 4 +ret rcfail 10 +end +rchold +stpexact 3 +if not rcfile 1 +ret rcfail 5 +end +put STPL 0 0 +rckp RKEXE +if not rcfile 2 +ret rcfail 6 +end +if not rcsum +ret rcfail 7 +end +if not rcsame +ret rcfail 11 +end +e = rcmansha +if ne e 0 +ret rcfail ulong e +end +rcident +put STOP 0 0 +rcreport +if ne get STQT 0 1 +r = stflush 1 +end +stpexact 6 +if ne stwfile 0 +ret 15 +end +ret 0 +end + +fn rcmain to int +if lt argcnt 9 +ret rcfail 1 +end +for k ulong 7 +if eq stargb add k 2 k 0 +ret rcfail 1 +end +end +ret rcrun +end diff --git a/om/reuse-eval/ref.om b/om/reuse-eval/ref.om new file mode 100644 index 0000000..6f4f5ce --- /dev/null +++ b/om/reuse-eval/ref.om @@ -0,0 +1,643 @@ +note SPDX-License-Identifier: Apache-2.0 +note ref.om: the evaluator's own reference of REUSE-1 profile R1 (docs/reuse/REUSE-1.md v1.0, +note omega-mv d6edaad1, section 1), written from the contract text alone (no candidate code read). +note Units before it: sha256 (omega-mv main om/sha256/sha256.om, unchanged). Prefix rf / RF. +note +note Use: put one request frame (op, p, p payload words) into RFRQ, call rfreq; the response is in +note RFRS (0 status, 1 q, 2 r0, 3 r1, 4 route 0, rest 0) and rfreq returns the status. +note Status rules (contract 1.3, 2, integrator clarification K2): +note p > 7234 or unknown op: 4. p not matching its op: 4. BEGIN: p < 65 or p != 65 + n: 4, +note n > 4096: 5, invalid PROG: 2, a value outside the domain: 3; a refused BEGIN keeps the +note previous session. Ops 2..8 without a session: 6. STATS and END: 0, q 0 (END drops the +note session). SET/INS/DEL/SWAP: 3 when an index is out of range, a value is outside the domain +note or INS would make n > 4096. BATCH: m outside 1..1024: 3; item op outside 3..6 or a DEL item +note with b != 0: 3; items judged in order on the state the earlier items leave; all or nothing. +note PROGRAM: invalid PROG 2 first, then any state value outside the new domain 3. +note Validity of one change depends only on n and the domain, so BATCH is validated by simulating n +note over the items and applied only when every item is valid (nothing is written before that). +note +note Hashing: rfpdig hashes RFP (512 LE bytes) into RFPD; streams use a context slot 0..7: +note rfhini slot, rfhabs slot n (RFHB[0..n), n <= 65536), rfhfin slot (-> RFHD). Digest word j = +note bytes 8j..8j+7 read big endian (contract 1.1). + +global RFP ulong 64 +global RFQ ulong 64 +global RFN ulong 1 +global RFX ulong 4096 +global RFS ulong 1 +global RFR ulong 2 +global RFRQ ulong 7240 +global RFRS ulong 8 +global RFPD ulong 4 +global RFHB uchar 65536 +global RFHC uchar 832 +global RFHD ulong 4 + +note ---- lane map, folds, transitions (contract 1.2) ---- + +note one lane step: v < 2^wl, c < 2^wl, shifts c < wl +fn rfop wl ulong op ulong c ulong v ulong to ulong +m = sub shl ulong 1 wl 1 +if eq op 1 +ret and add v c m +end +if eq op 2 +ret and sub v c m +end +if eq op 3 +ret and mul v c m +end +if eq op 4 +ret and v c +end +if eq op 5 +ret or v c +end +if eq op 6 +ret xor v c +end +if eq op 7 +ret and shl v c m +end +ret shr v c +end + +fn rflane x ulong to ulong +wl = get RFP 2 +k = get RFP 4 +v = x +for j ulong k +o = get RFP add 5 mul j 2 +c = get RFP add 6 mul j 2 +v = rfop wl o c v +end +ret v +end + +fn rfident f ulong to ulong +if or eq f 3 eq f 6 +ret 18446744073709551615 +end +ret 0 +end + +fn rffold f ulong a ulong b ulong to ulong +if eq f 1 +ret add a b +end +if eq f 2 +ret xor a b +end +if eq f 3 +if lt b a +ret b +end +ret a +end +if eq f 4 +if gt b a +ret b +end +ret a +end +if eq f 5 +ret or a b +end +ret and a b +end + +note delta(s, a): t of the lowest-numbered rule with rule.s = s and lo <= a <= hi, else s +fn rfdelta s ulong a ulong to ulong +r = get RFP 5 +for i ulong r +w = get RFP add 22 i +if eq and w 255 s +lo = and shr w 8 255 +hi = and shr w 16 255 +if and le lo a le a hi +ret shr w 24 +end +end +end +ret s +end + +fn rfagg to void +n = get RFN 0 +f = get RFP 3 +acc = rfident f +for i ulong n +e = rflane get RFX i +acc = rffold f acc e +end +put RFR 0 acc +put RFR 1 n +end + +fn rffsm to void +n = get RFN 0 +q = get RFP 4 +sum = ulong 0 +for t ulong n +q = rfdelta q get RFX t +sum = add sum get RFP add 6 q +end +put RFR 0 q +put RFR 1 sum +end + +note the result of RFP over (RFN, RFX) into RFR +fn rffull to void +if eq get RFP 1 1 +rfagg +ret +end +rffsm +end + +fn rfshape to ulong +if eq get RFP 1 2 +ret 1 +end +s = ulong 0 +m = ulong 65536 +k = get RFP 4 +for j ulong k +s = add s mul m get RFP add 5 mul j 2 +m = mul m 16 +end +b = add get RFP 2 mul 256 get RFP 3 +ret add add b mul 4096 k s +end + +note ---- program validation (contract 1.1), on the staging buffer RFQ ---- + +fn rfvagg to int +wl = get RFQ 2 +if and ne wl 8 ne wl 16 +ret 2 +end +f = get RFQ 3 +if or lt f 1 gt f 6 +ret 2 +end +k = get RFQ 4 +if or lt k 1 gt k 6 +ret 2 +end +lim = shl ulong 1 wl +for j ulong 6 +o = get RFQ add 5 mul j 2 +c = get RFQ add 6 mul j 2 +if lt j k +if or lt o 1 gt o 8 +ret 2 +end +if ge c lim +ret 2 +end +if and ge o 7 ge c wl +ret 2 +end +else +if or ne o 0 ne c 0 +ret 2 +end +end +end +for i ulong 47 +if ne get RFQ add i 17 0 +ret 2 +end +end +ret 0 +end + +note one FSM rule word, r < R: s < S, t < S, lo <= hi < A +fn rfvrule w ulong s ulong a ulong to bool +rs = and w 255 +lo = and shr w 8 255 +hi = and shr w 16 255 +t = shr w 24 +if or ge rs s ge t s +ret false +end +if or gt lo hi ge hi a +ret false +end +ret true +end + +fn rfvfsm to int +s = get RFQ 2 +a = get RFQ 3 +if or lt s 2 gt s 16 +ret 2 +end +if or lt a 2 gt a 16 +ret 2 +end +if ge get RFQ 4 s +ret 2 +end +r = get RFQ 5 +if or lt r 1 gt r 24 +ret 2 +end +for i ulong 16 +l = get RFQ add 6 i +if lt i s +if gt l 255 +ret 2 +end +else +if ne l 0 +ret 2 +end +end +end +for j ulong 24 +w = get RFQ add 22 j +if lt j r +if not rfvrule w s a +ret 2 +end +else +if ne w 0 +ret 2 +end +end +end +for k ulong 18 +if ne get RFQ add k 46 0 +ret 2 +end +end +ret 0 +end + +note 0 valid, 2 invalid (RFQ) +fn rfvalid to int +if ne get RFQ 0 3544411312749556050 +ret 2 +end +fam = get RFQ 1 +if eq fam 1 +ret rfvagg +end +if eq fam 2 +ret rfvfsm +end +ret 2 +end + +note value domain of a valid program: AGG 2^wl, FSM A +fn rfdomq to ulong +if eq get RFQ 1 1 +ret shl ulong 1 get RFQ 2 +end +ret get RFQ 3 +end + +fn rfdom to ulong +if eq get RFP 1 1 +ret shl ulong 1 get RFP 2 +end +ret get RFP 3 +end + +note ---- changes (contract 1.3) ---- + +note validity of one change on a state of n values with domain d: 0 or 3 +fn rfchk op ulong a ulong b ulong n ulong d ulong to ulong +if eq op 3 +if or ge a n ge b d +ret 3 +end +ret 0 +end +if eq op 4 +if or gt a n ge b d +ret 3 +end +if ge n 4096 +ret 3 +end +ret 0 +end +if eq op 5 +if or ge a n ne b 0 +ret 3 +end +ret 0 +end +if eq op 6 +if or ge a n ge b n +ret 3 +end +ret 0 +end +ret 3 +end + +note apply one already validated change to RFX, RFN +fn rfdo op ulong a ulong b ulong to void +n = get RFN 0 +if eq op 3 +put RFX a b +ret +end +if eq op 4 +i = n +while gt i a bound 4097 +put RFX i get RFX sub i 1 +i = sub i 1 +end +put RFX a b +put RFN 0 add n 1 +ret +end +if eq op 5 +j = a +while lt add j 1 n bound 4097 +put RFX j get RFX add j 1 +j = add j 1 +end +put RFN 0 sub n 1 +ret +end +t = get RFX a +put RFX a get RFX b +put RFX b t +end + +note BATCH payload at RFRQ[2..]: m, then m triples; p already checked against 1 + 3m +fn rfbatch to ulong +m = get RFRQ 2 +if or lt m 1 gt m 1024 +ret 3 +end +d = rfdom +n = get RFN 0 +for i ulong m +o = get RFRQ add 3 mul i 3 +a = get RFRQ add 4 mul i 3 +b = get RFRQ add 5 mul i 3 +if ne rfchk o a b n d 0 +ret 3 +end +if eq o 4 +n = add n 1 +end +if eq o 5 +n = sub n 1 +end +end +for j ulong m +o2 = get RFRQ add 3 mul j 3 +a2 = get RFRQ add 4 mul j 3 +b2 = get RFRQ add 5 mul j 3 +rfdo o2 a2 b2 +end +ret 0 +end + +note ---- requests (contract 2) ---- + +fn rfbegin p ulong to ulong +if lt p 65 +ret 4 +end +n = get RFRQ 66 +if ne p add n 65 +ret 4 +end +if gt n 4096 +ret 5 +end +for i ulong 64 +put RFQ i get RFRQ add i 2 +end +if ne rfvalid 0 +ret 2 +end +d = rfdomq +for j ulong n +if ge get RFRQ add j 67 d +ret 3 +end +end +for k ulong 64 +put RFP k get RFQ k +end +for t ulong n +put RFX t get RFRQ add t 67 +end +put RFN 0 n +put RFS 0 1 +ret 0 +end + +fn rfprog to ulong +for i ulong 64 +put RFQ i get RFRQ add i 2 +end +if ne rfvalid 0 +ret 2 +end +d = rfdomq +n = get RFN 0 +for j ulong n +if ge get RFX j d +ret 3 +end +end +for k ulong 64 +put RFP k get RFQ k +end +ret 0 +end + +fn rfquery to ulong +rffull +put RFRS 1 3 +put RFRS 2 get RFR 0 +put RFRS 3 get RFR 1 +ret 0 +end + +note the expected payload length of op given the frame, or 7235 when it cannot match +fn rfplen op ulong p ulong to ulong +if or eq op 2 or eq op 9 eq op 10 +ret 0 +end +if or eq op 3 or eq op 4 eq op 6 +ret 2 +end +if eq op 5 +ret 1 +end +if eq op 8 +ret 64 +end +if eq op 7 +if lt p 1 +ret 7235 +end +m = get RFRQ 2 +if gt m 2411 +ret 7235 +end +ret add 1 mul 3 m +end +ret 7235 +end + +fn rfreq2 to ulong +op = get RFRQ 0 +p = get RFRQ 1 +if gt p 7234 +ret 4 +end +if or lt op 1 gt op 10 +ret 4 +end +if eq op 1 +ret rfbegin p +end +if ne p rfplen op p +ret 4 +end +if eq op 9 +ret 0 +end +if eq op 10 +put RFS 0 0 +ret 0 +end +if eq get RFS 0 0 +ret 6 +end +if eq op 2 +ret rfquery +end +if eq op 7 +ret rfbatch +end +if eq op 8 +ret rfprog +end +b = ulong 0 +if ne op 5 +b = get RFRQ 3 +end +a = get RFRQ 2 +if ne rfchk op a b get RFN 0 rfdom 0 +ret 3 +end +rfdo op a b +ret 0 +end + +fn rfreq to int +for i ulong 8 +put RFRS i 0 +end +st = rfreq2 +put RFRS 0 st +ret int st +end + +fn rfreset to void +put RFS 0 0 +put RFN 0 0 +end + +note ---- SHA-256 through omsha (sha256 unit) ---- + +fn rfbswap x ulong to ulong +r = ulong 0 +v = x +for i ulong 8 +r = or shl r 8 and v 255 +v = shr v 8 +end +ret r +end + +fn rfhini slot ulong to void +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +omsha c b 0 0 w b8 +rfhst c slot +end + +note context slot into c and back; RFHB[off..off+k) into b +fn rfhld c edit uchar 104 slot ulong to void +o = mul slot 104 +for i ulong 104 +put c i get RFHC add o i +end +end + +fn rfhst c edit uchar 104 slot ulong to void +o = mul slot 104 +for i ulong 104 +put RFHC add o i get c i +end +end + +fn rfhcp b edit uchar 4096 off ulong k ulong to void +for j ulong k +put b j get RFHB add off j +end +end + +fn rfhabs slot ulong n ulong to void +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +rfhld c slot +off = ulong 0 +while lt off n bound 17 +k = sub n off +if gt k 4096 +k = 4096 +end +rfhcp b off k +omsha c b k 1 w b8 +off = add off k +end +rfhst c slot +end + +fn rfhfin slot ulong to void +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +rfhld c slot +omsha c b 0 2 w b8 +for j ulong 4 +put RFHD j rfbswap get w j +end +end + +note program digest of RFP into RFPD (uses slot 7 and RFHB[0..512)) +fn rfpdig to void +for i ulong 64 +x = get RFP i +for j ulong 8 +put RFHB add mul i 8 j uchar and shr x mul j 8 255 +end +end +rfhini 7 +rfhabs 7 512 +rfhfin 7 +for k ulong 4 +put RFPD k get RFHD k +end +end diff --git a/om/reuse-eval/sha256.om b/om/reuse-eval/sha256.om new file mode 100644 index 0000000..88e6b0b --- /dev/null +++ b/om/reuse-eval/sha256.om @@ -0,0 +1,1527 @@ +note SPDX-License-Identifier: Apache-2.0 +note sha256.om: FIPS 180-4 SHA-256 as one function-mode unit, bound through the omega-bridge native +note call ABI (docs/NATIVE-ABI.md) and exported as omega_omsha. It replaces the algorithm of +note src/sha256.c: the C file keeps only the sha256_* entry points that cut caller data into +note pieces of at most 4096 bytes. +note +note The whole hash state lives in the caller's sha256_ctx (104 bytes, src/sha256.h): +note bytes 0..31 state[8], uint32 little endian +note bytes 32..39 count, uint64 little endian (bytes absorbed so far) +note bytes 40..103 buffer, the pending partial block +note omsha c b n op w b8: +note op 0 init: count 0, FIPS initial hash value +note op 1 absorb b[0..n), n <= 4096, with src/sha256.c's buffering rules +note op 2 final: pad, absorb the bit length, the 32-byte digest packed into w[0..4) +note op 3 one shot: the digest of the n < 4096 bytes of b8 packed into w[0..4); c is not used +note w is the caller's scratch for the message schedule (64 words, contents ignored and overwritten): +note Omega writes every word before reading it, so the caller need not clear it. +note n > 4096 traps 3; any other op traps 9. + +note little-endian word of nb bytes at byte offset p of the context +fn getle c edit uchar 104 p ulong nb ulong to ulong +v = ulong 0 +i = nb +while gt i 0 bound 8 +i = sub i 1 +v = or shl v 8 ulong get c add p i +end +ret v +end + +fn putle c edit uchar 104 p ulong nb ulong v ulong to void +x = v +for i ulong nb +put c add p i uchar and x 255 +x = shr x 8 +end +end + +note the hash words of the context into h, and back +fn loadh c edit uchar 104 h edit uint 8 to void +for i ulong 8 +put h i uint getle c mul i 4 4 +end +end + +fn storeh c edit uchar 104 h edit uint 8 to void +for i ulong 8 +putle c mul i 4 4 ulong get h i +end +end + +note big-endian words of the block at byte o of b into w[0..16), then the schedule +fn schedb b view uchar 4096 o ulong w edit ulong 64 to void +for i ulong 16 +q = add o mul i 4 +v = ulong get b q +v = or shl v 8 ulong get b add q 1 +v = or shl v 8 ulong get b add q 2 +v = or shl v 8 ulong get b add q 3 +put w i or v shl v 32 +end +expand w +end + +note big-endian words of the block at byte 40 of b into w[0..16), then the schedule +fn schedc b edit uchar 104 w edit ulong 64 to void +for i ulong 16 +q = add 40 mul i 4 +v = ulong get b q +v = or shl v 8 ulong get b add q 1 +v = or shl v 8 ulong get b add q 2 +v = or shl v 8 ulong get b add q 3 +put w i or v shl v 32 +end +expand w +end + +note the 64 rounds, unrolled with the working words in locals (names rotate instead of moving). +note Same lazy low-32-bit cells and rotate trick as expand; K is an immediate; the eight words are +note reduced to 32 bits only when they are added back into h. +fn rounds h edit uint 8 w view ulong 64 to void +a = ulong get h 0 +b = ulong get h 1 +c = ulong get h 2 +d = ulong get h 3 +e = ulong get h 4 +f = ulong get h 5 +g = ulong get h 6 +x = ulong get h 7 +t = ulong 0 +u = ulong 0 +t = add x add get w 0 1116352408 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 1 1899447441 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 2 3049323471 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 3 3921009573 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 4 961987163 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 5 1508970993 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 6 2453635748 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 7 2870763221 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 8 3624381080 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 9 310598401 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 10 607225278 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 11 1426881987 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 12 1925078388 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 13 2162078206 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 14 2614888103 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 15 3248222580 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 16 3835390401 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 17 4022224774 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 18 264347078 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 19 604807628 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 20 770255983 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 21 1249150122 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 22 1555081692 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 23 1996064986 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 24 2554220882 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 25 2821834349 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 26 2952996808 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 27 3210313671 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 28 3336571891 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 29 3584528711 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 30 113926993 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 31 338241895 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 32 666307205 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 33 773529912 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 34 1294757372 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 35 1396182291 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 36 1695183700 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 37 1986661051 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 38 2177026350 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 39 2456956037 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 40 2730485921 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 41 2820302411 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 42 3259730800 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 43 3345764771 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 44 3516065817 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 45 3600352804 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 46 4094571909 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 47 275423344 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 48 430227734 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 49 506948616 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 50 659060556 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 51 883997877 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 52 958139571 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 53 1322822218 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 54 1537002063 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 55 1747873779 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 56 1955562222 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 57 2024104815 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 58 2227730452 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 59 2361852424 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 60 2428436474 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 61 2756734187 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 62 3204031479 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 63 3329325298 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add ulong get h 0 a +put h 0 uint and t 4294967295 +t = add ulong get h 1 b +put h 1 uint and t 4294967295 +t = add ulong get h 2 c +put h 2 uint and t 4294967295 +t = add ulong get h 3 d +put h 3 uint and t 4294967295 +t = add ulong get h 4 e +put h 4 uint and t 4294967295 +t = add ulong get h 5 f +put h 5 uint and t 4294967295 +t = add ulong get h 6 g +put h 6 uint and t 4294967295 +t = add ulong get h 7 x +put h 7 uint and t 4294967295 +end + +fn tobuf c edit uchar 104 bi ulong b view uchar 4096 bo ulong n ulong to void +for i ulong n +put c add 40 add bi i get b add bo i +end +end + +note absorb b[0..n), n <= 4096, exactly as src/sha256.c sha256_update does for that piece +fn absorb c edit uchar 104 b view uchar 4096 n ulong w edit ulong 64 to void +if gt n 4096 +trap 3 +end +h = new uint 8 0 +cnt = getle c 32 8 +bi = and cnt 63 +putle c 32 8 add cnt n +off = ulong 0 +if gt bi 0 +lf = sub 64 bi +if lt n lf +tobuf c bi b 0 n +ret +end +tobuf c bi b 0 lf +loadh c h +schedc c w +rounds h w +storeh c h +off = lf +end +if le add off 64 n +loadh c h +while le add off 64 n bound 65 +schedb b off w +rounds h w +off = add off 64 +end +storeh c h +end +tobuf c 0 b off sub n off +end + +fn init c edit uchar 104 to void +putle c 32 8 0 +putle c 0 4 1779033703 +putle c 4 4 3144134277 +putle c 8 4 1013904242 +putle c 12 4 2773480762 +putle c 16 4 1359893119 +putle c 20 4 2600822924 +putle c 24 4 528734635 +putle c 28 4 1541459225 +end + +note compress the context's own block buffer (bytes 40..103) into its hash words +fn compbuf c edit uchar 104 w edit ulong 64 to void +h = new uint 8 0 +loadh c h +schedc c w +rounds h w +storeh c h +end + +note zero buffer bytes s..e-1 (indices into the 64-byte block) +fn zbuf c edit uchar 104 s ulong e ulong to void +i = s +while lt i e bound 64 +put c add 40 i 0 +i = add i 1 +end +end + +note sha256_final of src/sha256.c, padding in place: 0x80, zeros to 56 mod 64 (one more block +note when the pending part is 56 bytes or more), the 64-bit big-endian bit count, then the digest. +note The count field is left as it was (src/sha256.c adds the padding to it; nothing reads it after). +fn final c edit uchar 104 w edit ulong 64 to void +cnt = getle c 32 8 +bi = and cnt 63 +put c add 40 bi 128 +zbuf c add bi 1 64 +if ge bi 56 +compbuf c w +zbuf c 0 56 +end +bits = mul cnt 8 +for i ulong 8 +sh = mul sub 7 i 8 +put c add 96 i uchar and shr bits sh 255 +end +compbuf c w +h = new uint 8 0 +loadh c h +digest8 h w +end + +note IV into h +fn initiv h edit uint 8 to void +put h 0 uint 1779033703 +put h 1 uint 3144134277 +put h 2 uint 1013904242 +put h 3 uint 2773480762 +put h 4 uint 1359893119 +put h 5 uint 2600822924 +put h 6 uint 528734635 +put h 7 uint 1541459225 +end + +note expand w[0..16) into the full 64-word schedule, unrolled (constant indices need no bounds checks). +note Every schedule word is stored duplicated, the 32-bit value in both halves (d = (x << 32) | x), so +note a rotate right by r is the low half of d >> r and a plain shift right by n is d >> (32 + n); sums +note are formed in the low 32 bits (add, and, xor, or need no masks) and duplicated once on store. +fn expand w edit ulong 64 to void +u = ulong 0 +v = ulong 0 +x = ulong 0 +x = get w 14 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 1 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 9 +u = add u get w 0 +u = shl u 32 +put w 16 or u shr u 32 +x = get w 15 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 2 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 10 +u = add u get w 1 +u = shl u 32 +put w 17 or u shr u 32 +x = get w 16 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 3 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 11 +u = add u get w 2 +u = shl u 32 +put w 18 or u shr u 32 +x = get w 17 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 4 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 12 +u = add u get w 3 +u = shl u 32 +put w 19 or u shr u 32 +x = get w 18 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 5 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 13 +u = add u get w 4 +u = shl u 32 +put w 20 or u shr u 32 +x = get w 19 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 6 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 14 +u = add u get w 5 +u = shl u 32 +put w 21 or u shr u 32 +x = get w 20 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 7 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 15 +u = add u get w 6 +u = shl u 32 +put w 22 or u shr u 32 +x = get w 21 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 8 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 16 +u = add u get w 7 +u = shl u 32 +put w 23 or u shr u 32 +x = get w 22 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 9 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 17 +u = add u get w 8 +u = shl u 32 +put w 24 or u shr u 32 +x = get w 23 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 10 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 18 +u = add u get w 9 +u = shl u 32 +put w 25 or u shr u 32 +x = get w 24 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 11 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 19 +u = add u get w 10 +u = shl u 32 +put w 26 or u shr u 32 +x = get w 25 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 12 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 20 +u = add u get w 11 +u = shl u 32 +put w 27 or u shr u 32 +x = get w 26 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 13 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 21 +u = add u get w 12 +u = shl u 32 +put w 28 or u shr u 32 +x = get w 27 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 14 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 22 +u = add u get w 13 +u = shl u 32 +put w 29 or u shr u 32 +x = get w 28 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 15 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 23 +u = add u get w 14 +u = shl u 32 +put w 30 or u shr u 32 +x = get w 29 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 16 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 24 +u = add u get w 15 +u = shl u 32 +put w 31 or u shr u 32 +x = get w 30 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 17 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 25 +u = add u get w 16 +u = shl u 32 +put w 32 or u shr u 32 +x = get w 31 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 18 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 26 +u = add u get w 17 +u = shl u 32 +put w 33 or u shr u 32 +x = get w 32 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 19 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 27 +u = add u get w 18 +u = shl u 32 +put w 34 or u shr u 32 +x = get w 33 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 20 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 28 +u = add u get w 19 +u = shl u 32 +put w 35 or u shr u 32 +x = get w 34 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 21 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 29 +u = add u get w 20 +u = shl u 32 +put w 36 or u shr u 32 +x = get w 35 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 22 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 30 +u = add u get w 21 +u = shl u 32 +put w 37 or u shr u 32 +x = get w 36 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 23 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 31 +u = add u get w 22 +u = shl u 32 +put w 38 or u shr u 32 +x = get w 37 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 24 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 32 +u = add u get w 23 +u = shl u 32 +put w 39 or u shr u 32 +x = get w 38 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 25 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 33 +u = add u get w 24 +u = shl u 32 +put w 40 or u shr u 32 +x = get w 39 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 26 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 34 +u = add u get w 25 +u = shl u 32 +put w 41 or u shr u 32 +x = get w 40 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 27 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 35 +u = add u get w 26 +u = shl u 32 +put w 42 or u shr u 32 +x = get w 41 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 28 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 36 +u = add u get w 27 +u = shl u 32 +put w 43 or u shr u 32 +x = get w 42 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 29 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 37 +u = add u get w 28 +u = shl u 32 +put w 44 or u shr u 32 +x = get w 43 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 30 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 38 +u = add u get w 29 +u = shl u 32 +put w 45 or u shr u 32 +x = get w 44 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 31 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 39 +u = add u get w 30 +u = shl u 32 +put w 46 or u shr u 32 +x = get w 45 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 32 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 40 +u = add u get w 31 +u = shl u 32 +put w 47 or u shr u 32 +x = get w 46 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 33 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 41 +u = add u get w 32 +u = shl u 32 +put w 48 or u shr u 32 +x = get w 47 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 34 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 42 +u = add u get w 33 +u = shl u 32 +put w 49 or u shr u 32 +x = get w 48 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 35 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 43 +u = add u get w 34 +u = shl u 32 +put w 50 or u shr u 32 +x = get w 49 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 36 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 44 +u = add u get w 35 +u = shl u 32 +put w 51 or u shr u 32 +x = get w 50 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 37 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 45 +u = add u get w 36 +u = shl u 32 +put w 52 or u shr u 32 +x = get w 51 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 38 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 46 +u = add u get w 37 +u = shl u 32 +put w 53 or u shr u 32 +x = get w 52 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 39 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 47 +u = add u get w 38 +u = shl u 32 +put w 54 or u shr u 32 +x = get w 53 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 40 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 48 +u = add u get w 39 +u = shl u 32 +put w 55 or u shr u 32 +x = get w 54 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 41 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 49 +u = add u get w 40 +u = shl u 32 +put w 56 or u shr u 32 +x = get w 55 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 42 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 50 +u = add u get w 41 +u = shl u 32 +put w 57 or u shr u 32 +x = get w 56 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 43 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 51 +u = add u get w 42 +u = shl u 32 +put w 58 or u shr u 32 +x = get w 57 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 44 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 52 +u = add u get w 43 +u = shl u 32 +put w 59 or u shr u 32 +x = get w 58 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 45 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 53 +u = add u get w 44 +u = shl u 32 +put w 60 or u shr u 32 +x = get w 59 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 46 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 54 +u = add u get w 45 +u = shl u 32 +put w 61 or u shr u 32 +x = get w 60 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 47 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 55 +u = add u get w 46 +u = shl u 32 +put w 62 or u shr u 32 +x = get w 61 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 48 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 56 +u = add u get w 47 +u = shl u 32 +put w 63 or u shr u 32 +end + +note Word access for the aligned paths. b8 is the caller's 8-byte-aligned copy of the input lent a +note second time as ulong cells (b views the same bytes), so one load brings 8 bytes. Swapping the +note bytes inside each 32-bit half (two mask-and-shift steps; the constants stay in registers) turns +note little-endian bytes b0..b7 into the big-endian words b0..b3 (low half) and b4..b7 (high half). +note Each word is stored duplicated, as expand requires. +fn blk8 b8 view ulong 512 q ulong w edit ulong 64 to void +for i ulong 8 +x = get b8 add q i +y = or shl and x 71777214294589695 8 and shr x 8 71777214294589695 +y = or shl and y 281470681808895 16 and shr y 16 281470681808895 +j = mul i 2 +t = shl y 32 +put w j or t shr t 32 +put w add j 1 or and y 18446744069414584320 shr y 32 +end +end + +note the padded tail b[off..n) (less than 64 bytes), read as words through b8 (the bytes past n +note are inside the caller's 4096-byte copy and are masked off here): the word holding byte n keeps +note its k valid bytes and gets 0x80 after them, later words are zero, the 64-bit bit count goes in +note words 14 and 15; a second block when the tail is 56 bytes or more +fn tail8 h edit uint 8 b8 view ulong 512 off ulong n ulong w edit ulong 64 to void +blk8 b8 shr off 3 w +r = sub n off +fw = shr r 2 +k = and r 3 +sh = mul k 8 +v = get w fw +v = and v shl 4294967295 sub 32 sh +v = and v 4294967295 +v = or v shl 128 sub 24 sh +put w fw or v shl v 32 +i = add fw 1 +while lt i 16 bound 16 +put w i 0 +i = add i 1 +end +if ge r 56 +expand w +rounds h w +for j ulong 14 +put w j 0 +end +end +bits = mul n 8 +v = shr bits 32 +put w 14 or v shl v 32 +v = and bits 4294967295 +put w 15 or v shl v 32 +expand w +rounds h w +end + +note the digest of h as 32 bytes packed little endian into w[0..4): word i holds the big-endian +note bytes of h[2i] then h[2i+1], so the caller copies the digest out of w with memcpy +fn digest8 h edit uint 8 w edit ulong 64 to void +for i ulong 4 +j = mul i 2 +x = or ulong get h j shl ulong get h add j 1 32 +y = or shl and x 71777214294589695 8 and shr x 8 71777214294589695 +y = or shl and y 281470681808895 16 and shr y 16 281470681808895 +put w i y +end +end + +note SHA-256 of the n < 4096 bytes in b8, state in locals only (sha256_hash's short path) +fn oneshot b8 view ulong 512 n ulong w edit ulong 64 to void +if ge n 4096 +trap 3 +end +h = new uint 8 0 +initiv h +off = ulong 0 +while le add off 64 n bound 64 +blk8 b8 shr off 3 w +expand w +rounds h w +off = add off 64 +end +tail8 h b8 off n w +digest8 h w +end + +fn omsha c edit uchar 104 b view uchar 4096 n ulong op ulong w edit ulong 64 b8 view ulong 512 to void +if eq op 0 +init c +ret +end +if eq op 1 +absorb c b n w +ret +end +if eq op 2 +final c w +ret +end +if eq op 3 +oneshot b8 n w +ret +end +trap 9 +end diff --git a/om/reuse-eval/sha256.pin b/om/reuse-eval/sha256.pin new file mode 100644 index 0000000..e5c3edf --- /dev/null +++ b/om/reuse-eval/sha256.pin @@ -0,0 +1,5 @@ +source aien-dev/omega-mv main +commit acb3f15cdc691b1b046b48b0dad0f9255a12ba4b +path om/sha256/sha256.om +sha256 7f034814303a8a40b4bc56383ddd55ab2ae8460291f80793340bc3b0ac024e21 +copy om/reuse-eval/sha256.om (byte identical, unchanged) diff --git a/om/reuse-eval/stats.om b/om/reuse-eval/stats.om new file mode 100644 index 0000000..da07168 --- /dev/null +++ b/om/reuse-eval/stats.om @@ -0,0 +1,2204 @@ +note SPDX-License-Identifier: Apache-2.0 +note stats.om (lane EvalStats, spark-rsi-mv #73): the REUSE-1 statistics and decision unit. +note Contract: omega-mv d6edaad1 docs/reuse/REUSE-1.md (sections 6, 9, 10); evaluator formats: +note docs EVAL-FORMATS (split directory, raw run log, proc.log, acq.log, controls.log K7, seeds K6). +note No fn main here: the evaluator dispatcher calls stmain. Names: functions st*, globals ST*, +note constants SK*. turing.om and receipt.om reuse the st* output, path and file helpers. +note +note CLI (argv[1] is the dispatcher's subcommand and is not read): +note stats SPLITDIR RUNDIR CTRLDIR SEEDHEX OUTDIR +note SPLITDIR = the FINAL split directory (index, sessions, gNN.exp); RUNDIR = arm-A-rep-R-gNN.log, +note proc.log, acq.log; CTRLDIR = the directory holding controls.log, or - when no control run +note exists (every control then counts as not run); SEEDHEX = the 32-byte FINAL seed as 64 hex; +note OUTDIR receives stats.txt (the report, also written to stdout) and stats.sum (words below). +note Exit 0 = report written (the decision is inside it), 2 = inputs refused (status=REFUSED line +note with a code, nothing else decided), other = output write failure. +note +note Definitions (all integer, no floating point): +note - reps R = 3 (0-based in names and logs), arms 0 echo 1 full 2 cache 3 method 4 delta +note 5 idelta 6 deltap 7 select. Library charged per arm: method, delta, select = acq lib 1 +note (TRAIN), deltap = lib 2 (TRAINP), every other arm none (idelta runs with LIBDIR -). +note - cost of one arm process (arm a, rep r, group g) = start-to-ready (proc word 3, which +note includes request 0's round trip) + sum of round trips of requests 1.. of the group + the END +note round trip (proc word 15, K17; raw logs and proc word 12 exclude END). This charges +note start-to-ready to the first request (contract 5.4). +note - process exit (proc word 10, K17): 0 ok; any nonzero value (exit code, 256 + signal, +note 512 + judge kill code, 1023 reap failure, + 1024 when END itself failed) is a failed process +note and counts as one wrong refusal of its arm (so STOP for arms 1..7); reported per arm as +note proc_failed (correct line), exit_nonzero and end_failed (memory line). +note - V(a, g) = sum over the 3 reps of the process cost; acq(a) = sum over the 3 reps of the +note elapsed ns of the arm's library build. T(a) = sum over groups of V(a, g) + acq(a). Sums over +note reps stand for the per-group means of contract 10 (the factor 3 cancels in every ratio). +note - rho(a) = T(a) / T(full); ratio rho(x)/rho(y) = T(x) / T(y) (full cancels, same resample). +note Statistic s: 0..7 rho(arm s); 8 delta/cache; 9 delta/idelta; 10 select/delta; +note 11 delta/method; 12 idelta/full. +note - ppm = floor(num * 1000000 / den), exact 128-bit product and division. Floor makes the +note decision comparisons exact: ppm < 1000000 iff ratio < 1; ppm >= 1000000 iff ratio >= 1. +note - bootstrap: B = 10000 resamples; resample b draws G group indices, each = splitmix64() mod G +note (bias below G / 2^64); one draw serves every arm (paired); splitmix64 state starts at the +note FINAL seed bytes 0..7 read little endian (contract 10, K6) and is advanced once per draw. +note The 10000 values of each statistic are sorted ascending; interval = (v[k_lo], v[k_hi]) with +note nearest rank k = ceil(p * B) - 1 (0-based): p = 0.025 gives k_lo = 249, p = 0.975 gives 9749. +note The point value is the statistic on the sample itself (every group once). +note - quantiles: nearest rank on ascending values, index ceil(p * m / 100) - 1 for p = 50, 95, 99, +note over the QUERY round trips (all 3 reps) of one arm, cold (exp cold flag 1) or warm (0), +note per category: all, session type, novelty class, family, n class. m = 0 prints na. +note - cat_rho: request round trips only (no start-to-ready, no acquisition), per session category, +note arm over full; regime lines are the cat_rho ratios delta/method and idelta/full per type. +note - correctness: the log's word 15 is recomputed from words 5..11 (QUERY 1 iff status, r0, r1 +note equal; other requests 2 iff status equal; echo 2); a record is wrong when either the log or +note the recomputation says 0; disagreements are counted as log_inconsistent. Echo is never scored. +note - transfer coverage: delta-arm QUERYs (all reps) in sessions of novelty class 2 with route 3 +note or 4, over all such QUERYs. Fallback = route 5 among an arm's QUERYs. +note - payback(a): FINAL request order (group 0.., request 0..), per request the rep-summed +note (full - arm) cost (request 0 = start-to-ready only), then after each group's last request +note the rep-summed (full - arm) END round trip; the number of QUERYs seen when the cumulative +note sum first exceeds acq(a) (tested after every request and after every END term); none if +note it never does. rho totals include END as before. +note - Cbar (contract 6, #744), per arm, ppm of one full QUERY: F = floor(full QUERY round-trip +note sum / count); r = echo mean QUERY / F; q = QUERYs not served by routes 2..4 / QUERYs; +note e = mean of the route 2..4 QUERYs / F - r; K = acq(a) / F (full-QUERY units); N = the arm's +note QUERYs over 3 reps; cbar = r + (1 - q) e + q + K / N (signed, truncating toward zero); +note observed = (QUERY round-trip sum + acq) / N / F. Reported, never in the decision. +note - echo_sub(a) = (T(a) - T(echo)) / (T(full) - T(echo)), signed ppm (secondary figure). +note - decision (contract 10, K7): STOP on any wrong answer or wrong refusal of arms 1..7, a control +note with outcome 0 or the served-tampered flag, or lower bound of rho(delta) >= 1; else GO when +note upper bounds of rho(delta), delta/cache and delta/idelta are < 1, transfer coverage >= 1/2 +note (with at least one transfer QUERY) and every control C1..C12 has all its required +note (control, sub-case) pairs (stcreq) and none not run; a missing pair counts as not run; +note else INVESTIGATE. Every failing condition is listed as a reason line. +note +note stats.sum: 256 words LE. 0 magic 3544386041195737426 (R1STS001), 1 version 1, 2 decision +note (1 GO, 2 INVESTIGATE, 3 STOP), 3 reason bits (0 wrong_answer, 1 wrong_refusal, +note 2 control_undetected, 3 tampered_served, 4 rho_delta_lower_ge_1, 5 rho_delta_upper_ge_1, +note 6 delta_over_cache_upper_ge_1, 7 delta_over_idelta_upper_ge_1, 8 transfer_coverage_below_half, +note 9 control_not_run), 4 groups, 5 sessions, 6 requests, 7 queries (per rep), 8 reps, 9 split id, +note 10 bootstrap seed, 11 resamples, 12 scored QUERY responses (arms 1..7, all reps), 13 correct +note ones, 14 wrong ones, 15 wrong refusals, 16 transfer QUERYs, 17 covered, 18..21 holdout digest +note (index words 7..10 as stored), 22 log inconsistencies, 24 + 3 s .. 26 + 3 s point, lo, hi ppm +note of statistic s (s 0..12), 64 + a T(a), 72 + a acq(a), 80 + a route-5 QUERYs of arm a, +note 88 + a payback QUERYs (18446744073709551615 = none or not applicable), 96 + a failed +note processes of arm a (K17 nonzero exit), 104 + a processes of arm a whose END failed; the rest 0. +note +note Refusal codes: 1 usage, 2 index unreadable, 3 index invalid, 4 sessions invalid, 5 exp invalid, +note 6 log missing, 7 log size, 8 log identity words, 9 log expectation words differ from exp, +note 10 proc.log invalid, 11 proc record missing or duplicate, 12 acq.log invalid or a needed build +note missing, 13 controls.log invalid (detail k.0 field range, k.1 reported outside C12, k.2 +note sub-case not required, k.3 repeated pair; k = record), 14 capacity, 15 output write failed. + +const SKINDEX ulong 0 +const SKSESS ulong 1 +const SKEXP ulong 2 +const SKARMP ulong 3 +const SKREPP ulong 4 +const SKGP ulong 5 +const SKLOG ulong 6 +const SKPROC ulong 7 +const SKACQ ulong 8 +const SKCTL ulong 9 +const SKTXT ulong 10 +const SKSUM ulong 11 +const SKHEAD ulong 12 +const SKREFU ulong 13 +const SKDETL ulong 14 +const SKINPUT ulong 15 +const SKGROUP ulong 16 +const SKSESN ulong 17 +const SKREQS ulong 18 +const SKQRYS ulong 19 +const SKREPS ulong 20 +const SKARM ulong 21 +const SKTOTAL ulong 22 +const SKRTNS ulong 23 +const SKREADY ulong 24 +const SKACQNS ulong 25 +const SKTOTNS ulong 26 +const SKRHO ulong 27 +const SKPOINT ulong 28 +const SKLO ulong 29 +const SKHI ulong 30 +const SKRATIO ulong 31 +const SKCORR ulong 32 +const SKQOK ulong 33 +const SKQBAD ulong 34 +const SKCOK ulong 35 +const SKCBAD ulong 36 +const SKUNSC ulong 37 +const SKINCON ulong 38 +const SKROUTE ulong 39 +const SKRN ulong 40 +const SKEQ ulong 41 +const SKROTH ulong 42 +const SKFALL ulong 43 +const SKCOVER ulong 44 +const SKCOVD ulong 45 +const SKCOVP ulong 46 +const SKMEM ulong 47 +const SKPROCS ulong 48 +const SKHWMX ulong 49 +const SKHWMM ulong 50 +const SKRSSX ulong 51 +const SKCPU ulong 52 +const SKEXITN ulong 53 +const SKACQL ulong 54 +const SKBUILD ulong 55 +const SKELAP ulong 56 +const SKLIBB ulong 57 +const SKDRIVN ulong 58 +const SKPAYB ulong 59 +const SKPAYQ ulong 60 +const SKNONE ulong 61 +const SKCBAR ulong 62 +const SKCR ulong 63 +const SKCQ ulong 64 +const SKCE ulong 65 +const SKCK ulong 66 +const SKCN ulong 67 +const SKCBV ulong 68 +const SKCOBS ulong 69 +const SKECHO ulong 70 +const SKPPM ulong 71 +const SKNA ulong 72 +const SKQUANT ulong 73 +const SKTEMP ulong 74 +const SKCOLD ulong 75 +const SKWARM ulong 76 +const SKCAT ulong 77 +const SKCOUNT ulong 78 +const SKP50 ulong 79 +const SKP95 ulong 80 +const SKP99 ulong 81 +const SKCATR ulong 82 +const SKREGT ulong 83 +const SKDOM ulong 84 +const SKIOF ulong 85 +const SKCTLID ulong 86 +const SKRECS ulong 87 +const SKDET ulong 88 +const SKUNDET ulong 89 +const SKREPD ulong 90 +const SKNRUN ulong 91 +const SKTAMP ulong 92 +const SKDECI ulong 93 +const SKREAS ulong 94 +const SKI742 ulong 95 +const SKI743 ulong 96 +const SKI744 ulong 97 +const SKVERD ulong 98 +const SKHELPS ulong 99 +const SKNHELP ulong 100 +const SKINCO ulong 101 +const SKVERDS ulong 102 +const SKSIMNR ulong 103 +const SKSTEP ulong 104 +const SKBOOT ulong 105 +const SKSEED ulong 106 +const SKRKLO ulong 107 +const SKRKHI ulong 108 +const SKGO ulong 109 +const SKINV ulong 110 +const SKSTOP ulong 111 +const SKRWA ulong 112 +const SKRWR ulong 113 +const SKRCU ulong 114 +const SKRTS ulong 115 +const SKRLO ulong 116 +const SKRUP ulong 117 +const SKRDC ulong 118 +const SKRDI ulong 119 +const SKRCOV ulong 120 +const SKRNR ulong 121 +const SKMATCH ulong 122 +const SKYES ulong 123 +const SKNO ulong 124 +const SKARM0 ulong 125 +const SKCAT0 ulong 133 +const SKRAT0 ulong 153 +const SKCID0 ulong 157 +const SKOC0 ulong 172 +const SKBINDF ulong 177 +const SKRESTA ulong 178 +const SKDOMR ulong 179 +const SKIOFR ulong 180 +const SKR5 ulong 181 +const SKSPACE ulong 182 +const SKDIG ulong 183 +const SKR5D ulong 184 +const SKMISSP ulong 185 +const SKENDNS ulong 186 +const SKENDF ulong 187 +const SKPROCF ulong 188 + +text STK "index\nsessions\n.exp\narm-\n-rep-\n-g\n.log\nproc.log\nacq.log\ncontrols.log\nstats.txt\nstats.sum\nreport=reuse1-stats version=1 contract=REUSE-1 v1.0\nstatus=REFUSED code=\n detail=\ninput split=\n groups=\n sessions=\n requests=\n queries=\n reps=\n arm=\ntotal\n rt_ns=\n ready_ns=\n acq_ns=\n total_ns=\nrho\n point_ppm=\n lo_ppm=\n hi_ppm=\nratio name=\ncorrect\n query_ok=\n query_wrong=\n change_ok=\n change_wrong=\n unscored=\n log_inconsistent=\nroutes\n r\n=\n other=\n fallback_ppm=\ncoverage arm=delta class=transfer queries=\n method_served=\n coverage_ppm=\nmemory\n procs=\n hwm_max_kb=\n hwm_mean_kb=\n rss_max_kb=\n cpu_ticks=\n exit_nonzero=\nacq lib=\n builds=\n elapsed_ns=\n libdir_bytes_max=\n drive_nonzero=\npayback\n queries=\nnone\ncbar\n r_ppm=\n q_ppm=\n e_ppm=\n k_units_ppm=\n n=\n cbar_ppm=\n observed_ppm=\necho_sub\n ppm=\nna\nquant\n temp=\ncold\nwarm\n cat=\n count=\n p50_ns=\n p95_ns=\n p99_ns=\ncat_rho\nregime cat=\n delta_over_method_ppm=\n idelta_over_full_ppm=\ncontrol id=\n records=\n detected=\n undetected=\n reported=\n not_run=\n served_tampered=\ndecision=\nreason=\nissue742 transfer_coverage_ppm=\nissue743\nissue744 select_over_delta\n verdict=\nhelps\ndoes_not_help\ninconclusive\nverdicts source=REVIEW_REQUIRED host=\n simulator=NOT_RUN physical=NOT_RUN\nfull_ns_per_step=NOT_RECORDED reason=raw_logs_carry_no_reference_timing\nbootstrap resamples=\n seed=\n rank_lo=\n rank_hi=\nGO\nINVESTIGATE\nSTOP\nwrong_answer\nwrong_refusal\ncontrol_undetected\ntampered_served\nrho_delta_lower_ge_1\nrho_delta_upper_ge_1\ndelta_over_cache_upper_ge_1\ndelta_over_idelta_upper_ge_1\ntransfer_coverage_below_half\ncontrol_not_run\n matched_correctness=\nyes\nno\necho\nfull\ncache\nmethod\ndelta\nidelta\ndeltap\nselect\nall\ntype:Z\ntype:S\ntype:D\ntype:R\ntype:I\ntype:A\ntype:P\ntype:C\nnov:none\nnov:recall\nnov:transfer\nnov:novel\nnov:fsm_recall\nnov:fsm_new\nfam:AGG\nfam:FSM\nn:64\nn:512\nn:4096\ndelta/cache\ndelta/idelta\nselect/delta\ndelta/method\nidelta/full\nC1\nC1b\nC1c\nC2\nC3\nC4\nC5\nC6\nC7\nC8\nC9\nC10\nC11\nC12\ndetected\nundetected\nreported\nnot_run\nmissing\n bind_failures=NOT_RECORDED\n restart_identity=\n delta_over_method\n idelta_over_full\n route5_method=\n \n0123456789abcdef\n route5_delta=\n missing_pairs=\n end_ns=\n end_failed=\n proc_failed=\n" + +global STOB uchar 4194304 +global STOP ulong 1 +global STPB uchar 4096 +global STPL ulong 1 +global STBD uchar 32768 +global STBL ulong 8 +global STFB uchar 8388608 +global STRNG ulong 1 +global STRF ulong 4 +global STNG ulong 1 +global STNS ulong 1 +global STNR ulong 1 +global STNQ ulong 1 +global STSPL ulong 1 +global STHD ulong 4 +global STSEED ulong 1 +global STGO ulong 128 +global STGN ulong 128 +global STSG ulong 1024 +global STSF ulong 1024 +global STST ulong 1024 +global STSN ulong 1024 +global STSC ulong 1024 +global STRO ulong 65536 +global STRC ulong 65536 +global STRS ulong 65536 +global STRX ulong 65536 +global STR0 ulong 65536 +global STR1 ulong 65536 +global STRT ulong 1572864 +global STAG ulong 3072 +global STA0 ulong 3072 +global STPR ulong 3072 +global STPF ulong 3072 +global STPE ulong 3072 +global STCNT ulong 256 +global STSS ulong 8192 +global STAQ ulong 32 +global STAQC ulong 32 +global STAQX ulong 32 +global STAQB ulong 32 +global STAQF ulong 32 +global STCT ulong 128 +global STV ulong 1024 +global STAA ulong 8 +global STT ulong 8 +global STBS ulong 130000 +global STPT ulong 13 +global STLO ulong 13 +global STHI ulong 13 +global STQV ulong 262144 +global STQI ulong 262144 +global STHL ulong 2 +global STDEC ulong 2 +global STSUM ulong 256 +global STPYC long 1 +global STPYQ ulong 1 +global STQT ulong 1 + +note ---------- output buffer ---------- +fn stoc c uchar to void +p = get STOP 0 +put STOB p c +put STOP 0 add p 1 +end + +fn stkoff k ulong to ulong +i = ulong 0 +c = ulong 0 +while lt c k bound 999999 +if eq get STK i 10 +c = add c 1 +end +i = add i 1 +end +ret i +end + +fn stks k ulong to void +i = stkoff k +while ne get STK i 10 bound 4096 +stoc get STK i +i = add i 1 +end +end + +fn stnl to void +stoc 10 +end + +fn stou v ulong to void +d = new uchar 24 0 +n = ulong 0 +x = v +while true bound 30 +put d n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +if eq x 0 +break +end +end +for i ulong n +stoc get d sub sub n i 1 +end +end + +fn stol v long to void +if lt v 0 +stoc 45 +stou ulong neg v +ret +end +stou ulong v +end + +note one lowercase hex digit pair of byte b +fn stohb b ulong to void +h = add stkoff SKDIG shr b 4 +l = add stkoff SKDIG and b 15 +stoc get STK h +stoc get STK l +end + +note a digest word as stored in the split files (bytes 8j..8j+7 read big endian) as 16 hex digits +fn stohw w ulong to void +for k ulong 8 +stohb and shr w mul sub 7 k 8 255 +end +end + +note key k, then value v +fn stkv k ulong v ulong to void +stks k +stou v +end + +fn stkvl k ulong v long to void +stks k +stol v +end + +note write the output buffer to fd; 0 ok +fn stflush fd int to int +n = get STOP 0 +o = ulong 0 +while lt o n bound 999999 +w = write fd STOB o sub n o +if le w 0 +ret 1 +end +o = add o ulong w +end +ret 0 +end + +note ---------- paths and files ---------- +fn stpc c uchar to void +p = get STPL 0 +put STPB p c +put STPL 0 add p 1 +end + +fn stpk k ulong to void +i = stkoff k +while ne get STK i 10 bound 4096 +stpc get STK i +i = add i 1 +end +end + +fn stpu v ulong to void +d = new uchar 24 0 +n = ulong 0 +x = v +while true bound 30 +put d n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +if eq x 0 +break +end +end +for i ulong n +stpc get d sub sub n i 1 +end +end + +fn stpu2 v ulong to void +stpc uchar add div v 10 48 +stpc uchar add rem v 10 48 +end + +note base slot b (an argv copy) exactly as the path +fn stpexact b ulong to void +put STPL 0 0 +o = mul b 4096 +for i ulong get STBL b +stpc get STBD add o i +end +end + +note base slot b as the path, then a slash +fn stpbase b ulong to void +stpexact b +stpc 47 +end + +note argv[ix] into base slot b; returns its length (0 = missing) +fn stargb ix ulong b ulong to ulong +o = mul b 4096 +n = argread ix STBD o 4095 +if le n 0 +put STBL b 0 +ret 0 +end +put STBL b ulong n +ret ulong n +end + +note the whole file at STPB into STFB; bytes read, or -errno, or -27 when it does not fit +fn stload to long +fd = fopen STPB 0 get STPL 0 0 0 +if lt fd 0 +ret fd +end +tot = ulong 0 +cap = len STFB +r = long 0 +while lt tot cap bound 999999 +m = sub cap tot +if gt m 1048576 +m = 1048576 +end +n = read int fd STFB tot m +if lt n 0 +r = n +break +end +if eq n 0 +break +end +tot = add tot ulong n +end +c = fclose int fd +if lt r 0 +ret r +end +if lt c 0 +ret c +end +if eq tot cap +ret -27 +end +ret long tot +end + +note little-endian word at byte o of STFB +fn stw o ulong to ulong +v = ulong 0 +for k ulong 8 +b = ulong get STFB add o k +v = or v shl b mul k 8 +end +ret v +end + +note word k of record rec (rb bytes per record) +fn strw rec ulong rb ulong k ulong to ulong +ret stw add mul rec rb mul k 8 +end + +note write STOB[0..n) to the path in STPB (create or truncate, mode 0644, fsync); 0 ok +fn stwfile to int +fd = fopen STPB 0 get STPL 0 577 420 +if lt fd 0 +ret 1 +end +r = stflush int fd +s = fsync int fd +c = fclose int fd +if or ne r 0 or ne s 0 ne c 0 +ret 1 +end +ret 0 +end + +note ---------- 128-bit exact arithmetic ---------- +note a * b into STHL (0 high, 1 low) +fn stmul a ulong b ulong to void +m = ulong 4294967295 +al = and a m +bl = and b m +p0 = mul al bl +p1 = mul al shr b 32 +p2 = mul shr a 32 bl +mid = add add shr p0 32 and p1 m and p2 m +put STHL 1 or and p0 m shl mid 32 +hi = mul shr a 32 shr b 32 +hi = add add hi shr p1 32 add shr p2 32 shr mid 32 +put STHL 0 hi +end + +note floor(a * b / c), saturated at 2^64 - 1; c = 0 gives 2^64 - 1 +fn stmd a ulong b ulong c ulong to ulong +if eq c 0 +ret 18446744073709551615 +end +stmul a b +hi = get STHL 0 +lo = get STHL 1 +r = ulong 0 +q = ulong 0 +ov = false +bit = ulong 0 +for i ulong 128 +if lt i 64 +bit = and shr hi sub 63 i 1 +else +bit = and shr lo sub 127 i 1 +end +cy = shr r 63 +r = or shl r 1 bit +qb = ulong 0 +if or eq cy 1 ge r c +r = sub r c +qb = 1 +end +if and lt i 64 eq qb 1 +ov = true +end +q = or shl q 1 qb +end +if ov +ret 18446744073709551615 +end +ret q +end + +note ppm of num over den (floor) +fn stppm num ulong den ulong to ulong +ret stmd num 1000000 den +end + +note signed ppm (truncation toward zero); den must be > 0 +fn stppms num long den long to long +if lt num 0 +ret neg long stmd ulong neg num 1000000 ulong den +end +ret long stmd ulong num 1000000 ulong den +end + +note ---------- splitmix64 ---------- +fn stsm to ulong +s = add get STRNG 0 11400714819323198485 +put STRNG 0 s +z = mul xor s shr s 30 13787848793156543929 +z = mul xor z shr z 27 10723151780598845931 +ret xor z shr z 31 +end + +note hex digit value, 16 = not a hex digit +fn sthexv c uchar to ulong +if and ge c 48 le c 57 +ret ulong sub c 48 +end +if and ge c 97 le c 102 +ret ulong sub c 87 +end +if and ge c 65 le c 70 +ret ulong sub c 55 +end +ret 16 +end + +note byte i (0..31) of the 64-hex text held in base slot b; 256 = bad +fn sthexb b ulong i ulong to ulong +o = add mul b 4096 mul i 2 +h = sthexv get STBD o +l = sthexv get STBD add o 1 +if or gt h 15 gt l 15 +ret 256 +end +ret or shl h 4 l +end + +note little-endian word from hex bytes s..s+7 of base slot b; STRF 3 = 1 on a bad digit +fn sthexw b ulong s ulong to ulong +v = ulong 0 +for k ulong 8 +x = sthexb b add s k +if gt x 255 +put STRF 3 1 +x = 0 +end +v = or v shl x mul k 8 +end +ret v +end + +note ---------- refusal ---------- +fn stref code ulong a ulong r ulong g ulong to int +put STRF 0 code +put STRF 1 a +put STRF 2 r +put STRF 3 g +ret int code +end + +fn stprref to void +stks SKREFU +stou get STRF 0 +stks SKDETL +stou get STRF 1 +stoc 46 +stou get STRF 2 +stoc 46 +stou get STRF 3 +stnl +end + +note ---------- split directory ---------- +fn stidx to int +stpbase 0 +stpk SKINDEX +n = stload +if lt n 128 +ret stref 2 0 0 0 +end +if or ne stw 0 3544386032354079058 ne stw 8 1 +ret stref 3 0 0 0 +end +g = stw 24 +if or eq g 0 gt g 99 +ret stref 3 1 0 0 +end +if ne ulong n add 128 mul g 8 +ret stref 3 2 0 0 +end +put STNG 0 g +put STSPL 0 stw 16 +put STNS 0 stw 32 +put STNR 0 stw 40 +put STNQ 0 stw 48 +for j ulong 4 +put STHD j stw add 56 mul j 8 +end +off = ulong 0 +for i ulong g +c = stw add 128 mul i 8 +put STGN i c +put STGO i off +off = add off c +end +if ne off get STNR 0 +ret stref 3 3 0 0 +end +if gt off len STRO +ret stref 14 0 0 0 +end +ret 0 +end + +note checks one sessions record i; 0 ok +fn stsone i ulong to int +g = strw i 128 1 +f = strw i 128 2 +t = strw i 128 3 +v = strw i 128 4 +c = strw i 128 5 +if or ne strw i 128 0 i ge g get STNG 0 +ret 1 +end +if or or lt f 1 gt f 2 or lt t 1 gt t 8 +ret 1 +end +if or gt v 5 gt c 2 +ret 1 +end +put STSG i g +put STSF i f +put STST i t +put STSN i v +put STSC i c +ret 0 +end + +fn stsess to int +stpbase 0 +stpk SKSESS +n = stload +s = get STNS 0 +if or eq s 0 gt s len STSG +ret stref 4 0 0 0 +end +if ne n long mul s 128 +ret stref 4 1 0 0 +end +for i ulong s +if ne stsone i 0 +ret stref 4 2 i 0 +end +end +ret 0 +end + +fn stexpg g ulong to int +stpbase 0 +stpc 103 +stpu2 g +stpk SKEXP +n = stload +c = get STGN g +if ne n long mul c 64 +ret stref 5 0 0 g +end +o = get STGO g +for j ulong c +i = add o j +s = strw j 64 5 +if or ge s get STNS 0 ne get STSG s g +ret stref 5 1 j g +end +put STRX i strw j 64 0 +put STR0 i strw j 64 2 +put STR1 i strw j 64 3 +put STRO i strw j 64 4 +put STRS i s +put STRC i strw j 64 6 +end +ret 0 +end + +fn stexps to int +q = ulong 0 +for g ulong get STNG 0 +r = stexpg g +if ne r 0 +ret r +end +o = get STGO g +for j ulong get STGN g +if eq get STRO add o j 2 +q = add q 1 +end +end +end +if ne q get STNQ 0 +ret stref 5 2 q 0 +end +ret 0 +end + +note ---------- raw run logs ---------- +fn stcadd a ulong k ulong v ulong to void +x = add mul a 32 k +put STCNT x add get STCNT x v +end + +fn stcmax a ulong k ulong v ulong to void +x = add mul a 32 k +if gt v get STCNT x +put STCNT x v +end +end + +note the correctness the log should carry for record j (byte base o) of request i +fn stwant a ulong i ulong o ulong to ulong +if eq a 0 +ret 2 +end +sg = stw add o 40 +if ne sg get STRX i +ret 0 +end +if ne get STRO i 2 +ret 2 +end +if and eq stw add o 48 get STR0 i eq stw add o 56 get STR1 i +ret 1 +end +ret 0 +end + +note correctness counters for one record +fn stcorr a ulong i ulong o ulong to void +corr = stw add o 120 +want = stwant a i o +if ne corr want +stcadd a 5 1 +end +if eq a 0 +stcadd a 4 1 +ret +end +bad = or eq want 0 eq corr 0 +if eq get STRO i 2 +if bad +stcadd a 1 1 +else +stcadd a 0 1 +end +ret +end +if bad +stcadd a 3 1 +else +stcadd a 2 1 +end +end + +note QUERY route, round-trip, hit and transfer counters +fn stquery a ulong i ulong o ulong rt ulong to void +rte = stw add o 64 +if le rte 5 +stcadd a add 6 rte 1 +else +stcadd a 12 1 +end +stcadd a 13 rt +stcadd a 14 1 +hit = and ge rte 2 le rte 4 +if hit +stcadd a 15 rt +stcadd a 16 1 +end +s = get STRS i +if and eq a 4 eq get STSN s 2 +stcadd a 17 1 +if and ge rte 3 le rte 4 +stcadd a 18 1 +end +end +end + +note word k of the record at byte o differs from v +fn stwne o ulong k ulong v ulong to bool +ret ne stw add o mul k 8 v +end + +note identity and expectation words of record j at byte o; 0 ok, else refusal code +fn stchk a ulong r ulong g ulong j ulong o ulong to int +i = add get STGO g j +if or stwne o 0 g stwne o 1 r +ret 8 +end +if or stwne o 2 a stwne o 3 j +ret 8 +end +if stwne o 4 get STRO i +ret 8 +end +if or stwne o 9 get STRX i stwne o 10 get STR0 i +ret 9 +end +if or stwne o 11 get STR1 i stwne o 13 get STRC i +ret 9 +end +if stwne o 14 get STRS i +ret 9 +end +ret 0 +end + +note one raw log record j of (a, r, g), already in STFB; 0 ok, else a refusal code +fn strec a ulong r ulong g ulong j ulong to int +o = mul j 128 +e = stchk a r g j o +if ne e 0 +ret e +end +i = add get STGO g j +rt = stw add o 96 +put STRT add mul add mul a 3 r 65536 i rt +slot = add mul add mul a 3 r 128 g +put STAG slot add get STAG slot rt +if eq j 0 +put STA0 slot rt +end +s = add mul a 1024 get STRS i +put STSS s add get STSS s rt +stcorr a i o +if eq get STRO i 2 +stquery a i o rt +end +ret 0 +end + +fn stlog a ulong r ulong g ulong to int +stpbase 1 +stpk SKARMP +stpc uchar add a 48 +stpk SKREPP +stpc uchar add r 48 +stpk SKGP +stpu2 g +stpk SKLOG +n = stload +if lt n 0 +ret stref 6 a r g +end +c = get STGN g +if ne n long mul c 128 +ret stref 7 a r g +end +for j ulong c +e = strec a r g j +if ne e 0 +ret stref ulong e a r add mul g 100000 j +end +end +ret 0 +end + +fn stlogs to int +for a ulong 8 +for r ulong 3 +for g ulong get STNG 0 +e = stlog a r g +if ne e 0 +ret e +end +end +end +end +ret 0 +end + +note ---------- proc.log, acq.log, controls.log ---------- +fn stproc1 k ulong to int +a = strw k 128 0 +g = strw k 128 1 +r = strw k 128 2 +if or or ge a 8 ge g get STNG 0 ge r 3 +ret stref 10 k 0 0 +end +slot = add mul add mul a 3 r 128 g +if ne get STPF slot 0 +ret stref 11 a r g +end +put STPF slot 1 +put STPR slot strw k 128 3 +put STPE slot strw k 128 15 +stcadd a 26 strw k 128 15 +stcadd a 19 1 +stcmax a 20 strw k 128 8 +stcadd a 21 strw k 128 8 +stcmax a 22 strw k 128 9 +cpu = add add strw k 128 4 strw k 128 5 add strw k 128 6 strw k 128 7 +stcadd a 23 cpu +stpexit a strw k 128 10 +stcadd a 25 strw k 128 3 +ret 0 +end + +note K17 exit word x of one arm process: nonzero = a failed process, counted as one wrong +note refusal of the arm (counter 3, so STOP for arms 1..7) and in counters 24 (exit nonzero) and +note 28 (failed processes); x >= 1024 = END itself failed (counter 27) +fn stpexit a ulong x ulong to void +if eq x 0 +ret +end +stcadd a 24 1 +stcadd a 28 1 +stcadd a 3 1 +if ge x 1024 +stcadd a 27 1 +end +end + +fn stprocs to int +stpbase 1 +stpk SKPROC +n = stload +if or lt n 0 ne rem ulong n 128 0 +ret stref 10 0 0 0 +end +for k ulong div ulong n 128 +e = stproc1 k +if ne e 0 +ret e +end +end +for a ulong 8 +for r ulong 3 +for g ulong get STNG 0 +if eq get STPF add mul add mul a 3 r 128 g 0 +ret stref 11 a r g +end +end +end +end +ret 0 +end + +fn stacq1 k ulong to int +l = strw k 64 0 +r = strw k 64 1 +if or gt l 9 ge r 3 +ret stref 12 k 0 0 +end +x = add mul l 3 r +if ne get STAQF x 0 +ret stref 12 k 1 0 +end +put STAQF x 1 +put STAQ x strw k 64 2 +put STAQC x add strw k 64 3 strw k 64 4 +put STAQX x strw k 64 5 +put STAQB x strw k 64 6 +ret 0 +end + +fn stacqs to int +stpbase 1 +stpk SKACQ +n = stload +if or lt n 0 ne rem ulong n 64 0 +ret stref 12 0 0 0 +end +for k ulong div ulong n 64 +e = stacq1 k +if ne e 0 +ret e +end +end +for l ulong 2 +for r ulong 3 +if eq get STAQF add mul add l 1 3 r 0 +ret stref 12 add l 1 r 2 +end +end +end +ret 0 +end + +note required sub-cases of control c as a bit mask (bit s = sub-case s), the 36 pairs EvalJudge's +note controls run writes (confirmed with EvalJudge 2026-10-25): C1 0,1; C1b 0,1; C1c 0; C2 0,1; +note C3 0,1; C4 0; C5 0..5; C6 0,1,2; C7 0,1; C8 1..9 (crashafter K); C9 0,1; C10 0,1; C11 0; +note C12 0 +fn stcreq c ulong to ulong +if or or eq c 3 eq c 6 or eq c 13 eq c 14 +ret 1 +end +if eq c 7 +ret 63 +end +if eq c 8 +ret 7 +end +if eq c 10 +ret 1022 +end +ret 3 +end + +note required pairs of control c with no record +fn stcmiss c ulong to ulong +m = and stcreq c not get STCT add mul c 8 6 +n = ulong 0 +for s ulong 10 +n = add n and shr m s 1 +end +ret n +end + +note STCT per control id c (1..14), 8 slots: 0 records, 1 detected, 2 undetected, 3 reported, +note 4 not run, 5 served tampered, 6 bit mask of the sub-cases seen. A sub-case outside the +note required list or a repeated (control, sub-case) pair is refused (13). +fn stctl1 k ulong to int +c = strw k 64 0 +o = strw k 64 2 +f = strw k 64 3 +if or or lt c 1 gt c 14 or gt o 3 gt f 1 +ret stref 13 k 0 0 +end +if and eq o 2 ne c 14 +ret stref 13 k 1 0 +end +s = strw k 64 1 +if ge s 10 +ret stref 13 k 2 0 +end +if eq and shr stcreq c s 1 0 +ret stref 13 k 2 0 +end +b = mul c 8 +bit = shl ulong 1 s +if ne and get STCT add b 6 bit 0 +ret stref 13 k 3 0 +end +put STCT add b 6 or get STCT add b 6 bit +put STCT b add get STCT b 1 +if eq o 1 +put STCT add b 1 add get STCT add b 1 1 +end +if eq o 0 +put STCT add b 2 add get STCT add b 2 1 +end +if eq o 2 +put STCT add b 3 add get STCT add b 3 1 +end +if eq o 3 +put STCT add b 4 add get STCT add b 4 1 +end +if eq f 1 +put STCT add b 5 add get STCT add b 5 1 +end +ret 0 +end + +fn stctls to int +if and eq get STBL 2 1 eq get STBD 8192 45 +ret 0 +end +stpbase 2 +stpk SKCTL +n = stload +if or lt n 0 ne rem ulong n 64 0 +ret stref 13 0 0 0 +end +for k ulong div ulong n 64 +e = stctl1 k +if ne e 0 +ret e +end +end +ret 0 +end + +note ---------- totals and bootstrap ---------- +fn stlib a ulong to ulong +if or or eq a 3 eq a 4 eq a 7 +ret 1 +end +if eq a 6 +ret 2 +end +ret 0 +end + +note process cost of (a, r, g) +fn stpcost a ulong r ulong g ulong to ulong +slot = add mul add mul a 3 r 128 g +v = add get STPR slot get STPE slot +ret sub add v get STAG slot get STA0 slot +end + +fn sttotals to void +for a ulong 8 +t = ulong 0 +for g ulong get STNG 0 +v = ulong 0 +for r ulong 3 +v = add v stpcost a r g +end +put STV add mul a 128 g v +t = add t v +end +l = stlib a +q = ulong 0 +if gt l 0 +for r ulong 3 +q = add q get STAQ add mul l 3 r +end +end +put STAA a q +put STT a add t q +end +end + +fn stnum s ulong to ulong +if lt s 8 +ret s +end +if eq s 11 +ret 4 +end +if eq s 12 +ret 5 +end +if eq s 10 +ret 7 +end +ret 4 +end + +fn stden s ulong to ulong +if lt s 8 +ret 1 +end +if eq s 8 +ret 2 +end +if eq s 9 +ret 5 +end +if eq s 10 +ret 4 +end +if eq s 11 +ret 3 +end +ret 1 +end + +note one resample b: acc holds the 8 resampled totals +fn stres b ulong acc edit ulong 8 to void +for a ulong 8 +put acc a get STAA a +end +g = get STNG 0 +for i ulong g +x = rem stsm g +for a ulong 8 +put acc a add get acc a get STV add mul a 128 x +end +end +for s ulong 13 +v = stppm get acc stnum s get acc stden s +put STBS add mul s 10000 b v +end +end + +note ---------- heap sort of STQV[0..n) ascending, STQI moved along ---------- +fn stswap i ulong j ulong to void +v = get STQV i +put STQV i get STQV j +put STQV j v +w = get STQI i +put STQI i get STQI j +put STQI j w +end + +fn stsift s ulong n ulong to void +r = s +while true bound 64 +c = add mul r 2 1 +if ge c n +break +end +if lt add c 1 n +if gt get STQV add c 1 get STQV c +c = add c 1 +end +end +if le get STQV c get STQV r +break +end +stswap r c +r = c +end +end + +fn stsort n ulong to void +if lt n 2 +ret +end +i = div n 2 +while gt i 0 bound 999999 +i = sub i 1 +stsift i n +end +e = n +while gt e 1 bound 999999 +e = sub e 1 +stswap 0 e +stsift 0 e +end +end + +note nearest rank index for p per mille of n (n > 0): ceil(p n / 1000) - 1 +fn strank p ulong n ulong to ulong +ret sub div add mul p n 999 1000 1 +end + +fn stboot to void +put STRNG 0 get STSEED 0 +acc = new ulong 8 0 +for b ulong 10000 +stres b acc +end +for s ulong 13 +put STPT s stppm get STT stnum s get STT stden s +for b ulong 10000 +put STQV b get STBS add mul s 10000 b +put STQI b 0 +end +stsort 10000 +put STLO s get STQV strank 25 10000 +put STHI s get STQV strank 975 10000 +end +end + +note ---------- categories and quantiles ---------- +fn stcatm cat ulong s ulong to bool +if eq cat 0 +ret true +end +if le cat 8 +ret eq get STST s cat +end +if le cat 14 +ret eq get STSN s sub cat 9 +end +if le cat 16 +ret eq get STSF s sub cat 14 +end +ret eq get STSC s sub cat 17 +end + +note request i is a QUERY with cold flag t +fn stisq i ulong t ulong to bool +if ne get STRO i 2 +ret false +end +ret eq get STRC i t +end + +note fill STQV/STQI with the QUERY round trips of arm a with cold flag t; returns the count +fn stqfill a ulong t ulong to ulong +m = ulong 0 +n = get STNR 0 +for r ulong 3 +base = mul add mul a 3 r 65536 +for i ulong n +if stisq i t +put STQV m get STRT add base i +put STQI m get STRS i +m = add m 1 +end +end +end +ret m +end + +note the value at rank k (0-based) among the sorted entries of category cat +fn stqpick m ulong cat ulong k ulong to ulong +c = ulong 0 +for j ulong m +if stcatm cat get STQI j +if eq c k +ret get STQV j +end +c = add c 1 +end +end +ret 0 +end + +fn stqline a ulong t ulong cat ulong m ulong to void +c = ulong 0 +for j ulong m +if stcatm cat get STQI j +c = add c 1 +end +end +stks SKQUANT +stks SKARM +stks add SKARM0 a +stks SKTEMP +if eq t 1 +stks SKCOLD +else +stks SKWARM +end +stks SKCAT +stks add SKCAT0 cat +stkv SKCOUNT c +if eq c 0 +stks SKP50 +stks SKNA +stks SKP95 +stks SKNA +stks SKP99 +stks SKNA +stnl +ret +end +stkv SKP50 stqpick m cat strank 500 c +stkv SKP95 stqpick m cat strank 950 c +stkv SKP99 stqpick m cat strank 990 c +stnl +end + +fn stquants to void +for a ulong 8 +for t ulong 2 +tt = sub 1 t +m = stqfill a tt +stsort m +for cat ulong 20 +stqline a tt cat m +end +end +end +end + +note request round-trip sum of arm a over sessions of category cat (all reps) +fn stcsum a ulong cat ulong to ulong +v = ulong 0 +for s ulong get STNS 0 +if stcatm cat s +v = add v get STSS add mul a 1024 s +end +end +ret v +end + +fn stcatline a ulong cat ulong to void +d = stcsum 1 cat +if eq d 0 +ret +end +stks SKCATR +stks SKARM +stks add SKARM0 a +stks SKCAT +stks add SKCAT0 cat +stkv SKPPM stppm stcsum a cat d +stnl +end + +fn stregime t ulong to void +m = stcsum 3 t +f = stcsum 1 t +if or eq m 0 eq f 0 +ret +end +stks SKREGT +stks add SKCAT0 t +stkv SKDOM stppm stcsum 4 t m +stkv SKIOF stppm stcsum 5 t f +stnl +end + +note ---------- payback ---------- +note rep-summed cost of request j of group g for arm a (request 0 = start-to-ready) +fn streqc a ulong g ulong j ulong to ulong +v = ulong 0 +i = add get STGO g j +for r ulong 3 +k = add mul a 3 r +if eq j 0 +v = add v get STPR add mul k 128 g +else +v = add v get STRT add mul k 65536 i +end +end +ret v +end + +note rep-summed END round trip of arm a's processes for group g +fn stendc a ulong g ulong to ulong +v = ulong 0 +for r ulong 3 +v = add v get STPE add mul add mul a 3 r 128 g +end +ret v +end + +note one group of the payback walk; state in STPYC (cumulative) and STPYQ (QUERYs seen); +note true when the cumulative sum exceeds lim. The END difference is added after the group's +note last request, so END savings never count before that group's QUERYs. +fn stpayg a ulong g ulong lim long to bool +o = get STGO g +for j ulong get STGN g +d = sub long streqc 1 g j long streqc a g j +cum = add get STPYC 0 d +put STPYC 0 cum +if eq get STRO add o j 2 +put STPYQ 0 add get STPYQ 0 1 +end +if gt cum lim +ret true +end +end +d = sub long stendc 1 g long stendc a g +cum = add get STPYC 0 d +put STPYC 0 cum +ret gt cum lim +end + +note QUERYs until the cumulative (full - arm) cost exceeds acq(a); 2^64 - 1 = never +fn stpay a ulong to ulong +put STPYC 0 0 +put STPYQ 0 0 +lim = long get STAA a +for g ulong get STNG 0 +if stpayg a g lim +ret get STPYQ 0 +end +end +ret 18446744073709551615 +end + +note ---------- report sections ---------- +fn starmk k ulong a ulong to void +stks k +stks SKARM +stks add SKARM0 a +end + +fn sttotline a ulong to void +starmk SKTOTAL a +rt = ulong 0 +rd = ulong 0 +for r ulong 3 +for g ulong get STNG 0 +slot = add mul add mul a 3 r 128 g +rt = add rt get STAG slot +rd = add rd get STPR slot +end +end +stkv SKRTNS rt +stkv SKREADY rd +stkv SKENDNS stc a 26 +stkv SKACQNS get STAA a +stkv SKTOTNS get STT a +stnl +end + +fn ststatline s ulong to void +if lt s 8 +starmk SKRHO s +else +stks SKRATIO +stks add SKRAT0 sub s 8 +end +stkv SKPOINT get STPT s +stkv SKLO get STLO s +stkv SKHI get STHI s +stnl +end + +fn stc a ulong k ulong to ulong +ret get STCNT add mul a 32 k +end + +fn stcorrline a ulong to void +starmk SKCORR a +stkv SKQOK stc a 0 +stkv SKQBAD stc a 1 +stkv SKCOK stc a 2 +stkv SKCBAD stc a 3 +stkv SKUNSC stc a 4 +stkv SKINCON stc a 5 +stkv SKPROCF stc a 28 +stnl +end + +fn strouteline a ulong to void +starmk SKROUTE a +for k ulong 6 +stks SKRN +stou k +stks SKEQ +stou stc a add 6 k +end +stkv SKROTH stc a 12 +stkv SKFALL stppm stc a 11 stc a 14 +stnl +end + +fn stmemline a ulong to void +starmk SKMEM a +n = stc a 19 +stkv SKPROCS n +stkv SKHWMX stc a 20 +if gt n 0 +stkv SKHWMM div stc a 21 n +end +stkv SKRSSX stc a 22 +stkv SKCPU stc a 23 +stkv SKEXITN stc a 24 +stkv SKENDF stc a 27 +stnl +end + +fn stacqline l ulong to void +stks SKACQL +stou l +e = ulong 0 +c = ulong 0 +b = ulong 0 +x = ulong 0 +for r ulong 3 +k = add mul l 3 r +e = add e get STAQ k +c = add c get STAQC k +if gt get STAQB k b +b = get STAQB k +end +if ne get STAQX k 0 +x = add x 1 +end +end +stkv SKBUILD 3 +stkv SKELAP e +stkv SKCPU c +stkv SKLIBB b +stkv SKDRIVN x +stnl +end + +fn stpayline a ulong to void +starmk SKPAYB a +p = stpay a +put STSUM add 88 a p +stks SKPAYQ +if eq p 18446744073709551615 +stks SKNONE +else +stou p +end +stnl +end + +note r + (1 - q) e + q + kn, every term in ppm (division truncates toward zero) +fn stcbarv r long q long e long kn long to long +t = div mul sub 1000000 q e 1000000 +ret add add r t add q kn +end + +note the Cbar line of arm a, f = mean full QUERY round trip (ns, > 0) +fn stcbar2 a ulong f ulong to void +n = stc a 14 +r = long stppm div stc 0 13 stc 0 14 f +h = stc a 16 +e = sub long 0 r +if gt h 0 +e = sub long stppm div stc a 15 h f r +end +q = long stppm sub n h n +k = stppm get STAA a f +starmk SKCBAR a +stkvl SKCR r +stkvl SKCQ q +stkvl SKCE e +stkv SKCK k +stkv SKCN n +stkvl SKCBV stcbarv r q e long div k n +stkv SKCOBS stppm div add stc a 13 get STAA a n f +stnl +end + +fn stcbarline a ulong to void +fc = stc 1 14 +if or or eq fc 0 eq stc a 14 0 eq stc 0 14 0 +ret +end +f = div stc 1 13 fc +if gt f 0 +stcbar2 a f +end +end + +fn stecholine a ulong to void +num = sub long get STT a long get STT 0 +den = sub long get STT 1 long get STT 0 +starmk SKECHO a +stks SKPPM +if le den 0 +stks SKNA +else +stol stppms num den +end +stnl +end + +note outcome word of control c: 1 detected, 0 undetected, 2 reported, 3 not run, 4 missing +fn stcout c ulong to ulong +b = mul c 8 +if eq get STCT b 0 +ret 4 +end +if or gt get STCT add b 2 0 gt get STCT add b 5 0 +ret 0 +end +if or gt get STCT add b 4 0 gt stcmiss c 0 +ret 3 +end +if gt get STCT add b 3 0 +ret 2 +end +ret 1 +end + +fn stctlline c ulong to void +b = mul c 8 +stks SKCTLID +stks add SKCID0 c +stkv SKRECS get STCT b +stkv SKDET get STCT add b 1 +stkv SKUNDET get STCT add b 2 +stkv SKREPD get STCT add b 3 +stkv SKNRUN get STCT add b 4 +stkv SKTAMP get STCT add b 5 +stkv SKMISSP stcmiss c +stnl +end + +note the outcome word of stcout value o +fn stocw o ulong to void +if eq o 1 +stks SKOC0 +ret +end +if eq o 0 +stks add SKOC0 1 +ret +end +stks add SKOC0 o +end + +note " Cx=<outcome word>" +fn stctlw c ulong to void +stks SKSPACE +stks add SKCID0 c +stks SKEQ +stocw stcout c +end + +note ---------- decision ---------- +fn streason k ulong bit ulong to void +stks SKREAS +stks k +stnl +put STDEC 1 or get STDEC 1 shl ulong 1 bit +end + +fn streasa k ulong bit ulong a ulong to void +stks SKREAS +stks k +stks SKARM +stks add SKARM0 a +stnl +put STDEC 1 or get STDEC 1 shl ulong 1 bit +end + +fn streasc k ulong bit ulong c ulong to void +stks SKREAS +stks k +stks SKSPACE +stks add SKCID0 c +stnl +put STDEC 1 or get STDEC 1 shl ulong 1 bit +end + +note writes the reason lines; returns 3 STOP, 1 GO, 2 INVESTIGATE +fn stdecide to ulong +put STDEC 1 0 +for a ulong 8 +if gt a 0 +if gt stc a 1 0 +streasa SKRWA 0 a +end +if gt stc a 3 0 +streasa SKRWR 1 a +end +end +end +for c ulong 15 +if gt c 0 +if gt get STCT add mul c 8 2 0 +streasc SKRCU 2 c +end +if gt get STCT add mul c 8 5 0 +streasc SKRTS 3 c +end +end +end +if ge get STLO 4 1000000 +streason SKRLO 4 +end +stop = gt get STDEC 1 0 +if ge get STHI 4 1000000 +streason SKRUP 5 +end +if ge get STHI 8 1000000 +streason SKRDC 6 +end +if ge get STHI 9 1000000 +streason SKRDI 7 +end +tq = stc 4 17 +if or eq tq 0 lt mul stc 4 18 2 tq +streason SKRCOV 8 +end +for c ulong 15 +if gt c 0 +o = stcout c +if or eq o 3 eq o 4 +streasc SKRNR 9 c +end +end +end +if stop +ret 3 +end +if eq get STDEC 1 0 +ret 1 +end +ret 2 +end + +fn stiss to void +tq = stc 4 17 +stks SKI742 +stou stppm stc 4 18 tq +stks SKBINDF +stks SKR5 +stou stc 3 11 +stks SKR5D +stou stc 4 11 +stks SKRESTA +stocw stcout 13 +stctlw 1 +stctlw 2 +stctlw 3 +stctlw 4 +stctlw 5 +for c ulong 6 +stctlw add c 8 +end +stnl +stks SKI743 +stks SKDOMR +stkv SKPOINT get STPT 11 +stkv SKLO get STLO 11 +stkv SKHI get STHI 11 +stks SKIOFR +stkv SKPOINT get STPT 12 +stkv SKLO get STLO 12 +stkv SKHI get STHI 12 +stctlw 6 +stctlw 10 +stnl +stks SKI744 +stkv SKPOINT get STPT 10 +stkv SKLO get STLO 10 +stkv SKHI get STHI 10 +m = and and eq stc 4 1 0 eq stc 4 3 0 and eq stc 7 1 0 eq stc 7 3 0 +stks SKMATCH +if m +stks SKYES +else +stks SKNO +end +stks SKVERD +if lt get STHI 10 1000000 +stks SKHELPS +else +if ge get STLO 10 1000000 +stks SKNHELP +else +stks SKINCO +end +end +stnl +end + +note ---------- report and summary ---------- +fn stsumw k ulong v ulong to void +put STSUM k v +end + +fn stfillsum d ulong to void +stsumw 0 3544386041195737426 +stsumw 1 1 +stsumw 2 d +stsumw 3 get STDEC 1 +stsumw 4 get STNG 0 +stsumw 5 get STNS 0 +stsumw 6 get STNR 0 +stsumw 7 get STNQ 0 +stsumw 8 3 +stsumw 9 get STSPL 0 +stsumw 10 get STSEED 0 +stsumw 11 10000 +sc = ulong 0 +ok = ulong 0 +bad = ulong 0 +cw = ulong 0 +for a ulong 8 +if gt a 0 +ok = add ok stc a 0 +bad = add bad stc a 1 +cw = add cw stc a 3 +end +end +stsumw 12 add ok bad +stsumw 13 ok +stsumw 14 bad +stsumw 15 cw +stsumw 16 stc 4 17 +stsumw 17 stc 4 18 +for j ulong 4 +stsumw add 18 j get STHD j +end +ic = ulong 0 +for a ulong 8 +ic = add ic stc a 5 +end +stsumw 22 ic +for s ulong 13 +stsumw add 24 mul s 3 get STPT s +stsumw add 25 mul s 3 get STLO s +stsumw add 26 mul s 3 get STHI s +end +for a ulong 8 +stsumw add 64 a get STT a +stsumw add 72 a get STAA a +stsumw add 80 a stc a 11 +stsumw add 96 a stc a 28 +stsumw add 104 a stc a 27 +end +end + +fn streport to ulong +stks SKHEAD +stnl +stks SKINPUT +stou get STSPL 0 +stkv SKGROUP get STNG 0 +stkv SKSESN get STNS 0 +stkv SKREQS get STNR 0 +stkv SKQRYS get STNQ 0 +stkv SKREPS 3 +stnl +stks SKBOOT +stou 10000 +stkv SKSEED get STSEED 0 +stkv SKRKLO strank 25 10000 +stkv SKRKHI strank 975 10000 +stnl +for a ulong 8 +sttotline a +end +for s ulong 13 +ststatline s +end +for a ulong 8 +stcorrline a +end +for a ulong 8 +strouteline a +end +stks SKCOVER +stou stc 4 17 +stkv SKCOVD stc 4 18 +stkv SKCOVP stppm stc 4 18 stc 4 17 +stnl +for a ulong 8 +stmemline a +end +stacqline 1 +stacqline 2 +for a ulong 8 +put STSUM add 88 a 18446744073709551615 +if gt a 1 +stpayline a +end +end +for a ulong 8 +if gt a 1 +stcbarline a +end +end +for a ulong 8 +if ne a 1 +stecholine a +end +end +for a ulong 8 +for cat ulong 20 +if gt cat 0 +stcatline a cat +end +end +end +for t ulong 8 +stregime add t 1 +end +stquants +stks SKSTEP +stnl +for c ulong 14 +stctlline add c 1 +end +stiss +d = stdecide +stks SKDECI +if eq d 1 +stks SKGO +end +if eq d 2 +stks SKINV +end +if eq d 3 +stks SKSTOP +end +stnl +stks SKVERDS +if eq d 1 +stks SKGO +end +if eq d 2 +stks SKINV +end +if eq d 3 +stks SKSTOP +end +stks SKSIMNR +stnl +ret d +end + +note one little-endian word appended to STOB +fn stow v ulong to void +for b ulong 8 +stoc uchar and shr v mul b 8 255 +end +end + +note STSUM as 2048 bytes into STOB (replacing its contents) +fn stsumbytes to void +put STOP 0 0 +for k ulong 256 +stow get STSUM k +end +end + +note the path now in STPB becomes base slot b +fn stbfromp b ulong to void +o = mul b 4096 +n = get STPL 0 +for i ulong n +put STBD add o i get STPB i +end +put STBL b n +end + +note zero every accumulator, so one process can run several evaluations (tests) +fn streset to void +for i ulong len STCNT +put STCNT i 0 +end +for i ulong len STAG +put STAG i 0 +put STA0 i 0 +put STPR i 0 +put STPE i 0 +put STPF i 0 +end +for i ulong len STSS +put STSS i 0 +end +for i ulong len STAQ +put STAQ i 0 +put STAQC i 0 +put STAQX i 0 +put STAQB i 0 +put STAQF i 0 +end +for i ulong len STCT +put STCT i 0 +end +for i ulong len STSUM +put STSUM i 0 +end +put STDEC 0 0 +put STDEC 1 0 +put STOP 0 0 +end + +note runs every reading step; 0 ok, else refusal code +fn stread to int +e = stidx +if ne e 0 +ret e +end +e = stsess +if ne e 0 +ret e +end +e = stexps +if ne e 0 +ret e +end +e = stlogs +if ne e 0 +ret e +end +e = stprocs +if ne e 0 +ret e +end +e = stacqs +if ne e 0 +ret e +end +ret stctls +end + +note prints the refusal line to stdout; returns the exit code 2 +fn stfail code ulong d ulong to int +r = stref code d 0 0 +stprref +w = stflush 1 +ret 2 +end + +note the evaluation on base slots 0 split, 1 run, 2 ctrl (- = none), 3 out and the seed in +note STSEED; the report goes to stdout unless STQT is 1. Returns the exit code. +fn strun to int +streset +e = stread +if ne e 0 +stprref +if ne get STQT 0 1 +r = stflush 1 +end +ret 2 +end +sttotals +stboot +d = streport +stfillsum d +if ne get STQT 0 1 +r = stflush 1 +end +stpbase 3 +stpk SKTXT +w = stwfile +if ne w 0 +ret 15 +end +stsumbytes +stpbase 3 +stpk SKSUM +w = stwfile +if ne w 0 +ret 15 +end +ret 0 +end + +fn stmain to int +put STOP 0 0 +if lt argcnt 7 +ret stfail 1 0 +end +l0 = stargb 2 0 +l1 = stargb 3 1 +l2 = stargb 4 2 +l3 = stargb 5 3 +if ne l3 64 +ret stfail 1 1 +end +put STRF 3 0 +put STSEED 0 sthexw 3 0 +if ne get STRF 3 0 +ret stfail 1 2 +end +l4 = stargb 6 3 +if or or eq l0 0 eq l1 0 or eq l2 0 eq l4 0 +ret stfail 1 3 +end +ret strun +end diff --git a/om/reuse-eval/turing.om b/om/reuse-eval/turing.om new file mode 100644 index 0000000..17c9cec --- /dev/null +++ b/om/reuse-eval/turing.om @@ -0,0 +1,905 @@ +note SPDX-License-Identifier: Apache-2.0 +note turing.om (lane EvalStats, spark-rsi-mv #73): Turing accounting of REUSE-1 section 8 under +note calibration/profiles/Turing-profile-REUSE-v1.0.toml. Needs the units sha256 and stats (st* +note helpers: paths, files, output, split readers). Names: functions tu*, globals TU*. +note +note CLI (argv[1] is the dispatcher's subcommand): +note turing SPLITDIR PROFILE TRAINLIB TRAINPLIB BASEOM CODER OUTDIR +note SPLITDIR = the FINAL split (index, sessions, gNN.exp); PROFILE = the profile TOML file; +note TRAINLIB, TRAINPLIB = the evaluator's rebuilt LIBDIRs (CURRENT, gen-G.man, gen-G.om); +note BASEOM = base.om written by drive base; CODER = the external turing-coder referee +note (omega-mv a647b6a9 src/turing), or - (T_real is then NOT_RUN); OUTDIR receives B.tps, +note M1.tps (TRAIN library), M2.tps (TRAINP library), D.tsy, the coded files X.tps.rans and +note X.tps.range, and turing.txt (the report, also on stdout). +note Exit 0 = report written; 2 = inputs refused (status=REFUSED code=N); 15 = output failure. +note +note D: the low 4 bits of r0 of every QUERY record of gNN.exp, groups in order, records in order +note (the evaluator's reference = repetition 1 of every arm). One TPS1 record per symbol t: +note observation_index t, context_key 0, crumb ordinal t, norm_sum 65536, q = 65521 on the symbol +note and 1 on each of the 15 others (CODER_SPEC sections 2 and 3; K 16, qbits 16). +note profile_digest = SHA-256 of the profile file bytes; dataset_digest = the FINAL holdout digest +note (index words 7..10, each word's 8 bytes big endian); model_digest = SHA-256( +note "turing.reuse.model.v1" 0x00 || the 2048 manifest bytes of the arm's library), and for B the +note hashed bytes are 32 zero bytes (the profile's "or 32 zero bytes for B", read as the payload). +note Trailers: SHA-256("turing.tc.pstream.v1" 0x00 || header || records) and +note SHA-256("turing.tc.symbols.v1" 0x00 || header || symbols). +note +note Charges (profile model_code): P1 = 64 bits x 8 manifest words per template (manifest word 4 +note = K) plus, for select, 64 bits x 193 calibration values (192 cell words + E_q) when the +note manifest names a calibration file (words 52..55 not all 0). P2 = 8 bits x (bytes of gen-G.om +note - bytes of base.om + 2048 manifest bytes). Models: method, delta, select = M1; deltap = M2; +note idelta, cache = B (no charge). +note L_ideal(D|X) = n ub(65521) micro-bits for every model (CODER_SPEC section 8 rule). The data +note terms are equal, so T_ideal(arm) = -charge. T_real(arm, coder) = -charge + 8 (coded bytes +note of B - coded bytes of M), each coded file run through `CODER encode` then `CODER verify`. +note H1 per coded file: |coded bits x 10^6 - ideal ub - 448 x 10^6| <= 64 x 10^6 + 1000 n. +note No Turing verdict word is issued (profile verdict_rule). +note +note Refusal codes: 1 usage, 2 split (detail = the stats refusal code), 3 profile unreadable, +note 4 library CURRENT or manifest invalid (detail 1 TRAIN, 2 TRAINP), 5 base.om unreadable, +note 7 too many symbols for the TPS1 buffer, 15 output write failed. + +text TUK "turing.reuse.model.v1\nturing.tc.pstream.v1\nturing.tc.symbols.v1\nCURRENT\ngen-\n.man\n.om\nB.tps\nD.tsy\nM1.tps\nM2.tps\nencode\nverify\nrans\nrange\n.\nturing.txt\nreport=reuse1-turing version=1 profile=Turing-profile-REUSE-v1.0\nprofile_sha256=\n dataset_sha256=\n n=\n k=16\nmodel name=\n model_sha256=\n tps1_trailer=\n generation=\n k_templates=\n calibration=\n gen_om_bytes=\n base_om_bytes=\ndata ideal_ub=\n ub_per_symbol=\ncoded model=\n coder=\n bytes=\n overhead_ub=\n h1=\nPASS\nFAIL\nNOT_RUN\ncharge arm=\n p1_bits=\n p2_bits=\nturing arm=\n t_ideal_p1_bits=\n t_real_p1_bits_rans=\n t_real_p1_bits_range=\n t_ideal_p2_bits=\n t_real_p2_bits_rans=\n t_real_p2_bits_range=\nB\nM1\nM2\ndelta_t=NOT_APPLICABLE reason=one_library_generation_per_arm verdict=none\nstatus=REFUSED code=\n exit=\nyes\nno\nh1_all=\n tsy1_trailer=\n detail=\n" + +const TKMOD ulong 0 +const TKPST ulong 1 +const TKSYM ulong 2 +const TKCUR ulong 3 +const TKGEN ulong 4 +const TKMAN ulong 5 +const TKOM ulong 6 +const TKBTPS ulong 7 +const TKDTSY ulong 8 +const TKM1 ulong 9 +const TKM2 ulong 10 +const TKENC ulong 11 +const TKVER ulong 12 +const TKRANS ulong 13 +const TKRANGE ulong 14 +const TKDOT ulong 15 +const TKTXT ulong 16 +const TKHEAD ulong 17 +const TKPROF ulong 18 +const TKDATA ulong 19 +const TKN ulong 20 +const TKK ulong 21 +const TKMODEL ulong 22 +const TKMSHA ulong 23 +const TKTRAIL ulong 24 +const TKGENER ulong 25 +const TKKT ulong 26 +const TKCAL ulong 27 +const TKGOMB ulong 28 +const TKBOMB ulong 29 +const TKIDEAL ulong 30 +const TKUBPS ulong 31 +const TKCODED ulong 32 +const TKCODER ulong 33 +const TKBYTES ulong 34 +const TKOVH ulong 35 +const TKH1 ulong 36 +const TKPASS ulong 37 +const TKFAIL ulong 38 +const TKNRUN ulong 39 +const TKCHG ulong 40 +const TKP1 ulong 41 +const TKP2 ulong 42 +const TKTUR ulong 43 +const TKTI1 ulong 44 +const TKTR1R ulong 45 +const TKTR1G ulong 46 +const TKTI2 ulong 47 +const TKTR2R ulong 48 +const TKTR2G ulong 49 +const TKMB ulong 50 +const TKDELT ulong 53 +const TKREFU ulong 54 +const TKEXIT ulong 55 +const TKYES ulong 56 +const TKNO ulong 57 +const TKH1ALL ulong 58 +const TKTSYT ulong 59 +const TKDETL ulong 60 + +global TUFB uchar 8388608 +global TUFL ulong 1 +global TUD ulong 4 +global TUPD ulong 4 +global TUMD ulong 12 +global TUTR ulong 12 +global TUSYT ulong 4 +global TUSY uchar 1048576 +global TUN ulong 1 +global TUKT ulong 3 +global TUCAL ulong 3 +global TUGEN ulong 3 +global TUGOM ulong 3 +global TUBOM ulong 1 +global TUCS ulong 6 +global TUCX ulong 6 +global TUPK uchar 4096 +global TUPKL ulong 1 +global TUWS uchar 4 +global TURF ulong 2 + +note ---------- text table ---------- +fn tukoff k ulong to ulong +i = ulong 0 +c = ulong 0 +while lt c k bound 999999 +if eq get TUK i 10 +c = add c 1 +end +i = add i 1 +end +ret i +end + +fn tuks k ulong to void +i = tukoff k +while ne get TUK i 10 bound 4096 +stoc get TUK i +i = add i 1 +end +end + +fn tukp k ulong to void +i = tukoff k +while ne get TUK i 10 bound 4096 +stpc get TUK i +i = add i 1 +end +end + +note length of string k +fn tuklen k ulong to ulong +i = tukoff k +s = i +while ne get TUK i 10 bound 4096 +i = add i 1 +end +ret sub i s +end + +note ---------- SHA-256 over global bytes ---------- +note copies n bytes of source src (0 TUFB, 1 STFB, 2 TUSY) from byte off into b +fn tucopy b edit uchar 4096 src ulong off ulong n ulong to void +for i ulong n +if eq src 0 +put b i get TUFB add off i +else +if eq src 1 +put b i get STFB add off i +else +put b i get TUSY add off i +end +end +end +end + +note string k then a zero byte into b; returns the length +fn tutag b edit uchar 4096 k ulong to ulong +i = tukoff k +n = ulong 0 +while ne get TUK i 10 bound 4096 +put b n get TUK i +n = add n 1 +i = add i 1 +end +put b n 0 +ret add n 1 +end + +note SHA-256 of (domain string tag and 0x00, unless tag >= 1000) || src[off .. off + n) into TUD +note (TUD word j = digest bytes 8j..8j+7 read little endian) +fn tusha tag ulong src ulong off ulong n ulong to void +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +omsha c b 0 0 w b8 +if lt tag 1000 +m = tutag b tag +omsha c b m 1 w b8 +end +o = ulong 0 +while lt o n bound 999999 +m = sub n o +if gt m 4096 +m = 4096 +end +tucopy b src add off o m +omsha c b m 1 w b8 +o = add o m +end +omsha c b 0 2 w b8 +for j ulong 4 +put TUD j get w j +end +end + +note the 32 digest bytes of TUD as hex +fn tuohd to void +for j ulong 4 +v = get TUD j +for k ulong 8 +stohb and shr v mul k 8 255 +end +end +end + +note ---------- TPS1 / TSY1 byte building in TUFB ---------- +fn tub v ulong to void +p = get TUFL 0 +put TUFB p uchar and v 255 +put TUFL 0 add p 1 +end + +note little-endian integer of nb bytes +fn tule v ulong nb ulong to void +for k ulong nb +tub shr v mul k 8 +end +end + +note 32 bytes of digest words (word j little-endian bytes) +fn tudig4 a ulong b ulong c ulong d ulong to void +tule a 8 +tule b 8 +tule c 8 +tule d 8 +end + +note the dataset digest: index words 7..10, each word's bytes big endian +fn tudata to void +for j ulong 4 +v = get STHD j +for k ulong 8 +tub shr v mul sub 7 k 8 +end +end +end + +note TPS1 for model m (0 B, 1 M1, 2 M2) into TUFB; trailer digest stored in TUTR +fn tutps m ulong to void +put TUFL 0 0 +tule 827543636 4 +tule 1 2 +tule 16 1 +tule 16 1 +tule 0 4 +n = get TUN 0 +tule n 8 +tule 56 4 +tule 0 4 +tudig4 get TUPD 0 get TUPD 1 get TUPD 2 get TUPD 3 +b = mul m 4 +tudig4 get TUMD b get TUMD add b 1 get TUMD add b 2 get TUMD add b 3 +tudata +tule 0 4 +for t ulong n +tule t 8 +tule 0 8 +tule t 4 +tule 65536 4 +s = ulong get TUSY t +for x ulong 16 +if eq x s +tule 65521 2 +else +tule 1 2 +end +end +end +tusha TKPST 0 0 get TUFL 0 +for j ulong 4 +put TUTR add b j get TUD j +tule get TUD j 8 +end +end + +note TSY1 into TUFB +fn tutsy to void +put TUFL 0 0 +tule 827937620 4 +tule 1 2 +tule 16 1 +tule 0 1 +n = get TUN 0 +tule n 8 +tule 0 8 +tudata +for t ulong n +tub ulong get TUSY t +end +tusha TKSYM 0 0 get TUFL 0 +for j ulong 4 +put TUSYT j get TUD j +tule get TUD j 8 +end +end + +note TUFB[0..TUFL) to the path in STPB; 0 ok +fn tuwfile to int +fd = fopen STPB 0 get STPL 0 577 420 +if lt fd 0 +ret 1 +end +n = get TUFL 0 +o = ulong 0 +while lt o n bound 999999 +w = write int fd TUFB o sub n o +if le w 0 +c = fclose int fd +ret 1 +end +o = add o ulong w +end +s = fsync int fd +c = fclose int fd +if or ne s 0 ne c 0 +ret 1 +end +ret 0 +end + +note output file name of model m (k = TKBTPS, TKM1, TKM2) in OUTDIR (slot 6) +fn tutpsname m ulong to void +stpbase 6 +if eq m 0 +tukp TKBTPS +end +if eq m 1 +tukp TKM1 +end +if eq m 2 +tukp TKM2 +end +end + +note ---------- D ---------- +fn tusyms to int +n = ulong 0 +for i ulong get STNR 0 +if eq get STRO i 2 +if ge n len TUSY +ret 7 +end +put TUSY n uchar and get STR0 i 15 +n = add n 1 +end +end +put TUN 0 n +ret 0 +end + +note ---------- libraries ---------- +note checks library l (1 TRAIN in slot 2, 2 TRAINP in slot 3): CURRENT, gen-G.man (magic, SHA-256 +note equal to CURRENT's), K, calibration presence, model digest, gen-G.om size. 0 ok. +fn tulib l ulong to int +s = add l 1 +stpbase s +tukp TKCUR +n = stload +if ne n 40 +ret 1 +end +g = stw 0 +cd = new ulong 4 0 +for j ulong 4 +put cd j stw add 8 mul j 8 +end +put TUGEN l g +stpbase s +tukp TKGEN +stpu g +tukp TKMAN +n = stload +if ne n 2048 +ret 2 +end +if ne stw 0 3544386019401740626 +ret 3 +end +tusha 1000 1 0 2048 +for j ulong 4 +if ne get TUD j get cd j +ret 4 +end +end +put TUKT l stw 32 +cal = or or stw 416 stw 424 or stw 432 stw 440 +put TUCAL l 0 +if ne cal 0 +put TUCAL l 1 +end +tusha TKMOD 1 0 2048 +for j ulong 4 +put TUMD add mul l 4 j get TUD j +end +stpbase s +tukp TKGEN +stpu g +tukp TKOM +n = stload +if lt n 0 +ret 5 +end +put TUGOM l ulong n +ret 0 +end + +note B's model digest over 32 zero bytes +fn tubmodel to void +for i ulong 32 +put STFB i 0 +end +tusha TKMOD 1 0 32 +for j ulong 4 +put TUMD j get TUD j +end +end + +note ---------- the external coder ---------- +fn tupkc c uchar to void +p = get TUPKL 0 +put TUPK p c +put TUPKL 0 add p 1 +end + +note appends the path in STPB as one packed record +fn tupkpath to void +n = get STPL 0 +tupkc uchar and n 255 +tupkc uchar shr n 8 +for i ulong n +tupkc get STPB i +end +end + +fn tupkk k ulong to void +n = tuklen k +tupkc uchar n +tupkc 0 +i = tukoff k +for j ulong n +tupkc get TUK add i j +end +end + +note runs the packed list; returns the exit code, 256 + signal, or 512 when fork or exec failed +fn turun to ulong +put TUPK 0 6 +put TUPK 1 0 +pid = fork +if lt pid 0 +ret 512 +end +if eq pid 0 +d = dupfd 2 1 0 +r = execprog TUPK 0 get TUPKL 0 +exit 127 +end +r = waitpid int pid TUWS 0 4 0 +if ne r pid +ret 512 +end +sg = and ulong get TUWS 0 127 +if ne sg 0 +ret add 256 sg +end +ret ulong get TUWS 1 +end + +note the coded file name of model m, coder c (0 rans, 1 range) as the path +fn tucodedname m ulong c ulong to void +tutpsname m +tukp TKDOT +if eq c 0 +tukp TKRANS +else +tukp TKRANGE +end +end + +note CODER op coder model: op TKENC or TKVER +fn tucoder op ulong m ulong c ulong to ulong +put TUPKL 0 2 +stpexact 5 +tupkpath +tupkk op +if eq c 0 +tupkk TKRANS +else +tupkk TKRANGE +end +tutpsname m +tupkpath +stpbase 6 +tukp TKDTSY +tupkpath +tucodedname m c +tupkpath +ret turun +end + +note encode, verify and size one coded file; TUCX = exit (0 ok), TUCS = bytes +fn tucode m ulong c ulong to void +x = add mul m 2 c +e = tucoder TKENC m c +if eq e 0 +e = tucoder TKVER m c +end +put TUCX x e +put TUCS x 0 +if ne e 0 +ret +end +tucodedname m c +n = stload +if lt n 56 +put TUCX x 600 +ret +end +if ne stw 48 sub ulong n 56 +put TUCX x 601 +ret +end +put TUCS x ulong n +end + +note ---------- CODER_SPEC section 8 ideal length ---------- +fn tuub q ulong to ulong +ip = ulong 0 +for i ulong 64 +if ne and shr q i 1 0 +ip = i +end +end +m = shl q sub 62 ip +frac = ulong 0 +for i ulong 32 +stmul m m +m = or shl get STHL 0 2 shr get STHL 1 62 +if ge m 9223372036854775808 +frac = or frac shl ulong 1 sub 31 i +m = shr m 1 +end +end +lg = or shl ip 32 frac +x = sub 68719476736 lg +ret shr add mul x 1000000 2147483648 32 +end + +note ---------- report ---------- +note model of arm a: 0 B, 1 M1, 2 M2 +fn tumodel a ulong to ulong +if or or eq a 3 eq a 4 eq a 7 +ret 1 +end +if eq a 6 +ret 2 +end +ret 0 +end + +fn tup1 a ulong to ulong +m = tumodel a +if eq m 0 +ret 0 +end +v = mul 512 get TUKT m +if and eq a 7 eq get TUCAL m 1 +v = add v 12352 +end +ret v +end + +fn tup2 a ulong to long +m = tumodel a +if eq m 0 +ret 0 +end +d = sub long get TUGOM m long get TUBOM 0 +ret mul 8 add d 2048 +end + +note T_real for charge ch (bits) and coder c: -ch + 8 (bytes of B - bytes of M); 0 = NOT_RUN flag in TURF +fn tureal ch long m ulong c ulong to long +put TURF 0 0 +if or ne get TUCX c 0 ne get TUCX add mul m 2 c 0 +put TURF 0 1 +ret 0 +end +d = sub long get TUCS c long get TUCS add mul m 2 c +ret add neg ch mul 8 d +end + +fn tuoreal ch long m ulong c ulong to void +v = tureal ch m c +if eq get TURF 0 1 +tuks TKNRUN +else +stol v +end +end + +fn tuarmline a ulong to void +p1 = long tup1 a +p2 = tup2 a +m = tumodel a +tuks TKCHG +stks add SKARM0 a +tuks TKP1 +stol p1 +tuks TKP2 +stol p2 +stnl +tuks TKTUR +stks add SKARM0 a +tuks TKTI1 +stol neg p1 +tuks TKTR1R +tuoreal p1 m 0 +tuks TKTR1G +tuoreal p1 m 1 +tuks TKTI2 +stol neg p2 +tuks TKTR2R +tuoreal p2 m 0 +tuks TKTR2G +tuoreal p2 m 1 +stnl +end + +note H1 for coded file x: returns 1 PASS, 0 FAIL, 2 NOT_RUN +fn tuh1 x ulong to ulong +if ne get TUCX x 0 +ret 2 +end +n = get TUN 0 +id = mul n tuub 65521 +cb = mul get TUCS x 8000000 +ov = sub long sub long cb long id 448000000 +if lt ov 0 +ov = neg ov +end +if le ov long add 64000000 mul 1000 n +ret 1 +end +ret 0 +end + +fn tucodedline m ulong c ulong to ulong +x = add mul m 2 c +tuks TKCODED +tuks add TKMB m +tuks TKCODER +if eq c 0 +tuks TKRANS +else +tuks TKRANGE +end +h = tuh1 x +if eq h 2 +if ne get TUCX x 1000 +tuks TKEXIT +stou get TUCX x +end +tuks TKH1 +tuks TKNRUN +stnl +ret h +end +tuks TKBYTES +stou get TUCS x +n = get TUN 0 +tuks TKOVH +stol sub long mul get TUCS x 8000000 long mul n tuub 65521 +tuks TKH1 +if eq h 1 +tuks TKPASS +else +tuks TKFAIL +end +stnl +ret h +end + +fn tumodelline m ulong to void +tuks TKMODEL +tuks add TKMB m +tuks TKMSHA +b = mul m 4 +for j ulong 4 +v = get TUMD add b j +for k ulong 8 +stohb and shr v mul k 8 255 +end +end +tuks TKTRAIL +for j ulong 4 +v = get TUTR add b j +for k ulong 8 +stohb and shr v mul k 8 255 +end +end +if gt m 0 +tuks TKGENER +stou get TUGEN m +tuks TKKT +stou get TUKT m +tuks TKCAL +if eq get TUCAL m 1 +tuks TKYES +else +tuks TKNO +end +tuks TKGOMB +stou get TUGOM m +tuks TKBOMB +stou get TUBOM 0 +end +stnl +end + +fn tureport to void +tuks TKHEAD +stnl +tuks TKPROF +for j ulong 4 +put TUD j get TUPD j +end +tuohd +tuks TKDATA +for j ulong 4 +stohw get STHD j +end +tuks TKN +stou get TUN 0 +tuks TKK +tuks TKTSYT +for j ulong 4 +put TUD j get TUSYT j +end +tuohd +stnl +for m ulong 3 +tumodelline m +end +n = get TUN 0 +tuks TKIDEAL +stou mul n tuub 65521 +tuks TKUBPS +stou tuub 65521 +stnl +all = ulong 1 +for m ulong 3 +for c ulong 2 +h = tucodedline m c +if ne h 1 +all = 0 +end +end +end +tuks TKH1ALL +if eq all 1 +tuks TKPASS +else +if eq get TUCX 0 1000 +tuks TKNRUN +else +tuks TKFAIL +end +end +stnl +tuarmline 3 +tuarmline 4 +tuarmline 7 +tuarmline 6 +tuarmline 5 +tuarmline 2 +tuks TKDELT +stnl +end + +fn tufail code ulong d ulong to int +put STOP 0 0 +tuks TKREFU +stou code +tuks TKDETL +stou d +stnl +if ne get STQT 0 1 +r = stflush 1 +end +ret 2 +end + +note the evaluation on slots 0 split, 1 profile, 2 TRAIN lib, 3 TRAINP lib, 4 base.om, +note 5 coder (- = NOT_RUN), 6 out; report to stdout unless STQT is 1 +fn turun2 to int +streset +e = stidx +if eq e 0 +e = stsess +end +if eq e 0 +e = stexps +end +if ne e 0 +ret tufail 2 ulong e +end +if ne tusyms 0 +ret tufail 7 0 +end +stpexact 1 +n = stload +if lt n 0 +ret tufail 3 0 +end +tusha 1000 1 0 ulong n +for j ulong 4 +put TUPD j get TUD j +end +tubmodel +for l ulong 2 +e = tulib add l 1 +if ne e 0 +ret tufail 4 add mul add l 1 10 ulong e +end +end +stpexact 4 +n = stload +if lt n 0 +ret tufail 5 0 +end +put TUBOM 0 ulong n +for m ulong 3 +tutps m +tutpsname m +if ne tuwfile 0 +ret tufail 15 m +end +end +tutsy +stpbase 6 +tukp TKDTSY +if ne tuwfile 0 +ret tufail 15 3 +end +nocoder = and eq get STBL 5 1 eq get STBD 20480 45 +for x ulong 6 +put TUCX x 1000 +put TUCS x 0 +end +if not nocoder +for m ulong 3 +tucode m 0 +tucode m 1 +end +end +put STOP 0 0 +tureport +if ne get STQT 0 1 +r = stflush 1 +end +stpbase 6 +tukp TKTXT +if ne stwfile 0 +ret 15 +end +ret 0 +end + +fn tumain to int +if lt argcnt 9 +ret tufail 1 0 +end +for k ulong 7 +if eq stargb add k 2 k 0 +ret tufail 1 add k 1 +end +end +ret turun2 +end diff --git a/tests/reuse-eval/gen-det.om b/tests/reuse-eval/gen-det.om new file mode 100644 index 0000000..078379a --- /dev/null +++ b/tests/reuse-eval/gen-det.om @@ -0,0 +1,371 @@ +note units: sha256 ref +note needs: gen +note gen-det: gen is deterministic: every split twice gives byte-identical files; FINAL depends on +note seed bytes 8..15 only (K6: a change in byte 0 gives identical files, in byte 8 another +note holdout digest); DEV and FINAL differ; usage refusals exit 2. argv[1] scratch dir, argv[2] gen. +note Exit 0 pass; 1 args; 10 + k a gen run failed (k = run number); 40 files differ; +note 41 a seed byte 8 change kept the digest; 42 DEV equals FINAL; 43..46 a refusal was not 2. +text tgnull "/dev/null" +text tgs1 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +text tgs2 "000102030405060708ff0a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +text tgs3 "aa0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +text tgs4 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1" +global TGB uchar 16777216 +global TGC uchar 16777216 +global TGP uchar 4096 +global TGK uchar 4096 +global TGA uchar 4096 +global TGS uchar 4096 +global TGT ulong 16 +global TGST uchar 4 +global TGIX ulong 4 +global TGIY ulong 4 + +note TGT: 0 scratch length, 1 gen path length, 2 path length, 3 packet position, 4 record count, +note 5 directory path length, 6 TGB length, 7 TGC length, 8 run number + +fn tgpput v ulong n ulong to void +l = get TGT 2 +x = v +for i ulong n +put TGP add l i uchar and x 255 +x = shr x 8 +end +put TGT 2 add l n +end + +note TGP = scratch + "/" + the letter c +fn tgdir c ulong to void +l = get TGT 0 +for i ulong l +put TGP i get TGS i +end +put TGT 2 l +tgpput add 47 mul c 256 2 +put TGT 5 get TGT 2 +end + +fn tgfile v ulong n ulong to void +put TGT 2 get TGT 5 +tgpput 47 1 +tgpput v n +end + +fn tggfile g ulong ext ulong to void +put TGT 2 get TGT 5 +tgpput 26415 2 +tgpput add 48 div g 10 1 +tgpput add 48 rem g 10 1 +if eq ext 0 +tgpput 1902473774 4 +else +tgpput 1886938414 4 +end +end + +fn tgkini to void +put TGT 3 2 +put TGT 4 0 +end + +fn tgkhdr n ulong to ulong +p = get TGT 3 +put TGK p uchar and n 255 +put TGK add p 1 uchar shr n 8 +put TGT 3 add p add n 2 +put TGT 4 add get TGT 4 1 +ret add p 2 +end + +fn tgkgen to void +n = get TGT 1 +p = tgkhdr n +for i ulong n +put TGK add p i get TGA i +end +end + +fn tgkval v ulong n ulong to void +p = tgkhdr n +x = v +for i ulong n +put TGK add p i uchar and x 255 +x = shr x 8 +end +end + +fn tgkpath to void +n = get TGT 2 +p = tgkhdr n +for i ulong n +put TGK add p i get TGP i +end +end + +fn tgkseed w ulong to void +if eq w 4 +p4 = tgkhdr len tgs4 +for i4 ulong len tgs4 +put TGK add p4 i4 get tgs4 i4 +end +ret +end +p = tgkhdr 64 +for i ulong 64 +c = get tgs1 i +if eq w 2 +c = get tgs2 i +end +if eq w 3 +c = get tgs3 i +end +put TGK add p i c +end +end + +note run the packet; the exit status of gen (stdout to /dev/null), 256 when it did not exit +fn tgexec to ulong +c = get TGT 4 +put TGK 0 uchar c +put TGK 1 0 +pid = fork +if lt pid 0 +ret 256 +end +if eq pid 0 +fd = fopen tgnull 0 len tgnull 1 0 +if ge fd 0 +d = dupfd int fd 1 0 +end +r = execprog TGK 0 get TGT 3 +exit 97 +end +w = waitpid int pid TGST 0 4 0 +if ne w pid +ret 256 +end +if ne get TGST 0 0 +ret 256 +end +ret ulong get TGST 1 +end + +note gen NAME (packed v, n bytes) into directory letter c, seed w (0 none) +fn tggen v ulong n ulong c ulong w ulong to ulong +tgkini +tgkgen +tgkval v n +tgdir c +tgkpath +if ne w 0 +tgkseed w +end +ret tgexec +end + +fn tgreadb to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGB 0 len TGB +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +fn tgreadc to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGC 0 len TGC +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +note TGB[0..n) = TGC[0..n), in 4096-byte rows (one loop stops itself after a million passes) +fn tgcmp n ulong to bool +rows = add div n 4096 1 +for r ulong rows +b = mul r 4096 +k = ulong 4096 +if gt add b k n +k = sub n b +end +for i ulong k +if ne get TGB add b i get TGC add b i +ret false +end +end +end +ret true +end + +note one file of directory a against the same file of directory b (the file name set by caller) +fn tgsame a ulong b ulong v ulong n ulong to bool +tgdir a +tgfile v n +la = tgreadb +tgdir b +tgfile v n +lb = tgreadc +if or eq la 0 ne la lb +ret false +end +ret tgcmp la +end + +fn tgsameg a ulong b ulong g ulong ext ulong to bool +tgdir a +tggfile g ext +la = tgreadb +tgdir b +tggfile g ext +lb = tgreadc +if or eq la 0 ne la lb +ret false +end +ret tgcmp la +end + +fn tgword i ulong to ulong +v = ulong 0 +for j ulong 8 +v = or v shl ulong get TGB add mul i 8 j mul j 8 +end +ret v +end + +note every file of a split directory a equals b's +fn tgsamedir a ulong b ulong to bool +if not tgsame a b 517097156201 5 +ret false +end +g = tgword 3 +if or eq g 0 gt g 100 +ret false +end +if not tgsame a b 8317708060499076467 8 +ret false +end +for i ulong g +if not tgsameg a b i 0 +ret false +end +if not tgsameg a b i 1 +ret false +end +end +ret true +end + +note the holdout digest (index words 7..10) of directory a into TGIX +fn tgdig a ulong to void +tgdir a +tgfile 517097156201 5 +n = tgreadb +for j ulong 4 +put TGIX j 0 +if ge n 128 +put TGIX j tgword add 7 j +end +end +end + +fn tgrun v ulong n ulong c ulong w ulong to ulong +put TGT 8 add get TGT 8 1 +r = tggen v n c w +if ne r 0 +ret add 10 get TGT 8 +end +ret 0 +end + +fn main to int +if lt argcnt 3 +ret 1 +end +l = argread 1 TGS 0 3000 +m = argread 2 TGA 0 3000 +if or le l 0 le m 0 +ret 1 +end +put TGT 0 ulong l +put TGT 1 ulong m +r = tgrun 336236466772 5 65 0 +r = or r tgrun 336236466772 5 66 0 +r = or r tgrun 88297166688852 6 67 0 +r = or r tgrun 88297166688852 6 68 0 +r = or r tgrun 284697575747 5 69 0 +r = or r tgrun 284697575747 5 70 0 +r = or r tgrun 5653828 3 71 0 +r = or r tgrun 5653828 3 72 0 +r = or r tgrun 327513164102 5 73 1 +r = or r tgrun 327513164102 5 74 1 +r = or r tgrun 327513164102 5 75 3 +r = or r tgrun 327513164102 5 76 2 +if ne r 0 +ret int r +end +if not tgsamedir 65 66 +ret 40 +end +if not tgsamedir 67 68 +ret 40 +end +if not tgsamedir 69 70 +ret 40 +end +if not tgsamedir 71 72 +ret 40 +end +if not tgsamedir 73 74 +ret 40 +end +if not tgsamedir 73 75 +ret 40 +end +tgdig 73 +for i ulong 4 +put TGIY i get TGIX i +end +tgdig 76 +same = true +for j ulong 4 +if ne get TGIX j get TGIY j +same = false +end +end +if same +ret 41 +end +tgdig 71 +same2 = true +for k ulong 4 +if ne get TGIX k get TGIY k +same2 = false +end +end +if same2 +ret 42 +end +if ne tggen 327513164102 5 77 0 2 +ret 43 +end +if ne tggen 5653828 3 77 1 2 +ret 44 +end +if ne tggen 357913022274 5 77 0 2 +ret 45 +end +if ne tggen 327513164102 5 77 4 2 +ret 46 +end +ret 0 +end diff --git a/tests/reuse-eval/gen-final.om b/tests/reuse-eval/gen-final.om new file mode 100644 index 0000000..980a6c1 --- /dev/null +++ b/tests/reuse-eval/gen-final.om @@ -0,0 +1,937 @@ +note units: sha256 ref +note needs: gen +note gen-final: DEV and FINAL (a fixed test seed) are exactly the composition of contract 7.2 and +note clarification K8. Generates TRAIN, TRAINP, DEV, FINAL into argv[1]; replays every request +note through ref.om and checks: index (magic, version, split id, 24 groups, 192 sessions, request and +note QUERY counts, group counts, holdout digest = SHA-256 of the .req files in group order); every +note .exp record (status 0, q, r0, r1, op, ordinal, cold flag); the sessions file (ordinal, group, +note family, n class, n, shape id, program digest, counts, first request index); 4 sessions per +note family x type x n with n in {64, 512, 4096}; the request pattern of every type; novelty classes +note (recall = a TRAIN program, transfer = a TRAIN shape with a program not in TRAIN, novel = a shape +note in neither TRAIN nor TRAINP, FSM recall / new) with their frozen counts; type A: AGG f MIN or +note MAX and each DEL removes the first index holding the current extreme, FSM every symbol a +note permutation and every SET at index 0 changes q_t for every t >= 1 (no reconvergence); +note type P: each PROGRAM keeps the shape (FSM S and A) and changes the program. +note Exit 0 pass; 1 args; 2 a gen run failed; 3 file; codes 20..69 name the failed check. +text tgnull "/dev/null" +text tgs1 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +global TGB uchar 16777216 +global TGC uchar 16777216 +global TGP uchar 4096 +global TGK uchar 4096 +global TGA uchar 4096 +global TGS uchar 4096 +global TGT ulong 16 +global TGST uchar 4 +global TGIX ulong 128 +global TGSS ulong 3840 +global TGTR ulong 15360 +global TGTS ulong 240 +global TGPS ulong 240 +global TGCU ulong 32 +global TGOP ulong 256 +global TGOLD ulong 64 +global TGQ ulong 4097 +global TGCN ulong 64 +global TGNV ulong 384 + +note TGT: 0 scratch length, 1 gen path length, 2 path length, 3 packet position, 4 record count, +note 5 directory path length, 6 TGB length, 7 TGC length, 8 TRAIN rows, 9 TRAINP rows +note TGCU: 0 open session (1), 1 session requests, 2 session QUERYs, 3 cold pending, 4 type, +note 5 family, 6 novelty, 7 ordinal, 8 first failure, 9 requests, 10 QUERYs, 11 slot in group, +note 12 group, 13 n class + +fn tgpput v ulong n ulong to void +l = get TGT 2 +x = v +for i ulong n +put TGP add l i uchar and x 255 +x = shr x 8 +end +put TGT 2 add l n +end + +fn tgdir c ulong to void +l = get TGT 0 +for i ulong l +put TGP i get TGS i +end +put TGT 2 l +tgpput add 47 mul c 256 2 +put TGT 5 get TGT 2 +end + +fn tgfile v ulong n ulong to void +put TGT 2 get TGT 5 +tgpput 47 1 +tgpput v n +end + +fn tggfile g ulong ext ulong to void +put TGT 2 get TGT 5 +tgpput 26415 2 +tgpput add 48 div g 10 1 +tgpput add 48 rem g 10 1 +if eq ext 0 +tgpput 1902473774 4 +else +tgpput 1886938414 4 +end +end + +fn tgkhdr n ulong to ulong +p = get TGT 3 +put TGK p uchar and n 255 +put TGK add p 1 uchar shr n 8 +put TGT 3 add p add n 2 +put TGT 4 add get TGT 4 1 +ret add p 2 +end + +fn tgkgen to void +n = get TGT 1 +p = tgkhdr n +for i ulong n +put TGK add p i get TGA i +end +end + +fn tgkval v ulong n ulong to void +p = tgkhdr n +x = v +for i ulong n +put TGK add p i uchar and x 255 +x = shr x 8 +end +end + +fn tgkpath to void +n = get TGT 2 +p = tgkhdr n +for i ulong n +put TGK add p i get TGP i +end +end + +fn tgkseed to void +p = tgkhdr 64 +for i ulong 64 +put TGK add p i get tgs1 i +end +end + +fn tgexec to ulong +put TGK 0 uchar get TGT 4 +put TGK 1 0 +pid = fork +if lt pid 0 +ret 256 +end +if eq pid 0 +fd = fopen tgnull 0 len tgnull 1 0 +if ge fd 0 +d = dupfd int fd 1 0 +end +r = execprog TGK 0 get TGT 3 +exit 97 +end +w = waitpid int pid TGST 0 4 0 +if or ne w pid ne get TGST 0 0 +ret 256 +end +ret ulong get TGST 1 +end + +fn tggen v ulong n ulong c ulong w ulong to ulong +put TGT 3 2 +put TGT 4 0 +tgkgen +tgkval v n +tgdir c +tgkpath +if ne w 0 +tgkseed +end +ret tgexec +end + +fn tgreadb to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGB 0 len TGB +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +fn tgreadc to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGC 0 len TGC +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +fn tgwb i ulong to ulong +v = ulong 0 +b = mul i 8 +for j ulong 8 +v = or v shl ulong get TGB add b j mul j 8 +end +ret v +end + +fn tgwc i ulong to ulong +v = ulong 0 +b = mul i 8 +for j ulong 8 +v = or v shl ulong get TGC add b j mul j 8 +end +ret v +end + +fn tgerr code ulong to void +if eq get TGCU 8 0 +put TGCU 8 code +end +end + +note ---- TRAIN and TRAINP tables ---- + +note the BEGIN program at word w of TGB as TRAIN row r (which 1) or TRAINP shape r (which 5) +fn tgtrow w ulong r ulong which ulong to void +for j ulong 64 +put RFP j tgwb add add w 2 j +end +if eq which 1 +for i ulong 64 +put TGTR add mul r 64 i get RFP i +end +put TGTS r rfshape +else +put TGPS r rfshape +end +end + +note BEGIN programs of directory c into TGTR / TGTS (which 1) or their shapes into TGPS (which 5) +fn tgtrain c ulong which ulong to void +rows = ulong 0 +for g ulong 30 +tgdir c +tggfile g 0 +nw = div tgreadb 8 +w = ulong 0 +while lt w nw bound 99999 +op = tgwb w +p = tgwb add w 1 +if eq op 1 +tgtrow w rows which +rows = add rows 1 +end +w = add w add p 2 +end +end +if eq which 1 +put TGT 8 rows +else +put TGT 9 rows +end +end + +fn tgrowis r ulong to bool +for j ulong 64 +if ne get RFP j get TGTR add mul r 64 j +ret false +end +end +ret true +end + +note RFP equals a TRAIN session program +fn tgintr to bool +for r ulong get TGT 8 +if tgrowis r +ret true +end +end +ret false +end + +fn tgshtr sh ulong to bool +for r ulong get TGT 8 +fam = get TGTR add mul r 64 1 +if and eq fam 1 eq get TGTS r sh +ret true +end +end +ret false +end + +fn tgshtp sh ulong to bool +for r ulong get TGT 9 +if eq get TGPS r sh +ret true +end +end +ret false +end + +note ---- per-session checks ---- + +fn tgrec i ulong to ulong +ret get TGSS add mul get TGCU 7 16 i +end + +note the op at position j (1-based after BEGIN) of a session of type t, family f; 0 = past the end +fn tgpat t ulong f ulong j ulong to ulong +if eq t 1 +if le j 32 +ret 2 +end +ret 0 +end +if eq t 7 +if gt j 20 +ret 0 +end +if eq rem j 5 4 +ret 8 +end +ret 2 +end +if and eq t 6 eq f 1 +if gt j 192 +ret 0 +end +r = rem j 3 +if eq r 1 +ret 5 +end +if eq r 2 +ret 4 +end +ret 2 +end +lim = ulong 128 +if eq t 3 +lim = 16 +end +if gt j lim +ret 0 +end +if eq rem j 2 0 +ret 2 +end +if eq t 3 +ret 7 +end +if eq t 4 +ret 6 +end +if eq t 5 +if eq rem div sub j 1 2 2 0 +ret 5 +end +ret 4 +end +ret 3 +end + +fn tgendsess to void +if eq get TGCU 0 0 +ret +end +put TGCU 0 0 +nr = get TGCU 1 +if or ne tgrec 12 nr ne tgrec 13 get TGCU 2 +tgerr 20 +end +t = get TGCU 4 +f = get TGCU 5 +if ne get TGOP 0 1 +tgerr 21 +end +for j ulong 255 +want = tgpat t f add j 1 +got = ulong 0 +if lt add j 1 nr +got = get TGOP add j 1 +end +if ne want got +tgerr 21 +end +end +end + +fn tgnewsess k ulong to void +tgendsess +ord = add mul get TGCU 12 8 get TGCU 11 +put TGCU 11 add get TGCU 11 1 +put TGCU 7 ord +put TGCU 0 1 +put TGCU 1 0 +put TGCU 2 0 +if ge ord 192 +tgerr 22 +put TGCU 7 0 +ret +end +if or ne tgrec 0 ord ne tgrec 1 get TGCU 12 +tgerr 22 +end +if or ne tgrec 14 k ne tgrec 15 0 +tgerr 22 +end +put TGCU 4 tgrec 3 +put TGCU 5 tgrec 2 +put TGCU 6 tgrec 4 +end + +note every symbol's transition of RFP is a permutation of the states +fn tgperm to bool +s = get RFP 2 +a = get RFP 3 +for x ulong a +seen = ulong 0 +for st ulong s +t = rfdelta st x +b = shl ulong 1 t +if ne and seen b 0 +ret false +end +seen = or seen b +end +end +ret true +end + +fn tgnovchk nov ulong t ulong sh ulong to void +if eq nov 1 +if not tgintr +tgerr 30 +end +end +if eq nov 2 +if or not tgshtr sh tgintr +tgerr 31 +end +end +if eq nov 3 +if or tgshtr sh tgshtp sh +tgerr 32 +end +end +if eq nov 4 +if not tgintr +tgerr 33 +end +end +if eq nov 5 +if tgintr +tgerr 34 +end +end +f = get RFP 1 +if eq f 1 +if or lt nov 1 gt nov 3 +tgerr 35 +end +if and eq t 8 ne nov 3 +tgerr 35 +end +if eq t 6 +if and ne get RFP 3 3 ne get RFP 3 4 +tgerr 36 +end +end +else +if or lt nov 4 gt nov 5 +tgerr 35 +end +if and eq t 8 ne nov 5 +tgerr 35 +end +if eq t 6 +if not tgperm +tgerr 37 +end +end +end +end + +fn tgbegpost to void +n = get RFN 0 +if or ne tgrec 2 get RFP 1 ne tgrec 6 n +tgerr 23 +end +nc = tgrec 5 +if gt nc 2 +tgerr 24 +ret +end +want = ulong 64 +if eq nc 1 +want = 512 +end +if eq nc 2 +want = 4096 +end +if ne n want +tgerr 24 +end +sh = rfshape +if ne tgrec 7 sh +tgerr 25 +end +rfpdig +for j ulong 4 +if ne tgrec add 8 j get RFPD j +tgerr 26 +end +end +t = get TGCU 4 +if or lt t 1 gt t 8 +tgerr 27 +ret +end +f = get RFP 1 +nov = get TGCU 6 +tgnovchk nov t sh +c = add mul sub f 1 24 add mul sub t 1 3 nc +put TGCN c add get TGCN c 1 +v = add mul c 6 nov +put TGNV v add get TGNV v 1 +end + +fn tgtraj to void +q = get RFP 4 +put TGQ 0 q +n = get RFN 0 +for t ulong n +q = rfdelta q get RFX t +put TGQ add t 1 q +end +end + +fn tgdiverge to bool +q = get RFP 4 +n = get RFN 0 +for t ulong n +q = rfdelta q get RFX t +if eq q get TGQ add t 1 +ret false +end +end +ret true +end + +fn tgextr i ulong to bool +rffull +ex = get RFR 0 +if ge i get RFN 0 +ret false +end +for j ulong i +if eq rflane get RFX j ex +ret false +end +end +ret eq rflane get RFX i ex +end + +fn tgpre op ulong to void +t = get TGCU 4 +f = get TGCU 5 +if and eq t 6 eq op 5 +if eq f 1 +if not tgextr get RFRQ 2 +tgerr 40 +end +end +end +if and eq t 6 eq op 3 +if eq f 2 +if ne get RFRQ 2 0 +tgerr 41 +end +tgtraj +end +end +if eq op 7 +if ne get RFRQ 2 1024 +tgerr 42 +end +m = get RFRQ 2 +for i ulong m +if ne get RFRQ add 3 mul i 3 3 +tgerr 42 +end +end +end +if eq op 8 +for j ulong 64 +put TGOLD j get RFP j +end +end +end + +fn tgpost op ulong to void +t = get TGCU 4 +if eq op 1 +tgbegpost +end +if and eq t 6 eq op 3 +if eq get TGCU 5 2 +if not tgdiverge +tgerr 43 +end +end +end +if eq op 8 +same = true +for j ulong 64 +if ne get TGOLD j get RFP j +same = false +end +end +if same +tgerr 44 +end +if eq get RFP 1 1 +if ne get RFP 1 get TGOLD 1 +tgerr 45 +end +for x ulong 17 +if or lt x 6 eq rem x 2 1 +if ne get RFP x get TGOLD x +tgerr 45 +end +end +end +else +if ne get TGOLD 1 2 +tgerr 45 +end +if ne get RFP 2 get TGOLD 2 +tgerr 45 +end +if ne get RFP 3 get TGOLD 3 +tgerr 45 +end +end +end +end + +note the expected record k against the reference's response +fn tgexpchk k ulong op ulong st ulong to void +b = mul k 8 +if ne st 0 +tgerr 50 +end +if or ne tgwc b 0 ne tgwc add b 1 get RFRS 1 +tgerr 51 +end +if or ne tgwc add b 2 get RFRS 2 ne tgwc add b 3 get RFRS 3 +tgerr 52 +end +if or ne tgwc add b 4 op ne tgwc add b 5 get TGCU 7 +tgerr 53 +end +cold = ulong 0 +if eq op 2 +if eq get TGCU 3 1 +cold = 1 +end +put TGCU 3 0 +put TGCU 2 add get TGCU 2 1 +put TGCU 10 add get TGCU 10 1 +end +if or eq op 1 eq op 8 +put TGCU 3 1 +end +if or ne tgwc add b 6 cold ne tgwc add b 7 0 +tgerr 54 +end +end + +fn tgstep w ulong k ulong to ulong +op = tgwb w +p = tgwb add w 1 +if gt p 7234 +tgerr 55 +ret 18446744073709551615 +end +for j ulong add p 2 +put RFRQ j tgwb add w j +end +if eq op 1 +tgnewsess k +end +tgpre op +st = ulong rfreq +tgpost op +tgexpchk k op st +r = get TGCU 1 +if lt r 256 +put TGOP r op +end +put TGCU 1 add r 1 +put TGCU 9 add get TGCU 9 1 +ret add w add p 2 +end + +fn tgabs nb ulong to void +off = ulong 0 +while lt off nb bound 999 +k = sub nb off +if gt k 65536 +k = 65536 +end +for i ulong k +put RFHB i get TGB add off i +end +rfhabs 0 k +off = add off k +end +end + +fn tggroup c ulong g ulong to void +tgdir c +tggfile g 0 +nb = tgreadb +tgdir c +tggfile g 1 +ne8 = tgreadc +tgabs nb +nw = div nb 8 +put TGCU 12 g +put TGCU 11 0 +rfreset +w = ulong 0 +k = ulong 0 +while lt w nw bound 99999 +w = tgstep w k +k = add k 1 +end +tgendsess +if ne w nw +tgerr 56 +end +if ne mul k 64 ne8 +tgerr 56 +end +if ne get TGCU 11 8 +tgerr 57 +end +gc = get TGIX add 16 g +if ne k gc +tgerr 57 +end +end + +note index and sessions of directory c into TGIX / TGSS; 0 or a failure code +fn tgload c ulong sid ulong to ulong +tgdir c +tgfile 517097156201 5 +if ne tgreadb 320 +ret 60 +end +for i ulong 40 +put TGIX i tgwb i +end +tgdir c +tgfile 8317708060499076467 8 +if ne tgreadb 24576 +ret 61 +end +for j ulong 3072 +put TGSS j tgwb j +end +if ne get TGIX 0 3544386032354079058 +ret 62 +end +if ne get TGIX 1 1 +ret 62 +end +if ne get TGIX 2 sid +ret 62 +end +if ne get TGIX 3 24 +ret 62 +end +if ne get TGIX 4 192 +ret 63 +end +if ne get TGIX 5 17952 +ret 63 +end +if ne get TGIX 6 9024 +ret 63 +end +for z ulong 5 +if ne get TGIX add 11 z 0 +ret 62 +end +end +ret 0 +end + +fn tgclear to void +for u ulong 64 +put TGCN u 0 +end +for v ulong 384 +put TGNV v 0 +end +put TGCU 8 0 +put TGCU 9 0 +put TGCU 10 0 +end + +fn tgsplit c ulong sid ulong to ulong +e = tgload c sid +if ne e 0 +ret e +end +tgclear +rfhini 0 +tot = ulong 0 +for g ulong 24 +tggroup c g +tot = add tot get TGIX add 16 g +end +if ne get TGCU 8 0 +ret get TGCU 8 +end +rfhfin 0 +for d ulong 4 +if ne get RFHD d get TGIX add 7 d +ret 64 +end +end +if ne tot 17952 +ret 65 +end +if ne get TGCU 9 17952 +ret 65 +end +if ne get TGCU 10 9024 +ret 65 +end +e = tgcounts +if ne e 0 +ret e +end +ret tgmixed +end + +note novelty counts of cell v: classes 1..5 must be a b c d e +fn tgnvok v ulong a ulong b ulong c ulong d ulong e ulong to bool +x = mul v 6 +if ne get TGNV add x 1 a +ret false +end +if ne get TGNV add x 2 b +ret false +end +if ne get TGNV add x 3 c +ret false +end +if ne get TGNV add x 4 d +ret false +end +ret eq get TGNV add x 5 e +end + +note the seeded dealing: no group holds 8 sessions of one family and type (the composition order, +note dealt without a permutation, would) +fn tgmixed to ulong +for g ulong 24 +b = mul g 128 +k0 = add mul get TGSS add b 2 16 get TGSS add b 3 +same = true +for i ulong 8 +r = add b mul i 16 +k = add mul get TGSS add r 2 16 get TGSS add r 3 +if ne k k0 +same = false +end +end +if same +ret 69 +end +end +ret 0 +end + +note 4 sessions per family x type x n class, novelty counts of contract 7.2 and K8 +fn tgcounts to ulong +for f ulong 2 +for t ulong 8 +for nc ulong 3 +c = add mul f 24 add mul t 3 nc +if ne get TGCN c 4 +ret 66 +end +ok = false +if eq f 0 +if eq t 7 +ok = tgnvok c 0 0 4 0 0 +else +ok = tgnvok c 1 2 1 0 0 +end +else +if eq t 7 +ok = tgnvok c 0 0 0 0 4 +else +ok = tgnvok c 0 0 0 2 2 +end +end +if not ok +ret 67 +end +end +end +end +ret 0 +end + +fn main to int +if lt argcnt 3 +ret 1 +end +l = argread 1 TGS 0 3000 +m = argread 2 TGA 0 3000 +if or le l 0 le m 0 +ret 1 +end +put TGT 0 ulong l +put TGT 1 ulong m +r = tggen 336236466772 5 84 0 +r = or r tggen 88297166688852 6 80 0 +r = or r tggen 5653828 3 68 0 +r = or r tggen 327513164102 5 70 1 +if ne r 0 +ret 2 +end +tgtrain 84 1 +tgtrain 80 5 +if or ne get TGT 8 240 ne get TGT 9 240 +ret 3 +end +e = tgsplit 68 3 +if ne e 0 +ret int e +end +e = tgsplit 70 4 +ret int e +end diff --git a/tests/reuse-eval/gen-train.om b/tests/reuse-eval/gen-train.om new file mode 100644 index 0000000..23f0f4d --- /dev/null +++ b/tests/reuse-eval/gen-train.om @@ -0,0 +1,759 @@ +note units: sha256 ref +note needs: gen +note gen-train: TRAIN, TRAINP and CALIB are what contract 7.1 / 7.2 and clarification K8 (f, g) say. +note Generates the three splits into argv[1]; replays every request through ref.om and checks the +note index (magic, version, split id, groups, sessions, request and QUERY counts, group counts, +note holdout digest), every .exp record, the sessions file (ordinal, group, type, family, n class, +note n in {64, 512, 4096}, shape id, program digest, counts, first request index). TRAIN and TRAINP: +note BEGIN + 8 x (SET, QUERY); session s is FSM iff s mod 6 = 5; 10 distinct machines used 4 times +note each, 5 of them permutation machines; at most 24 AGG shapes; at least 50 AGG sessions repeat an +note earlier AGG program exactly; TRAINP's AGG shapes are disjoint from TRAIN's. CALIB: BEGIN + +note 16 x (change, QUERY) with one change class per session (0, 1, 2..64, > 64; only SET and BATCH +note of SET), the session type matching it, and every family x n class x change class cell (the +note R1CAL001 cells) holding at least 4 sessions. +note Exit 0 pass; 1 args; 2 a gen run failed; codes 20..76 name the failed check. +text tgnull "/dev/null" +text tgs1 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +global TGB uchar 16777216 +global TGC uchar 16777216 +global TGP uchar 4096 +global TGK uchar 4096 +global TGA uchar 4096 +global TGS uchar 4096 +global TGT ulong 16 +global TGST uchar 4 +global TGIX ulong 128 +global TGSS ulong 3840 +global TGPR ulong 15360 +global TGSH ulong 240 +global TGCU ulong 32 +global TGOP ulong 256 +global TGQ ulong 4097 +global TGCN ulong 64 + +note TGT: 0 scratch length, 1 gen path length, 2 path length, 3 packet position, 4 record count, +note 5 directory path length +note TGCU: 0 open session (1), 1 session requests, 2 session QUERYs, 3 cold pending, 5 family, +note 7 ordinal, 8 first failure, 9 requests, 10 QUERYs, 11 slot in group, 12 group, +note 14 changes since the previous QUERY, 15 session change class, 16 split id + +fn tgpput v ulong n ulong to void +l = get TGT 2 +x = v +for i ulong n +put TGP add l i uchar and x 255 +x = shr x 8 +end +put TGT 2 add l n +end + +fn tgdir c ulong to void +l = get TGT 0 +for i ulong l +put TGP i get TGS i +end +put TGT 2 l +tgpput add 47 mul c 256 2 +put TGT 5 get TGT 2 +end + +fn tgfile v ulong n ulong to void +put TGT 2 get TGT 5 +tgpput 47 1 +tgpput v n +end + +fn tggfile g ulong ext ulong to void +put TGT 2 get TGT 5 +tgpput 26415 2 +tgpput add 48 div g 10 1 +tgpput add 48 rem g 10 1 +if eq ext 0 +tgpput 1902473774 4 +else +tgpput 1886938414 4 +end +end + +fn tgkhdr n ulong to ulong +p = get TGT 3 +put TGK p uchar and n 255 +put TGK add p 1 uchar shr n 8 +put TGT 3 add p add n 2 +put TGT 4 add get TGT 4 1 +ret add p 2 +end + +fn tgkgen to void +n = get TGT 1 +p = tgkhdr n +for i ulong n +put TGK add p i get TGA i +end +end + +fn tgkval v ulong n ulong to void +p = tgkhdr n +x = v +for i ulong n +put TGK add p i uchar and x 255 +x = shr x 8 +end +end + +fn tgkpath to void +n = get TGT 2 +p = tgkhdr n +for i ulong n +put TGK add p i get TGP i +end +end + +fn tgkseed to void +p = tgkhdr 64 +for i ulong 64 +put TGK add p i get tgs1 i +end +end + +fn tgexec to ulong +put TGK 0 uchar get TGT 4 +put TGK 1 0 +pid = fork +if lt pid 0 +ret 256 +end +if eq pid 0 +fd = fopen tgnull 0 len tgnull 1 0 +if ge fd 0 +d = dupfd int fd 1 0 +end +r = execprog TGK 0 get TGT 3 +exit 97 +end +w = waitpid int pid TGST 0 4 0 +if or ne w pid ne get TGST 0 0 +ret 256 +end +ret ulong get TGST 1 +end + +fn tggen v ulong n ulong c ulong w ulong to ulong +put TGT 3 2 +put TGT 4 0 +tgkgen +tgkval v n +tgdir c +tgkpath +if ne w 0 +tgkseed +end +ret tgexec +end + +fn tgreadb to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGB 0 len TGB +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +fn tgreadc to ulong +fd = fopen TGP 0 get TGT 2 0 0 +if lt fd 0 +ret 0 +end +n = read int fd TGC 0 len TGC +x = fclose int fd +if lt n 0 +ret 0 +end +ret ulong n +end + +fn tgwb i ulong to ulong +v = ulong 0 +b = mul i 8 +for j ulong 8 +v = or v shl ulong get TGB add b j mul j 8 +end +ret v +end + +fn tgwc i ulong to ulong +v = ulong 0 +b = mul i 8 +for j ulong 8 +v = or v shl ulong get TGC add b j mul j 8 +end +ret v +end + +fn tgerr code ulong to void +if eq get TGCU 8 0 +put TGCU 8 code +end +end + + +fn tgperm to bool +s = get RFP 2 +a = get RFP 3 +for x ulong a +seen = ulong 0 +for st ulong s +t = rfdelta st x +b = shl ulong 1 t +if ne and seen b 0 +ret false +end +seen = or seen b +end +end +ret true +end + + +fn tgabs nb ulong to void +off = ulong 0 +while lt off nb bound 999 +k = sub nb off +if gt k 65536 +k = 65536 +end +for i ulong k +put RFHB i get TGB add off i +end +rfhabs 0 k +off = add off k +end +end + + +note the expected record k against the reference's response; per-QUERY change class +fn tgexpchk k ulong op ulong st ulong to void +b = mul k 8 +if ne st 0 +tgerr 50 +end +if ne tgwc b 0 +tgerr 51 +end +if ne tgwc add b 1 get RFRS 1 +tgerr 51 +end +if ne tgwc add b 2 get RFRS 2 +tgerr 52 +end +if ne tgwc add b 3 get RFRS 3 +tgerr 52 +end +if ne tgwc add b 4 op +tgerr 53 +end +if ne tgwc add b 5 get TGCU 7 +tgerr 53 +end +cold = ulong 0 +if eq op 2 +if eq get TGCU 3 1 +cold = 1 +end +put TGCU 3 0 +put TGCU 2 add get TGCU 2 1 +put TGCU 10 add get TGCU 10 1 +tgqclass +end +if or eq op 1 eq op 8 +put TGCU 3 1 +end +if ne tgwc add b 6 cold +tgerr 54 +end +if ne tgwc add b 7 0 +tgerr 54 +end +end + +note change class of the changes since the previous QUERY: 0, 1, 2..64, > 64; all QUERYs of a +note session must have the same class (TGCU 15, 9 = not yet seen) +fn tgqclass to void +n = get TGCU 14 +c = ulong 3 +if le n 64 +c = 2 +end +if le n 1 +c = n +end +if eq get TGCU 15 9 +put TGCU 15 c +end +if ne get TGCU 15 c +tgerr 58 +end +put TGCU 14 0 +end + +fn tgrec i ulong to ulong +ret get TGSS add mul get TGCU 7 16 i +end + +fn tgendsess to void +if eq get TGCU 0 0 +ret +end +put TGCU 0 0 +nr = get TGCU 1 +nq = get TGCU 2 +if ne tgrec 12 nr +tgerr 20 +end +if ne tgrec 13 nq +tgerr 20 +end +if ne get TGOP sub nr 1 2 +tgerr 21 +end +cl = get TGCU 15 +sid = get TGCU 16 +if eq sid 2 +if ne nq 16 +tgerr 21 +end +want = ulong 33 +if eq cl 0 +want = 17 +end +if ne nr want +tgerr 21 +end +typ = ulong 3 +if lt cl 2 +typ = add cl 1 +end +if ne tgrec 3 typ +tgerr 27 +end +fm = sub get TGCU 5 1 +nc = tgrec 5 +c = add mul fm 12 add mul nc 4 cl +put TGCN c add get TGCN c 1 +else +if or ne nq 8 ne nr 17 +tgerr 21 +end +if ne cl 1 +tgerr 21 +end +if ne tgrec 3 2 +tgerr 27 +end +end +end + +fn tgnewsess k ulong to void +tgendsess +ord = add mul get TGCU 12 8 get TGCU 11 +put TGCU 11 add get TGCU 11 1 +put TGCU 7 ord +put TGCU 0 1 +put TGCU 1 0 +put TGCU 2 0 +put TGCU 14 0 +put TGCU 15 9 +if ge ord 240 +tgerr 22 +put TGCU 7 0 +ret +end +if ne tgrec 0 ord +tgerr 22 +end +if ne tgrec 1 get TGCU 12 +tgerr 22 +end +if ne tgrec 14 k +tgerr 22 +end +if ne tgrec 15 0 +tgerr 22 +end +if ne tgrec 4 0 +tgerr 22 +end +end + +fn tgbegpost to void +n = get RFN 0 +if ne tgrec 2 get RFP 1 +tgerr 23 +end +if ne tgrec 6 n +tgerr 23 +end +nc = tgrec 5 +want = ulong 64 +if eq nc 1 +want = 512 +end +if eq nc 2 +want = 4096 +end +if or gt nc 2 ne n want +tgerr 24 +end +if ne tgrec 7 rfshape +tgerr 25 +end +rfpdig +for j ulong 4 +if ne tgrec add 8 j get RFPD j +tgerr 26 +end +end +put TGCU 5 get RFP 1 +o = get TGCU 7 +for i ulong 64 +put TGPR add mul o 64 i get RFP i +end +end + +fn tgchg op ulong to void +sid = get TGCU 16 +if eq op 3 +put TGCU 14 add get TGCU 14 1 +ret +end +if and eq op 7 eq sid 2 +m = get RFRQ 2 +for i ulong m +if ne get RFRQ add 3 mul i 3 3 +tgerr 42 +end +end +put TGCU 14 add get TGCU 14 m +ret +end +tgerr 42 +end + +fn tgstep w ulong k ulong to ulong +op = tgwb w +p = tgwb add w 1 +if gt p 7234 +tgerr 55 +ret 18446744073709551615 +end +for j ulong add p 2 +put RFRQ j tgwb add w j +end +if eq op 1 +tgnewsess k +else +if ne op 2 +tgchg op +end +end +st = ulong rfreq +if eq op 1 +tgbegpost +end +tgexpchk k op st +r = get TGCU 1 +if lt r 256 +put TGOP r op +end +put TGCU 1 add r 1 +put TGCU 9 add get TGCU 9 1 +ret add w add p 2 +end + +fn tggroup c ulong g ulong to void +tgdir c +tggfile g 0 +nb = tgreadb +tgdir c +tggfile g 1 +ne8 = tgreadc +tgabs nb +nw = div nb 8 +put TGCU 12 g +put TGCU 11 0 +rfreset +w = ulong 0 +k = ulong 0 +while lt w nw bound 99999 +w = tgstep w k +k = add k 1 +end +tgendsess +if ne w nw +tgerr 56 +end +if ne mul k 64 ne8 +tgerr 56 +end +if ne get TGCU 11 8 +tgerr 57 +end +gc = get TGIX add 16 g +if ne k gc +tgerr 57 +end +end + +note index and sessions of directory c into TGIX / TGSS for split sid with G groups +fn tgload c ulong sid ulong g ulong to ulong +s = mul g 8 +tgdir c +tgfile 517097156201 5 +if ne tgreadb mul add 16 g 8 +ret 60 +end +for i ulong add 16 g +put TGIX i tgwb i +end +tgdir c +tgfile 8317708060499076467 8 +if ne tgreadb mul s 128 +ret 61 +end +for j ulong mul s 16 +put TGSS j tgwb j +end +if ne get TGIX 0 3544386032354079058 +ret 62 +end +if ne get TGIX 1 1 +ret 62 +end +if ne get TGIX 2 sid +ret 62 +end +if ne get TGIX 3 g +ret 62 +end +if ne get TGIX 4 s +ret 63 +end +for z ulong 5 +if ne get TGIX add 11 z 0 +ret 62 +end +end +ret 0 +end + +fn tgsplit c ulong sid ulong g ulong nr ulong nq ulong to ulong +e = tgload c sid g +if ne e 0 +ret e +end +for u ulong 64 +put TGCN u 0 +end +put TGCU 8 0 +put TGCU 9 0 +put TGCU 10 0 +put TGCU 16 sid +rfhini 0 +tot = ulong 0 +for i ulong g +tggroup c i +tot = add tot get TGIX add 16 i +end +if ne get TGCU 8 0 +ret get TGCU 8 +end +rfhfin 0 +for d ulong 4 +if ne get RFHD d get TGIX add 7 d +ret 64 +end +end +if or ne tot nr ne get TGIX 5 nr +ret 65 +end +if or ne get TGCU 9 nr ne get TGIX 6 nq +ret 65 +end +if ne get TGCU 10 nq +ret 65 +end +ret 0 +end + +note ---- split-level checks on the BEGIN programs TGPR ---- + +fn tgpreq a ulong b ulong to bool +for j ulong 64 +if ne get TGPR add mul a 64 j get TGPR add mul b 64 j +ret false +end +end +ret true +end + +fn tgrfp r ulong to void +for j ulong 64 +put RFP j get TGPR add mul r 64 j +end +end + +note rows equal to row s (s included); TGCU 20 = 1 when an earlier row is equal +fn tgdup s ulong to ulong +put TGCU 20 0 +cnt = ulong 0 +for t ulong 240 +if tgpreq s t +if lt t s +put TGCU 20 1 +end +cnt = add cnt 1 +end +end +ret cnt +end + +note TRAIN / TRAINP: families by ordinal, 10 machines x 4 (5 permutation), at most 24 AGG shapes, +note at least 50 AGG sessions repeating an earlier AGG program; shapes kept in TGSH (which 1 TRAIN) +note or checked disjoint from them (which 5) +fn tglist which ulong to ulong +mach = ulong 0 +perms = ulong 0 +reuse = ulong 0 +for s ulong 240 +f = get TGPR add mul s 64 1 +want = ulong 1 +if eq rem s 6 5 +want = 2 +end +if ne f want +ret 70 +end +cnt = tgdup s +first = eq get TGCU 20 0 +tgrfp s +if eq f 2 +if ne cnt 4 +ret 71 +end +if first +mach = add mach 1 +if tgperm +perms = add perms 1 +end +end +else +if not first +reuse = add reuse 1 +end +sh = rfshape +if eq which 1 +put TGSH s sh +else +if tghas sh +ret 74 +end +end +end +end +if or ne mach 10 ne perms 5 +ret 72 +end +if lt reuse 50 +ret 73 +end +if gt tgnshape 24 +ret 75 +end +ret 0 +end + +fn tghas sh ulong to bool +for s ulong 240 +if and ne rem s 6 5 eq get TGSH s sh +ret true +end +end +ret false +end + +note distinct AGG shapes of the current split (TGPR rows) +fn tgnshape to ulong +d = ulong 0 +for s ulong 240 +if ne rem s 6 5 +tgrfp s +sh = rfshape +put TGQ s sh +seen = false +for t ulong s +if and ne rem t 6 5 eq get TGQ t sh +seen = true +end +end +if not seen +d = add d 1 +end +end +end +ret d +end + +note CALIB: every cell family x n class x change class has at least 4 sessions +fn tgcells to ulong +for c ulong 24 +if lt get TGCN c 4 +ret 76 +end +end +ret 0 +end + +fn main to int +if lt argcnt 3 +ret 1 +end +l = argread 1 TGS 0 3000 +m = argread 2 TGA 0 3000 +if or le l 0 le m 0 +ret 1 +end +put TGT 0 ulong l +put TGT 1 ulong m +r = tggen 336236466772 5 84 0 +r = or r tggen 88297166688852 6 80 0 +r = or r tggen 284697575747 5 67 0 +if ne r 0 +ret 2 +end +e = tgsplit 84 1 30 4080 1920 +if ne e 0 +ret int e +end +e = tglist 1 +if ne e 0 +ret int e +end +e = tgsplit 80 5 30 4080 1920 +if ne e 0 +ret int e +end +e = tglist 5 +if ne e 0 +ret int e +end +e = tgsplit 67 2 12 2784 1536 +if ne e 0 +ret int e +end +ret int tgcells +end diff --git a/tests/reuse-eval/judge-arm.om b/tests/reuse-eval/judge-arm.om new file mode 100644 index 0000000..aa6ea68 --- /dev/null +++ b/tests/reuse-eval/judge-arm.om @@ -0,0 +1,156 @@ +note units: sha256 ref judge +note fixture: arm +note SPDX-License-Identifier: Apache-2.0 +note This fake is deliberately the evaluator reference, not candidate code. Protocol tests compile it. +global FJSEQ ulong 1 +fn fjread n ulong to bool +k = ulong 0 +while lt k n bound 999999 +r = read 0 JDIO k sub n k +if le r 0 +ret false +end +k = add k ulong r +end +ret true +end + +fn fjexp to void +for i ulong 1024 +put JDF i 0 +end +put FJSEQ 0 add get FJSEQ 0 1 +jdpfw 0 3544386028377026898 +jdpfw 8 1 +jdpfw 16 get FJSEQ 0 +jdpfw 24 get RFP 1 +jdpfw 32 get RFN 0 +jdpfw 40 get RFR 0 +jdpfw 48 get RFR 1 +jdpfw 56 get FJSEQ 0 +jdpfw 72 jdsval 13 +jdpfw 96 0 +jdpfw 104 1 +rfpdig +for i ulong 4 +jdpfw mul add 52 i 8 get RFPD i +end +for i ulong 64 +jdpfw mul add 64 i 8 get RFP i +end +z = jdwrf 12 1024 1089 +end + +fn fjresp mode ulong to void +st = get RFRS 0 +q = get RFRS 1 +jdpiw 0 st +jdpiw 8 q +if eq q 3 +r0 = get RFRS 2 +r1 = get RFRS 3 +if eq mode 1 +r0 = add r0 1 +end +if eq mode 2 +r0 = 0 +r1 = 0 +end +jdpiw 16 r0 +jdpiw 24 r1 +jdpiw 32 1 +if eq mode 2 +jdpiw 32 0 +end +end +if eq get RFRQ 0 9 +jdpiw 8 2 +jdpiw 16 17 +jdpiw 24 23 +q = 2 +end +n = write 1 JDIO 0 mul add q 2 8 +end + +fn main to int +if ne argcnt 7 +ret 2 +end +b = jdsarg 8 1 +b = jdsarg 12 5 +b = jdsarg 13 6 +m = jdspack 8 +rfreset +while true bound 999999 +if not fjread 16 +ret 3 +end +op = jdgiw 0 +p = jdgiw 8 +put RFRQ 0 op +put RFRQ 1 p +if gt p 7234 +ret 4 +end +if not fjread mul p 8 +ret 3 +end +for i ulong p +put RFRQ add i 2 jdgiw mul i 8 +end +if eq m 465674794099 +r = sleepns 10100000000 +end +if eq m 500136110195 +jdpiw 0 0 +r = write 1 JDIO 0 8 +ret 0 +end +if eq m 1902403938 +jdpiw 0 0 +jdpiw 8 33 +r = write 1 JDIO 0 16 +ret 0 +end +st = rfreq +mode = ulong 0 +if eq m 444234429047 +mode = 1 +end +if eq m 1869112165 +mode = 2 +end +if and eq m 7364980 eq op 2 +fjexp +end +if eq op 10 +ret fjend m +end +fjresp mode +end +ret 0 +end + +note END faults: endbad answers status 0 q 1; endst status 3 q 0; endeof exits without an answer; +note endexit answers correctly and exits 7. Every other mode answers 0 0 and exits 0. +fn fjend m ulong to int +if eq m 112628628483685 +ret 0 +end +jdpiw 0 0 +jdpiw 8 0 +jdpiw 16 0 +nb = ulong 16 +if eq m 110369425354341 +jdpiw 8 1 +nb = 24 +end +if eq m 500152168037 +jdpiw 0 3 +end +r = write 1 JDIO 0 nb +if eq m 32767063116508773 +ret 7 +end +ret 0 +end diff --git a/tests/reuse-eval/judge-build.om b/tests/reuse-eval/judge-build.om new file mode 100644 index 0000000..9bcfe88 --- /dev/null +++ b/tests/reuse-eval/judge-build.om @@ -0,0 +1,76 @@ +note units: sha256 ref judge +note needs: drive +note SPDX-License-Identifier: Apache-2.0 +text JBOMC "/no/compiler/needed/by/fake" +text JBMAN "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" +text JBFAIL "fail10" +fn main to int +if ne argcnt 3 +ret 2 +end +b = jdsarg 19 1 +b = jdsarg 18 2 +jdscp 30 19 +jdscp 9 19 +jdsc 9 47 +jdsc 9 108 +jdsclr 20 +for i ulong len JBOMC +jdsc 20 get JBOMC i +end +jdsdsh 11 +jdsdsh 21 +jdx0 +rc = jdbuild 1 0 +if ne rc 0 +ret 1 +end +jdsclr 1 +for i ulong len JBMAN +jdsc 1 get JBMAN i +end +if not jdseq 10 1 +ret 3 +end +jdspath 0 30 JWACQ 7 +n = jdldw 0 JDLOGW 16 +if ne n 8 +ret 4 +end +if ne get JDM JDLOGW 1 +ret 5 +end +if ne get JDM add JDLOGW 1 0 +ret 6 +end +if lt get JDM add JDLOGW 2 2000000 +ret 7 +end +if ne get JDM add JDLOGW 5 0 +ret 8 +end +if ne get JDM add JDLOGW 6 37 +ret 9 +end +jdsclr 0 +for i ulong len JBFAIL +jdsc 0 get JBFAIL i +end +jdxadd 0 +rc = jdbuild 1 1 +if ne rc 10 +ret 10 +end +jdspath 0 30 JWACQ 7 +n = jdldw 0 JDLOGW 16 +if ne n 16 +ret 11 +end +if ne get JDM add JDLOGW 13 10 +ret 12 +end +if ne get JDSL 10 0 +ret 13 +end +ret 0 +end diff --git a/tests/reuse-eval/judge-calib.om b/tests/reuse-eval/judge-calib.om new file mode 100644 index 0000000..3649a93 --- /dev/null +++ b/tests/reuse-eval/judge-calib.om @@ -0,0 +1,87 @@ +note units: sha256 ref judge +note SPDX-License-Identifier: Apache-2.0 +fn main to int +n = ulong 0 +n = jdpair 0 30 n +n = jdpair 0 10 n +n = jdpair 0 20 n +n = jdpair 12 8 n +n = jdpair 12 4 n +n = jdpair 24 6 n +n = jdpair 24 2 n +n = jdpair 72 19 n +n = jdpair 200 120 n +n = jdpair 200 100 n +n = jdpair 100 190 n +n = jdpair 100 150 n +n = jdpair 205 1000 n +n = jdpair 105 1200 n +jdcalout n 12345 +if ne get JDM JMEX 3544386010811150674 +ret 1 +end +if ne get JDM add JMEX 2 12345 +ret 2 +end +if ne get JDM add JMEX 8 20 +ret 3 +end +if ne get JDM add JMEX 9 30 +ret 4 +end +if ne get JDM add JMEX 32 4 +ret 5 +end +if ne get JDM add JMEX 33 8 +ret 6 +end +if ne get JDM add JMEX 56 2 +ret 7 +end +if ne get JDM add JMEX 152 19 +ret 8 +end +if ne get JDM add JMEX 80 50 +ret 9 +end +if ne get JDM add JMEX 81 90 +ret 10 +end +if ne get JDM add JMEX 192 200 +ret 11 +end +if ne get JDM add JMEX 193 200 +ret 12 +end +if ne get JDM add JMEX 190 0 +ret 13 +end +if ne jdfloor1 10 20 1 +ret 14 +end +if ne jdccls 0 0 +ret 15 +end +if ne jdccls 1 1 +ret 16 +end +if ne jdccls 64 2 +ret 17 +end +if ne jdccls 65 3 +ret 18 +end +note Harness mutant: change one expected value and require correctness to flip to wrong. +put JDM JMEX 0 +put JDM add JMEX 2 17 +put JDM add JMEX 3 2 +put JDC 10 1 +if ne jdcorr 2 0 0 17 2 JMEX 1 +ret 19 +end +put JDM add JMEX 2 18 +if ne jdcorr 2 0 0 17 2 JMEX 0 +ret 20 +end +ret 0 +end diff --git a/tests/reuse-eval/judge-cli.om b/tests/reuse-eval/judge-cli.om new file mode 100644 index 0000000..eaa6b33 --- /dev/null +++ b/tests/reuse-eval/judge-cli.om @@ -0,0 +1,222 @@ +note units: sha256 ref judge +note needs: eval arm +note SPDX-License-Identifier: Apache-2.0 +text JCW "run0125-1004tap1calib134" +fn jcw r ulong o ulong n ulong to void +jdsclr r +for i ulong n +jdsc r get JCW add o i +end +end +fn jcexec to ulong +jdpkfin +pid = fork +if lt pid 0 +ret 1023 +end +if eq pid 0 +e = execprog JDPK 0 get JDPKN 0 +exit 127 +end +r = waitpid int pid JDWS 0 4 0 +ret jdwstat +end +fn jcfixture to bool +r = jdmkdir 3 448 +jdctsyn 16 1 +nr = get JDK 0 +jdgpath 0 3 0 JWREQ +x = jdstw 0 JMRQ get JDK 1 705 +if ne x 0 +ret false +end +jdgpath 0 3 0 JWEXP +x = jdstw 0 JMEX mul nr 8 705 +if ne x 0 +ret false +end +for i ulong 17 +put JDM add JMIX i 0 +end +put JDM JMIX 3544386032354079058 +put JDM add JMIX 1 1 +put JDM add JMIX 2 2 +put JDM add JMIX 3 1 +put JDM add JMIX 4 1 +put JDM add JMIX 5 nr +put JDM add JMIX 6 10 +put JDM add JMIX 16 nr +jdspath 0 3 JWINDEX 5 +x = jdstw 0 JMIX 17 705 +for i ulong 16 +put JDM add JMSE i 0 +end +put JDM add JMSE 2 1 +put JDM add JMSE 3 2 +put JDM add JMSE 6 4 +put JDM add JMSE 12 nr +put JDM add JMSE 13 10 +jdspath 0 3 JWSESS 8 +x = jdstw 0 JMSE 16 705 +ret eq x 0 +end +fn jcrun arms ulong to ulong +jdpk0 +jdpkr 21 +jcw 0 0 3 +jdpkr 0 +jdpkr 3 +jdpkr 4 +jdsclr 0 +jdsc 0 50 +jdpkr 0 +jcw 0 8 4 +jdpkr 0 +if eq arms 0 +jcw 0 3 4 +else +jcw 0 21 3 +end +jdpkr 0 +jdpkr 5 +jdsdsh 0 +jdpkr 0 +if eq arms 0 +jdpkr 0 +jdpkr 0 +else +jdpkr 14 +jdpkr 15 +end +jdsdsh 0 +jdpkr 0 +jdpkr 0 +jdpkr 0 +ret jcexec +end +fn jctap to ulong +jdpk0 +jdpkr 21 +jcw 0 12 3 +jdpkr 0 +jdpkr 3 +jdpkr 5 +jdpkr 12 +jcw 0 15 1 +jdpkr 0 +jdsdsh 0 +jdpkr 0 +ret jcexec +end +fn main to int +if ne argcnt 4 +ret 2 +end +b = jdsarg 22 1 +b = jdsarg 21 2 +b = jdsarg 5 3 +jdscp 3 22 +jdsc 3 47 +jdsc 3 115 +if not jcfixture +ret 1 +end +jdscp 4 22 +jdsc 4 47 +jdsc 4 114 +if ne jcrun 0 0 +ret 3 +end +jdspath 0 4 JWPLOG 8 +n = jdldw 0 JDLOGW 128 +if ne n 128 +ret 4 +end +for i ulong 8 +if ne get JDM add add JDLOGW mul i 16 10 0 +ret 5 +end +end +x = jdcload 1 0 0 +if ne x mul get JDK 0 16 +ret 6 +end +if ne get JDM add JDLOGW 31 1 +ret 7 +end +x = jdcload 0 0 0 +if ne get JDM add JDLOGW 31 2 +ret 8 +end +jdscp 12 22 +jdsc 12 47 +jdsc 12 116 +if ne jctap 0 +ret 9 +end +if ne jdfsize 12 10240 +ret 10 +end +if ne jctap 3 +ret 11 +end +note Calibration run uses fresh library copies even though the fake arm ignores the library. +jdscp 14 22 +jdsc 14 47 +jdsc 14 108 +r = jdmkdir 14 448 +jdspath 0 14 JWGEN 4 +jdsnum 0 1 1 +jdsw 0 JWELF 4 +put JDF 0 99 +z = jdwrf 0 1 705 +jdsclr 15 +for i ulong 64 +jdsc 15 97 +end +jdscp 4 22 +jdsc 4 47 +jdsc 4 99 +if ne jcrun 1 0 +ret 12 +end +jdpk0 +jdpkr 21 +jcw 0 16 5 +jdpkr 0 +jdpkr 3 +jdpkr 4 +jdsclr 0 +jdsc 0 50 +jdpkr 0 +jdscp 1 22 +jdsc 1 47 +jdsc 1 102 +jdpkr 1 +if ne jcexec 0 +ret 13 +end +if ne jdfsize 1 1600 +ret 14 +end +n = jdldw 1 JDLOGW 200 +if ne n 200 +ret 15 +end +if ne get JDM JDLOGW 3544386010811150674 +ret 16 +end +if ne get JDM add JDLOGW 2 10000 +ret 17 +end +if eq get JDM add JDLOGW 8 0 +ret 18 +end +if eq get JDM add JDLOGW 32 0 +ret 19 +end +if eq get JDM add JDLOGW 56 0 +ret 20 +end +ret 0 +end diff --git a/tests/reuse-eval/judge-controls.om b/tests/reuse-eval/judge-controls.om new file mode 100644 index 0000000..31562c0 --- /dev/null +++ b/tests/reuse-eval/judge-controls.om @@ -0,0 +1,141 @@ +note units: sha256 ref judge +note needs: eval arm drive +note SPDX-License-Identifier: Apache-2.0 +note The fake has no guard/admission/identity checks. Controls MUST report its failures, not PASS it. +text JOW "controls" +fn josplit to bool +r = jdmkdir 25 448 +jdctsyn 16 1 +nr = get JDK 0 +jdgpath 0 25 0 JWREQ +x = jdstw 0 JMRQ get JDK 1 705 +jdgpath 0 25 0 JWEXP +x = jdstw 0 JMEX mul nr 8 705 +for i ulong 17 +put JDM add JMIX i 0 +end +put JDM JMIX 3544386032354079058 +put JDM add JMIX 1 1 +put JDM add JMIX 2 3 +put JDM add JMIX 3 1 +put JDM add JMIX 4 1 +put JDM add JMIX 5 nr +put JDM add JMIX 6 10 +put JDM add JMIX 16 nr +jdspath 0 25 JWINDEX 5 +x = jdstw 0 JMIX 17 705 +for i ulong 16 +put JDM add JMSE i 0 +end +put JDM add JMSE 2 1 +put JDM add JMSE 3 2 +put JDM add JMSE 6 4 +put JDM add JMSE 12 nr +put JDM add JMSE 13 10 +jdspath 0 25 JWSESS 8 +x = jdstw 0 JMSE 16 705 +ret eq x 0 +end +fn main to int +if ne argcnt 5 +ret 2 +end +b = jdsarg 19 1 +b = jdsarg 21 2 +b = jdsarg 5 3 +b = jdsarg 18 4 +jdscp 25 19 +jdsc 25 47 +jdsc 25 100 +if not josplit +ret 1 +end +jdscp 6 19 +jdsc 6 47 +jdsc 6 97 +x = jdwrf 6 0 705 +jdscp 22 19 +jdsc 22 47 +jdsc 22 99 +jdpk0 +jdpkr 21 +jdsclr 0 +for i ulong len JOW +jdsc 0 get JOW i +end +jdpkr 0 +jdpkr 25 +jdpkr 5 +jdpkr 18 +jdpkr 19 +jdpkr 5 +jdpkr 6 +jdpkr 5 +jdpkr 5 +jdpkr 22 +jdsdsh 0 +jdpkr 0 +jdpkfin +pid = fork +if lt pid 0 +ret 3 +end +if eq pid 0 +e = execprog JDPK 0 get JDPKN 0 +exit 127 +end +w = waitpid int pid JDWS 0 4 0 +if ne jdwstat 4 +ret 4 +end +jdspath 0 22 JWCLOG 12 +n = jdldw 0 JDLOGW 4096 +if or le n 0 ne rem n 8 0 +ret 5 +end +for i ulong 15 +put JDK i 0 +end +nr = div ulong n 8 +for i ulong nr +e = jocheck add JDLOGW mul i 8 +if ne e 0 +ret e +end +end +for i ulong 14 +if eq get JDK add i 1 0 +ret 12 +end +end +ret 0 +end +fn jocheck b0 ulong to int +id = get JDM b0 +if or lt id 1 gt id 14 +ret 6 +end +put JDK id add get JDK id 1 +outcome = get JDM add b0 2 +if gt outcome 3 +ret 7 +end +for k ulong 4 +if ne get JDM add add b0 4 k 0 +ret 8 +end +end +sub0 = eq get JDM add b0 1 0 +if and eq id 1 sub0 +if ne outcome 0 +ret 9 +end +end +if and eq id 7 ne outcome 1 +ret 10 +end +if and eq id 14 ne outcome 2 +ret 11 +end +ret 0 +end diff --git a/tests/reuse-eval/judge-drive.om b/tests/reuse-eval/judge-drive.om new file mode 100644 index 0000000..b26043e --- /dev/null +++ b/tests/reuse-eval/judge-drive.om @@ -0,0 +1,29 @@ +note units: sha256 ref judge +note fixture: drive +note SPDX-License-Identifier: Apache-2.0 +note Fake drive for testing acquisition accounting and printed-manifest capture, not candidate code. +text FDMS "manifest_sha256=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\ngeneration=1\ntemplates=0\n" +text FDFAIL "fail10" +fn main to int +if lt argcnt 6 +ret 2 +end +b = jdsarg 9 5 +if eq argcnt 7 +b = jdsarg 0 6 +if eq jdspack 0 52988830376294 +ret 10 +end +end +r = jdmkdir 9 448 +jdspath 0 9 JWGEN 4 +jdsnum 0 1 1 +jdsw 0 JWELF 4 +for i ulong 37 +put JDF i uchar i +end +x = jdwrf 0 37 705 +r = sleepns 2000000 +n = write 1 FDMS 0 len FDMS +ret 0 +end diff --git a/tests/reuse-eval/judge-end.om b/tests/reuse-eval/judge-end.om new file mode 100644 index 0000000..794ccd5 --- /dev/null +++ b/tests/reuse-eval/judge-end.om @@ -0,0 +1,103 @@ +note units: sha256 ref judge +note needs: arm +note SPDX-License-Identifier: Apache-2.0 +note K17 END validation and the arm-order permutation. The expected permutations for splitmix64 seed 0 +note were computed outside the judge from the published splitmix64 constants (reviewer's vector for the +note first draw; the second continues the same state). +text JEMODES "fullendbadendstendeofendexit" +text JEP1 "25034617" +text JEP2 "37056214" +fn jeset off ulong n ulong rep ulong to void +jdsclr 8 +for i ulong n +jdsc 8 get JEMODES add off i +end +put JDC 10 1 +put JDC 11 0 +put JDC 12 rep +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 1 +jdcnt0 +jdctsyn 16 1 +end +note run one fake arm; returns 0 when proc.log record rep has exit word want and a nonzero END time +fn jerun off ulong n ulong rep ulong want ulong to int +jeset off n rep +e = jdpgroup 0 get JDK 0 +if ne e 0 +ret 1 +end +if ne get JDA 1 0 +ret 2 +end +jdspath 0 4 JWPLOG 8 +x = jdldw 0 JDLOGW 4096 +if ne ulong x mul add rep 1 16 +ret 3 +end +b = add JDLOGW mul rep 16 +if ne get JDM add b 10 want +ret 4 +end +if eq get JDM add b 15 0 +ret 5 +end +if ne get JDM add b 11 get JDK 0 +ret 6 +end +ret 0 +end +fn jeperm want view uchar 8 to int +jdperm 8 +for i ulong 8 +if ne get JDM add add JMSC 16 i sub ulong get want i 48 +ret 1 +end +end +ret 0 +end +fn main to int +if ne argcnt 3 +ret 2 +end +for i ulong 8 +put JDM add JMSC i i +end +put JDSM 0 0 +if ne jeperm JEP1 0 +ret 60 +end +if ne jeperm JEP2 0 +ret 61 +end +b = jdsarg 4 1 +b = jdsarg 5 2 +jdsdsh 7 +jdsdsh 9 +jdsdsh 10 +jdsdsh 11 +jdsdsh 12 +jdsdsh 13 +e = jerun 0 4 0 0 +if ne e 0 +ret add 10 e +end +e = jerun 4 6 1 1024 +if ne e 0 +ret add 20 e +end +e = jerun 10 5 2 1024 +if ne e 0 +ret add 30 e +end +e = jerun 15 6 3 1541 +if ne e 0 +ret add 40 e +end +e = jerun 21 7 4 7 +if ne e 0 +ret add 50 e +end +ret 0 +end diff --git a/tests/reuse-eval/judge-protocol.om b/tests/reuse-eval/judge-protocol.om new file mode 100644 index 0000000..f3c40e8 --- /dev/null +++ b/tests/reuse-eval/judge-protocol.om @@ -0,0 +1,175 @@ +note units: sha256 ref judge +note needs: arm +note SPDX-License-Identifier: Apache-2.0 +text JPMODES "fullwrongechobadqshortstall" +fn jpset off ulong n ulong rep ulong a ulong to void +jdsclr 8 +for i ulong n +jdsc 8 get JPMODES add off i +end +put JDC 10 a +put JDC 11 0 +put JDC 12 rep +put JDC 16 JDNONE +put JDC 17 JDNONE +put JDC 19 1 +jdcnt0 +jdctsyn 16 1 +end +fn jpviolation off ulong n ulong rep ulong code ulong to int +jpset off n rep 1 +e = jdpgroup 0 get JDK 0 +if ne e 0 +ret 21 +end +if ne get JDA 15 1 +ret 22 +end +if ne get JDC 9 code +ret 23 +end +if ne get JDC 18 add 512 code +ret 24 +end +if ne get JDA 1 get JDK 0 +ret 25 +end +x = jdcload 1 rep 0 +if ne x mul get JDK 0 16 +ret 26 +end +if ne get JDM add JDLOGW 5 JDNONE +ret 27 +end +if ne get JDM add JDLOGW 21 sub JDNONE 1 +ret 28 +end +if ne get JDM add JDLOGW 28 0 +ret 29 +end +ret 0 +end +fn main to int +if ne argcnt 3 +ret 2 +end +b = jdsarg 4 1 +b = jdsarg 5 2 +jdsdsh 7 +jdsdsh 9 +jdsdsh 10 +jdsdsh 11 +jdsdsh 12 +jdsdsh 13 +jpset 0 4 0 1 +e = jdpgroup 0 get JDK 0 +if ne e 0 +ret 1 +end +if ne get JDA 1 0 +ret 3 +end +if ne get JDA 0 10 +ret 4 +end +x = jdcload 1 0 0 +if ne x mul get JDK 0 16 +ret 5 +end +if ne get JDM add JDLOGW 15 2 +ret 6 +end +if ne get JDM add JDLOGW 31 1 +ret 7 +end +if ne get JDM add JDLOGW 24 1 +ret 8 +end +if eq get JDM add JDLOGW 28 0 +ret 9 +end +jdspath 0 4 JWPLOG 8 +y = jdldw 0 JDLOGW 16 +if ne y 16 +ret 10 +end +if ne get JDM add JDLOGW 10 0 +ret 11 +end +if ne get JDM add JDLOGW 11 get JDK 0 +ret 12 +end +if eq get JDM add JDLOGW 8 0 +ret 13 +end +jdscp 0 4 +jdsc 0 47 +textpath = new uchar 16 0 +put textpath 0 115 +put textpath 1 116 +put textpath 2 97 +put textpath 3 116 +put textpath 4 115 +put textpath 5 45 +put textpath 6 49 +put textpath 7 45 +put textpath 8 48 +put textpath 9 45 +put textpath 10 103 +put textpath 11 48 +put textpath 12 48 +put textpath 13 46 +put textpath 14 99 +put textpath 15 116 +for i ulong 16 +jdsc 0 get textpath i +end +jdsc 0 114 +y = jdldw 0 JDLOGW 34 +if ne y 34 +ret 14 +end +if ne get JDM add JDLOGW 1 2 +ret 15 +end +if ne get JDM add JDLOGW 2 17 +ret 16 +end +if ne get JDM add JDLOGW 3 23 +ret 17 +end +for i ulong 30 +if ne get JDM add add JDLOGW 4 i 0 +ret 18 +end +end +jpset 4 5 1 1 +e = jdpgroup 0 get JDK 0 +if ne e 0 +ret 30 +end +if ne get JDA 14 10 +ret 31 +end +jpset 9 4 2 0 +e = jdpgroup 0 get JDK 0 +if ne e 0 +ret 32 +end +if ne get JDA 1 0 +ret 33 +end +e = jpviolation 13 4 3 2 +if ne e 0 +ret e +end +e = jpviolation 17 5 4 1 +if ne e 0 +ret e +end +e = jpviolation 22 5 5 3 +if ne e 0 +ret e +end +ret 0 +end diff --git a/tests/reuse-eval/receipt-fields.om b/tests/reuse-eval/receipt-fields.om new file mode 100644 index 0000000..a14c0ca --- /dev/null +++ b/tests/reuse-eval/receipt-fields.om @@ -0,0 +1,464 @@ +note units: sha256 stats turing receipt +note SPDX-License-Identifier: Apache-2.0 +note receipt-fields: the receipt layout. Inputs: an index with known holdout words, three +note acq-1-R.mansha files, a stats.sum with known words, a contract file. The receipt must equal +note RTEXP byte for byte except the two 64-hex values marked ?: the evaluator binary digest +note (checked against SHA-256 of /proc/self/exe computed here) and the receipt identity digest +note (recomputed here from the documented length-prefixed field list). policy_sha256 and +note stats_summary_sha256 are SHA-256 values computed independently (Python hashlib, development +note only). Then the refusals: MANSHA differing from a rebuild (9), a missing rebuild file (8), +note an uppercase commit (2), a stats.sum with a wrong magic (7), a summary whose holdout digest +note differs from the index (11), a DEV summary (11), a DEV index (10), a summary with another +note request count (11). +note argv[1] = temporary directory (default /tmp/reuse-test-evalstats-rc-<pid>). +note Exit 0 = pass; otherwise the failing check's code. + +text RTK "/tmp/reuse-test-evalstats-rc-\nsplit\nrun\nstats\ncontract.md\nreceipt.txt\nindex\nacq-1-0.mansha\nacq-1-1.mansha\nacq-1-2.mansha\nstats.sum\n/proc/self/exe\n" +text RTCON "REUSE-1 test contract v1.0\n" +text RTC "0123456789abcdef0123456789abcdef01234567" +text RTCU "0123456789ABCDEF0123456789abcdef01234567" +text RTM "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" +text RTM2 "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5b" +text RTH "0102030405060708090a0b0c0d0e0f1011111111111111111918171615141312" +text RTP "0e6940071a1f189c69a3faa6d9ca6dc78f92f8520c4548f2c6a878c89e4e9e98" +text RTS "dd51cbe03f9a9c7e61a4d471f9312ee703b2910541daf12bbd7c9b5790dfe192" +text RTD "spark-rsi.reuse1-receipt.v2-unsigned" +text RTEXP "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=0123456789abcdef0123456789abcdef01234567\nsubject_mansha=5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a\nholdout_set_sha256=0102030405060708090a0b0c0d0e0f1011111111111111111918171615141312\npolicy_sha256=0e6940071a1f189c69a3faa6d9ca6dc78f92f8520c4548f2c6a878c89e4e9e98\nevaluator_binary_sha256=????????????????????????????????????????????????????????????????\nstats_summary_sha256=dd51cbe03f9a9c7e61a4d471f9312ee703b2910541daf12bbd7c9b5790dfe192\nholdouts_total=189504 holdouts_passed=189500\ncounts groups=24 sessions=192 requests=18000 queries=9024 reps=3 arms=8 wrong_refusals=1\ndecision=INVESTIGATE reason_bits=512\nbudget split=FINAL runs_allowed=1 runs_used=1 seed=burned\nindependence=UNISOLATED\nreceipt_identity_sha256=????????????????????????????????????????????????????????????????\n" + +global RTRB uchar 4096 +global RTRL ulong 1 +global RTEV uchar 64 +global RTID uchar 64 + +fn rtoff k ulong to ulong +i = ulong 0 +c = ulong 0 +while lt c k bound 100000 +if eq get RTK i 10 +c = add c 1 +end +i = add i 1 +end +ret i +end + +fn rtkp k ulong to void +i = rtoff k +while ne get RTK i 10 bound 4096 +stpc get RTK i +i = add i 1 +end +end + +fn rtroot to void +put STPL 0 0 +for i ulong get RTRL 0 +stpc get RTRB i +end +end + +fn rtpath k ulong f ulong to void +rtroot +stpc 47 +rtkp k +if gt f 0 +stpc 47 +rtkp f +end +end + +fn rtinit to int +put RTRL 0 0 +if ge argcnt 2 +n = argread 1 RTRB 0 4000 +if gt n 0 +put RTRL 0 ulong n +end +end +if eq get RTRL 0 0 +put STPL 0 0 +rtkp 0 +stpu ulong getpid +for i ulong get STPL 0 +put RTRB i get STPB i +end +put RTRL 0 get STPL 0 +end +rtroot +r = makedir STPB 0 get STPL 0 448 +if and ne r 0 ne r -17 +ret 1 +end +for k ulong 3 +rtpath add k 1 0 +r = makedir STPB 0 get STPL 0 448 +if and ne r 0 ne r -17 +ret 2 +end +end +ret 0 +end + +note the mansha text (m 0 = RTM, 1 = RTM2) and a newline into STOB +fn rtmsh m ulong to void +put STOP 0 0 +for i ulong 64 +if eq m 0 +stoc get RTM i +else +stoc get RTM2 i +end +end +stoc 10 +end + +note the split index: split id sp, 24 groups of 750 requests, 192 sessions, 9024 QUERYs +fn rtindex sp ulong to int +put STOP 0 0 +stow 3544386032354079058 +stow 1 +stow sp +stow 24 +stow 192 +stow 18000 +stow 9024 +stow 72623859790382856 +stow 651345242494996240 +stow 1229782938247303441 +stow 1808220633999610642 +for k ulong 5 +stow 0 +end +for g ulong 24 +stow 750 +end +rtpath 1 6 +if ne stwfile 0 +ret 3 +end +ret 0 +end + +fn rtfiles to int +r = rtindex 4 +if ne r 0 +ret r +end +for k ulong 3 +rtmsh 0 +rtpath 2 add 7 k +if ne stwfile 0 +ret 4 +end +end +r = rtsum 3544386041195737426 4 0 +if ne r 0 +ret r +end +put STOP 0 0 +for i ulong len RTCON +stoc get RTCON i +end +rtpath 4 0 +ret stwfile +end + +note stats.sum with split id sp; hx is added to holdout word 7 (0 = the index's digest) +fn rtsum magic ulong sp ulong hx ulong to int +put STOP 0 0 +stow magic +stow 1 +stow 2 +stow 512 +stow 24 +stow 192 +stow 18000 +stow 9024 +stow 3 +stow sp +stow 0 +stow 10000 +stow 189504 +stow 189500 +stow 4 +stow 1 +stow 0 +stow 0 +stow add 72623859790382856 hx +stow 651345242494996240 +stow 1229782938247303441 +stow 1808220633999610642 +for k ulong 234 +stow 0 +end +rtpath 3 10 +if ne stwfile 0 +ret 5 +end +ret 0 +end + +note slots for rcrun; commit from RTC (u = 0) or RTCU (u = 1) +fn rtslots u ulong to void +rtpath 1 0 +stbfromp 0 +rtpath 2 0 +stbfromp 1 +rtpath 3 0 +stbfromp 2 +rtpath 4 0 +stbfromp 3 +put STPL 0 0 +for i ulong 40 +if eq u 0 +stpc get RTC i +else +stpc get RTCU i +end +end +stbfromp 4 +put STPL 0 0 +for i ulong 64 +stpc get RTM i +end +stbfromp 5 +rtpath 5 0 +stbfromp 6 +end + +note 64 hex of TUD into RTEV (e = 0) or RTID (e = 1) +fn rthex e ulong to void +h = stkoff SKDIG +for j ulong 4 +v = get TUD j +for k ulong 8 +b = and shr v mul k 8 255 +p = add mul j 16 mul k 2 +c1 = get STK add h shr b 4 +c2 = get STK add h and b 15 +if eq e 0 +put RTEV p c1 +put RTEV add p 1 c2 +else +put RTID p c1 +put RTID add p 1 c2 +end +end +end +end + +note appends u64 LE length n then the bytes of text t (0 RTD, 1 RTC, 2 RTM, 3 RTH, 4 RTP, 5 RTEV, 6 RTS) +fn rtlp t ulong to void +n = ulong 64 +if eq t 0 +n = len RTD +end +if eq t 1 +n = 40 +end +tule n 8 +for i ulong n +if eq t 0 +tub ulong get RTD i +end +if eq t 1 +tub ulong get RTC i +end +if eq t 2 +tub ulong get RTM i +end +if eq t 3 +tub ulong get RTH i +end +if eq t 4 +tub ulong get RTP i +end +if eq t 5 +tub ulong get RTEV i +end +if eq t 6 +tub ulong get RTS i +end +end +end + +note the identity digest recomputed from the documented field list +fn rtident to void +put TUFL 0 0 +for t ulong 7 +rtlp t +end +tule 8 8 +tule 189504 8 +tule 8 8 +tule 189500 8 +tule 8 8 +tule 2 8 +tule 8 8 +tule 512 8 +tusha 1000 0 0 get TUFL 0 +rthex 1 +end + +note the receipt file equals RTEXP, with RTEV and RTID at the two ? runs +fn rtcmp to int +rtpath 5 0 +n = stload +if ne n long len RTEXP +ret 20 +end +q = ulong 0 +for i ulong len RTEXP +e = get RTEXP i +g = get STFB i +if eq e 63 +if lt q 64 +e = get RTEV q +else +e = get RTID sub q 64 +end +q = add q 1 +end +if ne e g +ret 21 +end +end +if ne q 128 +ret 22 +end +ret 0 +end + +fn rtrefuse to int +rtmsh 1 +rtpath 2 8 +if ne stwfile 0 +ret 30 +end +if ne rcrun 2 +ret 31 +end +if ne get STOB 20 57 +ret 32 +end +rtmsh 0 +rtpath 2 8 +r = stwfile +rtpath 2 9 +u = unlink STPB 0 get STPL 0 +if ne rcrun 2 +ret 33 +end +if ne get STOB 20 56 +ret 34 +end +rtmsh 0 +rtpath 2 9 +r = stwfile +rtslots 1 +if ne rcrun 2 +ret 35 +end +if ne get STOB 20 50 +ret 36 +end +rtslots 0 +r = rtsum 3544386041195737427 4 0 +if ne rcrun 2 +ret 37 +end +if ne get STOB 20 55 +ret 38 +end +ret rtfinal +end + +note the refusal code printed by the last rcrun +fn rtcode to ulong +if ne get STOB 0 115 +ret 999 +end +v = ulong 0 +for k ulong 4 +c = get STOB add 20 k +if or lt c 48 gt c 57 +break +end +v = add mul v 10 ulong sub c 48 +end +ret v +end + +note split and summary identity: a mismatched holdout digest, a DEV summary, DEV index, and +note a summary with another request count are refused (11, 11, 10, 11); restored = accepted +fn rtfinal to int +r = rtsum 3544386041195737426 4 1 +if or ne rcrun 2 ne rtcode 11 +ret 39 +end +r = rtsum 3544386041195737426 3 0 +if or ne rcrun 2 ne rtcode 11 +ret 40 +end +r = rtsum 3544386041195737426 4 0 +r = rtindex 3 +if or ne rcrun 2 ne rtcode 10 +ret 41 +end +r = rtindex 4 +if ne rcrun 0 +ret 42 +end +r = rtsumreq +if or ne rcrun 2 ne rtcode 11 +ret 43 +end +ret 0 +end + +note stats.sum as written by rtsum but with request count 17999 (word 6) +fn rtsumreq to int +r = rtsum 3544386041195737426 4 0 +rtpath 3 10 +n = stload +put STOP 0 0 +for k ulong 256 +if eq k 6 +stow 17999 +else +stow stw mul k 8 +end +end +rtpath 3 10 +ret stwfile +end + +fn main to int +r = rtinit +if ne r 0 +ret r +end +r = rtfiles +if ne r 0 +ret r +end +put STPL 0 0 +rtkp 11 +n = stload +if lt n 0 +ret 10 +end +tusha 1000 1 0 ulong n +rthex 0 +rtident +rtslots 0 +put STQT 0 1 +if ne rcrun 0 +ret 11 +end +r = rtcmp +if ne r 0 +ret r +end +ret rtrefuse +end diff --git a/tests/reuse-eval/ref-hand.om b/tests/reuse-eval/ref-hand.om new file mode 100644 index 0000000..be16e06 --- /dev/null +++ b/tests/reuse-eval/ref-hand.om @@ -0,0 +1,482 @@ +note units: sha256 ref +note ref-hand: ref.om against hand-computed cases (contract v1.0 section 1, statuses section 2 and +note clarification K2). Values worked by hand in the notes beside each case; the digest constant is +note the SHA-256 of the 512 program bytes computed outside Omega. +note Exit 0 pass, otherwise the number of the first failed check. + +fn thbeg fam ulong n ulong to void +put RFRQ 0 1 +put RFRQ 1 add n 65 +put RFRQ 2 3544411312749556050 +for i ulong 63 +put RFRQ add i 3 0 +end +put RFRQ 3 fam +put RFRQ 66 n +end + +note PROGRAM frame header with the same layout as BEGIN's PROG (payload words 2..65) +fn thprog fam ulong to void +put RFRQ 0 8 +put RFRQ 1 64 +put RFRQ 2 3544411312749556050 +for i ulong 63 +put RFRQ add i 3 0 +end +put RFRQ 3 fam +end + +fn thsend op ulong p ulong to int +put RFRQ 0 op +put RFRQ 1 p +ret rfreq +end + +fn thq r0 ulong r1 ulong to bool +put RFRQ 0 2 +put RFRQ 1 0 +if ne rfreq 0 +ret false +end +if ne get RFRS 1 3 +ret false +end +ret and eq get RFRS 2 r0 eq get RFRS 3 r1 +end + +fn thchg op ulong a ulong b ulong to int +put RFRQ 2 a +put RFRQ 3 b +p = ulong 2 +if eq op 5 +p = 1 +end +ret thsend op p +end + +note BATCH item i +fn thitem i ulong op ulong a ulong b ulong to void +put RFRQ add 3 mul i 3 op +put RFRQ add 4 mul i 3 a +put RFRQ add 5 mul i 3 b +end + +note case A: wl 8, ADD fold, k 3: ADD 200, MUL 3, SHR 1. e(100) = ((300 mod 256) 3 mod 256) >> 1 = +note (44 * 3 = 132) >> 1 = 66; e(0) = (600 mod 256 = 88) >> 1 = 44; e(255) = (199 * 3 = 597 mod 256 +note = 85) >> 1 = 42; e(1) = (201 * 3 = 603 mod 256 = 91) >> 1 = 45. +fn thcasea to int +thbeg 1 2 +put RFRQ 4 8 +put RFRQ 5 1 +put RFRQ 6 3 +put RFRQ 7 1 +put RFRQ 8 200 +put RFRQ 9 3 +put RFRQ 10 3 +put RFRQ 11 8 +put RFRQ 12 1 +put RFRQ 67 100 +put RFRQ 68 0 +if ne rfreq 0 +ret 1 +end +if not thq 110 2 +ret 2 +end +if ne rfshape 137441544 +ret 3 +end +rfpdig +if or ne get RFPD 0 2728764828787738933 ne get RFPD 1 894935584194808807 +ret 4 +end +if or ne get RFPD 2 17635222896771188420 ne get RFPD 3 1726349768284173359 +ret 4 +end +if ne thchg 3 1 255 0 +ret 5 +end +if not thq 108 2 +ret 6 +end +if ne thchg 4 0 1 0 +ret 7 +end +if not thq 153 3 +ret 8 +end +if ne thchg 5 1 0 0 +ret 9 +end +if not thq 87 2 +ret 10 +end +if ne thchg 6 0 1 0 +ret 11 +end +if ne thchg 6 1 1 0 +ret 12 +end +if not thq 87 2 +ret 13 +end +if ne thchg 3 2 5 3 +ret 14 +end +if ne thchg 3 0 256 3 +ret 15 +end +if ne thchg 4 3 0 3 +ret 16 +end +if ne thchg 4 2 256 3 +ret 17 +end +if ne thchg 5 2 0 3 +ret 18 +end +if ne thchg 6 0 2 3 +ret 19 +end +if not thq 87 2 +ret 20 +end +ret 0 +end + +note case B: empty state identities, ADD 0, XOR 0, MIN 2^64 - 1, MAX 0, OR 0, AND 2^64 - 1 +fn thcaseb to int +for f ulong 6 +thbeg 1 0 +put RFRQ 4 16 +put RFRQ 5 add f 1 +put RFRQ 6 1 +put RFRQ 7 6 +if ne rfreq 0 +ret 21 +end +want = ulong 0 +if or eq f 2 eq f 5 +want = 18446744073709551615 +end +if not thq want 0 +ret 22 +end +end +note FSM n = 0: r0 = s0, r1 = 0 +thbeg 2 0 +put RFRQ 4 3 +put RFRQ 5 2 +put RFRQ 6 2 +put RFRQ 7 1 +put RFRQ 24 65536 +if ne rfreq 0 +ret 23 +end +if not thq 2 0 +ret 24 +end +ret 0 +end + +note case C: S 3, A 4, s0 1, lambda 10 20 30; rule0 (0, 0..3, 2), rule1 (1, 2..3, 0), +note rule2 (1, 3..3, 2) shadowed by rule1. w = 0 3 1 0: q1 = 1 (no rule for state 1 and symbol 0: +note default self-loop, +20), q2 = 0 (rule1, +10; rule2 would give 2), q3 = 2 (rule0, +30), +note q4 = 2 (state 2 has no rule, +30): r0 2, r1 90. +fn thcasec to int +thbeg 2 4 +put RFRQ 4 3 +put RFRQ 5 4 +put RFRQ 6 1 +put RFRQ 7 3 +put RFRQ 8 10 +put RFRQ 9 20 +put RFRQ 10 30 +put RFRQ 24 33751040 +put RFRQ 25 197121 +put RFRQ 26 33751809 +put RFRQ 67 0 +put RFRQ 68 3 +put RFRQ 69 1 +put RFRQ 70 0 +if ne rfreq 0 +ret 31 +end +if not thq 2 90 +ret 32 +end +if ne rfshape 1 +ret 33 +end +ret 0 +end + +note case D (after C): BATCH all or nothing. (SET 0 1, SET 1 4): the second is outside A = 4, so 3 +note and the state is unchanged. (INS 4 3, SET 4 2, DEL 0): SET 4 is valid only on the state INS +note left; result state 3 1 0 2: q = 0 (+10), 2 (+30), 2 (+30), 2 (+30) = r0 2, r1 100. +fn thcased to int +put RFRQ 2 2 +thitem 0 3 0 1 +thitem 1 3 1 4 +if ne thsend 7 7 3 +ret 41 +end +if not thq 2 90 +ret 42 +end +put RFRQ 2 3 +thitem 0 4 4 3 +thitem 1 3 4 2 +thitem 2 5 0 0 +if ne thsend 7 10 0 +ret 43 +end +if not thq 2 100 +ret 44 +end +put RFRQ 2 1 +thitem 0 5 0 1 +if ne thsend 7 4 3 +ret 45 +end +put RFRQ 2 0 +if ne thsend 7 1 3 +ret 46 +end +put RFRQ 2 2 +if ne thsend 7 4 4 +ret 47 +end +put RFRQ 2 1 +thitem 0 9 0 0 +if ne thsend 7 4 3 +ret 48 +end +put RFRQ 2 1025 +if ne thsend 7 3076 3 +ret 49 +end +if ne thsend 7 0 4 +ret 50 +end +note (DEL 3, DEL 2, DEL 1, DEL 0, DEL 0): the fifth finds n = 0, so 3 and all four stay +put RFRQ 2 5 +thitem 0 5 3 0 +thitem 1 5 2 0 +thitem 2 5 1 0 +thitem 3 5 0 0 +thitem 4 5 0 0 +if ne thsend 7 16 3 +ret 51 +end +if not thq 2 100 +ret 52 +end +ret 0 +end + +note case E (after D, state 3 1 0 2): PROGRAM to AGG wl 8 MAX k 1 ADD 1: e = 4 2 1 3, r0 4, r1 4. +note PROGRAM to FSM with A = 3: the value 3 is outside, 3, unchanged. Invalid PROG (k 7): 2. +note Invalid and out of domain together (FSM A 2, R 0): 2 first. +fn thcasee to int +thprog 1 +put RFRQ 4 8 +put RFRQ 5 4 +put RFRQ 6 1 +put RFRQ 7 1 +put RFRQ 8 1 +if ne rfreq 0 +ret 61 +end +if not thq 4 4 +ret 62 +end +thprog 2 +put RFRQ 4 4 +put RFRQ 5 3 +put RFRQ 6 0 +put RFRQ 7 1 +put RFRQ 24 65536 +if ne rfreq 3 +ret 63 +end +if not thq 4 4 +ret 64 +end +thprog 1 +put RFRQ 4 8 +put RFRQ 5 4 +put RFRQ 6 7 +put RFRQ 7 1 +put RFRQ 8 1 +if ne rfreq 2 +ret 65 +end +thprog 2 +put RFRQ 4 4 +put RFRQ 5 2 +put RFRQ 6 0 +put RFRQ 7 0 +if ne rfreq 2 +ret 66 +end +note a shift constant equal to wl is invalid, wl - 1 is valid +thprog 1 +put RFRQ 4 8 +put RFRQ 5 4 +put RFRQ 6 1 +put RFRQ 7 7 +put RFRQ 8 8 +if ne rfreq 2 +ret 67 +end +put RFRQ 8 7 +if ne rfreq 0 +ret 68 +end +note e = shl x 7 mod 256: 3 -> 128, 1 -> 128, 0 -> 0, 2 -> 0: max 128 +if not thq 128 4 +ret 69 +end +note BEGIN refusals keep the session: value outside the domain 3; n 4097 with p = 4162: 5; +note p 64: 4; invalid PROG: 2 +thbeg 1 1 +put RFRQ 4 8 +put RFRQ 5 1 +put RFRQ 6 1 +put RFRQ 7 1 +put RFRQ 8 0 +put RFRQ 67 256 +if ne rfreq 3 +ret 70 +end +thbeg 1 4097 +put RFRQ 4 8 +put RFRQ 5 1 +put RFRQ 6 1 +put RFRQ 7 1 +if ne rfreq 5 +ret 71 +end +thbeg 1 1 +put RFRQ 1 64 +if ne rfreq 4 +ret 72 +end +thbeg 1 1 +put RFRQ 4 9 +put RFRQ 5 1 +put RFRQ 6 1 +put RFRQ 7 1 +if ne rfreq 2 +ret 73 +end +if not thq 128 4 +ret 74 +end +ret 0 +end + +note case F: framing and no session +fn thcasef to int +rfreset +if ne thsend 2 0 6 +ret 81 +end +if ne thchg 3 0 0 6 +ret 82 +end +if ne thsend 9 0 0 +ret 83 +end +if ne thsend 10 0 0 +ret 84 +end +if ne thsend 11 0 4 +ret 85 +end +if ne thsend 0 0 4 +ret 86 +end +if ne thsend 2 1 4 +ret 87 +end +if ne thsend 3 1 4 +ret 88 +end +if ne thsend 2 7235 4 +ret 89 +end +ret 0 +end + +note case G: n = 4096 refuses INS (3); DEL then INS succeed; AGG XOR wl 16 identity map with +note values i: xor of 0..4095 = 0, after DEL 0 and INS 0 7 the xor is 7 +fn thcaseg to int +thbeg 1 4096 +put RFRQ 4 16 +put RFRQ 5 2 +put RFRQ 6 1 +put RFRQ 7 1 +put RFRQ 8 0 +for i ulong 4096 +put RFRQ add 67 i i +end +if ne rfreq 0 +ret 91 +end +if not thq 0 4096 +ret 92 +end +if ne thchg 4 0 0 3 +ret 93 +end +if ne thchg 5 0 0 0 +ret 94 +end +if ne thchg 4 0 7 0 +ret 95 +end +if not thq 7 4096 +ret 96 +end +if ne thsend 10 0 0 +ret 97 +end +if ne thsend 2 0 6 +ret 98 +end +ret 0 +end + +fn main to int +r = thcasea +if ne r 0 +ret r +end +r = thcaseb +if ne r 0 +ret r +end +r = thcasec +if ne r 0 +ret r +end +r = thcased +if ne r 0 +ret r +end +r = thcasee +if ne r 0 +ret r +end +r = thcasef +if ne r 0 +ret r +end +r = thcaseg +if ne r 0 +ret r +end +ret 0 +end diff --git a/tests/reuse-eval/ref-kat.om b/tests/reuse-eval/ref-kat.om new file mode 100644 index 0000000..561c7fb --- /dev/null +++ b/tests/reuse-eval/ref-kat.om @@ -0,0 +1,264 @@ +note units: sha256 ref +note ref-kat: ref.om against the integrator's known-answer vectors (Wolfram Language, outside Omega), +note tests/reuse-eval/ref-kat.txt = byte copy of omega-mv 0c72ad55 tests/reuse/kat.txt, sha256 pinned. +note Records (one per line, decimal tokens): 1 wl op c x e (lane step) | 2 f a b r (fold) | +note 3 wl f k op1 c1 .. opk ck n x0 .. x(n-1) r0 (AGG program) | +note 4 S A s0 R lam0 .. lam(S-1) (R quads s lo hi t) n w1 .. wn r0 r1 (FSM). +note AGG and FSM records run through rfreq: BEGIN (status 0) then QUERY. cwd = repo root. +note Exit: 0 pass; 1 open; 2 read; 3 digest pin; 4 parse; 10 lane; 11 fold; 12 AGG begin status; +note 13 AGG r0; 14 AGG r1; 15 FSM begin; 16 FSM r0; 17 FSM r1; 18 record counts. +text ktpath "tests/reuse-eval/ref-kat.txt" +global KTB uchar 1048576 +global KTL ulong 1 +global KTI ulong 1 +global KTE ulong 1 + +note next decimal token; sets KTE 1 on a malformed token; a token never crosses a newline check +fn ktnum to ulong +i = get KTI 0 +l = get KTL 0 +while and lt i l eq get KTB i 32 bound 999999 +i = add i 1 +end +if or ge i l lt get KTB i 48 +put KTE 0 1 +put KTI 0 i +ret 0 +end +v = ulong 0 +d = ulong 0 +while and lt i l and ge get KTB i 48 le get KTB i 57 bound 21 +v = add mul v 10 ulong sub get KTB i 48 +i = add i 1 +d = add d 1 +end +if eq d 0 +put KTE 0 1 +end +put KTI 0 i +ret v +end + +note the record must end here: a newline (or the end of the file) +fn kteol to void +i = get KTI 0 +if lt i get KTL 0 +if ne get KTB i 10 +put KTE 0 1 +ret +end +put KTI 0 add i 1 +end +end + +fn ktbegin to int +put RFRQ 0 1 +put RFRQ 2 3544411312749556050 +for i ulong 63 +put RFRQ add i 3 0 +end +ret 0 +end + +fn ktagg to int +x = ktbegin +put RFRQ 3 1 +put RFRQ 4 ktnum +put RFRQ 5 ktnum +k = ktnum +put RFRQ 6 k +for j ulong k +put RFRQ add 7 mul j 2 ktnum +put RFRQ add 8 mul j 2 ktnum +end +n = ktnum +if gt n 4096 +ret 4 +end +put RFRQ 66 n +for t ulong n +put RFRQ add 67 t ktnum +end +put RFRQ 1 add n 65 +r0 = ktnum +kteol +if ne get KTE 0 0 +ret 4 +end +if ne rfreq 0 +ret 12 +end +put RFRQ 0 2 +put RFRQ 1 0 +if ne rfreq 0 +ret 12 +end +if ne get RFRS 2 r0 +ret 13 +end +if ne get RFRS 3 n +ret 14 +end +ret 0 +end + +fn ktfsm to int +x = ktbegin +put RFRQ 3 2 +s = ktnum +put RFRQ 4 s +put RFRQ 5 ktnum +put RFRQ 6 ktnum +r = ktnum +put RFRQ 7 r +if or gt s 16 gt r 24 +ret 4 +end +for i ulong s +put RFRQ add 8 i ktnum +end +for j ulong r +q = ktnum +q = add q mul 256 ktnum +q = add q mul 65536 ktnum +q = add q mul 16777216 ktnum +put RFRQ add 24 j q +end +n = ktnum +if gt n 4096 +ret 4 +end +put RFRQ 66 n +for t ulong n +put RFRQ add 67 t ktnum +end +put RFRQ 1 add n 65 +r0 = ktnum +r1 = ktnum +kteol +if ne get KTE 0 0 +ret 4 +end +if ne rfreq 0 +ret 15 +end +put RFRQ 0 2 +put RFRQ 1 0 +if ne rfreq 0 +ret 15 +end +if ne get RFRS 2 r0 +ret 16 +end +if ne get RFRS 3 r1 +ret 17 +end +ret 0 +end + +fn ktdigest to int +rfhini 0 +l = get KTL 0 +off = ulong 0 +while lt off l bound 32 +k = sub l off +if gt k 65536 +k = 65536 +end +for i ulong k +put RFHB i get KTB add off i +end +rfhabs 0 k +off = add off k +end +rfhfin 0 +if ne get RFHD 0 3585239006480054916 +ret 3 +end +if ne get RFHD 1 3222387400420703059 +ret 3 +end +if ne get RFHD 2 3587373920770209618 +ret 3 +end +if ne get RFHD 3 12396970866340444107 +ret 3 +end +ret 0 +end + +fn main to int +fd = fopen ktpath 0 len ktpath 0 0 +if lt fd 0 +ret 1 +end +n = read int fd KTB 0 len KTB +x = fclose int fd +if or le n 0 ge n 1048576 +ret 2 +end +put KTL 0 ulong n +d = ktdigest +if ne d 0 +ret d +end +c1 = ulong 0 +c2 = ulong 0 +c3 = ulong 0 +c4 = ulong 0 +while lt get KTI 0 get KTL 0 bound 100000 +kind = ktnum +if eq kind 1 +wl = ktnum +op = ktnum +c = ktnum +v = ktnum +e = ktnum +kteol +if ne rfop wl op c v e +ret 10 +end +c1 = add c1 1 +else +if eq kind 2 +f = ktnum +a = ktnum +b = ktnum +r = ktnum +kteol +if ne rffold f a b r +ret 11 +end +c2 = add c2 1 +else +if eq kind 3 +s3 = ktagg +if ne s3 0 +ret s3 +end +c3 = add c3 1 +else +if eq kind 4 +s4 = ktfsm +if ne s4 0 +ret s4 +end +c4 = add c4 1 +else +ret 4 +end +end +end +end +if ne get KTE 0 0 +ret 4 +end +end +if or ne c1 336 ne c2 150 +ret 18 +end +if or ne c3 80 ne c4 60 +ret 18 +end +ret 0 +end diff --git a/tests/reuse-eval/ref-kat.txt b/tests/reuse-eval/ref-kat.txt new file mode 100644 index 0000000..edaae23 --- /dev/null +++ b/tests/reuse-eval/ref-kat.txt @@ -0,0 +1,626 @@ +1 8 1 0 0 0 +1 8 1 0 1 1 +1 8 1 0 255 255 +1 8 1 0 128 128 +1 8 1 1 0 1 +1 8 1 1 1 2 +1 8 1 1 255 0 +1 8 1 1 128 129 +1 8 1 128 0 128 +1 8 1 128 1 129 +1 8 1 128 255 127 +1 8 1 128 128 0 +1 8 1 255 0 255 +1 8 1 255 1 0 +1 8 1 255 255 254 +1 8 1 255 128 127 +1 8 2 0 0 0 +1 8 2 0 1 1 +1 8 2 0 255 255 +1 8 2 0 128 128 +1 8 2 1 0 255 +1 8 2 1 1 0 +1 8 2 1 255 254 +1 8 2 1 128 127 +1 8 2 128 0 128 +1 8 2 128 1 129 +1 8 2 128 255 127 +1 8 2 128 128 0 +1 8 2 255 0 1 +1 8 2 255 1 2 +1 8 2 255 255 0 +1 8 2 255 128 129 +1 8 3 0 0 0 +1 8 3 0 1 0 +1 8 3 0 255 0 +1 8 3 0 128 0 +1 8 3 1 0 0 +1 8 3 1 1 1 +1 8 3 1 255 255 +1 8 3 1 128 128 +1 8 3 128 0 0 +1 8 3 128 1 128 +1 8 3 128 255 128 +1 8 3 128 128 0 +1 8 3 255 0 0 +1 8 3 255 1 255 +1 8 3 255 255 1 +1 8 3 255 128 128 +1 8 4 0 0 0 +1 8 4 0 1 0 +1 8 4 0 255 0 +1 8 4 0 128 0 +1 8 4 1 0 0 +1 8 4 1 1 1 +1 8 4 1 255 1 +1 8 4 1 128 0 +1 8 4 128 0 0 +1 8 4 128 1 0 +1 8 4 128 255 128 +1 8 4 128 128 128 +1 8 4 255 0 0 +1 8 4 255 1 1 +1 8 4 255 255 255 +1 8 4 255 128 128 +1 8 5 0 0 0 +1 8 5 0 1 1 +1 8 5 0 255 255 +1 8 5 0 128 128 +1 8 5 1 0 1 +1 8 5 1 1 1 +1 8 5 1 255 255 +1 8 5 1 128 129 +1 8 5 128 0 128 +1 8 5 128 1 129 +1 8 5 128 255 255 +1 8 5 128 128 128 +1 8 5 255 0 255 +1 8 5 255 1 255 +1 8 5 255 255 255 +1 8 5 255 128 255 +1 8 6 0 0 0 +1 8 6 0 1 1 +1 8 6 0 255 255 +1 8 6 0 128 128 +1 8 6 1 0 1 +1 8 6 1 1 0 +1 8 6 1 255 254 +1 8 6 1 128 129 +1 8 6 128 0 128 +1 8 6 128 1 129 +1 8 6 128 255 127 +1 8 6 128 128 0 +1 8 6 255 0 255 +1 8 6 255 1 254 +1 8 6 255 255 0 +1 8 6 255 128 127 +1 8 7 0 0 0 +1 8 7 0 1 1 +1 8 7 0 255 255 +1 8 7 0 128 128 +1 8 7 1 0 0 +1 8 7 1 1 2 +1 8 7 1 255 254 +1 8 7 1 128 0 +1 8 7 7 0 0 +1 8 7 7 1 128 +1 8 7 7 255 128 +1 8 7 7 128 0 +1 8 8 0 0 0 +1 8 8 0 1 1 +1 8 8 0 255 255 +1 8 8 0 128 128 +1 8 8 1 0 0 +1 8 8 1 1 0 +1 8 8 1 255 127 +1 8 8 1 128 64 +1 8 8 7 0 0 +1 8 8 7 1 0 +1 8 8 7 255 1 +1 8 8 7 128 1 +1 16 1 0 0 0 +1 16 1 0 1 1 +1 16 1 0 255 255 +1 16 1 0 256 256 +1 16 1 0 32768 32768 +1 16 1 0 65535 65535 +1 16 1 1 0 1 +1 16 1 1 1 2 +1 16 1 1 255 256 +1 16 1 1 256 257 +1 16 1 1 32768 32769 +1 16 1 1 65535 0 +1 16 1 32768 0 32768 +1 16 1 32768 1 32769 +1 16 1 32768 255 33023 +1 16 1 32768 256 33024 +1 16 1 32768 32768 0 +1 16 1 32768 65535 32767 +1 16 1 65535 0 65535 +1 16 1 65535 1 0 +1 16 1 65535 255 254 +1 16 1 65535 256 255 +1 16 1 65535 32768 32767 +1 16 1 65535 65535 65534 +1 16 1 255 0 255 +1 16 1 255 1 256 +1 16 1 255 255 510 +1 16 1 255 256 511 +1 16 1 255 32768 33023 +1 16 1 255 65535 254 +1 16 2 0 0 0 +1 16 2 0 1 1 +1 16 2 0 255 255 +1 16 2 0 256 256 +1 16 2 0 32768 32768 +1 16 2 0 65535 65535 +1 16 2 1 0 65535 +1 16 2 1 1 0 +1 16 2 1 255 254 +1 16 2 1 256 255 +1 16 2 1 32768 32767 +1 16 2 1 65535 65534 +1 16 2 32768 0 32768 +1 16 2 32768 1 32769 +1 16 2 32768 255 33023 +1 16 2 32768 256 33024 +1 16 2 32768 32768 0 +1 16 2 32768 65535 32767 +1 16 2 65535 0 1 +1 16 2 65535 1 2 +1 16 2 65535 255 256 +1 16 2 65535 256 257 +1 16 2 65535 32768 32769 +1 16 2 65535 65535 0 +1 16 2 255 0 65281 +1 16 2 255 1 65282 +1 16 2 255 255 0 +1 16 2 255 256 1 +1 16 2 255 32768 32513 +1 16 2 255 65535 65280 +1 16 3 0 0 0 +1 16 3 0 1 0 +1 16 3 0 255 0 +1 16 3 0 256 0 +1 16 3 0 32768 0 +1 16 3 0 65535 0 +1 16 3 1 0 0 +1 16 3 1 1 1 +1 16 3 1 255 255 +1 16 3 1 256 256 +1 16 3 1 32768 32768 +1 16 3 1 65535 65535 +1 16 3 32768 0 0 +1 16 3 32768 1 32768 +1 16 3 32768 255 32768 +1 16 3 32768 256 0 +1 16 3 32768 32768 0 +1 16 3 32768 65535 32768 +1 16 3 65535 0 0 +1 16 3 65535 1 65535 +1 16 3 65535 255 65281 +1 16 3 65535 256 65280 +1 16 3 65535 32768 32768 +1 16 3 65535 65535 1 +1 16 3 255 0 0 +1 16 3 255 1 255 +1 16 3 255 255 65025 +1 16 3 255 256 65280 +1 16 3 255 32768 32768 +1 16 3 255 65535 65281 +1 16 4 0 0 0 +1 16 4 0 1 0 +1 16 4 0 255 0 +1 16 4 0 256 0 +1 16 4 0 32768 0 +1 16 4 0 65535 0 +1 16 4 1 0 0 +1 16 4 1 1 1 +1 16 4 1 255 1 +1 16 4 1 256 0 +1 16 4 1 32768 0 +1 16 4 1 65535 1 +1 16 4 32768 0 0 +1 16 4 32768 1 0 +1 16 4 32768 255 0 +1 16 4 32768 256 0 +1 16 4 32768 32768 32768 +1 16 4 32768 65535 32768 +1 16 4 65535 0 0 +1 16 4 65535 1 1 +1 16 4 65535 255 255 +1 16 4 65535 256 256 +1 16 4 65535 32768 32768 +1 16 4 65535 65535 65535 +1 16 4 255 0 0 +1 16 4 255 1 1 +1 16 4 255 255 255 +1 16 4 255 256 0 +1 16 4 255 32768 0 +1 16 4 255 65535 255 +1 16 5 0 0 0 +1 16 5 0 1 1 +1 16 5 0 255 255 +1 16 5 0 256 256 +1 16 5 0 32768 32768 +1 16 5 0 65535 65535 +1 16 5 1 0 1 +1 16 5 1 1 1 +1 16 5 1 255 255 +1 16 5 1 256 257 +1 16 5 1 32768 32769 +1 16 5 1 65535 65535 +1 16 5 32768 0 32768 +1 16 5 32768 1 32769 +1 16 5 32768 255 33023 +1 16 5 32768 256 33024 +1 16 5 32768 32768 32768 +1 16 5 32768 65535 65535 +1 16 5 65535 0 65535 +1 16 5 65535 1 65535 +1 16 5 65535 255 65535 +1 16 5 65535 256 65535 +1 16 5 65535 32768 65535 +1 16 5 65535 65535 65535 +1 16 5 255 0 255 +1 16 5 255 1 255 +1 16 5 255 255 255 +1 16 5 255 256 511 +1 16 5 255 32768 33023 +1 16 5 255 65535 65535 +1 16 6 0 0 0 +1 16 6 0 1 1 +1 16 6 0 255 255 +1 16 6 0 256 256 +1 16 6 0 32768 32768 +1 16 6 0 65535 65535 +1 16 6 1 0 1 +1 16 6 1 1 0 +1 16 6 1 255 254 +1 16 6 1 256 257 +1 16 6 1 32768 32769 +1 16 6 1 65535 65534 +1 16 6 32768 0 32768 +1 16 6 32768 1 32769 +1 16 6 32768 255 33023 +1 16 6 32768 256 33024 +1 16 6 32768 32768 0 +1 16 6 32768 65535 32767 +1 16 6 65535 0 65535 +1 16 6 65535 1 65534 +1 16 6 65535 255 65280 +1 16 6 65535 256 65279 +1 16 6 65535 32768 32767 +1 16 6 65535 65535 0 +1 16 6 255 0 255 +1 16 6 255 1 254 +1 16 6 255 255 0 +1 16 6 255 256 511 +1 16 6 255 32768 33023 +1 16 6 255 65535 65280 +1 16 7 0 0 0 +1 16 7 0 1 1 +1 16 7 0 255 255 +1 16 7 0 256 256 +1 16 7 0 32768 32768 +1 16 7 0 65535 65535 +1 16 7 1 0 0 +1 16 7 1 1 2 +1 16 7 1 255 510 +1 16 7 1 256 512 +1 16 7 1 32768 0 +1 16 7 1 65535 65534 +1 16 7 15 0 0 +1 16 7 15 1 32768 +1 16 7 15 255 32768 +1 16 7 15 256 0 +1 16 7 15 32768 0 +1 16 7 15 65535 32768 +1 16 8 0 0 0 +1 16 8 0 1 1 +1 16 8 0 255 255 +1 16 8 0 256 256 +1 16 8 0 32768 32768 +1 16 8 0 65535 65535 +1 16 8 1 0 0 +1 16 8 1 1 0 +1 16 8 1 255 127 +1 16 8 1 256 128 +1 16 8 1 32768 16384 +1 16 8 1 65535 32767 +1 16 8 15 0 0 +1 16 8 15 1 0 +1 16 8 15 255 0 +1 16 8 15 256 0 +1 16 8 15 32768 1 +1 16 8 15 65535 1 +2 1 0 0 0 +2 1 0 1 1 +2 1 0 65535 65535 +2 1 0 9223372036854775808 9223372036854775808 +2 1 0 18446744073709551615 18446744073709551615 +2 1 1 0 1 +2 1 1 1 2 +2 1 1 65535 65536 +2 1 1 9223372036854775808 9223372036854775809 +2 1 1 18446744073709551615 0 +2 1 65535 0 65535 +2 1 65535 1 65536 +2 1 65535 65535 131070 +2 1 65535 9223372036854775808 9223372036854841343 +2 1 65535 18446744073709551615 65534 +2 1 9223372036854775808 0 9223372036854775808 +2 1 9223372036854775808 1 9223372036854775809 +2 1 9223372036854775808 65535 9223372036854841343 +2 1 9223372036854775808 9223372036854775808 0 +2 1 9223372036854775808 18446744073709551615 9223372036854775807 +2 1 18446744073709551615 0 18446744073709551615 +2 1 18446744073709551615 1 0 +2 1 18446744073709551615 65535 65534 +2 1 18446744073709551615 9223372036854775808 9223372036854775807 +2 1 18446744073709551615 18446744073709551615 18446744073709551614 +2 2 0 0 0 +2 2 0 1 1 +2 2 0 65535 65535 +2 2 0 9223372036854775808 9223372036854775808 +2 2 0 18446744073709551615 18446744073709551615 +2 2 1 0 1 +2 2 1 1 0 +2 2 1 65535 65534 +2 2 1 9223372036854775808 9223372036854775809 +2 2 1 18446744073709551615 18446744073709551614 +2 2 65535 0 65535 +2 2 65535 1 65534 +2 2 65535 65535 0 +2 2 65535 9223372036854775808 9223372036854841343 +2 2 65535 18446744073709551615 18446744073709486080 +2 2 9223372036854775808 0 9223372036854775808 +2 2 9223372036854775808 1 9223372036854775809 +2 2 9223372036854775808 65535 9223372036854841343 +2 2 9223372036854775808 9223372036854775808 0 +2 2 9223372036854775808 18446744073709551615 9223372036854775807 +2 2 18446744073709551615 0 18446744073709551615 +2 2 18446744073709551615 1 18446744073709551614 +2 2 18446744073709551615 65535 18446744073709486080 +2 2 18446744073709551615 9223372036854775808 9223372036854775807 +2 2 18446744073709551615 18446744073709551615 0 +2 3 0 0 0 +2 3 0 1 0 +2 3 0 65535 0 +2 3 0 9223372036854775808 0 +2 3 0 18446744073709551615 0 +2 3 1 0 0 +2 3 1 1 1 +2 3 1 65535 1 +2 3 1 9223372036854775808 1 +2 3 1 18446744073709551615 1 +2 3 65535 0 0 +2 3 65535 1 1 +2 3 65535 65535 65535 +2 3 65535 9223372036854775808 65535 +2 3 65535 18446744073709551615 65535 +2 3 9223372036854775808 0 0 +2 3 9223372036854775808 1 1 +2 3 9223372036854775808 65535 65535 +2 3 9223372036854775808 9223372036854775808 9223372036854775808 +2 3 9223372036854775808 18446744073709551615 9223372036854775808 +2 3 18446744073709551615 0 0 +2 3 18446744073709551615 1 1 +2 3 18446744073709551615 65535 65535 +2 3 18446744073709551615 9223372036854775808 9223372036854775808 +2 3 18446744073709551615 18446744073709551615 18446744073709551615 +2 4 0 0 0 +2 4 0 1 1 +2 4 0 65535 65535 +2 4 0 9223372036854775808 9223372036854775808 +2 4 0 18446744073709551615 18446744073709551615 +2 4 1 0 1 +2 4 1 1 1 +2 4 1 65535 65535 +2 4 1 9223372036854775808 9223372036854775808 +2 4 1 18446744073709551615 18446744073709551615 +2 4 65535 0 65535 +2 4 65535 1 65535 +2 4 65535 65535 65535 +2 4 65535 9223372036854775808 9223372036854775808 +2 4 65535 18446744073709551615 18446744073709551615 +2 4 9223372036854775808 0 9223372036854775808 +2 4 9223372036854775808 1 9223372036854775808 +2 4 9223372036854775808 65535 9223372036854775808 +2 4 9223372036854775808 9223372036854775808 9223372036854775808 +2 4 9223372036854775808 18446744073709551615 18446744073709551615 +2 4 18446744073709551615 0 18446744073709551615 +2 4 18446744073709551615 1 18446744073709551615 +2 4 18446744073709551615 65535 18446744073709551615 +2 4 18446744073709551615 9223372036854775808 18446744073709551615 +2 4 18446744073709551615 18446744073709551615 18446744073709551615 +2 5 0 0 0 +2 5 0 1 1 +2 5 0 65535 65535 +2 5 0 9223372036854775808 9223372036854775808 +2 5 0 18446744073709551615 18446744073709551615 +2 5 1 0 1 +2 5 1 1 1 +2 5 1 65535 65535 +2 5 1 9223372036854775808 9223372036854775809 +2 5 1 18446744073709551615 18446744073709551615 +2 5 65535 0 65535 +2 5 65535 1 65535 +2 5 65535 65535 65535 +2 5 65535 9223372036854775808 9223372036854841343 +2 5 65535 18446744073709551615 18446744073709551615 +2 5 9223372036854775808 0 9223372036854775808 +2 5 9223372036854775808 1 9223372036854775809 +2 5 9223372036854775808 65535 9223372036854841343 +2 5 9223372036854775808 9223372036854775808 9223372036854775808 +2 5 9223372036854775808 18446744073709551615 18446744073709551615 +2 5 18446744073709551615 0 18446744073709551615 +2 5 18446744073709551615 1 18446744073709551615 +2 5 18446744073709551615 65535 18446744073709551615 +2 5 18446744073709551615 9223372036854775808 18446744073709551615 +2 5 18446744073709551615 18446744073709551615 18446744073709551615 +2 6 0 0 0 +2 6 0 1 0 +2 6 0 65535 0 +2 6 0 9223372036854775808 0 +2 6 0 18446744073709551615 0 +2 6 1 0 0 +2 6 1 1 1 +2 6 1 65535 1 +2 6 1 9223372036854775808 0 +2 6 1 18446744073709551615 1 +2 6 65535 0 0 +2 6 65535 1 1 +2 6 65535 65535 65535 +2 6 65535 9223372036854775808 0 +2 6 65535 18446744073709551615 65535 +2 6 9223372036854775808 0 0 +2 6 9223372036854775808 1 0 +2 6 9223372036854775808 65535 0 +2 6 9223372036854775808 9223372036854775808 9223372036854775808 +2 6 9223372036854775808 18446744073709551615 9223372036854775808 +2 6 18446744073709551615 0 0 +2 6 18446744073709551615 1 1 +2 6 18446744073709551615 65535 65535 +2 6 18446744073709551615 9223372036854775808 9223372036854775808 +2 6 18446744073709551615 18446744073709551615 18446744073709551615 +3 16 3 2 2 65535 3 65535 0 18446744073709551615 +3 16 6 2 2 1 7 9 2 64591 0 39936 +3 8 3 1 6 0 17 0 18 255 79 255 195 255 0 255 64 255 0 255 0 255 0 255 0 +3 16 2 1 1 1 2 256 65535 257 +3 16 6 1 8 7 17 13634 256 0 65535 7283 65535 0 65535 0 6571 65535 0 0 0 256 65256 54204 0 +3 16 5 3 6 0 5 65535 2 255 17 46664 0 25857 25185 28599 65535 14622 65535 65535 2904 0 0 0 256 65535 0 0 65280 +3 16 2 3 8 7 6 0 2 65535 5 256 0 256 0 256 3 +3 8 2 1 2 255 1 0 1 +3 8 6 2 2 1 6 255 0 18446744073709551615 +3 16 2 5 4 65535 3 28847 7 0 8 6 3 60774 2 0 0 0 +3 16 5 5 3 10978 5 30706 3 0 5 0 2 255 1 5402 65281 +3 8 6 1 3 0 1 255 0 +3 16 2 4 1 0 4 33979 3 43024 8 7 1 256 0 +3 8 2 2 2 186 1 99 17 0 0 0 80 255 136 235 155 255 218 255 0 255 255 96 169 255 192 +3 8 6 2 6 0 2 42 17 0 99 0 255 255 146 92 255 180 75 65 255 221 255 0 255 255 0 +3 16 2 2 5 65535 7 11 1 2085 63488 +3 8 6 4 8 1 3 255 5 0 5 214 0 18446744073709551615 +3 16 2 1 5 255 17 36257 0 0 42013 65535 65535 0 0 256 63041 0 0 0 65535 0 48483 256 40447 +3 8 4 3 2 0 7 1 4 0 17 0 0 255 0 116 255 0 0 255 255 255 0 0 13 119 255 255 0 +3 16 3 2 2 1 4 255 17 0 65535 0 0 9043 65535 65535 0 0 0 0 19674 2330 65535 65535 64182 0 25 +3 16 5 5 2 0 7 5 5 0 8 4 4 255 0 0 +3 16 5 3 6 0 5 65535 5 56452 17 0 0 0 65535 39464 34742 256 29141 0 0 11390 256 65535 65535 0 8669 45510 65535 +3 16 2 6 7 15 5 1 5 0 7 3 6 41351 3 41784 5 256 256 5454 65535 65535 25672 +3 8 6 3 3 255 4 255 8 7 1 255 0 +3 8 6 3 2 1 5 0 1 0 0 18446744073709551615 +3 8 5 3 8 3 4 0 1 255 2 165 110 255 +3 16 2 5 6 65535 4 65535 2 1 8 8 4 58034 2 65535 0 0 +3 8 1 5 5 255 8 4 2 255 1 255 6 6 0 0 +3 16 1 4 6 0 3 22170 3 0 2 255 0 0 +3 8 6 4 8 1 7 0 8 0 7 6 0 18446744073709551615 +3 8 6 1 5 255 17 255 50 160 159 0 255 159 255 0 0 255 0 255 255 0 255 98 255 +3 8 6 1 8 1 1 255 127 +3 8 4 4 7 4 5 1 8 7 2 0 2 255 118 1 +3 8 2 1 4 1 0 0 +3 16 6 2 7 6 1 65535 0 18446744073709551615 +3 16 6 3 1 65535 2 255 8 0 1 44881 44625 +3 8 4 4 6 227 8 5 4 0 5 218 17 195 0 255 0 255 255 255 255 255 0 164 255 0 31 255 83 255 218 +3 8 2 5 5 255 3 104 1 255 7 4 3 255 17 0 255 212 255 255 0 255 255 185 255 255 255 182 211 111 255 4 144 +3 16 4 5 7 3 7 3 1 255 6 56806 5 255 2 256 1360 40447 +3 8 2 1 6 1 2 0 27 27 +3 16 6 1 1 10202 2 7385 65535 1169 +3 16 4 5 3 65535 1 0 5 29453 4 1 3 65535 0 0 +3 8 1 3 5 255 8 6 3 193 17 255 255 255 255 255 138 1 255 0 0 255 240 255 255 255 255 235 1139 +3 16 4 2 8 2 2 0 5 65535 256 65535 65535 0 16383 +3 8 3 4 2 255 6 255 4 0 3 0 5 255 255 0 119 255 0 +3 8 1 2 6 109 2 226 1 255 176 +3 16 5 1 5 255 1 40080 40191 +3 16 4 1 2 1 17 25762 28509 32560 45056 51669 256 65535 59314 256 0 65535 65535 65535 0 0 61444 0 65535 +3 8 2 3 2 255 4 255 1 255 0 0 +3 8 6 6 3 73 4 255 4 0 4 1 2 1 1 1 1 255 0 +3 8 4 5 8 1 5 255 4 1 8 0 8 7 0 0 +3 16 2 4 7 6 6 65535 5 65535 1 65535 5 52208 3021 256 256 256 65534 +3 16 5 1 6 0 0 0 +3 16 6 4 3 62633 4 0 6 65535 1 1 1 15789 0 +3 8 1 6 8 4 7 7 7 0 2 1 4 255 2 255 17 0 0 0 0 255 255 255 255 0 255 255 255 204 148 255 255 255 1408 +3 8 3 6 7 3 8 3 6 255 4 255 1 1 3 255 5 83 245 0 255 255 0 +3 16 5 5 7 15 7 14 7 8 1 65535 1 255 2 65535 256 254 +3 8 4 1 8 6 5 0 0 0 255 95 3 +3 16 3 5 3 65535 3 0 1 65535 3 1 2 21732 0 18446744073709551615 +3 8 1 5 3 27 5 0 4 0 4 0 5 1 17 255 255 255 112 255 255 255 255 0 255 0 253 0 255 255 255 255 17 +3 16 4 2 6 1 1 0 5 3502 2060 0 256 0 3503 +3 16 5 6 7 3 3 0 7 8 2 1 4 255 4 65535 17 256 65535 13837 65535 0 256 0 28396 256 63153 0 59451 65535 256 256 65535 256 255 +3 16 4 6 4 22323 3 65535 7 8 5 0 2 65535 5 65535 1 12276 65535 +3 8 6 3 7 3 4 1 1 0 5 255 255 255 255 144 0 +3 16 4 3 7 0 1 255 6 255 2 49859 256 49981 +3 8 5 3 8 7 1 255 8 7 1 255 0 +3 8 6 3 3 0 2 1 5 1 1 255 255 +3 8 5 5 7 1 6 0 7 3 8 5 2 76 5 255 255 255 255 255 187 +3 8 5 5 5 1 7 6 6 255 3 1 7 7 5 0 127 255 0 242 128 +3 16 3 5 6 17785 5 65535 5 255 8 11 8 2 1 256 7 +3 16 2 6 4 38198 8 0 3 1 6 1 7 1 6 1 2 65535 42521 8780 +3 16 2 2 7 11 7 0 17 0 0 256 5391 0 9132 256 0 0 9075 11647 0 11693 0 41086 32680 0 40960 +3 16 3 2 6 255 3 255 0 18446744073709551615 +3 16 2 1 8 15 2 65535 56975 0 +3 16 5 1 7 13 1 0 0 +3 16 5 1 3 1 17 65535 16629 65535 0 256 0 11834 50670 0 0 65032 256 256 35774 256 256 256 65535 +3 8 6 5 7 4 7 4 2 0 6 122 4 255 0 18446744073709551615 +3 8 1 6 5 255 5 255 4 255 7 6 7 4 5 255 17 0 255 61 26 0 255 255 255 211 30 99 255 255 0 255 255 255 4335 +3 16 4 5 7 6 1 255 7 2 5 65535 1 65535 2 27880 65535 65534 +3 16 5 2 1 1 4 0 2 0 0 0 +4 7 6 0 21 137 11 106 149 176 125 191 2 5 5 2 5 0 2 4 5 1 5 3 4 1 3 2 5 1 5 6 2 4 4 0 0 2 2 4 1 5 5 0 4 4 5 6 1 3 5 6 3 2 3 1 2 3 3 0 1 1 3 1 1 3 3 4 5 5 5 3 3 3 3 4 1 1 4 6 6 5 5 0 0 5 5 4 2 4 5 5 2 2 5 2 1 2 4 176 +4 11 8 3 23 249 93 147 27 114 244 86 67 76 59 249 1 0 0 2 8 6 6 4 10 1 4 8 8 4 4 2 8 1 3 9 4 4 6 9 2 6 7 4 7 2 7 7 6 2 6 2 6 5 6 6 9 0 1 9 8 1 7 7 7 7 7 7 2 0 1 3 7 2 6 3 10 4 5 4 5 5 7 1 7 4 4 4 2 6 6 4 10 4 5 9 0 6 6 3 7 0 0 5 8 4 7 4 40 6 2 1 3 2 4 2 4 5 5 2 6 5 0 7 5 4 5 5 5 4 5 0 5 6 7 7 4 4 0 4 3 7 3 1 2 7 2 2 2 3 1080 +4 8 5 5 7 121 93 170 144 135 86 157 72 2 0 0 6 2 2 3 0 1 0 0 4 1 1 3 4 7 3 4 0 4 3 4 2 0 1 1 4 3 2 3 4 5 258 +4 10 7 1 19 217 28 62 128 105 43 228 52 119 197 5 4 5 4 2 0 2 9 1 4 5 7 2 5 6 0 6 2 3 8 7 3 6 8 0 5 5 5 7 3 6 3 9 6 6 1 5 2 4 0 9 5 5 8 6 0 1 4 2 2 5 8 2 4 4 0 2 0 3 9 2 3 6 6 7 6 6 3 7 0 5 3 5 2 2 3 40 5 6 6 1 0 2 0 5 0 3 4 4 5 5 4 0 2 2 2 3 1 0 2 3 1 3 3 3 2 4 6 4 0 3 4 2 1 3 1 1 8 4693 +4 6 10 5 5 47 6 57 56 107 228 2 1 8 3 0 0 1 0 1 7 7 5 1 4 8 1 5 2 4 3 10 0 0 5 2 6 4 0 2 8 5 3 1076 +4 7 12 3 9 102 239 147 29 208 112 237 4 4 6 6 2 11 11 0 1 4 8 4 2 10 11 5 5 9 11 6 3 6 8 0 2 10 10 6 4 4 7 2 3 1 10 0 10 1 9 3 5 0 7 6 8 6 9 0 1020 +4 13 16 6 14 162 28 235 70 9 106 109 195 171 12 184 7 206 7 4 12 3 11 15 15 10 2 14 14 4 8 12 15 9 9 8 14 11 11 3 5 5 4 7 13 5 9 0 4 9 3 0 3 2 2 11 13 5 4 7 12 9 5 12 12 4 4 13 14 0 10 0 3 12 0 6 0 +4 7 12 3 9 182 113 76 45 105 88 246 6 6 8 1 1 3 8 1 0 0 6 0 2 7 9 1 5 4 6 6 2 11 11 1 2 4 5 4 6 5 9 5 3 5 7 1 0 3 0 +4 7 4 6 15 145 92 200 169 18 43 92 1 3 3 0 3 2 3 5 2 1 1 6 2 1 3 3 0 2 3 5 1 0 3 2 6 0 1 3 6 0 1 4 4 0 0 4 4 1 2 6 4 2 3 2 0 2 3 4 6 0 0 0 4 3 3 0 6 3 3 2 10 2 0 0 3 2 0 2 0 3 1 5 731 +4 4 12 2 10 134 61 187 107 0 5 8 2 1 9 10 0 3 7 7 0 2 11 11 1 0 4 11 1 3 11 11 3 3 1 11 3 0 10 10 0 0 1 5 2 2 4 7 0 1 0 2 187 +4 8 8 7 1 74 85 97 57 217 91 188 114 1 7 7 6 40 3 6 5 6 7 0 4 4 3 0 7 5 6 6 0 2 5 5 6 6 5 6 5 2 5 4 6 7 1 0 4 6 7 7 5 7 0 3 3 1 7 4560 +4 6 16 4 16 118 218 206 100 94 249 4 8 15 0 5 6 9 5 1 1 9 2 0 5 9 0 4 5 8 2 4 12 13 2 4 5 14 4 4 1 1 2 5 12 13 1 0 4 15 1 5 12 13 1 0 3 9 1 5 15 15 1 0 7 13 0 4 14 14 1 5 3 3 3 0 4 0 +4 14 16 3 21 241 33 21 109 38 110 247 160 172 209 242 89 206 78 8 8 9 4 13 4 10 10 7 15 15 4 9 6 12 8 12 3 9 8 10 3 10 13 0 7 8 9 12 6 15 5 3 10 11 8 4 8 12 0 1 14 14 3 5 12 14 12 1 9 13 9 3 7 14 13 2 2 15 11 7 6 14 5 2 8 8 6 4 12 13 8 7 1 15 7 6 8 8 10 3 11 14 7 0 3 0 +4 8 5 0 12 146 104 107 145 84 10 162 78 3 3 4 3 2 3 4 5 0 2 2 4 0 1 3 3 6 0 2 0 4 1 4 0 4 0 2 3 3 1 1 5 4 1 3 6 2 4 4 2 0 4 4 5 1 2 4 0 40 2 1 0 2 3 3 0 4 2 4 1 0 4 2 2 1 2 0 1 1 3 1 2 4 1 1 0 2 3 0 0 1 1 4 1 4 3 4 3 2 5 1631 +4 5 12 3 20 81 180 1 224 196 4 5 9 3 1 5 5 0 3 0 9 2 2 7 8 0 2 6 7 2 2 6 8 4 3 3 6 3 3 9 11 0 0 10 10 4 3 4 10 3 2 2 7 3 2 2 10 4 0 4 4 4 4 3 10 0 3 11 11 4 1 0 1 3 2 1 10 0 3 3 11 0 3 2 2 3 4 5 10 3 10 10 11 5 8 0 7 8 10 3 0 0 925 +4 10 5 8 18 210 254 170 98 149 228 243 104 251 231 6 0 4 4 6 3 4 3 1 2 4 9 3 0 1 0 1 2 4 5 3 4 4 1 0 3 4 2 2 2 2 4 9 3 3 3 5 0 3 4 2 3 4 1 2 3 3 0 4 0 2 7 1 4 4 1 4 4 4 7 6 4 4 4 8 4 4 4 4 0 0 7 3 1 4 1 7 504 +4 4 6 1 11 181 95 215 118 0 0 0 0 1 5 5 1 2 1 1 1 1 3 3 1 2 5 5 3 3 3 3 1 1 4 5 2 1 4 5 0 3 5 5 3 1 4 5 1 0 4 4 3 10 4 2 2 5 0 1 3 0 3 5 1 1379 +4 3 14 2 9 245 218 58 0 13 13 2 0 11 12 1 2 6 10 0 0 10 10 1 2 2 7 1 2 11 11 0 1 10 12 0 1 4 12 1 0 8 9 1 0 2 0 +4 10 7 1 13 200 208 236 32 203 123 252 94 96 58 4 5 6 8 9 5 6 7 0 5 5 4 5 4 5 6 2 2 3 0 4 1 3 3 1 4 4 9 7 0 2 6 3 5 5 4 2 2 2 2 1 2 6 1 0 1 5 2 9 0 4 8 1 1 1 208 +4 5 8 0 4 130 163 13 217 235 0 6 7 4 2 7 7 4 1 6 7 3 0 4 4 3 40 0 5 1 6 1 5 6 4 1 6 5 3 0 5 0 5 7 0 1 2 3 2 2 7 1 7 0 5 7 0 0 7 5 5 7 4 6 6 0 5 4 9085 +4 7 15 5 15 54 177 2 95 233 114 208 5 9 11 4 3 12 13 2 6 9 14 1 6 11 11 2 1 9 13 6 2 11 11 6 1 6 9 1 3 0 11 6 6 13 13 6 2 5 9 1 4 13 14 6 5 8 10 0 4 11 14 0 4 5 8 1 0 12 14 5 0 5 0 +4 11 6 6 7 139 223 174 235 40 180 218 225 251 71 214 5 3 3 1 7 4 4 0 1 0 1 8 6 5 5 0 5 3 3 6 7 3 5 4 0 1 5 9 10 5 5 3 1 4 3 5 4 1 2 9 778 +4 7 6 3 2 75 129 179 44 227 132 140 1 2 2 3 5 1 1 3 1 3 3 44 +4 14 16 0 10 14 65 223 57 196 9 81 98 46 174 198 172 188 155 6 9 11 12 3 0 9 4 9 9 14 4 10 1 2 7 2 14 14 3 8 9 12 13 13 10 14 10 12 9 10 3 9 1 5 6 2 15 15 8 10 5 11 8 15 1 11 3 8 11 2 0 140 +4 15 11 10 24 166 185 162 43 21 108 187 98 246 237 243 109 75 5 251 10 10 10 11 0 4 9 7 11 2 9 5 13 10 10 11 6 8 9 1 12 6 9 11 5 4 4 8 2 10 10 10 11 8 8 1 12 1 9 13 0 0 5 9 9 2 4 14 3 2 8 5 0 0 9 2 2 7 9 13 13 0 5 12 4 1 2 12 1 4 8 6 0 5 7 10 0 10 10 6 9 8 8 11 9 9 10 3 12 0 9 5 11 8 9 11 40 9 10 9 9 7 10 5 10 1 2 5 2 1 3 7 7 1 1 4 10 1 0 5 6 3 9 7 10 6 9 3 4 5 2 9 6 5 1 2 8 8 7492 +4 8 8 6 12 212 166 159 112 129 140 16 2 3 3 4 3 0 5 5 0 1 0 3 5 2 6 7 2 7 6 7 0 2 0 6 7 5 2 7 1 1 0 0 5 7 5 7 4 4 3 7 6 0 4 6 7 2 5 7 6 0 6 0 +4 2 15 1 9 114 53 0 13 14 0 1 10 11 0 1 13 13 0 0 12 14 1 1 6 12 1 1 9 13 0 0 6 11 1 0 1 1 1 0 0 11 0 0 1 0 +4 15 16 2 20 189 189 62 65 246 222 178 5 221 121 31 205 187 172 46 6 5 7 8 1 2 15 4 10 9 13 12 13 15 15 4 14 4 13 1 4 10 13 14 12 10 14 6 12 3 4 14 6 3 13 9 12 0 13 12 3 15 15 14 1 0 13 14 1 0 6 4 14 3 11 6 13 0 13 9 6 9 10 5 8 1 8 11 4 8 14 10 12 4 15 9 11 4 9 13 10 8 2 13 7 15 0 8 7 1 8 2 620 +4 14 6 10 1 239 71 44 112 211 78 142 99 211 4 197 125 124 147 3 0 5 2 10 3 5 3 3 1 0 0 3 0 4 10 1970 +4 7 14 0 11 229 56 58 155 27 225 20 5 7 12 5 5 12 13 0 0 13 13 6 5 10 13 6 3 9 13 4 1 0 11 6 3 10 13 5 1 13 13 0 6 12 12 2 0 13 13 6 1 3 9 0 3 1 3 11 0 687 +4 9 13 6 15 215 97 105 232 34 136 169 141 211 5 11 12 6 6 10 10 3 8 7 7 3 7 12 12 0 0 9 10 7 7 6 8 6 1 7 11 6 0 12 12 8 2 2 12 2 1 3 6 7 8 5 9 7 3 3 9 5 8 7 11 2 6 3 7 7 6 12 12 1 1 10 3 232 +4 12 14 1 12 113 190 12 233 98 217 44 212 166 86 148 191 8 2 12 0 2 6 7 8 1 4 10 7 10 11 13 10 8 5 6 11 5 11 13 0 11 2 11 2 9 4 5 8 6 0 12 10 6 6 11 7 7 0 1 2 1 2 3 2 10 10 10 4 12 5 11 11 9 11 7 7 2120 +4 4 16 2 18 14 32 160 88 2 11 11 0 2 11 11 1 1 15 15 3 3 7 12 2 3 15 15 1 2 12 13 0 0 5 14 2 2 12 13 3 0 14 14 3 2 0 10 0 2 1 15 3 3 5 8 2 2 4 6 0 1 14 14 2 2 12 15 3 3 3 14 1 0 6 11 2 2 9 12 0 3 4 3 15 0 42 +4 7 4 4 20 23 130 98 61 164 91 172 3 0 3 0 4 3 3 2 3 3 3 5 6 3 3 5 6 3 3 2 1 1 1 2 6 1 3 1 6 1 1 3 1 3 3 0 0 1 3 6 3 1 3 3 3 3 3 0 3 2 3 4 1 3 3 5 4 2 2 0 4 3 3 6 1 2 3 5 6 0 2 5 4 2 2 0 2 1 1 1 1 2 0 23 +4 15 2 7 3 45 103 241 104 83 122 217 179 153 88 120 140 40 232 158 5 0 1 6 14 1 1 8 11 1 1 12 10 1 1 1 1 1 1 0 1 0 1 7 1790 +4 9 12 1 20 80 31 111 217 204 175 133 85 38 5 7 8 0 2 4 11 6 6 6 7 8 4 5 5 0 3 1 9 0 6 2 2 2 1 7 10 6 8 5 7 2 0 4 9 0 5 4 10 6 0 3 9 5 4 0 3 4 0 3 3 8 7 7 9 1 0 2 8 0 4 0 6 4 7 5 8 2 2 9 10 2 0 4 9 2 5 3 9 2 0 1 0 +4 11 12 1 14 254 16 34 69 211 161 60 51 228 120 165 7 2 5 7 10 6 10 5 9 10 10 4 2 8 10 7 8 0 1 1 5 2 10 7 7 9 9 0 4 2 9 4 6 0 9 7 10 8 8 10 6 5 9 10 10 11 11 3 8 7 7 0 2 11 11 5 3 11 4 5 1 48 +4 2 4 1 3 89 93 0 1 3 1 1 1 1 0 0 2 2 0 0 1 0 +4 3 4 1 10 221 146 94 2 2 3 1 1 1 1 2 0 2 2 2 0 0 2 1 1 0 2 2 0 1 2 1 1 3 3 2 1 2 3 1 2 2 2 1 1 2 3 0 40 3 1 2 0 2 2 1 3 2 2 3 3 2 3 0 3 2 0 3 3 0 3 3 3 0 1 0 3 2 1 0 0 3 0 2 0 1 2 0 3 1 4540 +4 6 3 3 16 42 187 163 126 209 104 4 0 0 0 2 1 1 5 1 2 2 5 4 1 1 2 5 0 1 2 5 0 2 5 5 0 2 2 0 0 1 0 0 2 2 2 3 2 2 4 0 1 1 5 4 0 0 5 1 2 2 5 2 0 0 3 2 2 2 4 5 0 2 0 0 3 0 +4 11 9 5 10 216 64 32 138 50 163 43 43 154 86 72 6 3 5 4 4 4 5 0 4 6 7 0 3 4 5 4 9 4 7 10 7 1 2 9 10 6 8 5 6 5 5 3 7 2 2 4 8 7 8 7 10 7 5 7 0 8 2 2 8 5 3 5 1630 +4 3 16 0 21 60 92 179 2 9 13 0 1 2 2 0 1 7 11 1 1 15 15 2 1 8 9 2 0 11 12 1 0 1 5 0 0 0 1 0 1 13 14 1 1 11 15 0 0 15 15 2 0 7 7 2 0 6 12 0 0 8 9 2 0 9 12 0 0 0 4 2 2 15 15 1 0 1 3 2 2 0 4 2 2 3 3 0 0 5 13 1 40 1 11 9 1 3 7 6 13 9 12 8 8 14 11 14 10 12 4 1 10 4 8 0 12 1 12 0 12 10 8 6 0 14 14 6 9 11 0 7 0 1 3232 +4 6 5 2 1 152 247 196 79 89 98 0 0 3 5 0 2 0 +4 6 14 3 3 124 86 197 132 98 209 5 10 12 3 2 6 6 0 5 12 13 1 0 3 0 +4 9 9 0 18 45 179 116 106 210 39 79 223 224 0 8 8 7 3 4 5 2 0 2 3 3 8 0 6 7 2 0 3 3 3 1 5 1 0 3 4 0 1 4 7 2 5 6 6 1 7 5 5 0 7 2 4 5 8 2 2 3 8 0 4 7 0 8 8 0 7 7 8 2 6 7 8 8 0 7 7 3 1 1 4 5 3 2 5 3 3 328 +4 2 12 0 11 153 197 1 3 7 1 1 11 11 1 0 4 7 0 1 10 11 1 0 4 10 0 0 8 11 0 1 3 11 0 1 6 8 1 0 2 6 0 1 6 10 1 1 2 7 0 40 4 7 11 1 3 0 11 4 10 9 5 5 11 5 0 6 11 4 0 9 10 10 1 3 8 7 7 6 3 11 2 2 7 7 4 7 0 11 10 10 0 6120 +4 16 11 7 15 40 84 110 55 74 101 239 51 96 1 78 89 73 145 23 54 2 1 8 13 7 8 10 5 15 4 10 12 8 5 8 3 7 0 5 5 12 7 8 15 4 0 7 15 10 4 10 2 5 1 1 7 2 5 5 8 15 6 6 9 5 8 8 7 7 1 5 2 8 7 10 4 8 0 0 5 40 10 9 1 7 10 4 2 1 5 1 7 7 5 8 4 8 0 9 10 4 2 0 10 10 6 8 8 1 0 1 2 9 5 7 4 2 10 2 3 8 7 3440 +4 11 14 0 3 225 125 78 229 202 250 12 196 38 200 79 9 6 7 2 8 8 9 3 2 10 10 5 10 11 2 5 11 4 10 3 9 6 5 0 2250 +4 6 8 3 5 78 183 187 175 193 94 2 4 6 4 1 2 6 0 1 7 7 4 1 7 7 1 5 1 2 1 1 1 3 175 +4 5 6 1 18 132 120 175 8 98 1 4 4 1 0 3 3 2 1 0 1 1 1 0 5 0 0 5 5 0 4 5 5 4 0 4 4 2 3 5 5 1 1 3 3 1 4 1 1 1 4 4 5 0 2 0 2 3 2 1 5 4 3 0 3 2 4 5 5 4 3 5 5 3 1 5 5 4 4 3 3 2 10 0 1 2 0 2 2 2 5 0 4 2 1339 +4 4 4 2 2 120 128 118 113 1 2 3 2 0 3 3 2 0 2 0 +4 9 4 4 21 196 13 142 10 3 234 157 220 10 2 2 2 3 1 1 3 8 2 0 3 2 8 0 2 4 3 2 2 5 0 1 3 2 5 0 0 5 3 0 1 5 4 0 0 8 3 1 2 1 2 2 2 0 4 0 1 7 7 3 3 8 6 0 0 1 0 1 2 1 0 2 3 6 5 1 3 4 3 1 2 6 8 0 2 5 8 1 1 3 3 2 2 3 0 4 0 +4 2 6 1 23 176 106 1 0 5 0 0 1 5 0 1 1 4 1 0 4 4 1 0 3 5 0 0 4 4 0 1 1 3 0 0 5 5 1 1 2 4 1 1 3 3 0 1 2 2 0 1 5 5 0 1 3 4 0 1 2 5 0 1 3 3 0 0 0 1 1 0 4 4 0 1 1 1 1 1 5 5 0 1 0 5 0 0 2 5 0 1 2 2 1 1 4 4 0 0 1 0 +4 16 2 12 6 133 128 159 222 158 157 41 124 79 39 211 90 56 220 10 242 4 0 1 4 3 0 1 5 14 1 1 13 9 1 1 4 13 1 1 6 9 1 1 6 1 1 12 56 +4 3 15 0 23 113 255 70 2 6 11 2 1 8 11 2 0 0 5 0 1 1 3 2 2 6 10 0 1 12 14 0 0 0 7 0 0 14 14 0 0 5 11 0 1 2 5 1 0 5 12 1 2 8 12 0 1 12 14 2 2 10 11 0 1 3 5 2 0 4 8 1 1 11 14 1 0 2 12 0 0 14 14 0 1 8 14 2 1 11 14 0 2 9 12 0 0 8 13 2 10 12 7 6 7 9 1 12 10 12 5 1 1896 +4 3 13 2 13 128 10 119 0 3 12 0 0 3 10 0 2 9 12 2 2 7 10 2 2 5 11 2 2 6 9 1 0 0 2 1 2 5 11 0 1 10 10 2 1 8 8 2 0 2 8 1 0 9 10 2 2 9 11 2 3 11 5 3 2 357 +4 2 5 1 4 216 174 1 4 4 1 0 2 3 1 1 0 1 0 0 4 4 0 10 2 0 4 1 1 3 2 1 2 2 1 1950 +4 9 6 0 24 243 205 228 97 31 175 1 13 147 7 1 3 2 0 5 5 2 6 2 5 1 6 4 4 3 2 0 5 2 4 1 2 6 5 4 5 0 1 1 1 7 6 2 2 7 4 3 4 1 6 2 4 8 5 4 5 7 5 3 4 6 0 5 5 1 5 5 5 6 8 0 5 2 4 1 4 5 0 2 3 6 1 0 3 0 6 3 3 8 7 1 5 4 5 0 2 3 4 5 5 3 6 4 4 2 10 1 4 4 3 5 0 1 4 4 0 0 2150 +4 3 14 1 16 91 176 187 1 10 12 1 2 11 11 0 2 6 11 2 2 6 8 0 1 8 10 2 1 13 13 0 2 2 11 1 2 11 12 2 2 5 10 0 1 5 5 0 2 11 12 1 1 6 12 1 0 4 6 1 0 8 9 2 2 1 10 0 2 11 12 1 3 6 11 10 1 528 +4 13 5 5 5 90 90 213 164 79 50 5 35 83 253 193 252 183 3 2 3 2 5 1 1 3 5 1 3 7 1 3 4 1 11 0 0 3 1 1 3 164 diff --git a/tests/reuse-eval/run.om b/tests/reuse-eval/run.om new file mode 100644 index 0000000..f2a923d --- /dev/null +++ b/tests/reuse-eval/run.om @@ -0,0 +1,685 @@ +note SPDX-License-Identifier: Apache-2.0 +note Compile standalone. From repo root: run OMC [PREFIX]. See docs/reuse-eval/README.md. +global RVB uchar 65536 +global RVH uchar 4096 +global RVS uchar 65536 +global RVL ulong 16 +global RVN uchar 65536 +global RVNL ulong 256 +global RVP uchar 4096 +global RVPN ulong 2 +global RVW uchar 4 +global RVC ulong 8 +text RVU "om/reuse-eval/" +text RVTEST "tests/reuse-eval/" +text RVOM ".om" +text RVUNITS "note units: " +text RVNEEDS "note needs: " +text RVFIX "note fixture:" +text RVTMP "/tmp/reuse-test-run-" +text RVERR ".err" +text RVEXE ".elf" +text RVGEN "sha256 ref gen" +text RVEVAL "sha256 ref stats turing receipt judge main" +text RVARM "sha256 ref judge" +text RVAF "judge-arm.om" +text RVDF "judge-drive.om" +text RVPASS "PASS " +text RVFAIL "FAIL " +text RVRC " rc=" +text RVTOTAL "TOTAL pass=" +text RVF " fail=" + +fn rvclear r ulong to void +put RVL r 0 +end +fn rvch r ulong c uchar to void +n = get RVL r +if ge n 4095 +trap 3 +end +put RVS add mul r 4096 n c +put RVL r add n 1 +end +fn rvnum r ulong v ulong to void +a = new uchar 24 0 +n = ulong 0 +x = v +while true bound 24 +put a n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +if eq x 0 +break +end +end +while gt n 0 bound 24 +n = sub n 1 +rvch r get a n +end +end +fn rvcopy r ulong s ulong to void +rvclear r +for i ulong get RVL s +rvch r get RVS add mul s 4096 i +end +end +fn rvarg r ulong i ulong to void +n = argread i RVS mul r 4096 4095 +if lt n 0 +exit 2 +end +put RVL r ulong n +end +fn rvtext r ulong s view uchar 4096 n ulong to void +for i ulong n +rvch r get s i +end +end +fn rvopen r ulong flags int to long +ret fopen RVS mul r 4096 get RVL r flags 420 +end +fn rvout r ulong to void +rvch r 10 +w = write 1 RVS mul r 4096 get RVL r +put RVL r sub get RVL r 1 +end +fn rvabs r ulong to void +if eq get RVS mul r 4096 47 +ret +end +n = cwd RVB 0 4096 +rvclear 15 +for i ulong sub ulong n 1 +rvch 15 get RVB i +end +rvch 15 47 +for i ulong get RVL r +rvch 15 get RVS add mul r 4096 i +end +rvcopy r 15 +end +fn rvpk0 to void +put RVPN 0 2 +put RVPN 1 0 +end +fn rvpkb c uchar to void +n = get RVPN 0 +put RVP n c +put RVPN 0 add n 1 +end +fn rvpk r ulong to void +n = get RVL r +rvpkb uchar and n 255 +rvpkb uchar shr n 8 +for i ulong n +rvpkb get RVS add mul r 4096 i +end +put RVPN 1 add get RVPN 1 1 +end +fn rvpkend to void +put RVP 0 uchar and get RVPN 1 255 +put RVP 1 uchar shr get RVPN 1 8 +end +fn rvwait pid int limit long to ulong +dl = add monons limit +while true bound 999999 +r = waitpid pid RVW 0 4 1 +if eq r long pid +sig = and ulong get RVW 0 127 +if ne sig 0 +ret add 256 sig +end +ret ulong get RVW 1 +end +if lt r 0 +ret 1023 +end +if gt monons dl +k = killpid pid 9 +r = waitpid pid RVW 0 4 0 +ret 521 +end +s = sleepns 1000000 +end +ret 1023 +end +fn rvexec limit long to ulong +rvpkend +pid = fork +if lt pid 0 +ret 1023 +end +if eq pid 0 +x = execprog RVP 0 get RVPN 0 +exit 127 +end +ret rvwait int pid limit +end +fn rvcopyfd fd int path ulong to bool +x = rvopen path 0 +if lt x 0 +ret false +end +rd = int x +while true bound 999999 +n = read rd RVB 0 65536 +if lt n 0 +c = fclose rd +ret false +end +if eq n 0 +break +end +w = write fd RVB 0 ulong n +if ne w n +c = fclose rd +ret false +end +end +c = fclose rd +ret true +end +fn rvappendunit fd int off ulong n ulong to bool +rvclear 0 +for i ulong len RVU +rvch 0 get RVU i +end +for i ulong n +rvch 0 get RVH add off i +end +for i ulong len RVOM +rvch 0 get RVOM i +end +ret rvcopyfd fd 0 +end +fn rvwhite p ulong to bool +c = get RVH p +ret or eq c 32 eq c 10 +end +fn rvunits fd int off ulong n ulong to bool +p = off +stop = add off n +while lt p stop bound 100 +if or eq get RVH p 32 eq get RVH p 10 +p = add p 1 +continue +end +start = p +while lt p stop bound 100 +if rvwhite p +break +end +p = add p 1 +end +if not rvappendunit fd start sub p start +ret false +end +end +ret true +end + +note compile source register 7 to ELF register 8, using OMC register 1; source temp register 9. +fn rvcompile to ulong +rvpk0 +rvpk 1 +rvpkend +x = rvopen 7 0 +if lt x 0 +ret 1023 +end +rd = int x +x = rvopen 8 577 +if lt x 0 +c = fclose rd +ret 1023 +end +wr = int x +pid = fork +if lt pid 0 +ret 1023 +end +if eq pid 0 +c = dupfd rd 0 0 +c = dupfd wr 1 0 +x = execprog RVP 0 get RVPN 0 +exit 127 +end +c = fclose rd +c = fclose wr +rc = rvwait int pid 120000000000 +if eq rc 0 +c = chmod RVS 32768 get RVL 8 493 +end +ret rc +end + +note compose a test source at register 4, first line note units; output source register 7. +fn rvcompose to bool +x = rvopen 4 0 +if lt x 0 +ret false +end +rd = int x +n = read rd RVH 0 4096 +c = fclose rd +if lt n long len RVUNITS +ret false +end +for i ulong len RVUNITS +if ne get RVH i get RVUNITS i +ret false +end +end +p = ulong 0 +while and lt p ulong n ne get RVH p 10 bound 4096 +p = add p 1 +end +put RVC 4 p +x = rvopen 7 577 +if lt x 0 +ret false +end +fd = int x +ok = rvunits fd len RVUNITS sub p len RVUNITS +if ok +ok = rvcopyfd fd 4 +end +c = fclose fd +ret ok +end + +note build gen/eval/arm in the run scratch; kind 0 gen, 1 eval, 2 arm, 3 stats, 4 turing, 5 receipt. +fn rvbin kind ulong to bool +rvcopy 7 3 +rvch 7 47 +rvch 7 98 +rvnum 7 kind +for i ulong len RVOM +rvch 7 get RVOM i +end +rvcopy 8 3 +rvch 8 47 +rvch 8 98 +rvnum 8 kind +for i ulong len RVEXE +rvch 8 get RVEXE i +end +x = faccess RVS 32768 get RVL 8 1 +if eq x 0 +ret true +end +rvclear 4 +n = ulong 0 +if eq kind 0 +for i ulong len RVGEN +put RVH i get RVGEN i +end +n = len RVGEN +else +n = rvbinwords kind +end +x = rvopen 7 577 +if lt x 0 +ret false +end +fd = int x +ok = rvunits fd 0 n +if ge kind 2 +for i ulong len RVTEST +rvch 4 get RVTEST i +end +rvfixture kind +ok = and ok rvcopyfd fd 4 +end +c = fclose fd +if not ok +ret false +end +ret eq rvcompile 0 +end +fn rvbinwords kind ulong to ulong +if eq kind 1 +for i ulong len RVEVAL +put RVH i get RVEVAL i +end +ret len RVEVAL +end +for i ulong len RVARM +put RVH i get RVARM i +end +ret len RVARM +end +fn rvfixture kind ulong to void +if eq kind 2 +for i ulong len RVAF +rvch 4 get RVAF i +end +else +for i ulong len RVDF +rvch 4 get RVDF i +end +end +end + +note load directory names from tests/reuse-eval/; only *.om, sorted lexicographically. +fn rvlist to ulong +rvclear 0 +for i ulong len RVTEST +rvch 0 get RVTEST i +end +x = rvopen 0 0 +if lt x 0 +ret 0 +end +fd = int x +count = ulong 0 +while true bound 1000 +n = getdnts fd RVB 0 65536 +if le n 0 +break +end +p = ulong 0 +while lt p ulong n bound 1000 +rl = rvrec add p 16 +count = rvname add p 19 count +p = add p rl +end +end +c = fclose fd +for i ulong count +for j ulong i +if rvless i j +rvswap i j +end +end +end +ret count +end +fn rvrec p ulong to ulong +ret or ulong get RVB p shl ulong get RVB add p 1 8 +end +fn rvname p ulong n ulong to ulong +k = ulong 0 +while ne get RVB add p k 0 bound 256 +k = add k 1 +end +if or lt k 4 ge n 256 +ret n +end +if ne get RVB add p sub k 3 46 +ret n +end +if ne get RVB add p sub k 2 111 +ret n +end +if ne get RVB add p sub k 1 109 +ret n +end +if eq k 6 +if and eq get RVB p 114 eq get RVB add p 1 117 +ret n +end +end +if not rvprefix p k +ret n +end +put RVNL n k +for i ulong k +put RVN add mul n 256 i get RVB add p i +end +ret add n 1 +end +fn rvprefix p ulong k ulong to bool +for i ulong get RVL 2 +if ge i k +ret false +end +if ne get RVB add p i get RVS add 8192 i +ret false +end +end +ret true +end +fn rvless a ulong b ulong to bool +n = get RVNL a +if gt n get RVNL b +n = get RVNL b +end +for i ulong n +x = get RVN add mul a 256 i +y = get RVN add mul b 256 i +if lt x y +ret true +end +if gt x y +ret false +end +end +ret lt get RVNL a get RVNL b +end +fn rvswap a ulong b ulong to void +for i ulong 256 +x = get RVN add mul a 256 i +put RVN add mul a 256 i get RVN add mul b 256 i +put RVN add mul b 256 i x +end +n = get RVNL a +put RVNL a get RVNL b +put RVNL b n +end +fn rvtestpath i ulong to void +rvclear 4 +for j ulong len RVTEST +rvch 4 get RVTEST j +end +for j ulong get RVNL i +rvch 4 get RVN add mul i 256 j +end +end +fn rvmatch off ulong t view uchar 12 to bool +for i ulong 12 +if ne get RVH add off i get t i +ret false +end +end +ret true +end + +note need tokens parsed before binary builds (which reuse RVH); registers 10..14 hold argv values. +fn rvneeds to ulong +n = ulong 0 +p = add get RVC 4 1 +if gt add p len RVNEEDS 4096 +ret 0 +end +for i ulong len RVNEEDS +if ne get RVH add p i get RVNEEDS i +ret 0 +end +end +p = add p len RVNEEDS +while ne get RVH p 10 bound 100 +if eq get RVH p 32 +p = add p 1 +continue +end +r = add 10 n +rvclear r +while and ne get RVH p 10 ne get RVH p 32 bound 100 +rvch r get RVH p +p = add p 1 +end +n = add n 1 +if ge n 5 +break +end +end +ret n +end +fn rvkind r ulong to ulong +v = ulong 0 +for i ulong get RVL r +v = or v shl ulong get RVS add mul r 4096 i mul i 8 +end +if eq v 7234919 +ret 0 +end +if eq v 1818326629 +ret 1 +end +if eq v 7172705 +ret 2 +end +if eq v 435778318948 +ret 3 +end +if eq v 6516079 +ret 6 +end +ret 99 +end +fn rvneedbins n ulong to bool +for i ulong n +r = add i 10 +k = rvkind r +if eq k 6 +rvcopy r 1 +continue +end +if gt k 3 +ret false +end +if not rvbin k +ret false +end +rvcopy r 8 +end +ret true +end + +fn rvtest i ulong to ulong +rvtestpath i +rvcopy 7 3 +rvch 7 47 +rvch 7 116 +rvnum 7 i +for j ulong len RVOM +rvch 7 get RVOM j +end +rvcopy 8 3 +rvch 8 47 +rvch 8 116 +rvnum 8 i +for j ulong len RVEXE +rvch 8 get RVEXE j +end +if not rvcompose +ret 1024 +end +p = add get RVC 4 1 +fix = true +for j ulong len RVFIX +if ne get RVH add p j get RVFIX j +fix = false +end +end +if fix +ret 1025 +end +needs = rvneeds +rc = rvcompile +if ne rc 0 +ret add 2048 rc +end +rvcopy 6 8 +if not rvneedbins needs +ret 1026 +end +rvcopy 5 3 +rvch 5 47 +rvch 5 115 +rvnum 5 i +c = makedir RVS 20480 get RVL 5 448 +rvpk0 +rvpk 6 +rvpk 5 +for j ulong needs +rvpk add j 10 +end +ret rvexec 120000000000 +end +fn rvreport i ulong rc ulong to void +rvclear 0 +if eq rc 0 +for j ulong len RVPASS +rvch 0 get RVPASS j +end +else +for j ulong len RVFAIL +rvch 0 get RVFAIL j +end +end +for j ulong get RVNL i +rvch 0 get RVN add mul i 256 j +end +if ne rc 0 +for j ulong len RVRC +rvch 0 get RVRC j +end +rvnum 0 rc +end +rvout 0 +end +fn main to int +if or lt argcnt 2 gt argcnt 3 +ret 2 +end +rvarg 1 1 +rvabs 1 +rvclear 2 +if eq argcnt 3 +rvarg 2 2 +end +rvclear 3 +for i ulong len RVTMP +rvch 3 get RVTMP i +end +rvnum 3 ulong getpid +c = makedir RVS 12288 get RVL 3 448 +if ne c 0 +ret 3 +end +n = rvlist +pass = ulong 0 +fail = ulong 0 +for i ulong n +rc = rvtest i +if eq rc 1025 +continue +end +rvreport i rc +if eq rc 0 +pass = add pass 1 +else +fail = add fail 1 +end +end +rvclear 0 +for i ulong len RVTOTAL +rvch 0 get RVTOTAL i +end +rvnum 0 pass +for i ulong len RVF +rvch 0 get RVF i +end +rvnum 0 fail +rvout 0 +if eq n 0 +ret 4 +end +if gt fail 0 +ret 1 +end +ret 0 +end diff --git a/tests/reuse-eval/stats-decide.om b/tests/reuse-eval/stats-decide.om new file mode 100644 index 0000000..82cb5f6 --- /dev/null +++ b/tests/reuse-eval/stats-decide.om @@ -0,0 +1,287 @@ +note units: stats +note SPDX-License-Identifier: Apache-2.0 +note stats-decide: the contract 10 decision (with K7 control outcomes) as a truth table over the +note globals stdecide reads. Every STOP, GO and INVESTIGATE branch and the boundary values +note (ppm 999999 versus 1000000, coverage exactly one half, no transfer QUERY) are covered, plus +note a missing (control, sub-case) pair (not run), K17 failed processes (END failure, nonzero +note exit: wrong refusal, STOP; echo is not scored) and the controls.log record checks +note (unknown sub-case and repeated pair refused with code 13). +note Return value of stdecide: 1 GO, 2 INVESTIGATE, 3 STOP; STDEC 1 holds the reason bits. +note Exit 0 = pass; otherwise the failing case number. + +note the GO state: every bound below 1, coverage 5 of 10, C1..C11 detected, C12 reported, every +note required sub-case present +fn tdbase to void +streset +for s ulong 13 +put STLO s 500000 +put STHI s 500000 +end +stcadd 4 17 10 +stcadd 4 18 5 +for c ulong 14 +b = mul add c 1 8 +put STCT b 1 +put STCT add b 6 stcreq add c 1 +if eq c 13 +put STCT add b 3 1 +else +put STCT add b 1 1 +end +end +end + +note controls.log record k in STFB: control c, sub-case s, outcome o +fn tdrec k ulong c ulong s ulong o ulong to void +v = new ulong 8 0 +put v 0 c +put v 1 s +put v 2 o +for w ulong 8 +tdword add mul k 64 mul w 8 get v w +end +end + +note one little-endian word at byte p of STFB +fn tdword p ulong x ulong to void +for b ulong 8 +put STFB add p b uchar and shr x mul b 8 255 +end +end + +note stctl1 on record 0 = (c, s, 1) after streset; returns STRF 2 when refused (13), 9 when +note accepted, 99 on another code +fn tdone c ulong s ulong to ulong +streset +tdrec 0 c s 1 +e = stctl1 0 +if eq e 0 +ret 9 +end +if ne e 13 +ret 99 +end +ret get STRF 2 +end + +note the 36 (control, sub-case) pairs of EvalJudge's controls run (controls-dev2/controls.log, +note confirmed by EvalJudge), written here independently of stcreq as control*10 + sub-case +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 " + +note every listed pair is accepted, no pair is missing, and there are exactly 36 +fn tdlist to int +streset +k = ulong 0 +v = ulong 0 +for i ulong len TDL +c = get TDL i +if eq c 32 +tdrec k div v 10 rem v 10 1 +k = add k 1 +v = 0 +else +v = add mul v 10 ulong sub c 48 +end +end +if ne k 36 +ret 50 +end +for j ulong k +if ne stctl1 j 0 +ret 51 +end +end +for c ulong 14 +if ne stcmiss add c 1 0 +ret 52 +end +end +ret 0 +end + +fn tdctl to int +if ne tdone 3 1 2 +ret 30 +end +if ne tdone 10 0 2 +ret 31 +end +if ne tdone 10 10 2 +ret 32 +end +if ne tdone 7 5 9 +ret 33 +end +if ne tdone 10 9 9 +ret 34 +end +streset +tdrec 0 8 2 1 +tdrec 1 8 2 1 +if ne stctl1 0 0 +ret 35 +end +if or ne stctl1 1 13 ne get STRF 2 3 +ret 36 +end +if ne stcmiss 8 2 +ret 37 +end +if ne stcout 8 3 +ret 38 +end +ret 0 +end + +fn tdk17 to int +tdbase +stpexit 4 1024 +if not tdis 3 2 +ret 41 +end +if or ne stc 4 27 1 ne stc 4 28 1 +ret 42 +end +tdbase +stpexit 7 1 +if or not tdis 3 2 ne stc 7 27 0 +ret 43 +end +tdbase +stpexit 2 0