omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / docs / polyglot / review-polyglot-0.md
| 1 | # POLYGLOT-0 independent adversarial review (lane G) |
| 2 | |
| 3 | > **Lane B3 (Mojo) removed on 2026-10-15.** Modular MAX and Mojo were dropped from AIEN, and the Mojo lane's source, |
| 4 | > build rules and test were deleted from this repo. Mojo text below is the original design record, kept unchanged; |
| 5 | > the Mojo receipts stay in `evidence/`. |
| 6 | |
| 7 | Reviewer: worker G (Opus 5.5), did not author any reviewed code. |
| 8 | Reviewed: branch `feat/polyglot-0` at 17d2854 (worktree `~/workspace/omega-polyglot-review`, branch `polyglot/review`). |
| 9 | Scope: `spec/polyglot-0.md`, `docs/polyglot/POLYGLOT_AGENT_OWNERSHIP.md`, `mk/polyglot*.mk`, `src/polyglot/**`, |
| 10 | `polyglot/mojo/omx_mojo.mojo`, `tests/polyglot/**`. |
| 11 | |
| 12 | What was run (correctness only, plus one smoke bench; no full timed bench): |
| 13 | |
| 14 | - `build/polyglot/verify_polyglot` (plain, 2,000 and 20,000 random) and `_asan`: PASS, 18 candidates. |
| 15 | - `make test-polyglot-asm`, `test-polyglot-encoder`, `test-polyglot-mojo`: PASS (encoder byte compare 356/356 identical). |
| 16 | - `make bench-polyglot-smoke` (`.spark-quiet` absent, load 1.0): 72 receipts in `build/polyglot/smoke`. |
| 17 | - `polyglot_explain` on the smoke receipts, twice (byte-identical), plus tampered copies (below). |
| 18 | - 10 mutants (5 assembly edits in this worktree, restored after each run; 5 C mutant candidates in a scratch lane |
| 19 | file linked in place of the Mojo lane) and one callee-saved-register sentinel harness (appendix). |
| 20 | |
| 21 | Headline: the shipped kernels are correct on everything I threw at them, and they preserve callee-saved registers. |
| 22 | The weak spots are the gate machinery: the bench breaks its own 1 ms rule on S1, two receipt fields are wrong |
| 23 | for Mojo and the encoder, and the shared verifier misses five of my ten mutants. |
| 24 | |
| 25 | ## Mutant results |
| 26 | |
| 27 | | id | defect injected | verify plain | verify ASan | lane test | bench would catch | |
| 28 | |---|---|---|---|---|---| |
| 29 | | A | `asm_crumb` reads 16 B past the end of the packed weights (`ldr q5,[x5]` at `.Lcr_ok`) | **missed** | **missed** | caught (test-polyglot-asm segfault) | no | |
| 30 | | B | `asm_sdot` tail mask off by one lane | caught (41,376 fails) | caught | n/a | yes | |
| 31 | | C | `asm_sdot` zeroes d8 and d15 (callee-saved) | **missed** | **missed** | **missed** (test-polyglot-asm PASS) | no | |
| 32 | | D | `asm_sdot` zeroes x27, x28 | caught (crash) | caught (crash) | caught (crash) | n/a | |
| 33 | | E | `asm_sdot` reads x[n..n+15] | caught (guard fault) | caught | n/a | n/a | |
| 34 | | M1 | `-1 * x` computed as int8 negation (wrong only at x = -128) | caught (32,760 fails) | | | | |
| 35 | | M2 | weight column offset kept in 16 bits (wraps at n > 65536) | **missed** | | | **no** (n <= 4096) | |
| 36 | | M3 | rows with index >= 301 off by one | **missed** | | | yes (S3, m = 4096) | |
| 37 | | M4 | memoises the last two results keyed on (plan, x pointer, m, n, first 16 bytes of x) | **missed** | | | **no**, and would win S1-S3 | |
| 38 | | M5 | vectorised validator: only the last (m*n) % 16 weights really validated | **missed** | | | no | |
| 39 | |
| 40 | Commands: `/tmp/pgrev/mut.sh NAME FILE 'perl-subst' [asm]` (applies the edit, builds into |
| 41 | `build-mut/NAME`, runs both verifiers and optionally `test-polyglot-asm`, then `git checkout` the file). |
| 42 | C mutants: `/tmp/pgrev/mut_lane.c` defines a strong `omx_lane_mojo[]`; built with |
| 43 | `cc -std=gnu11 -O2 -march=armv8.6-a+dotprod+i8mm+sve -Isrc -o verify_mut tests/polyglot/verify_polyglot.c |
| 44 | src/polyglot/omx_lang.c src/polyglot/omx_bench.c src/sha256.c mut_lane.c build/polyglot/o2/*.o -lm`. |
| 45 | The mutant bodies are quoted in the findings below so they can be recreated without `/tmp`. |
| 46 | |
| 47 | ## BLOCKING |
| 48 | |
| 49 | ### G-B1. Timed samples on S1 are shorter than the 1 ms the spec requires |
| 50 | `tests/polyglot/bench_polyglot.c:647-655` (calibration) and `:670-686` (sampling). Spec section 7, gate 10.5. |
| 51 | |
| 52 | Calibration times ONE call with two `clock_gettime` reads around it, so for S1 (about 35 ns per call) the timer |
| 53 | overhead dominates: `one` came out as 64 ns for R1_sdot, giving reps = ceil(1.25e6 / 64) = 19,532 and a real sample |
| 54 | of 19,532 x 36.3 ns = 0.71 ms. Nothing checks the sample length afterwards. |
| 55 | Smoke run evidence (`calls_per_sample * latency median` from the receipts): 13 of 18 S1 cells are below 1 ms, |
| 56 | from 0.709 ms (R1_sdot, R1_sdot@O3) to 0.991 ms (R1_smmla). S2-S4 are fine. |
| 57 | Fix: calibrate with a doubling loop of `sample()` until one sample is >= 1 ms, and reject or re-take any sample with |
| 58 | `t < 1e6` (count it in the receipt). |
| 59 | |
| 60 | ### G-B2. `code_size_bytes` is wrong for Mojo and the own encoder; encoder compile time measures the wrong thing |
| 61 | `tests/polyglot/bench_polyglot.c:342-343, 403-406`; `src/polyglot/omx_mojo.c:48-80`; `src/polyglot/omx_encoder.c:671-679`. |
| 62 | Spec section 7 ("code size of the realization's text section"). |
| 63 | |
| 64 | The rule "run + pack function symbol sizes" resolves `im->run` to the C adapter, not the realization: |
| 65 | MJ1_sdot/MJ2c_crumb report `run_i8`/`run_crumb` = 72 B (the Mojo kernels `omx_mj_i8_run` etc. are not counted); |
| 66 | enc_sdot/enc_crumb report `enc_*_run` = 112 B (a thunk; the 156 / 200 emitted instructions = 624 / 800 B are not |
| 67 | counted). asm_sdot correctly reports 624 B. A ledger built from these receipts would say Mojo's run code is 9x |
| 68 | smaller than hand assembly. Encoder `compile_time_s_min_of_5` (0.189 s) is the gcc compile of |
| 69 | `omx_encoder.c`, not the time Omega's encoder takes to emit the kernel at run time. |
| 70 | Fix: let each lane name its realization symbols (or byte count) in `omx_candidate`; for the encoder use |
| 71 | `omx_encoder_code(k, &bytes)` and time `omx_encoder_build`. |
| 72 | |
| 73 | ## SHOULD-FIX |
| 74 | |
| 75 | ### G-S1. Shared verifier never guards the packed weights; non-C kernels are not ASan-instrumented |
| 76 | `tests/polyglot/verify_polyglot.c:187-201`. Mutant A. |
| 77 | Guard pages surround the canonical W, but run kernels read `p->mem` (heap, from `oma_rz_alloc`, rounded to 64 B). |
| 78 | ASan does not see assembly, JIT code or the Mojo object. Mutant A (16-byte over-read past the packed buffer) PASSES |
| 79 | both verifier builds. B1 and B2's own tests move `p->mem` against a guard page and catch it; the Mojo lane test has no |
| 80 | guard pages at all, so a Mojo packed-weight over-read is caught by nothing. Fix: in `run_case`, copy `p.mem` into a |
| 81 | guarded buffer (flush against the trailing guard, and once flush against the leading one) for every candidate, as |
| 82 | `tests/polyglot/test_asm.c:172-190` does. |
| 83 | |
| 84 | ### G-S2. Random cases never reach n > 65536 with random data, or m > 300 |
| 85 | `tests/polyglot/verify_polyglot.c:341-357`. Mutants M2, M3. |
| 86 | Random n <= 8200 and m <= 300; the only n > 65536 cases (`:345, :347, :348`) use all -1 or all +1 weights with |
| 87 | x = -128, so a 16-bit column wrap reads a different column with the same value and passes (M2: |
| 88 | `a += W[i*n + (uint16_t)j] * x[j]`, 0 failures). M3 (`y[i] += 1` for i >= 301) passes the verifier; only the bench's |
| 89 | S3 check would catch it, without guard pages. Fix: add random-data cases at the four bench shapes (S3 is |
| 90 | m = 4096, n = 4096) and at n in {65537, 131073, 1,000,003} with m in {1, 5}, plus a few with m in 1000-4100. |
| 91 | |
| 92 | ### G-S3. Error contract tested only on a 2x3 matrix |
| 93 | `tests/polyglot/verify_polyglot.c:232-260`. Mutant M5. |
| 94 | Six weights never reach a 16-byte vector body, so a validator that only checks the scalar tail passes |
| 95 | (M5: loop `for (i = (m*n) & ~15; i < m*n; i++)`). MJ1_sdot's pack is exactly this shape |
| 96 | (`polyglot/mojo/omx_mojo.mojo:67-72`); it is correct today and the Mojo lane test covers it (shapes up to 7x129), |
| 97 | but the shared gate does not. Fix: bad weight at first, last and a random position for shapes like 4x65, 7x129, |
| 98 | 3x1000. |
| 99 | |
| 100 | ### G-S4. No test checks callee-saved registers |
| 101 | Mutant C (d8 and d15 zeroed in `asm_sdot`) passes verify plain, verify ASan and `test-polyglot-asm`. x19-x28 |
| 102 | clobbers happen to crash the caller (mutant D), d8-d15 clobbers are silent. Current code is clean: the sentinel |
| 103 | harness in the appendix ran all 18 candidates on 7 shapes (126 calls), 0 clobbers of x19-x28 / d8-d15; the same |
| 104 | harness flags mutant C on all 7 shapes. Fix: add the trampoline to `test_asm.c` and `test_encoder.c` |
| 105 | (or the shared verifier). |
| 106 | |
| 107 | ### G-S5. The bench cannot detect a memoising candidate |
| 108 | `tests/polyglot/bench_polyglot.c:67-69, 176-190`. Mutant M4. |
| 109 | S1-S3 use one x (`nx = 1`), so every call in a sample has identical inputs and the checksum is the same whether or |
| 110 | not the kernel ran. M4 (returns a cached y when plan, x pointer, m, n and the first 16 bytes of x match) passes the |
| 111 | verifier (the verifier never calls run twice in a row with the same x) and would report near-zero latency on S1-S3. |
| 112 | My own lanes do not do this; the harness should still make it impossible. Fix: rotate at least 2 x vectors per |
| 113 | workload (S4 already rotates 256), or flip one byte of x between calls and fold it into the expected checksum. |
| 114 | |
| 115 | ### G-S6. Explainer selects from smoke, N < 20, and leftover receipts of other runs |
| 116 | `tests/polyglot/polyglot_explain.c:225, 316-323, 378-389`. |
| 117 | `gate_eligible` and `smoke` only print a NOTE. Run on the smoke receipts it prints SELECT/CHOSEN lines from N = 3 |
| 118 | data. Tamper test: copy the smoke receipts, add `ghost_sdot__S1.json` (asm_sdot with id renamed, run_id |
| 119 | `...-OLDRUN`, median 1.0): the explainer lists both runs and SELECTS `ghost_sdot` for S1 (median 1.0 with min 35.2 |
| 120 | is not questioned). This becomes blocking if `evidence/POLYGLOT/` ever holds more than one run. Fix: eligibility |
| 121 | requires `gate_eligible`, `tree_dirty_files == 0`, one `run_id` (or one per workload, refused otherwise), and |
| 122 | `min <= median`. |
| 123 | |
| 124 | ### G-S7. Noise band too narrow to support "CHOSEN" |
| 125 | `tests/polyglot/polyglot_explain.c:405`. |
| 126 | Band = 3 x max(MAD/median) from within-run samples. On S1 the smoke run gives asm_sdot MAD 0.0 and R1_sdot@O3 a 0.2% |
| 127 | band, so a 3.2% gap is called CHOSEN. Within-run MAD does not include run-to-run, core-to-core or boot-state spread |
| 128 | (see the X925 clock-cap episode). Fix: a floor (for example 2%) or a second full run on a different X925 core that |
| 129 | must agree before CHOSEN is printed; report TIE otherwise. |
| 130 | |
| 131 | ### G-S8. Own-encoder candidate breaks section 1's "effects: none" and run's error contract |
| 132 | `src/polyglot/omx_encoder.c:620-676`. |
| 133 | The first `run()` call does `mmap` + `mprotect` (global state, a syscall) through `pthread_once`, and if that fails |
| 134 | every later `run()` returns `OMA_RZ_E_NOMEM`, which section 1 lists only for pack. W^X and cache maintenance are |
| 135 | right (RW, write, mprotect RX, then `__builtin___clear_cache` on the code range; DC CVAU on a read-only page is |
| 136 | allowed), and `test_encoder.c` checks the mapping permissions. Fix: build the code in `pack` (or an explicit init |
| 137 | step recorded in the plan), or add the exception to section 1. |
| 138 | |
| 139 | ### G-S9. Compile time comparability |
| 140 | `tests/polyglot/bench_polyglot.c:212-252`, `mk/polyglot.mk:141-153`. |
| 141 | Compile commands run as children of the pinned bench process, so they inherit one-core affinity: `mojo build` |
| 142 | (multithreaded) is handicapped relative to gcc. C timings compile the whole MA-3 file (4 realizations per object, |
| 143 | noted in the receipt). Record the affinity in `compile_note`, or unpin before timing compiles. |
| 144 | |
| 145 | ## NOTE |
| 146 | |
| 147 | - N1. Contract digest covers section 1 only (`src/polyglot/omx_bench.c:72-95`), as section 8 says. Changing section 7 |
| 148 | (tested: "N >= 20" to "N >= 2") leaves every receipt "not stale". Gate 10.1 says "this contract, unchanged"; |
| 149 | consider hashing sections 1-7. |
| 150 | - N2. `spec/polyglot-0.md:16` says overlap of y with W/x is "checked by the verifier". The verifier never builds an |
| 151 | overlapping case; it only never creates one. Reword ("never produced by the verifier"). |
| 152 | - N3. y is always 4-byte aligned (`verify_polyglot.c:159, 226`); all 16-byte residues are covered. Fine for `int32_t *`, |
| 153 | but gate 10.3 says "unaligned x and y". |
| 154 | - N4. The size-overflow case accepts `E_NOMEM` as well as `E_OVERFLOW` (`verify_polyglot.c:278-280`); all candidates |
| 155 | actually return `E_OVERFLOW` via `oma_rz_check_shape`. |
| 156 | - N5. The verifier memsets the plan before pack, so a pack that returns early without clearing `*p` is invisible |
| 157 | (same as MA-3; the Mojo adapter returns shape errors before its memset, `omx_mojo.c:27-31`). |
| 158 | - N6. Undeclared stack scratch: `asm_crumb` uses 64 B of stack (`omx_crumb.S:73`), Mojo `load_x64` a 64-byte |
| 159 | temporary; `scratch_bytes` is 0 for both. |
| 160 | - N7. S4 cannot be compute-bound by construction: the GEMV ABI re-reads all of W for every x, so the 256 x only |
| 161 | rotate. In practice asm_sdot does 64 Ki MAC in 413 ns (about 2.6 SDOT per cycle), close to SDOT throughput, so |
| 162 | the label holds empirically, not by design. |
| 163 | - N8. Round-robin order is fixed (candidate 0 always first in each round); rotate the start per round. |
| 164 | - N9. The schedstat run-delay test does not see IRQ/softirq time on the pinned core. |
| 165 | - N10. The checksum loop (m adds per call) is inside the timed region for every candidate; at most 4,096 adds per |
| 166 | about 0.5 ms S3 call, negligible. |
| 167 | - N11. Flags: the -O3 flavor keeps `-march=...` and adds `-mcpu=native` (generic tune on gcc 13.3), recorded. |
| 168 | Mojo builds for the host CPU (X925 tuning) while C uses generic tuning; the Mojo receipt's `flags` does not |
| 169 | say so, and its toolchain string "mojo 1.0.0" is hard-coded (`omx_mojo.c:97-98`), not read from `mojo --version`. |
| 170 | - N12. Break-even: the bench uses the cheapest pack over all measured candidates, including the weak baseline and |
| 171 | toolchain-only ones (`bench_polyglot.c:708`); the explainer uses eligible ones only. The receipt and the |
| 172 | explanation can disagree. MJ1_sdot packs about 8x cheaper (0.08 ns/weight, vector validation), so it is |
| 173 | the pack reference in most cells. |
| 174 | - N13. `peak_rss_kib` is the whole bench process with every candidate's plans alive (230 MB in smoke), the same in all |
| 175 | receipts. |
| 176 | - N14. `rx_costmodel.state_bytes = (m*n + n + m) * 8` (`bench_polyglot.c:462-466`): the factor 8 is unexplained; check |
| 177 | against `rx_costmodel` before POLYGLOT-1 maps onto it. |
| 178 | - N15. `--workloads` uses `strstr` (`bench_polyglot.c:497`); harmless with S1-S4. |
| 179 | |
| 180 | ## Rules check (item 5) |
| 181 | |
| 182 | - 28 files changed against 4b217aa: no `.py`, no `.rs`, no Cargo files. No GPU code, no `/dev/nvidia*`, no CUDA. |
| 183 | - Runtime reads outside the repo: `/proc` and `/sys` (machine facts, schedstat), `$HOME/workspace/.spark-quiet` |
| 184 | (by design), `/tmp/polyglot-ctime-*` (compile timing scratch). The bench also spawns `mojo build` from |
| 185 | `$HOME/.pixi` for compile timing; that toolkit bundles Python 3.14 (already on Drake's flag list). The run |
| 186 | kernels themselves read nothing outside their arguments. |
| 187 | |
| 188 | ## Explainer checks passed |
| 189 | |
| 190 | - Byte-identical output on two runs over the same receipts. |
| 191 | - A one-character edit to section 1 marks all 72 receipts stale and selects nothing. |
| 192 | - No hard-coded candidate ids or winners in `polyglot_explain.c`; it names the runner-up, margins, pack and |
| 193 | break-even, per-language best, and a reason for every rejected candidate. |
| 194 | - Exact-median ties break by id; TIE is printed when inside the band. |
| 195 | |
| 196 | ## Appendix: callee-saved sentinel harness |
| 197 | |
| 198 | `cs_call(fn, p, x, y, out)` sets x19-x28 and d8-d15 to known values, calls `fn(p, x, y)`, and stores the registers to |
| 199 | `out[0..17]`. The driver packs each candidate at shapes (1,1) (3,15) (4,16) (5,17) (7,100) (9,1025) (33,4099), calls |
| 200 | through `cs_call`, and compares the registers and y against the oracle. |
| 201 | |
| 202 | ```asm |
| 203 | .text |
| 204 | .globl cs_call |
| 205 | .type cs_call, %function |
| 206 | cs_call: // x0 fn, x1 p, x2 x, x3 y, x4 out |
| 207 | stp x29, x30, [sp, #-176]! |
| 208 | mov x29, sp |
| 209 | stp x19, x20, [sp, #16] |
| 210 | stp x21, x22, [sp, #32] |
| 211 | stp x23, x24, [sp, #48] |
| 212 | stp x25, x26, [sp, #64] |
| 213 | stp x27, x28, [sp, #80] |
| 214 | stp d8, d9, [sp, #96] |
| 215 | stp d10, d11, [sp, #112] |
| 216 | stp d12, d13, [sp, #128] |
| 217 | stp d14, d15, [sp, #144] |
| 218 | str x4, [sp, #160] |
| 219 | mov x16, x0 |
| 220 | mov x0, x1 |
| 221 | mov x1, x2 |
| 222 | mov x2, x3 |
| 223 | movz x19, #0x1919 |
| 224 | movz x20, #0x2020 |
| 225 | movz x21, #0x2121 |
| 226 | movz x22, #0x2222 |
| 227 | movz x23, #0x2323 |
| 228 | movz x24, #0x2424 |
| 229 | movz x25, #0x2525 |
| 230 | movz x26, #0x2626 |
| 231 | movz x27, #0x2727 |
| 232 | movz x28, #0x2828 |
| 233 | fmov d8, x19 |
| 234 | fmov d9, x20 |
| 235 | fmov d10, x21 |
| 236 | fmov d11, x22 |
| 237 | fmov d12, x23 |
| 238 | fmov d13, x24 |
| 239 | fmov d14, x25 |
| 240 | fmov d15, x26 |
| 241 | blr x16 |
| 242 | ldr x4, [sp, #160] |
| 243 | stp x19, x20, [x4] |
| 244 | stp x21, x22, [x4, #16] |
| 245 | stp x23, x24, [x4, #32] |
| 246 | stp x25, x26, [x4, #48] |
| 247 | stp x27, x28, [x4, #64] |
| 248 | stp d8, d9, [x4, #80] |
| 249 | stp d10, d11, [x4, #96] |
| 250 | stp d12, d13, [x4, #112] |
| 251 | stp d14, d15, [x4, #128] |
| 252 | ldp x19, x20, [sp, #16] |
| 253 | ldp x21, x22, [sp, #32] |
| 254 | ldp x23, x24, [sp, #48] |
| 255 | ldp x25, x26, [sp, #64] |
| 256 | ldp x27, x28, [sp, #80] |
| 257 | ldp d8, d9, [sp, #96] |
| 258 | ldp d10, d11, [sp, #112] |
| 259 | ldp d12, d13, [sp, #128] |
| 260 | ldp d14, d15, [sp, #144] |
| 261 | ldp x29, x30, [sp], #176 |
| 262 | ret |
| 263 | .size cs_call, .-cs_call |
| 264 | .section .note.GNU-stack,"",%progbits |
| 265 | ``` |
| 266 | |
| 267 | Result on 17d2854: `cs_check: 18 candidates, 126 calls, 0 problems (x19-x28, d8-d15)`. With mutant C linked in place of |
| 268 | `omx_sdot.S.o`: 7 problems, all `asm_sdot reg#10` (d8). |
| 269 | |
| 270 | ## Fix verification |
| 271 | |
| 272 | Fixes on `feat/polyglot-0` after this review (commits dd1ba22, 0d46b87, f6f34ea, 8f8babe, 3ef4f69). |
| 273 | No timed benchmark was run for this section (no `make bench-polyglot`, no smoke bench); the bench changes are |
| 274 | checked by `bench_polyglot --selftest`, which does no timing and is now part of `make test-polyglot`. |
| 275 | |
| 276 | | finding | fix | |
| 277 | |---|---| |
| 278 | | G-B1 | Calibration doubles the call count until one whole sample (same loop as the timed one) lasts >= 1.25 ms. A timed sample under 1 ms is re-taken with twice the calls (kept only after 20 retakes). Receipt cells record `short_samples_retaken`, `short_samples_kept`, `shortest_sample_ns`. | |
| 279 | | G-B2 | `omx_candidate.code` lets a lane name its code parts. Mojo: C adapter run + pack plus `omx_mj_*_run` / `omx_mj_*_pack` (symbol sizes). Encoder: C thunk + the bytes Omega's encoder emitted + C pack. Receipts carry `code_parts`; `code_size_bytes` is null if any part is unknown, never a partial sum. Encoder `compile_time_s_min_of_5` is now min of 5 in-process emissions (`omx_encoder_emit_ns`), not gcc of `omx_encoder.c`. Self-test code sizes: MJ1_sdot 2036 B, MJ2c_crumb 1716 B, enc_sdot 1160 B, enc_crumb 1276 B (asm_sdot 1112 B). | |
| 280 | | G-S1 | The verifier copies each plan's packed weights into a read-only guarded mapping for two of the five runs per case: flush against the trailing guard page, then right after the leading one. Plans with an `aux` allocation (only MA-3's C R3_sparse) stay in place; ASan covers them. | |
| 281 | | G-S2 | 16 large random-data cases: the four bench shapes (up to 4096 x 4096), n in {65537, 131073, 1000003} with m in {1, 5}, and six cases with m in 1000..4100. | |
| 282 | | G-S3 | E_TRIT with one bad weight (2, -2, -128, 127, 3) at the first, last and a random position on 1x17, 5x16, 4x65, 7x129, 3x1000, 2x4099, 33x257, flush against a guard page. | |
| 283 | | G-S4 | `tests/polyglot/cs_call.S` (the appendix trampoline, distinct 64-bit sentinels) wraps the first run of every verifier case, all candidates, plain and ASan builds: x19-x28 and d8-d15 are compared after the call. | |
| 284 | | G-S5 | Verifier: runs 4 and 5 use one x pointer whose bytes at n-1 and n/2 change in place between them. Bench: before every timed call one byte of that call's x is flipped in place (x ^= 1) at a column with non-zero column sum; the checksum prediction follows every flip. The self-test proves the prediction for every candidate and that a memoising control candidate is caught. | |
| 285 | | G-S6 | Explainer: eligible also requires not smoke, the current run (`--run`, or the only non-smoke run; several runs and no `--run` select nothing), `gate_eligible`, `tree_dirty_files == 0`, 0 < min <= median, no kept sample under 1 ms. Tamper test repeated: the ghost receipt (run `...-OLDRUN`, median 1.0) makes "current run: none" without `--run`, and is rejected as "not from the current run" with `--run`; a receipt with min > median is rejected; smoke receipts select nothing. Output still byte-identical over two runs. | |
| 286 | | G-S7 | Band = max(3 x max relative MAD, 5%). The 5% floor comes from the 360 paired medians of `evidence/MIXED_ALGEBRA/ma3_bench_run1.json` / `_run2.json`: run-to-run shift p50 0.27%, p95 3.6%, p99 10.4%; 22/360 exceed 3 x within-run noise; 5% is the smallest whole percent that leaves at most 2.5% (8/360) outside max(3 x noise, floor). The S1 asm_sdot vs R1_sdot@O3 gap (3.2%) is now TIE. | |
| 287 | | G-S8 | The encoder kernel is emitted by `pack` (once per process); pack returns E_NOMEM if the W^X mapping fails. `run` only reads the code pointer (no syscall, no global write); a plan that never went through pack gets E_ARG. | |
| 288 | | G-S9 | The bench restores its original CPU affinity before timing compile commands; `compile_note` records it. | |
| 289 | |
| 290 | Also found while running the mutant lane: `omx_candidate_get` subscripted the one-element weak lane tables, |
| 291 | which UBSan flags for index >= 2 in the sanitizer build. Fixed (3ef4f69). |
| 292 | |
| 293 | ### Mutants re-run against the fixed suite |
| 294 | |
| 295 | Each mutant was applied to the working tree (or linked as a scratch lane), built into a scratch output |
| 296 | directory, run, and removed; none is committed. A and C: `perl` edit of the `.S` file, `make OUT_DIR=build-mut/<id>` |
| 297 | of both verifiers, `git checkout` of the file afterwards. M1-M5: the review's `mut_lane.c` (strong |
| 298 | `omx_lane_mojo[]` with the five mutants) linked in place of the Mojo lane, plain and ASan+UBSan builds. |
| 299 | |
| 300 | | id | defect | before (review) | after: verify plain | after: verify ASan+UBSan | caught by | |
| 301 | |---|---|---|---|---|---| |
| 302 | | A | `asm_crumb` `ldr q5,[x5]` at `.Lcr_ok` (16 B past the packed weights) | missed | FAIL, rc 139 | FAIL, rc 139 | packed-weight guard page: "guard-page fault (signal) in candidate asm_crumb" | |
| 303 | | C | `asm_sdot` zeroes v8 and v15 at entry | missed | FAIL, 45,190 failures | FAIL, 45,190 failures | callee-saved check: "callee-saved d8 not preserved" (and d15), every case | |
| 304 | | M1 | `-1 * x` as int8 negation | caught | FAIL, 54,597 failures | FAIL, 54,597 failures | oracle compare (unchanged) | |
| 305 | | M2 | column offset kept in 16 bits | missed | FAIL, 30 failures | FAIL, 30 failures | large random cases, first at m=1 n=65537 | |
| 306 | | M3 | rows >= 301 off by one | missed | FAIL, 35 failures | FAIL, 35 failures | large cases, first at m=4096 n=4096 | |
| 307 | | M4 | memoises last two results by (plan, x pointer, m, n, first 16 B of x) | missed | FAIL, 17,337 failures | FAIL, 17,337 failures | in-place x change behind one pointer (run 5); the bench self-test's memoising control is caught by the checksum too | |
| 308 | | M5 | validator checks only the (m*n) % 16 tail | missed | FAIL, 150 failures | FAIL, 150 failures | error contract on larger shapes, first "1x17 weight 2 at 0: rc 0, want E_TRIT" | |
| 309 | |
| 310 | Test results on the fixed tree (18 candidates): |
| 311 | |
| 312 | - `make test-polyglot`: verify plain PASS and verify ASan+UBSan PASS, each 12,612,555 checks, 0 failures |
| 313 | (2,579 MA-3 grid + 16 large + 20,000 random cases; harness 903,808/903,808); `bench_polyglot --selftest` |
| 314 | PASS, 103 checks, 0 failures. |
| 315 | - `make test-polyglot-asm`: PASS, 331,856 checks, 0 failures (plain and ASan). |
| 316 | - `make test-polyglot-encoder`: PASS, 337,522 checks, 0 failures, byte compare 356/356 identical (plain and ASan). |
| 317 | - `make test-polyglot-mojo`: PASS, 371,539 checks, 0 failures (plain and ASan). |
| 318 | |
| 319 | Not done here: a new timed run. Existing receipts (none committed for POLYGLOT-0 yet) predate the new fields and |
| 320 | would be refused by the explainer ("no sample-length record"). |