interplane.Get Omega
Read in your language

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

GitHub aien-dev/omega-mv#242 (code only)

closed derived d0be4854c66c5d9c #242

Imported from GitHub aien-dev/omega-mv#242 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base ab3bf6aed8377f7c4dcb24f9a74d5bff27f3f5c3 · Head 372fee181e3a53081b327ca301efe2adee8f8b15

Apply it

git checkout -b patch-d0be4854c66c5d9c ab3bf6aed8377f7c4dcb24f9a74d5bff27f3f5c3
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/d0be4854c66c5d9c.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-mv
242
372fee181e3a53081b327ca301efe2adee8f8b15
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":242,"url":"https://github.com/aien-dev/omega-mv/pull/242","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:56Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/docs/turing/PRD2_PREDICTION_FORMAT.md b/docs/turing/PRD2_PREDICTION_FORMAT.md
new file mode 100644
index 000000000..28524be7a
--- /dev/null
+++ b/docs/turing/PRD2_PREDICTION_FORMAT.md
@@ -0,0 +1,87 @@
+# PRD2: mixture-capable prediction format (EXP-002D Stage A)
+
+Status: PROTOCOL FREEZE for EXP-002D row 28. Written and hashed before any test vector or
+result existed (receipt `evidence/EXP-002D/01_protocol_freeze.txt`). PRD1 (`src/turing/ty_prd.*`,
+`docs/turing/TURING_QCONT_RECORDS_V0.md`) is not changed by this document; every PRD1 receipt
+and every Wave 1 sealed outcome stands as recorded.
+
+## Why
+
+EXP-002D (Brownian Wave 1 hostile cases) is INCOMPLETE because one hostile rule is not
+evaluable under the Wave 1 prediction format. The rule is the mixture-weight rule of the
+Brownian profile (spec section 5.2: "A finite Gaussian mixture with K <= 8 ... Weights must
+sum to 1 within 1e-9. The scorer refuses the prediction otherwise. It does not renormalize").
+Hostile row 28 expects FAIL_PROTOCOL for weights summing to 0.9, 1.1, and for a negative
+weight. PRD1 carries 24 bytes per record (index, family, loc, scale) and has no weight field,
+so in Wave 1 every mixture is refused by family before any weight can be read; the sealed
+harness prints "PENDING #28" and the row is not counted. This document defines the smallest
+format that makes the weight rule evaluable.
+
+## Wire format PRD2 (little-endian, binary64 IEEE values)
+
+Header, 16 bytes: magic `PRD2`, u32 version = 2, u32 count, u32 first_index.
+Then `count` records, record i:
+
+| field | type | rule |
+| --- | --- | --- |
+| index | u32 | exactly first_index + i |
+| family | u32 | 0 Gaussian, 2 Gaussian mixture; 1 (Student-t) refused (decision A2 deferred stands) |
+| K | u32 | family 0: exactly 1; family 2: 1 <= K <= 8 (TYQ_KMAX) |
+| reserved | u32 | 0 |
+| K components | each f64 pi, f64 loc, f64 scale | see below |
+
+Component rules: `pi` finite and `0 < pi <= 1`; `loc` finite; `scale` finite and `> 0`.
+Family 0 requires `pi == 1.0` exactly. Family 2 requires `|sum(pi) - 1| <= 1e-9`
+(TYQ_NORM_TOL). A file is refused as a whole on the first violation; nothing is renormalized,
+clipped or repaired. Trailing bytes, a short file, a PRD1 magic, or a version other than 2
+are refused. All refusals are TYQ_FAIL_PROTOCOL; a reason code names the violated rule
+(see `src/turing/ty_prd2.h`), so a refusal "by weight" is distinguishable from "by family".
+
+## Scoring a mixture under qint.v1
+
+One point: with `b_j` the qint.v1 Gaussian bits of component j (`ty_qcont_bits`, unchanged,
+sd floor applied per component), the mixture bits are
+
+```text
+bits = -log2( sum_j pi_j * 2^(-b_j) )
+```
+
+computed as `m - log2(sum_j pi_j * 2^(-(b_j - m)))` with `m = min_j b_j`. A point is a floor
+hit if any component was raised to sd_min. Micro-bit conversion, overflow guard and ty_add
+summation are the PRD1 rules verbatim. Consequence used as a check: a K = 1 mixture with
+`pi = 1` scores bit-identically to the Gaussian record, and K identical components score the
+same as one, so declaring a mixture earns nothing by itself.
+
+## Preregistered evaluation rule R28-v2 (row 28 MATCH iff all hold)
+
+1. weights 0.5 and 0.4 (sum 0.9): FAIL_PROTOCOL, reason WEIGHT_SUM;
+2. weights 0.5 and 0.6 (sum 1.1): FAIL_PROTOCOL, reason WEIGHT_SUM;
+3. weights 1.5 and -0.5 (sum 1, one negative): FAIL_PROTOCOL, reason WEIGHT_RANGE;
+4. weights 0.5 and 0.5: accepted and scored; the scorer called on case 1 returns
+   FAIL_PROTOCOL and no number (no renormalization path exists);
+5. K = 1, pi = 1 mixture bits equal the Gaussian bits exactly on the qint.v1 KAT grid;
+6. eight identical components with pi = 1/8 score within 1e-12 bits of the single Gaussian.
+
+## Preregistered negative controls (v2 must not make everything pass)
+
+On one synthetic path of 2000 Gaussian increments from a fixed-seed generator inside the
+test (no sealed world, no Brownian profile data), with the honest predictor H = Gaussian
+(previous value, true increment sd):
+
+- N1 format: PRD1 bytes given to the PRD2 reader are refused (reason MAGIC); PRD2 bytes given
+  to the unchanged PRD1 reader are refused;
+- N2 constant predictor (loc 0 every point, true sd) as a legal K = 2 mixture: summed bits
+  strictly greater than H;
+- N3 shuffled predictions (H's locs under a fixed permutation): summed bits strictly greater
+  than H;
+- N4 padded mixture (H plus a pi = 0.5 component with sd 1e6): summed bits exceed H by at
+  least 0.9 bits per point (the honest component carries half the mass, so the cost is at
+  least 1 bit per point minus the far component's negligible share).
+
+## What this does and does not close
+
+Passing R28-v2 in omega makes row 28 evaluable and gives the omega-side result. EXP-002D is
+closed only when the sealed harness test (`hostile_leak.c` "#28" in the private evaluator
+repository) is re-pointed at PRD2 and the EXP-002D development runner is re-run under a new
+omega pin, with its own receipt. Until then EXP-002D stays INCOMPLETE; this work changes the
+reason from "format cannot carry the rule" to "sealed harness re-run owed".
diff --git a/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md b/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md
index 156b7470d..a7ddd0066 100644
--- a/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md
+++ b/docs/turing/TURING_SCIENTIFIC_QUALIFICATION_STATE.md
@@ -24,7 +24,7 @@ from the sealed Wave 1 records (section 2 row "EXP-002A to D", section 7). No ev
 | H5 physical part (T/J) | NOT STARTED | needs H4 |
 | H3 (replay, statistical robustness) | PARTIAL | bootstrap and replay code exist; no standalone H3 receipt |
 | EXP-002A, 002B, 002C | PASS (Brownian Wave 1, sealed) | certification of the scorer on known stochastic cases; 002A PASS under a successor profile; 002B PASS without its Occam curve; the Occam curve itself PASS separately under profile v1.3; 002C repeated PASS on fresh sealed worlds under v1.3 |
-| EXP-002D (Brownian) | INCOMPLETE | one hostile rule is not evaluable with the Wave 1 prediction format; 0 wrong verdicts on the rules that were evaluated |
+| EXP-002D (Brownian) | INCOMPLETE | one hostile rule (row 28, mixture weights) was not evaluable with the Wave 1 prediction format; 0 wrong verdicts on the rules that were evaluated. Stage A (2026-10-04): PRD2 makes it evaluable, omega-side R28-v2 MATCH, receipts `evidence/EXP-002D/01..04`; still INCOMPLETE until the sealed harness is re-pointed at PRD2 and re-run |
 | interventional replication (Brownian) | PASS | profile v1.3, fresh sealed worlds |
 | EXP-003 | BLOCKED | needs a separate Wave 2 contract (draft under review, not accepted, not frozen) and must seal after BRN-10 |
 | R16 (orchestrator retirement) | CLOSED at candidate `850fc545`; living build IMPLEMENTED / NOT QUALIFIED | omega#112 merged (`3dd5eaa`), gates G1 to G8 PASS at that candidate (update 2026-09-30); merged with evidence-immutable FAILED, re-qualification owed (see the 2026-10-01 reconciliation section at the end) |
diff --git a/evidence/EXP-002D/01_protocol_freeze.txt b/evidence/EXP-002D/01_protocol_freeze.txt
new file mode 100644
index 000000000..0cb5455e6
--- /dev/null
+++ b/evidence/EXP-002D/01_protocol_freeze.txt
@@ -0,0 +1,13 @@
+EXP-002D Stage A, receipt 1 of 4: PROTOCOL FREEZE
+written: 2026-10-03T23:31:41Z
+base omega main: ab3bf6aed8377f7c4dcb24f9a74d5bff27f3f5c3
+frozen document: docs/turing/PRD2_PREDICTION_FORMAT.md
+sha256: 2199e24680e9ec62b6808ec56990a6fa6588049a161a90f8a2bc4534f0802db9
+contents frozen: PRD2 wire format, mixture scoring rule, evaluation rule R28-v2 (6 items), negative controls N1-N4.
+state at freeze: no PRD2 code, no test, no test vector exists in this tree. PRD1 files untouched (sha256 below).
+9f65a4579533325ca5fa87f20c457ef265846e0e294cf2501a0d7678c0313eed  src/turing/ty_prd.c
+7baf81e9e2be635a388ac0cc8c8a35396cf54084f6ca50a3f93d4f476600dcef  src/turing/ty_prd.h
+5ae3dcedf40e08b22e0624dc62e54b9a7054ed70a09befff1110a146346f8b6e  src/turing/ty_qcont.c
+a05f265945851b4e736b10ca84fbec43b081680e66739095f0cf7b99e55ca0bc  src/turing/ty_qcont.h
+sealed material opened for this work: none of the hidden-world specs, profile files, thresholds or calibration data.
+Read for ground truth only: EXP-002D-dev/results.txt rows, hostile_leak.c #28 block, spec section 5.2/14/15 headings.
diff --git a/evidence/EXP-002D/02_data_seal.txt b/evidence/EXP-002D/02_data_seal.txt
new file mode 100644
index 000000000..5e5d1228d
--- /dev/null
+++ b/evidence/EXP-002D/02_data_seal.txt
@@ -0,0 +1,20 @@
+EXP-002D Stage A, receipt 2 of 4: DATA SEAL
+written: 2026-10-03T23:33:54Z
+code commit: 93a3e3b64895681a6e63aff573e33efcb6a6fadb
+Row 28 is a wire-format and weight-rule check. It needs no sealed world and no Brownian profile data.
+The only data are the fixed test vectors inside tests/turing/test_ty_prd2.c (weights 0.5/0.4, 0.5/0.6, 1.5/-0.5, 0.5/0.5;
+KAT-like grids; one synthetic path: xorshift64* seed 0x9E3779B97F4A7C15, Box-Muller, 2000 increments, sd 0.05).
+Sealed by hash at this commit:
+77ecb4268fa32856dd1001351f7f686458ac34c8969898ad7ed2076cadb521fd  tests/turing/test_ty_prd2.c
+5f559526cd2825ec241ccbb68bd200c35b10684c7528a1e82cc8d47c1b255aa9  src/turing/ty_prd2.c
+a2e2a7babef811166e909f9fa14507ea9b230792599495fe4db7e847184b393e  src/turing/ty_prd2.h
+53a342567aef08766a41969142766b6faa27699067438747e93f0ad0e3bac995  mk/turing_prd2.mk
+2199e24680e9ec62b6808ec56990a6fa6588049a161a90f8a2bc4534f0802db9  docs/turing/PRD2_PREDICTION_FORMAT.md
+Unchanged PRD1/qint.v1 files (same hashes as receipt 1):
+9f65a4579533325ca5fa87f20c457ef265846e0e294cf2501a0d7678c0313eed  src/turing/ty_prd.c
+7baf81e9e2be635a388ac0cc8c8a35396cf54084f6ca50a3f93d4f476600dcef  src/turing/ty_prd.h
+5ae3dcedf40e08b22e0624dc62e54b9a7054ed70a09befff1110a146346f8b6e  src/turing/ty_qcont.c
+a05f265945851b4e736b10ca84fbec43b081680e66739095f0cf7b99e55ca0bc  src/turing/ty_qcont.h
+Declared deviation D-1: one development build-and-run of this test happened before this seal (all checks passed on that run).
+The execution of record is the fresh run in receipt 3, made after this seal from the committed files.
+Regression: make test-turing-qcont (PRD1 + qint.v1 KATs) passes unchanged at this commit.
diff --git a/evidence/EXP-002D/03_execution.log b/evidence/EXP-002D/03_execution.log
new file mode 100644
index 000000000..5f77b29d3
--- /dev/null
+++ b/evidence/EXP-002D/03_execution.log
@@ -0,0 +1,19 @@
+cc -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -ffp-contract=off -fno-fast-math -o build/tests-turing-prd2/test_ty_prd2 tests/turing/test_ty_prd2.c src/turing/ty_prd2.c src/turing/ty_qcont.c src/turing/ty_prd.c src/turing/ty_math.c -lm
+cc -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -ffp-contract=off -fno-fast-math -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -o build/tests-turing-prd2/test_ty_prd2_asan tests/turing/test_ty_prd2.c src/turing/ty_prd2.c src/turing/ty_qcont.c src/turing/ty_prd.c src/turing/ty_math.c -lm
+./build/tests-turing-prd2/test_ty_prd2
+R28-v2 1 sum 0.9 -> WEIGHT_SUM: ok
+R28-v2 4b no renormalization: scorer refuses, no number: ok
+R28-v2 2 sum 1.1 -> WEIGHT_SUM: ok
+R28-v2 3 negative weight -> WEIGHT_RANGE: ok
+R28-v2 4a well-formed mixture accepted and scored: ok
+R28-v2 5 K=1 pi=1 mixture bit-identical to Gaussian: ok
+R28-v2 6 eight identical components within 1e-12 of one: ok
+N1 PRD1 bytes to PRD2 reader: refused (MAGIC)
+N1 PRD2 bytes to PRD1 reader: refused
+bits/point honest 17.7270 constant 145.5141 shuffled 276.1282 padded 18.7270
+N2 constant predictor loses to honest: yes
+N3 shuffled predictions lose to honest: yes
+N4 padded mixture costs 1.0000 bits/point (>= 0.9 required): yes
+test_ty_prd2: 74 checks, 0 failed
+./build/tests-turing-prd2/test_ty_prd2_asan > /dev/null
+test-turing-prd2: PRD2 wire, R28-v2 and controls N1-N4 pass in plain and ASan/UBSan builds
diff --git a/evidence/EXP-002D/03_execution.txt b/evidence/EXP-002D/03_execution.txt
new file mode 100644
index 000000000..859821bbb
--- /dev/null
+++ b/evidence/EXP-002D/03_execution.txt
@@ -0,0 +1,21 @@
+EXP-002D Stage A, receipt 3 of 4: EXECUTION
+run: 2026-10-03T23:34:15Z on spark-b87b, cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
+tree: fdc31c38494585ba5deaab233cf3ee073944eb90 (clean build, build/tests-turing-prd2 removed first)
+command: make test-turing-prd2
+exit code: 0
+log: evidence/EXP-002D/03_execution.log sha256 d0d2e18d0944e89591c9d950c59129192c8684739db04e21bbb681f289264e67
+summary lines:
+R28-v2 1 sum 0.9 -> WEIGHT_SUM: ok
+R28-v2 4b no renormalization: scorer refuses, no number: ok
+R28-v2 2 sum 1.1 -> WEIGHT_SUM: ok
+R28-v2 3 negative weight -> WEIGHT_RANGE: ok
+R28-v2 4a well-formed mixture accepted and scored: ok
+R28-v2 5 K=1 pi=1 mixture bit-identical to Gaussian: ok
+R28-v2 6 eight identical components within 1e-12 of one: ok
+N1 PRD1 bytes to PRD2 reader: refused (MAGIC)
+N1 PRD2 bytes to PRD1 reader: refused
+bits/point honest 17.7270 constant 145.5141 shuffled 276.1282 padded 18.7270
+N2 constant predictor loses to honest: yes
+N3 shuffled predictions lose to honest: yes
+N4 padded mixture costs 1.0000 bits/point (>= 0.9 required): yes
+test_ty_prd2: 74 checks, 0 failed
diff --git a/evidence/EXP-002D/04_verdict.txt b/evidence/EXP-002D/04_verdict.txt
new file mode 100644
index 000000000..43bbefe2a
--- /dev/null
+++ b/evidence/EXP-002D/04_verdict.txt
@@ -0,0 +1,11 @@
+EXP-002D Stage A, receipt 4 of 4: VERDICT
+written: 2026-10-03T23:34:15Z
+rule: R28-v2 as frozen in receipt 1 (docs/turing/PRD2_PREDICTION_FORMAT.md, sha256 2199e24680e9ec62b6808ec56990a6fa6588049a161a90f8a2bc4534f0802db9)
+row 28 (mixture weight rule), omega side, under PRD2: MATCH
+negative controls N1-N4: all hold (v2 does not make everything pass)
+EXP-002D overall: INCOMPLETE (unchanged). Reason changed from "rule not evaluable under the Wave 1 prediction format"
+to "sealed harness re-run owed": the evaluator-side test (hostile_leak.c #28 in the private repository) still reads PRD1
+and prints PENDING; it must be re-pointed at PRD2 and the EXP-002D development runner re-run under a new omega pin, with
+its own receipt, before row 28 counts. Also still open from the last runner record: HC-meas-lag1-control block 0 edge
+mismatch (0.00313 vs null upper 0.00308) and the stop-27 TPS1-adapter gate PENDING; both outside this receipt.
+No sealed outcome of EXP-002A/B/C/AR was touched. No PRD1 byte or receipt was rewritten. No threshold changed.
diff --git a/mk/turing_prd2.mk b/mk/turing_prd2.mk
new file mode 100644
index 000000000..7297ee24b
--- /dev/null
+++ b/mk/turing_prd2.mk
@@ -0,0 +1,25 @@
+# PRD2 mixture-capable prediction format + mixture scorer (EXP-002D Stage A).
+# New files only: src/turing/ty_prd2.*, tests/turing/test_ty_prd2.c. Reads
+# ty_qcont/ty_prd/ty_math; changes none of them. Picked up by `-include mk/*.mk`.
+ifndef TURING_PRD2_MK
+TURING_PRD2_MK := 1
+.PHONY: test-turing-prd2
+TYP2_CFLAGS = -std=c11 -Wall -Wextra -Werror -pedantic -O2 -D_POSIX_C_SOURCE=200809L -Isrc -ffp-contract=off -fno-fast-math
+TYP2_ASAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all
+TYP2_SRCS = src/turing/ty_prd2.c src/turing/ty_qcont.c src/turing/ty_prd.c src/turing/ty_math.c
+TYP2_HDRS = src/turing/ty_prd2.h src/turing/ty_qcont.h src/turing/ty_prd.h src/turing/ty_math.h
+TYP2_DIR = $(OUT_DIR)/tests-turing-prd2
+
+$(TYP2_DIR)/test_ty_prd2: tests/turing/test_ty_prd2.c $(TYP2_SRCS) $(TYP2_HDRS)
+	@mkdir -p $(TYP2_DIR)
+	$(CC) $(TYP2_CFLAGS) -o $@ tests/turing/test_ty_prd2.c $(TYP2_SRCS) -lm
+
+$(TYP2_DIR)/test_ty_prd2_asan: tests/turing/test_ty_prd2.c $(TYP2_SRCS) $(TYP2_HDRS)
+	@mkdir -p $(TYP2_DIR)
+	$(CC) $(TYP2_CFLAGS) $(TYP2_ASAN) -o $@ tests/turing/test_ty_prd2.c $(TYP2_SRCS) -lm
+
+test-turing-prd2: $(TYP2_DIR)/test_ty_prd2 $(TYP2_DIR)/test_ty_prd2_asan
+	./$(TYP2_DIR)/test_ty_prd2
+	./$(TYP2_DIR)/test_ty_prd2_asan > /dev/null
+	@echo "test-turing-prd2: PRD2 wire, R28-v2 and controls N1-N4 pass in plain and ASan/UBSan builds"
+endif
diff --git a/src/turing/ty_prd2.c b/src/turing/ty_prd2.c
new file mode 100644
index 000000000..e4cef666b
--- /dev/null
+++ b/src/turing/ty_prd2.c
@@ -0,0 +1,305 @@
+#include "turing/ty_prd2.h"
+#include "turing/ty_math.h"
+
+#include <fenv.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define P2_HDR 16u
+#define P2_REC 16u  /* index, family, K, reserved */
+#define P2_CMP 24u  /* pi, loc, scale */
+
+const char *tyq_prd2_reason_name(int r)
+{
+    switch (r) {
+    case PRD2_R_NONE: return "NONE";
+    case PRD2_R_MAGIC: return "MAGIC";
+    case PRD2_R_VERSION: return "VERSION";
+    case PRD2_R_SIZE: return "SIZE";
+    case PRD2_R_COUNT: return "COUNT";
+    case PRD2_R_INDEX: return "INDEX";
+    case PRD2_R_FAMILY: return "FAMILY";
+    case PRD2_R_K: return "K";
+    case PRD2_R_RESERVED: return "RESERVED";
+    case PRD2_R_WEIGHT_NONFINITE: return "WEIGHT_NONFINITE";
+    case PRD2_R_WEIGHT_RANGE: return "WEIGHT_RANGE";
+    case PRD2_R_WEIGHT_SUM: return "WEIGHT_SUM";
+    case PRD2_R_GAUSS_WEIGHT: return "GAUSS_WEIGHT";
+    case PRD2_R_LOC: return "LOC";
+    case PRD2_R_SCALE: return "SCALE";
+    default: return "?";
+    }
+}
+
+static uint32_t rd32(const uint8_t *b)
+{
+    return (uint32_t)b[0] | (uint32_t)b[1] << 8 | (uint32_t)b[2] << 16 | (uint32_t)b[3] << 24;
+}
+static double rdf(const uint8_t *b)
+{
+    uint64_t u = 0;
+    double d;
+    for (int i = 7; i >= 0; i--)
+        u = (u << 8) | b[i];
+    memcpy(&d, &u, 8);
+    return d;
+}
+static void wr32(uint8_t *b, uint32_t v)
+{
+    for (int i = 0; i < 4; i++)
+        b[i] = (uint8_t)(v >> (8 * i));
+}
+static void wrf(uint8_t *b, double d)
+{
+    uint64_t u;
+    memcpy(&u, &d, 8);
+    for (int i = 0; i < 8; i++)
+        b[i] = (uint8_t)(u >> (8 * i));
+}
+
+static int refuse(int *reason, int r)
+{
+    if (reason)
+        *reason = r;
+    return TYQ_FAIL_PROTOCOL;
+}
+
+int ty_prd2_validate(const tyq_pred *p, int *reason)
+{
+    if (reason)
+        *reason = PRD2_R_NONE;
+    if (!p)
+        return TYQ_E_ARG;
+    if (p->family != TYQ_FAM_GAUSS && p->family != TYQ_FAM_MIX)
+        return refuse(reason, PRD2_R_FAMILY);
+    if (p->family == TYQ_FAM_GAUSS && p->K != 1u)
+        return refuse(reason, PRD2_R_K);
+    if (p->family == TYQ_FAM_MIX && (p->K < 1u || p->K > TYQ_KMAX))
+        return refuse(reason, PRD2_R_K);
+    double sum = 0.0;
+    for (uint32_t j = 0; j < p->K; j++) {
+        const tyq_comp *c = &p->comp[j];
+        if (!isfinite(c->pi))
+            return refuse(reason, PRD2_R_WEIGHT_NONFINITE);
+        if (!(c->pi > 0.0) || c->pi > 1.0)
+            return refuse(reason, PRD2_R_WEIGHT_RANGE);
+        if (!isfinite(c->loc))
+            return refuse(reason, PRD2_R_LOC);
+        if (!isfinite(c->scale) || !(c->scale > 0.0))
+            return refuse(reason, PRD2_R_SCALE);
+        sum += c->pi;
+    }
+    if (p->family == TYQ_FAM_GAUSS) {
+        if (p->comp[0].pi != 1.0)
+            return refuse(reason, PRD2_R_GAUSS_WEIGHT);
+        if (p->loc != p->comp[0].loc || p->scale != p->comp[0].scale)
+            return refuse(reason, PRD2_R_LOC);
+    } else if (fabs(sum - 1.0) > TYQ_NORM_TOL) {
+        return refuse(reason, PRD2_R_WEIGHT_SUM);
+    }
+    return TYQ_OK;
+}
+
+void ty_prd2_free(ty_prd2 *p)
+{
+    if (!p)
+        return;
+    free(p->rec);
+    p->rec = NULL;
+    p->n = 0;
+}
+
+int ty_prd2_parse(const uint8_t *buf, size_t len, uint32_t first_index, uint32_t count,
+                  ty_prd2 *out, int *reason)
+{
+    if (reason)
+        *reason = PRD2_R_NONE;
+    if (!buf || !out || count == 0)
+        return TYQ_E_ARG;
+    out->n = 0;
+    out->first_index = first_index;
+    out->rec = NULL;
+    if ((uint64_t)first_index + count > UINT32_MAX)
+        return TYQ_E_ARG;
+    if (len < P2_HDR)
+        return refuse(reason, PRD2_R_SIZE);
+    if (memcmp(buf, "PRD2", 4) != 0)
+        return refuse(reason, PRD2_R_MAGIC);
+    if (rd32(buf + 4) != 2u)
+        return refuse(reason, PRD2_R_VERSION);
+    if (rd32(buf + 8) != count || rd32(buf + 12) != first_index)
+        return refuse(reason, PRD2_R_COUNT);
+    tyq_pred *rec = calloc(count, sizeof *rec);
+    if (!rec)
+        return TYQ_E_IO;
+    size_t off = P2_HDR;
+    for (uint32_t i = 0; i < count; i++) {
+        if (len - off < P2_REC) {
+            free(rec);
+            return refuse(reason, PRD2_R_SIZE);
+        }
+        tyq_pred *r = &rec[i];
+        const uint8_t *q = buf + off;
+        r->index = rd32(q);
+        r->family = rd32(q + 4);
+        r->K = rd32(q + 8);
+        uint32_t reserved = rd32(q + 12);
+        off += P2_REC;
+        if (r->index != first_index + i) {
+            free(rec);
+            return refuse(reason, PRD2_R_INDEX);
+        }
+        if (reserved != 0u) {
+            free(rec);
+            return refuse(reason, PRD2_R_RESERVED);
+        }
+        if (r->K < 1u || r->K > TYQ_KMAX) {
+            free(rec);
+            return refuse(reason, PRD2_R_K);
+        }
+        if (len - off < (size_t)r->K * P2_CMP) {
+            free(rec);
+            return refuse(reason, PRD2_R_SIZE);
+        }
+        for (uint32_t j = 0; j < r->K; j++, off += P2_CMP) {
+            r->comp[j].pi = rdf(buf + off);
+            r->comp[j].loc = rdf(buf + off + 8);
+            r->comp[j].scale = rdf(buf + off + 16);
+        }
+        if (r->family == TYQ_FAM_GAUSS) {
+            r->loc = r->comp[0].loc;
+            r->scale = r->comp[0].scale;
+        }
+        int rr;
+        if (ty_prd2_validate(r, &rr) != TYQ_OK) {
+            free(rec);
+            return refuse(reason, rr);
+        }
+    }
+    if (off != len) {
+        free(rec);
+        return refuse(reason, PRD2_R_SIZE);
+    }
+    out->n = count;
+    out->rec = rec;
+    return TYQ_OK;
+}
+
+int ty_prd2_encode(const ty_prd2 *p, uint8_t **buf, size_t *len)
+{
+    if (!p || !buf || !len || (p->n && !p->rec))
+        return TYQ_E_ARG;
+    *buf = NULL;
+    *len = 0;
+    size_t total = P2_HDR;
+    for (uint32_t i = 0; i < p->n; i++) {
+        if (ty_prd2_validate(&p->rec[i], NULL) != TYQ_OK || p->rec[i].index != p->first_index + i)
+            return TYQ_FAIL_PROTOCOL;
+        total += P2_REC + (size_t)p->rec[i].K * P2_CMP;
+    }
+    uint8_t *b = malloc(total);
+    if (!b)
+        return TYQ_E_IO;
+    memcpy(b, "PRD2", 4);
+    wr32(b + 4, 2u);
+    wr32(b + 8, p->n);
+    wr32(b + 12, p->first_index);
+    size_t off = P2_HDR;
+    for (uint32_t i = 0; i < p->n; i++) {
+        const tyq_pred *r = &p->rec[i];
+        wr32(b + off, r->index);
+        wr32(b + off + 4, r->family);
+        wr32(b + off + 8, r->K);
+        wr32(b + off + 12, 0u);
+        off += P2_REC;
+        for (uint32_t j = 0; j < r->K; j++, off += P2_CMP) {
+            wrf(b + off, r->comp[j].pi);
+            wrf(b + off + 8, r->comp[j].loc);
+            wrf(b + off + 16, r->comp[j].scale);
+        }
+    }
+    *buf = b;
+    *len = total;
+    return TYQ_OK;
+}
+
+int ty_qcont2_bits(const tyq_pred *p, int64_t k, double *bits, int *floor_hit)
+{
+    if (!p || !bits)
+        return TYQ_E_ARG;
+    if (ty_prd2_validate(p, NULL) != TYQ_OK)
+        return TYQ_FAIL_PROTOCOL;
+    if (p->family == TYQ_FAM_GAUSS)
+        return ty_qcont_bits(p, k, bits, floor_hit);
+    if (fegetround() != FE_TONEAREST)
+        return TYQ_FAIL_PROTOCOL;
+    double b[TYQ_KMAX];
+    int anyhit = 0;
+    double m = INFINITY;
+    for (uint32_t j = 0; j < p->K; j++) {
+        tyq_pred g;
+        memset(&g, 0, sizeof g);
+        g.index = p->index;
+        g.family = TYQ_FAM_GAUSS;
+        g.loc = p->comp[j].loc;
+        g.scale = p->comp[j].scale;
+        int hit = 0;
+        int rc = ty_qcont_bits(&g, k, &b[j], &hit);
+        if (rc != TYQ_OK)
+            return rc;
+        anyhit |= hit;
+        if (b[j] < m)
+            m = b[j];
+    }
+    double acc = 0.0;
+    for (uint32_t j = 0; j < p->K; j++)
+        acc += p->comp[j].pi * exp2(-(b[j] - m));
+    double v = m - log2(acc);
+    if (!isfinite(v))
+        return TYQ_FAIL_PROTOCOL;
+    *bits = v;
+    if (floor_hit)
+        *floor_hit = anyhit;
+    return TYQ_OK;
+}
+
+int ty_qcont2_point_ub(const tyq_pred *p, int64_t k, int64_t *ub, int *floor_hit)
+{
+    if (!ub)
+        return TYQ_E_ARG;
+    if (p && p->family == TYQ_FAM_GAUSS && ty_prd2_validate(p, NULL) == TYQ_OK)
+        return ty_qcont_point_ub(p, k, ub, floor_hit);
+    double bits;
+    int rc = ty_qcont2_bits(p, k, &bits, floor_hit);
+    if (rc != TYQ_OK)
+        return rc;
+    double s = 1e6 * bits;
+    if (!isfinite(s) || s > 9.0e18 || s < -9.0e18)
+        return TYQ_FAIL_PROTOCOL;
+    *ub = llrint(s);
+    return TYQ_OK;
+}
+
+int ty_qcont2_sum_ub(const tyq_pred *p, const int64_t *k, size_t n,
+                     int64_t *ld_ub, uint64_t *floor_hits)
+{
+    if (!p || !k || !ld_ub || n == 0)
+        return TYQ_E_ARG;
+    int64_t sum = 0;
+    uint64_t hits = 0;
+    for (size_t i = 0; i < n; i++) {
+        int64_t ub;
+        int hit = 0;
+        int rc = ty_qcont2_point_ub(&p[i], k[i], &ub, &hit);
+        if (rc != TYQ_OK)
+            return rc;
+        if (ty_add(sum, ub, &sum) != TY_OK)
+            return TYQ_FAIL_PROTOCOL;
+        hits += (uint64_t)hit;
+    }
+    *ld_ub = sum;
+    if (floor_hits)
+        *floor_hits = hits;
+    return TYQ_OK;
+}
diff --git a/src/turing/ty_prd2.h b/src/turing/ty_prd2.h
new file mode 100644
index 000000000..2a30c01b5
--- /dev/null
+++ b/src/turing/ty_prd2.h
@@ -0,0 +1,39 @@
+/* PRD2: mixture-capable prediction file (EXP-002D Stage A). New files only;
+ * PRD1 (ty_prd.*) and the qint.v1 Gaussian scorer (ty_qcont.*) are not changed.
+ * Format: docs/turing/PRD2_PREDICTION_FORMAT.md. Header "PRD2", u32 version 2,
+ * u32 count, u32 first_index; record: u32 index, u32 family, u32 K, u32 reserved,
+ * then K x (f64 pi, f64 loc, f64 scale). Family 0 needs K = 1 and pi = 1 exactly;
+ * family 2 needs 1 <= K <= 8, each 0 < pi <= 1, |sum pi - 1| <= 1e-9. Nothing is
+ * renormalized. Every refusal is TYQ_FAIL_PROTOCOL plus a reason code. */
+#ifndef TURING_TY_PRD2_H
+#define TURING_TY_PRD2_H
+
+#include "turing/ty_qcont.h"
+
+enum tyq_prd2_reason {
+    PRD2_R_NONE = 0,
+    PRD2_R_MAGIC, PRD2_R_VERSION, PRD2_R_SIZE, PRD2_R_COUNT, PRD2_R_INDEX,
+    PRD2_R_FAMILY, PRD2_R_K, PRD2_R_RESERVED,
+    PRD2_R_WEIGHT_NONFINITE, PRD2_R_WEIGHT_RANGE, PRD2_R_WEIGHT_SUM, PRD2_R_GAUSS_WEIGHT,
+    PRD2_R_LOC, PRD2_R_SCALE
+};
+const char *tyq_prd2_reason_name(int r);
+
+typedef struct { uint32_t n, first_index; tyq_pred *rec; } ty_prd2;
+
+/* Family 0: comp[0] holds pi/loc/scale and K == 1 (loc/scale mirrored into p->loc/scale).
+ * Family 2: comp[0..K-1]. reason may be NULL. */
+int  ty_prd2_validate(const tyq_pred *p, int *reason);
+int  ty_prd2_parse(const uint8_t *buf, size_t len, uint32_t first_index, uint32_t count,
+                   ty_prd2 *out, int *reason);
+int  ty_prd2_encode(const ty_prd2 *p, uint8_t **buf, size_t *len);
+void ty_prd2_free(ty_prd2 *p);
+
+/* qint.v1 bits of a validated PRD2 record (Gaussian delegates to ty_qcont_bits;
+ * mixture = -log2 sum_j pi_j 2^-b_j, floor hit if any component was raised). */
+int  ty_qcont2_bits(const tyq_pred *p, int64_t k, double *bits, int *floor_hit);
+int  ty_qcont2_point_ub(const tyq_pred *p, int64_t k, int64_t *ub, int *floor_hit);
+int  ty_qcont2_sum_ub(const tyq_pred *p, const int64_t *k, size_t n,
+                      int64_t *ld_ub, uint64_t *floor_hits);
+
+#endif
diff --git a/tests/turing/test_ty_prd2.c b/tests/turing/test_ty_prd2.c
new file mode 100644
index 000000000..180be0b8c
--- /dev/null
+++ b/tests/turing/test_ty_prd2.c
@@ -0,0 +1,180 @@
+/* PRD2 reader + mixture scorer tests: EXP-002D row 28 under rule R28-v2 and
+ * negative controls N1-N4 of docs/turing/PRD2_PREDICTION_FORMAT.md. The fixture
+ * path is synthetic (fixed-seed xorshift64*, Box-Muller); no Brownian profile data. */
+#include "turing/ty_prd.h"
+#include "turing/ty_prd2.h"
+#include "turing/ty_qcont.h"
+
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int fails, checks;
+#define CHECK(c) do { checks++; if (!(c)) { fails++; printf("FAIL line %d: %s\n", __LINE__, #c); } } while (0)
+#define R28(label, cond) do { CHECK(cond); printf("R28-v2 %s: %s\n", label, (cond) ? "ok" : "VIOLATED"); } while (0)
+
+static tyq_pred G(uint32_t idx, double loc, double scale)
+{
+    tyq_pred p;
+    memset(&p, 0, sizeof p);
+    p.index = idx; p.family = TYQ_FAM_GAUSS; p.K = 1;
+    p.loc = loc; p.scale = scale;
+    p.comp[0].pi = 1.0; p.comp[0].loc = loc; p.comp[0].scale = scale;
+    return p;
+}
+static tyq_pred M2(uint32_t idx, double pi0, double l0, double s0, double pi1, double l1, double s1)
+{
+    tyq_pred p;
+    memset(&p, 0, sizeof p);
+    p.index = idx; p.family = TYQ_FAM_MIX; p.K = 2;
+    p.comp[0].pi = pi0; p.comp[0].loc = l0; p.comp[0].scale = s0;
+    p.comp[1].pi = pi1; p.comp[1].loc = l1; p.comp[1].scale = s1;
+    return p;
+}
+static int64_t kof(double y) { return (int64_t)floor(y / TYQ_DELTA); }
+
+static void test_row28(void)
+{
+    int r;
+    double bits;
+    tyq_pred p = M2(0, 0.5, 0.0, 1.0, 0.4, 0.0, 1.0);                 /* sum 0.9 */
+    R28("1 sum 0.9 -> WEIGHT_SUM", ty_prd2_validate(&p, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_WEIGHT_SUM);
+    R28("4b no renormalization: scorer refuses, no number", ty_qcont2_bits(&p, 0, &bits, NULL) == TYQ_FAIL_PROTOCOL);
+    p.comp[1].pi = 0.6;                                                /* sum 1.1 */
+    R28("2 sum 1.1 -> WEIGHT_SUM", ty_prd2_validate(&p, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_WEIGHT_SUM);
+    p.comp[0].pi = 1.5; p.comp[1].pi = -0.5;                           /* sum 1, negative */
+    R28("3 negative weight -> WEIGHT_RANGE", ty_prd2_validate(&p, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_WEIGHT_RANGE);
+    p.comp[0].pi = 0.5; p.comp[1].pi = 0.5;
+    R28("4a well-formed mixture accepted and scored",
+        ty_prd2_validate(&p, &r) == TYQ_OK && r == PRD2_R_NONE && ty_qcont2_bits(&p, 123, &bits, NULL) == TYQ_OK && isfinite(bits));
+    /* the reason is the weight rule, not the family: family itself is accepted */
+    CHECK(r != PRD2_R_FAMILY);
+
+    /* 5: K = 1, pi = 1 mixture == Gaussian, bit for bit, on a KAT-like grid */
+    int exact = 1;
+    for (int i = -40; i <= 40; i++) {
+        double loc = 0.37 * i, scale = 0.001 + 0.05 * (double)(i & 7);
+        int64_t k = kof(loc + 0.013 * i);
+        tyq_pred g = G(0, loc, scale);
+        tyq_pred m;
+        memset(&m, 0, sizeof m);
+        m.family = TYQ_FAM_MIX; m.K = 1; m.comp[0].pi = 1.0; m.comp[0].loc = loc; m.comp[0].scale = scale;
+        double bg, bm;
+        int hg = 0, hm = 0;
+        if (ty_qcont_bits(&g, k, &bg, &hg) != TYQ_OK || ty_qcont2_bits(&m, k, &bm, &hm) != TYQ_OK) { exact = 0; break; }
+        if (memcmp(&bg, &bm, sizeof bg) != 0 || hg != hm) exact = 0;
+    }
+    R28("5 K=1 pi=1 mixture bit-identical to Gaussian", exact);
+
+    /* 6: eight identical components earn nothing */
+    double worst = 0.0;
+    for (int i = -20; i <= 20; i++) {
+        double loc = 0.1 * i, scale = 0.2;
+        int64_t k = kof(loc + 0.05);
+        tyq_pred g = G(0, loc, scale), m;
+        memset(&m, 0, sizeof m);
+        m.family = TYQ_FAM_MIX; m.K = 8;
+        for (int j = 0; j < 8; j++) { m.comp[j].pi = 0.125; m.comp[j].loc = loc; m.comp[j].scale = scale; }
+        double bg, bm;
+        CHECK(ty_qcont_bits(&g, k, &bg, NULL) == TYQ_OK && ty_qcont2_bits(&m, k, &bm, NULL) == TYQ_OK);
+        if (fabs(bg - bm) > worst) worst = fabs(bg - bm);
+    }
+    R28("6 eight identical components within 1e-12 of one", worst <= 1e-12);
+}
+
+static void test_wire(void)
+{
+    /* round trip, refusals by reason */
+    tyq_pred rec[3] = { G(128, 0.5, 0.25), M2(129, 0.25, -1.0, 0.5, 0.75, 2.0, 0.125), G(130, 0.0, 1.0) };
+    ty_prd2 p = { 3, 128, rec }, d;
+    uint8_t *b; size_t len; int r;
+    CHECK(ty_prd2_encode(&p, &b, &len) == TYQ_OK && len == 16u + 3 * 16u + 4 * 24u);
+    CHECK(ty_prd2_parse(b, len, 128, 3, &d, &r) == TYQ_OK && d.n == 3 && d.rec[1].K == 2 && d.rec[1].comp[1].loc == 2.0 && d.rec[2].loc == 0.0);
+    uint8_t *e; size_t elen;
+    CHECK(ty_prd2_encode(&d, &e, &elen) == TYQ_OK && elen == len && memcmp(e, b, len) == 0);
+    free(e); ty_prd2_free(&d);
+    CHECK(ty_prd2_parse(b, len, 128, 4, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_COUNT);
+    CHECK(ty_prd2_parse(b, len, 129, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_COUNT);
+    CHECK(ty_prd2_parse(b, len - 1, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_SIZE);
+    { uint8_t *m = malloc(len + 1); memcpy(m, b, len); m[len] = 0;
+      CHECK(ty_prd2_parse(m, len + 1, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_SIZE); free(m); }
+    { uint8_t *m = malloc(len); memcpy(m, b, len); m[5] = 3;
+      CHECK(ty_prd2_parse(m, len, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_VERSION); free(m); }
+    { uint8_t *m = malloc(len); memcpy(m, b, len); m[16 + 12] = 1;               /* reserved of record 0 */
+      CHECK(ty_prd2_parse(m, len, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_RESERVED); free(m); }
+    { uint8_t *m = malloc(len); memcpy(m, b, len); m[16 + 4] = 1;                /* family 1 Student-t */
+      CHECK(ty_prd2_parse(m, len, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_FAMILY); free(m); }
+    { uint8_t *m = malloc(len); memcpy(m, b, len); m[16 + 8] = 9;                /* K = 9 */
+      CHECK(ty_prd2_parse(m, len, 128, 3, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_K); free(m); }
+    /* N1: v1 bytes into v2 reader, v2 bytes into the unchanged v1 reader */
+    ty_prd v1 = { 1, 7, rec }; uint8_t *vb; size_t vlen;
+    tyq_pred g7 = G(7, 1.0, 1.0); v1.rec = &g7;
+    CHECK(ty_prd_encode(&v1, &vb, &vlen) == TYQ_OK && vlen == 32u);
+    CHECK(ty_prd2_parse(vb, vlen, 7, 1, &d, &r) == TYQ_FAIL_PROTOCOL && r == PRD2_R_MAGIC);
+    printf("N1 PRD1 bytes to PRD2 reader: refused (MAGIC)\n");
+    ty_prd dv;
+    CHECK(ty_prd_parse(b, len, 128, 3, &dv) == TYQ_FAIL_PROTOCOL);
+    printf("N1 PRD2 bytes to PRD1 reader: refused\n");
+    free(vb); free(b);
+    /* encode refuses an invalid record */
+    tyq_pred bad = M2(0, 0.5, 0.0, 1.0, 0.4, 0.0, 1.0); ty_prd2 pb = { 1, 0, &bad };
+    CHECK(ty_prd2_encode(&pb, &b, &len) == TYQ_FAIL_PROTOCOL);
+    CHECK(ty_prd2_validate(NULL, &r) == TYQ_E_ARG);
+    CHECK(ty_prd2_parse(NULL, 0, 0, 1, &d, &r) == TYQ_E_ARG);
+}
+
+/* fixed-seed generator for the synthetic path */
+static uint64_t st = 0x9E3779B97F4A7C15ull;
+static double u01(void)
+{
+    st ^= st >> 12; st ^= st << 25; st ^= st >> 27;
+    uint64_t v = st * 2685821657736338717ull;
+    return ((double)(v >> 11) + 0.5) / 9007199254740992.0;
+}
+static double gauss(void)
+{
+    double a = u01(), b = u01();
+    return sqrt(-2.0 * log(a)) * cos(6.283185307179586 * b);
+}
+
+#define NPTS 2000
+static void test_controls(void)
+{
+    static double y[NPTS + 1];
+    static int64_t k[NPTS];
+    static tyq_pred H[NPTS], C[NPTS], S[NPTS], P[NPTS];
+    const double sd = 0.05;
+    y[0] = 0.0;
+    for (int i = 0; i < NPTS; i++) {
+        y[i + 1] = y[i] + sd * gauss();
+        k[i] = kof(y[i + 1]);
+        H[i] = G((uint32_t)i, y[i], sd);                               /* honest: previous value, true sd */
+        C[i] = M2((uint32_t)i, 0.5, 0.0, sd, 0.5, 0.0, sd);             /* N2 constant predictor as legal mixture */
+        P[i] = M2((uint32_t)i, 0.5, y[i], sd, 0.5, y[i], 1e6);          /* N4 padded far component */
+    }
+    for (int i = 0; i < NPTS; i++)                                      /* N3 fixed permutation (stride) */
+        S[i] = G((uint32_t)i, y[(i * 7919) % NPTS], sd);
+    int64_t h, c, s, p; uint64_t fh;
+    CHECK(ty_qcont2_sum_ub(H, k, NPTS, &h, &fh) == TYQ_OK && fh == 0);
+    CHECK(ty_qcont2_sum_ub(C, k, NPTS, &c, &fh) == TYQ_OK);
+    CHECK(ty_qcont2_sum_ub(S, k, NPTS, &s, &fh) == TYQ_OK);
+    CHECK(ty_qcont2_sum_ub(P, k, NPTS, &p, &fh) == TYQ_OK);
+    int64_t hv; CHECK(ty_qcont_sum_ub(H, k, NPTS, &hv, &fh) == TYQ_OK && hv == h);   /* v2 == v1 on Gaussians */
+    double per_h = (double)h / 1e6 / NPTS, per_c = (double)c / 1e6 / NPTS, per_s = (double)s / 1e6 / NPTS, per_p = (double)p / 1e6 / NPTS;
+    printf("bits/point honest %.4f constant %.4f shuffled %.4f padded %.4f\n", per_h, per_c, per_s, per_p);
+    CHECK(c > h); printf("N2 constant predictor loses to honest: %s\n", c > h ? "yes" : "NO");
+    CHECK(s > h); printf("N3 shuffled predictions lose to honest: %s\n", s > h ? "yes" : "NO");
+    CHECK(per_p - per_h >= 0.9); printf("N4 padded mixture costs %.4f bits/point (>= 0.9 required): %s\n", per_p - per_h, per_p - per_h >= 0.9 ? "yes" : "NO");
+}
+
+int main(void)
+{
+    fesetround(FE_TONEAREST);
+    test_row28();
+    test_wire();
+    test_controls();
+    printf("test_ty_prd2: %d checks, %d failed\n", checks, fails);
+    return fails ? 1 : 0;
+}