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#366 (code only)

closed derived 62840fa10800d255 #366

Imported from GitHub aien-dev/omega-mv#366 (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 026bad06b1a9a6d2ecdf29a2545cfd5799e6f05b · Head a9917440e7520ce9af3be9cc5b01e6dab2f04d07

Apply it

git checkout -b patch-62840fa10800d255 026bad06b1a9a6d2ecdf29a2545cfd5799e6f05b
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/62840fa10800d255.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
366
a9917440e7520ce9af3be9cc5b01e6dab2f04d07
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":366,"url":"https://github.com/aien-dev/omega-mv/pull/366","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:33Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 4d9ac04a8..024cdf94d 100644
--- a/.crumb
+++ b/.crumb
@@ -75,8 +75,8 @@
           "purpose": "Directory polyglot. Purpose not yet described by a human."
         },
         {
-          "digest": "c1892a602f7a49d16c0b68a0601b6331e60011466d082523c68e13c2e047b663",
-          "last_commit": "9b74392",
+          "digest": "84ee495292e4f9504e50987bdfd47af5a887c0e7b58fd503efc8be2ef32783f6",
+          "last_commit": "f21b4d5",
           "name": "research",
           "purpose": "Directory research. Purpose not yet described by a human."
         },
@@ -105,15 +105,15 @@
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:0e41b8f711ae9b4abe0014e110ac9c1e3b20570458214e2a09a952d192e0b22c",
-      "compiled_at": "2026-10-10T00:12:06Z",
+      "children_root": "sha256:309088ae30682e188bfca81c47c950834b4c257e39efe7b711893af640c12c53",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:866401d367844ec213817ba05860ee1f56773bb0b5c178e4007ee49673ac6e5c",
+      "digest": "sha256:5a7d557f6f74e06b0a6396975f831e67c31a7eea75cec5d670f58837bb10d04e",
       "evidence_files": 5073,
       "evidence_root": "sha256:bb99548e90817b99c9dec34420512eea42356dde58aac5b0235f63431f73831e",
-      "files": 7255,
-      "generated_at_commit": "9b74392c8a09ff50c9e1056a958bbee8f817dedd",
-      "source_tree": "sha256:ad8085bdbfac959fe54bedc6e2431f1265f6b0c6c21e78c3a391e282cca8098b"
+      "files": 7257,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:8621851b122054257bb0d6e42d1daf29023abc6451cf7ca70e90881316b969e7"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/research/.crumb b/research/.crumb
index 64bf98d5f..59e7c80f4 100644
--- a/research/.crumb
+++ b/research/.crumb
@@ -21,8 +21,8 @@
     "generated": {
       "children": [
         {
-          "digest": "1b517f13afb6a594740905e1a5a47c479137e1653ddd7637cea0242a2a8e985d",
-          "last_commit": "9b74392",
+          "digest": "272fde1a2a79e987bc387999c0ebe2d2c4dde65fbcb7f886b3ed69978c771fda",
+          "last_commit": "f21b4d5",
           "name": "atemporal",
           "purpose": "AT-0 Clock-Free Universe research program: relational (Page-Wootters) quantum models with no ext"
         },
@@ -33,15 +33,15 @@
           "purpose": "Directory research/dirac-oracle. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:e8a478d0197add1c9742e65bdd2a9aae7f806f7cfc307e15ea61bb29100cbea6",
-      "compiled_at": "2026-10-10T00:12:06Z",
+      "children_root": "sha256:02b9d33c215f8847d6da831a93151b9bc9edb1dd00344ce18b8ed43c2ad86517",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:c1892a602f7a49d16c0b68a0601b6331e60011466d082523c68e13c2e047b663",
+      "digest": "sha256:84ee495292e4f9504e50987bdfd47af5a887c0e7b58fd503efc8be2ef32783f6",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 316,
-      "generated_at_commit": "9b74392c8a09ff50c9e1056a958bbee8f817dedd",
-      "source_tree": "sha256:a822038f0f7ee2959c6d86d09fda0453f7a0f23e90b1b534e459af3c086ded55"
+      "files": 318,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:dea1f6a52680b3f632f8b8334b712b35e1df6b1ca1517099175ddd60aea6a773"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/research/atemporal/.crumb b/research/atemporal/.crumb
index 31b233ed1..08be5b9b6 100644
--- a/research/atemporal/.crumb
+++ b/research/atemporal/.crumb
@@ -3,21 +3,21 @@
     "generated": {
       "children": [
         {
-          "digest": "667ee4f01ea105c463161bb9243e4faee93ac3d6c73f1b92069889b3aa952493",
-          "last_commit": "9b74392",
+          "digest": "550bb945815bfa004ba35bf67687b434869f7cb4d0ae6ba3f040bc3b1c617706",
+          "last_commit": "f21b4d5",
           "name": "at0",
           "purpose": "AT-0 V1: finite clock plus one qubit under the AT0_CASE_V1 / AT0_RESULT_V1 contracts"
         }
       ],
-      "children_root": "sha256:5b9f8f5eaac64149d3f2319934574f600b007ca79cfa2640e45f75a308a472a5",
-      "compiled_at": "2026-10-10T00:12:06Z",
+      "children_root": "sha256:a953c3db7f7e85260e7ae2d5f4a78d4ab8af1489ff6386bad764fa0cb1dc05de",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:1b517f13afb6a594740905e1a5a47c479137e1653ddd7637cea0242a2a8e985d",
+      "digest": "sha256:272fde1a2a79e987bc387999c0ebe2d2c4dde65fbcb7f886b3ed69978c771fda",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 170,
-      "generated_at_commit": "9b74392c8a09ff50c9e1056a958bbee8f817dedd",
-      "source_tree": "sha256:990af2160e9e208d534cd7b5db391813ab51218da6839d32eb598947c35d53fe"
+      "files": 172,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:f9b67a6d4e68301b2afa28f8ff52857b1b51de7e3d7e326ea78b3a84531b9599"
     }
   },
   "name": "atemporal",
diff --git a/research/atemporal/at0/.crumb b/research/atemporal/at0/.crumb
index 9284df9be..aa0713bdb 100644
--- a/research/atemporal/at0/.crumb
+++ b/research/atemporal/at0/.crumb
@@ -15,27 +15,27 @@
           "purpose": "AT-0 Agent 5 integration runner, exact result assembler/judge, hygiene and isolation controls, a"
         },
         {
-          "digest": "470b8c119df44842fffddc8393b528c87f163bb6e0155341cbc6da0650e19483",
-          "last_commit": "b3a9476",
+          "digest": "ef28d16f103c0c1c4df8e35be927bd79020d2f22f6dc575e114fa64d6975bbc5",
+          "last_commit": "f21b4d5",
           "name": "model",
           "purpose": "Agent 3 candidate relational quantum engine in portable C11: state, Hamiltonians, constraint ker"
         },
         {
           "digest": "24340ae691dce9743ee4d3eedf80ae0d362dd707cac0b6bae6ebbb562dafcf39",
-          "last_commit": "9b74392",
+          "last_commit": "026bad0",
           "name": "oracle",
           "purpose": "AT-0 reference oracle (Rust, standard library only, built by rustc directly; research cross-chec"
         }
       ],
-      "children_root": "sha256:a16b37c4005002d52fd7ff41d8e6a5019cff9e7aaf3ddbd7bd9952691d12309d",
-      "compiled_at": "2026-10-10T00:12:06Z",
+      "children_root": "sha256:2ef6e2392fb23ac01a185b8c57db20ecd1beaadad91b8d23139970dfe7aea4a3",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:667ee4f01ea105c463161bb9243e4faee93ac3d6c73f1b92069889b3aa952493",
+      "digest": "sha256:550bb945815bfa004ba35bf67687b434869f7cb4d0ae6ba3f040bc3b1c617706",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 170,
-      "generated_at_commit": "9b74392c8a09ff50c9e1056a958bbee8f817dedd",
-      "source_tree": "sha256:990af2160e9e208d534cd7b5db391813ab51218da6839d32eb598947c35d53fe"
+      "files": 172,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:f9b67a6d4e68301b2afa28f8ff52857b1b51de7e3d7e326ea78b3a84531b9599"
     }
   },
   "name": "at0",
diff --git a/research/atemporal/at0/model/.crumb b/research/atemporal/at0/model/.crumb
index 33cdb5a87..d5ce8048e 100644
--- a/research/atemporal/at0/model/.crumb
+++ b/research/atemporal/at0/model/.crumb
@@ -3,21 +3,21 @@
     "generated": {
       "children": [
         {
-          "digest": "e9114c1e9534737dc1a4d49971f6abb3278e4dcf7c5b9c544795c90c8812bccc",
-          "last_commit": "84fd7ab",
+          "digest": "9153a6c121ecfbc87b0d7122afbb68c74d80590f6eb96f85e2cc8625e7020aab",
+          "last_commit": "f21b4d5",
           "name": "tests",
           "purpose": "Component tests and case files for the candidate engine"
         }
       ],
-      "children_root": "sha256:250f09a76e0e74b7f3921f23346262b006f7b267cf456f5d695a2be3c0fa7a65",
-      "compiled_at": "2026-10-09T22:45:44Z",
+      "children_root": "sha256:c7aac0c733e80ca1e02e7df958494d218c0d74b80a34a63c1e5abaa1480bd785",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:470b8c119df44842fffddc8393b528c87f163bb6e0155341cbc6da0650e19483",
+      "digest": "sha256:ef28d16f103c0c1c4df8e35be927bd79020d2f22f6dc575e114fa64d6975bbc5",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 18,
-      "generated_at_commit": "84fd7ab949fc95594f62c201618a17dcb0dc610e",
-      "source_tree": "sha256:5b4bcd2ea2633e7056e743cf7338296a48eeaf4ed8888b4792c721ecc5c79071"
+      "files": 20,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:c3f3c7eba04f7210e7e80a66f0b39478e1e42790ac0cd9132b54f001a236dc63"
     }
   },
   "name": "model",
diff --git a/research/atemporal/at0/model/README.md b/research/atemporal/at0/model/README.md
index 738c38d85..78b61656f 100644
--- a/research/atemporal/at0/model/README.md
+++ b/research/atemporal/at0/model/README.md
@@ -1,7 +1,7 @@
 # AT-0 candidate relational quantum engine (research model)
 
 **Status:** candidate implementation, research directory. Not a gate, not evidence, not a contract.
-**Program:** AT-0 Clock-Free Universe, tracking issue aien-dev/omega#358. Pinned to: frozen contracts `AT0_CASE_V1` at aien-architecture `044c9d1` and `AT0_RESULT_V2` (Agent 0 ruling on omega#358; `AT0_RESULT_V1` superseded, same section numbers); charter (ownership, gates) at aien-architecture `d390939`; draft `AT0_SPEC.md` at aien-architecture PR #176 head `0efd1a14` (DRAFT, not merged: the hand tables used by the tests must be re-verified when it merges).
+**Program:** AT-0 Clock-Free Universe, tracking issue aien-dev/omega#358. Pinned to: frozen contracts `AT0_CASE_V1` at aien-architecture `044c9d1` and `AT0_RESULT_V2` (Agent 0 ruling on omega#358; `AT0_RESULT_V1` superseded, same section numbers); charter (ownership, gates) at aien-architecture `d390939`; `AT0_SPEC.md` at aien-architecture `68f47e2` (PR #176 merged 2026-10-09; the hand tables the tests use were re-verified against it: section 13.2 P1/P1b and T1/T2 agree with `test_pauli_probabilities` and `test_schrodinger_general_n_phase_omega`).
 **Built from:** omega `19f73c7`. **Language:** portable C11 (`__int128` via `__extension__` for exact rationals),
 `-lm` only, single thread, no GPU, no network, no Python.
 
@@ -23,11 +23,12 @@ emergence of time** (charter section 1, draft spec section 11).
 
 | Component | File | Entry points |
 |---|---|---|
-| Exact arithmetic | `at0_exact.c` | reduced rationals with 128-bit intermediates and contract limits, scaled decimals, exact rational square root test, exact phase reduction mod one turn, exact integer comparison of a binary64 against decimal tolerances (`at0_exact_prob_status`) |
-| Versioned input | `at0_case.c` | `at0_case_parse` (AT0_CASE_V1 rules 1 to 6 in contract order), `at0_case_emit` (byte-exact), `at0_case_identities` (domain-tagged SHA-256 via omega `src/sha256.c`) |
+| Exact arithmetic | `at0_exact.c` | reduced rationals with 128-bit intermediates and contract limits, scaled decimals, exact phase reduction mod one turn, exact integer comparison of a binary64 against decimal tolerances (`at0_exact_prob_status`), and overflow-free exact helpers for derived quantities whose reduced denominators exceed 2^62 (`at0_rat_norm_exact` for `|h|`, `at0_exact_norm_plus_hz`, `at0_exact_sum_is_zero`; checked 128-bit products, never wrapped) |
+| Versioned input | `at0_case.c` | `at0_case_parse` (AT0_CASE_V1 rules 1 to 6 in contract order; a well-formed but noncanonical token such as `04` or `-0/1` is `CASE_NONCANONICAL`, judged after the whole shape pass, both within rule 1), `at0_case_emit` (byte-exact), `at0_case_identities` (domain-tagged SHA-256 via omega `src/sha256.c`); works on bytes only |
+| File input | `at0_io.c` | `at0_case_read_file`: the only object that touches the file system (fopen/fread), hands the bytes to `at0_case_parse` |
 | Quantum state | `at0_state.c` | bounds-checked vector in `C^N (x) C^2`, clock factor first; norms, inner products, finiteness checks |
-| Hamiltonian construction | `at0_hamiltonian.c` | exact spectrum `h0 +/- |h|`, binary64 eigenvectors, `H_total` applied to a state |
-| Constraint verification | `at0_constraint.c` | exact kernel enumeration (`E_j + e_s = 0` in rationals), nullspace projection `P_0 (|t_r> (x) |psi_0>)`, residual `||H_total Psi_hat||`, exact decision whether `Psi = 0` |
+| Hamiltonian construction | `at0_hamiltonian.c` | spectrum `h0 +/- |h|` (exact in the case's `h0`, `h_norm`; stored as binary64), binary64 eigenvectors, `H_total` applied to a state |
+| Constraint verification | `at0_constraint.c` | exact kernel enumeration (`E_j + h0 = -/+ |h|` compared in rationals, the eigenvalues are never reduced), nullspace projection `P_0 (|t_r> (x) |psi_0>)`, residual `||H_total Psi_hat||`, exact decision whether `Psi = 0` |
 | Internal clock POVM | `at0_povm.c` | `|t_k> = N^(-1/2) sum_j exp(-2 pi i E_j k tau) |E_j>` with the turn count reduced exactly before `cos`/`sin`; residual `||sum_k F_k - I||_F` |
 | Conditional state | `at0_conditional.c` | `phi_k = (<t_k| (x) I) Psi`, `p(k) = w ||phi_k||^2 / ||Psi||^2`, `rho_k = phi phi^dagger / ||phi||^2` |
 | Observables | `at0_observable.c` | `P(sigma = +/-1) = Tr(rho (I +/- sigma)/2)`, each sign computed directly from `rho`, never as one minus the other |
@@ -124,15 +125,24 @@ than 2; `RIGOROUS` bounds; shot sampling; the oracle's `reference` lines and the
 - Contract limits on written tokens (|n|, d <= 2^20; scaled k <= 40) are judged in rule 3 as `CASE_INVALID_PARAMETER`,
   after the shape (rule 1) and version (rule 2) checks. A token longer than 18 digits is parsed as a saturation value
   (never an integer overflow) and refused the same way; a scaled numerator above 10^18 - 1 is refused as unsupported.
-- Derived exact quantities (`|h|`, `h0 +/- |h|`, kernel sums, exact overlaps) use 128-bit intermediates and must fit
-  63-bit numerators and denominators; a case whose derived rationals do not fit stops with `AT0_ENGINE_ERROR ERR_OVERFLOW`
-  (explicit, never a wrong number). No valid case within the contract limits is known to hit this.
+- Derived exact quantities (`|h|`, `|h| + hz`, kernel matches, exact overlaps) never pass through a reduced rational:
+  with tokens at the rule-3 limit (2^20) and distinct denominators their reduced denominators reach 2^80 and beyond
+  (qualification finding D1, case P5). They are decided on unreduced 128-bit integers over the common denominator
+  `dx dy dz`, with every product bounded at the use site (largest: 2^124 in the overlap test) and checked with
+  overflow-detecting arithmetic; an exceeded bound stops with `AT0_ENGINE_ERROR ERR_OVERFLOW` (explicit, never a wrong
+  number), which no in-limit case can reach. `test_large_rationals_within_limits` covers P5, a case whose
+  overlap with one eigenvector is exactly zero (the kernel then holds that eigenvector only and `Psi = 0` must be
+  decided exactly), and a generic case with four distinct denominators.
 - Trivial kernel ruling (Agent 0, omega#358): `povm_residual` is still computed, nothing is divided, every label is
   `UNDEFINED`; this engine already behaves that way. Result files move to `AT0_RESULT_V2`; the `contract` line of the
   engine output names it, and the values block is unchanged.
 - Independent review (Claude Opus 5.5 over the full diff, 2026-10-09) found five arithmetic-limit defects, all fixed and
   covered by `test_review_findings`; it confirmed the eigenvectors, kernel projection, phase reduction, Born rule and
   identity hashing. Codex review was unavailable (usage limit).
+- Qualification fixes (Agent 5 first run, omega#363): D1 `ERR_OVERFLOW` on P5 (above), D2 noncanonical integers
+  (`clock_dim 04`, `-0/1`) now `CASE_NONCANONICAL` instead of `CASE_PARSE_ERROR`, D6 file reader moved to `at0_io.c`,
+  D8 spec pin moved to the merged commit. D3 (R31, R36: rule 1 against rule 3) is an Agent 0 contract call and is unchanged. Second Opus review (2026-10-09)
+  found no arithmetic defect; its test-strength and wording findings are applied.
 - `tests/cases/kat-ideal-qubit-n4.case` is the contract's section 6 example byte for byte
   (`case_file_sha256 ed16c95c...`).
 
diff --git a/research/atemporal/at0/model/at0_case.c b/research/atemporal/at0/model/at0_case.c
index 126217703..dc66c2893 100644
--- a/research/atemporal/at0/model/at0_case.c
+++ b/research/atemporal/at0/model/at0_case.c
@@ -82,15 +82,24 @@ static int valid_digest(const char *s)
         if (!((s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'f'))) return 0;
     return 1;
 }
+/* canonical integer token for counts and indices (same tri-state as the rational tokens:
+ * 1 canonical, 0 shape error, -1 noncanonical such as "04" or "-0"). Canonical form is judged
+ * before the length cut, so a long noncanonical token still reports CASE_NONCANONICAL; a canonical
+ * token above 9 digits saturates (above every limit; it then fails the list-count shape check).
+ * A negative value also fails the shape pass (list counts / next key), never silently. */
 static int parse_small_int(const char *s, long *out)
 {
-    /* canonical nonnegative integer token, bounded so counts cannot overflow */
-    size_t n = strlen(s);
-    if (n == 0 || n > 9) return 0;
-    if (s[0] == '0' && n > 1) return 0;
+    size_t n = strlen(s), i = 0; int neg = 0;
+    if (n > 0 && s[0] == '-') { neg = 1; i = 1; }
+    if (n == i) return 0;
+    for (size_t j = i; j < n; j++) if (!isdigit((unsigned char)s[j])) return 0;
+    int canonical = !(s[i] == '0' && (n - i > 1 || neg));
+    while (i < n - 1 && s[i] == '0') i++;                /* value of a noncanonical token: significant digits only */
     long v = 0;
-    for (size_t i = 0; i < n; i++) { if (!isdigit((unsigned char)s[i])) return 0; v = v * 10 + (s[i] - '0'); }
-    *out = v; return 1;
+    if (n - i > 9) v = 1000000000L;                      /* saturation, above every limit */
+    else for (; i < n; i++) v = v * 10 + (s[i] - '0');
+    *out = neg ? -v : v;
+    return canonical ? 1 : -1;
 }
 
 /* split a comma list in place (no spaces, no empty items, no trailing comma) */
@@ -122,6 +131,7 @@ typedef struct {
     int expected_codes_raw_count;
     char expected_codes_raw[AT0_FAILURE_CODE_COUNT + 1][48];
     int expected_codes_overflow;
+    int noncanonical;               /* a well-formed but noncanonical token was seen (rule 2, judged after the shape pass) */
 } raw_t;
 
 static at0_status copy_tok(const char *src, char *dst, size_t cap)
@@ -130,7 +140,11 @@ static at0_status copy_tok(const char *src, char *dst, size_t cap)
     strcpy(dst, src); return AT0_OK;
 }
 
-#define NEED(expr) do { at0_status st_ = (expr); if (st_ != AT0_OK) return st_; } while (0)
+/* token parse, both within AT0_CASE_V1 section 4 rule 1 (shape and encodings): a shape error
+ * returns at once; a well-formed but noncanonical token is recorded and judged after the whole
+ * shape pass, so a shape error anywhere in the file wins over canonical form */
+#define NEED(expr) do { at0_status st_ = (expr); if (st_ == AT0_CASE_NONCANONICAL) r->noncanonical = 1; else if (st_ != AT0_OK) return st_; } while (0)
+#define SMALL_INT(tok, out) do { int c_ = parse_small_int((tok), (out)); if (c_ == 0) return AT0_CASE_PARSE_ERROR; if (c_ < 0) r->noncanonical = 1; } while (0)
 #define FIXED(L, text) do { const char *l_ = next_line(L); if (!l_ || strcmp(l_, text) != 0) return AT0_CASE_PARSE_ERROR; } while (0)
 #define KEYED(L, key, rest) do { rest = key_rest(next_line(L), key); if (!rest) return AT0_CASE_PARSE_ERROR; } while (0)
 
@@ -150,7 +164,7 @@ static at0_status parse_shape(lines_t *L, at0_case *c, raw_t *r)
     FIXED(L, "begin semantic");
     KEYED(L, "model_family", rest);   NEED(copy_tok(rest, r->model_family, sizeof r->model_family));
     KEYED(L, "energy_unit", rest);    NEED(copy_tok(rest, r->energy_unit, sizeof r->energy_unit));
-    KEYED(L, "clock_dim", rest);      if (!parse_small_int(rest, &r->clock_dim)) return AT0_CASE_PARSE_ERROR;
+    KEYED(L, "clock_dim", rest);      SMALL_INT(rest, &r->clock_dim);
     KEYED(L, "clock_energies", rest);
     {
         if (strlen(rest) >= sizeof tmp) return AT0_CASE_PARSE_ERROR;
@@ -188,7 +202,7 @@ static at0_status parse_shape(lines_t *L, at0_case *c, raw_t *r)
     KEYED(L, "clock_povm", rest);     NEED(copy_tok(rest, r->clock_povm, sizeof r->clock_povm));
     KEYED(L, "povm_tau_turns", rest); NEED(at0_rat_parse(rest, &c->povm_tau_turns));
     KEYED(L, "povm_weight", rest);    NEED(at0_rat_parse(rest, &c->povm_weight));
-    KEYED(L, "clock_label_count", rest); if (!parse_small_int(rest, &r->label_count)) return AT0_CASE_PARSE_ERROR;
+    KEYED(L, "clock_label_count", rest); SMALL_INT(rest, &r->label_count);
     for (long k = 0; k < r->label_count; k++) {
         KEYED(L, "clock_label", rest);
         if (strlen(rest) >= sizeof tmp) return AT0_CASE_PARSE_ERROR;
@@ -197,7 +211,8 @@ static at0_status parse_shape(lines_t *L, at0_case *c, raw_t *r)
         if (!sp) return AT0_CASE_PARSE_ERROR;
         *sp = 0;
         long idx;
-        if (!parse_small_int(tmp, &idx) || idx != k) return AT0_CASE_PARSE_ERROR;
+        SMALL_INT(tmp, &idx);
+        if (idx != k) return AT0_CASE_PARSE_ERROR;
         if (!valid_label(sp + 1)) return AT0_CASE_PARSE_ERROR;
         if (k < AT0_LABEL_MAX) strcpy(c->labels[k], sp + 1);
     }
@@ -242,7 +257,7 @@ static at0_status parse_shape(lines_t *L, at0_case *c, raw_t *r)
     strcpy(c->acceptance_id, rest);
     FIXED(L, "end");
     if (L->pos != L->count) return AT0_CASE_PARSE_ERROR;      /* trailing lines */
-    return AT0_OK;
+    return r->noncanonical ? AT0_CASE_NONCANONICAL : AT0_OK;  /* canonical form, after the whole shape pass (still rule 1) */
 }
 
 /* rule 3: ranges and fixed values */
@@ -289,15 +304,11 @@ static at0_status check_parameters(at0_case *c, const raw_t *r)
 /* rule 4: |h|^2 must be the square of a rational */
 static at0_status check_spectrum(at0_case *c)
 {
-    at0_rat x2, y2, z2, s;
-    at0_status st;
-    if ((st = at0_rat_mul(c->hx, c->hx, &x2)) != AT0_OK) return AT0_ERR_OVERFLOW;
-    if ((st = at0_rat_mul(c->hy, c->hy, &y2)) != AT0_OK) return AT0_ERR_OVERFLOW;
-    if ((st = at0_rat_mul(c->hz, c->hz, &z2)) != AT0_OK) return AT0_ERR_OVERFLOW;
-    if ((st = at0_rat_add(x2, y2, &s)) != AT0_OK) return AT0_ERR_OVERFLOW;
-    if ((st = at0_rat_add(s, z2, &s)) != AT0_OK) return AT0_ERR_OVERFLOW;
+    /* |h|^2 is formed from unreduced 128-bit integers: the reduced rational |h|^2 can have a
+     * denominator up to 2^120 for in-limit tokens with distinct denominators. */
     int sq;
-    if ((st = at0_rat_sqrt_exact(s, &c->h_norm, &sq)) != AT0_OK) return AT0_ERR_OVERFLOW;
+    at0_status st = at0_rat_norm_exact(c->hx, c->hy, c->hz, &c->h_norm, &sq);
+    if (st != AT0_OK) return st;
     if (!sq) return AT0_CASE_IRRATIONAL_SPECTRUM;
     return AT0_OK;
 }
@@ -507,30 +518,3 @@ done:
     return st;
 }
 
-at0_status at0_case_read_file(const char *path, at0_case *out)
-{
-    if (!path || !out) return AT0_ERR_ARGUMENT;
-    FILE *f = fopen(path, "rb");
-    if (!f) return AT0_ERR_IO;
-    size_t cap = 65536, len = 0;
-    uint8_t *buf = malloc(cap);
-    if (!buf) { fclose(f); return AT0_ERR_INTERNAL; }
-    for (;;) {
-        size_t n = fread(buf + len, 1, cap - len, f);
-        len += n;
-        if (n == 0) break;
-        if (len == cap) {
-            if (cap > (size_t)LINE_CAP * 256) { free(buf); fclose(f); return AT0_CASE_PARSE_ERROR; }
-            cap *= 2;
-            uint8_t *nb = realloc(buf, cap);
-            if (!nb) { free(buf); fclose(f); return AT0_ERR_INTERNAL; }
-            buf = nb;
-        }
-    }
-    int err = ferror(f);
-    fclose(f);
-    if (err) { free(buf); return AT0_ERR_IO; }
-    at0_status st = at0_case_parse(buf, len, out);
-    free(buf);
-    return st;
-}
diff --git a/research/atemporal/at0/model/at0_constraint.c b/research/atemporal/at0/model/at0_constraint.c
index 9b4f79ea7..aefd57759 100644
--- a/research/atemporal/at0/model/at0_constraint.c
+++ b/research/atemporal/at0/model/at0_constraint.c
@@ -8,12 +8,17 @@ at0_status at0_constraint_kernel(const at0_case *c, const at0_system_hamiltonian
 {
     if (!c || !hs || !out) return AT0_ERR_ARGUMENT;
     memset(out, 0, sizeof *out);
+    /* E_j + h0 -/+ |h| == 0  <=>  (E_j + h0) == +/-|h|. E_j + h0 has a denominator <= 2^40 and
+     * |h| is representable, so at0_rat_cmp decides exactly; the eigenvalues themselves
+     * (reduced denominator up to 2^80) are never materialized as rationals. */
+    at0_rat neg_norm = c->h_norm;
+    neg_norm.n = -neg_norm.n;
     for (int j = 0; j < c->clock_dim; j++) {
+        at0_rat t;
+        at0_status st = at0_rat_add(c->clock_energies[j], c->h0, &t);
+        if (st != AT0_OK) return st;
         for (int s = 0; s < AT0_SYSTEM_DIM; s++) {
-            at0_rat sum;
-            at0_status st = at0_rat_add(c->clock_energies[j], hs->eig[s], &sum);
-            if (st != AT0_OK) return st;
-            if (at0_rat_is_zero(sum)) {
+            if (at0_rat_cmp(t, s == 0 ? c->h_norm : neg_norm) == 0) {
                 if (out->kernel_dim >= AT0_TOTAL_DIM_MAX) return AT0_ERR_INTERNAL;
                 out->match_j[out->kernel_dim] = j;
                 out->match_s[out->kernel_dim] = s;
@@ -35,56 +40,46 @@ static at0_status overlap_is_zero(const at0_case *c, const at0_system_hamiltonia
         *zero = at0_rat_is_zero(p.re) && at0_rat_is_zero(p.im);
         return AT0_OK;
     }
-    at0_rat a, rpz, hx = c->hx, hy = c->hy;
-    at0_status st = at0_rat_add(c->h_norm, c->hz, &rpz);
+    /* a = |h| + hz = A / D with D = dx dy dz (unreduced, |A| < 2^62, D <= 2^60) */
+    at0_i128 A, D;
+    at0_status st = at0_exact_norm_plus_hz(c->hx, c->hy, c->hz, c->h_norm, &A, &D);
     if (st != AT0_OK) return st;
-    if (at0_rat_is_zero(rpz)) {
+    if (A == 0) {
         /* h = (0, 0, -|h|): the eigenvectors are |0> (s = 0) and |1> (s = 1), as in at0_hamiltonian_system */
         at0_crat p = s == 0 ? p0 : p1;
         *zero = at0_rat_is_zero(p.re) && at0_rat_is_zero(p.im);
         return AT0_OK;
     }
-    /* conj(v_s) . psi0 with v_0 = (-(hx - i hy), a), v_1 = (a, hx + i hy), a = |h| + hz:
-     *   s=0: conj(v_0) = (-(hx + i hy), a)  -> -(hx + i hy) p0 + a p1
-     *   s=1: conj(v_1) = (a, hx - i hy)     ->  a p0 + (hx - i hy) p1
-     * Each is u*p + v*q with u, v complex rationals; test both parts for zero
-     * with cross-multiplied 128-bit integers (no reduction needed). */
-    a = rpz;
-    at0_crat u, v, p, q;
-    if (s == 0) {
-        u.re.n = -hx.n; u.re.d = hx.d; u.im.n = -hy.n; u.im.d = hy.d;   /* -(hx + i hy) */
-        v.re = a; v.im.n = 0; v.im.d = 1;
-        p = p0; q = p1;
-    } else {
-        u.re = a; u.im.n = 0; u.im.d = 1;
-        v.re = hx; v.im.n = -hy.n; v.im.d = hy.d;                          /* hx - i hy */
-        p = p0; q = p1;
-    }
-    /* (u.re + i u.im)(p.re + i p.im) + (v.re + i v.im)(q.re + i q.im) */
-    /* real: u.re p.re - u.im p.im + v.re q.re - v.im q.im ; imag: u.re p.im + u.im p.re + v.re q.im + v.im q.re */
-    /* The product test above can overflow for extreme inputs, so decide the zero test with
-     * the limit-checked rational API instead: each operand is at most 2^20, products are
-     * at most 2^40 and are reduced after every step; AT0_ERR_OVERFLOW is reported, never wrapped. */
-    {
-        at0_rat r1, r2, r3, r4, re, im, t;
-        /* real part */
-        if ((st = at0_rat_mul(u.re, p.re, &r1)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(u.im, p.im, &r2)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(v.re, q.re, &r3)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(v.im, q.im, &r4)) != AT0_OK) return st;
-        if ((st = at0_rat_sub(r1, r2, &t)) != AT0_OK) return st;
-        if ((st = at0_rat_add(t, r3, &t)) != AT0_OK) return st;
-        if ((st = at0_rat_sub(t, r4, &re)) != AT0_OK) return st;
-        /* imaginary part */
-        if ((st = at0_rat_mul(u.re, p.im, &r1)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(u.im, p.re, &r2)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(v.re, q.im, &r3)) != AT0_OK) return st;
-        if ((st = at0_rat_mul(v.im, q.re, &r4)) != AT0_OK) return st;
-        if ((st = at0_rat_add(r1, r2, &t)) != AT0_OK) return st;
-        if ((st = at0_rat_add(t, r3, &t)) != AT0_OK) return st;
-        if ((st = at0_rat_add(t, r4, &im)) != AT0_OK) return st;
-        *zero = at0_rat_is_zero(re) && at0_rat_is_zero(im);
-    }
+    /* conj(v_s) . psi0 with v_0 = (-(hx - i hy), a), v_1 = (a, hx + i hy):
+     *   s=0: conj(v_0) = (-(hx + i hy), a)  -> X p0 + Y p1 with X = -(hx + i hy), Y = a
+     *   s=1: conj(v_1) = (a, hx - i hy)     -> X p0 + Y p1 with X = a, Y = hx - i hy
+     * Every coefficient is written over the common denominator D: hx = nx (dy dz) / D,
+     * hy = ny (dx dz) / D, a = A / D, so each coefficient numerator is < 2^62.
+     * real = Xr p0r - Xi p0i + Yr p1r - Yi p1i,  imag = Xr p0i + Xi p0r + Yr p1i + Yi p1r.
+     * Each part is a sum of four terms (coef / D) * (m / d) with m <= 2^20, d <= 2^20, of which
+     * at most three have a nonzero coefficient (X or Y is real). at0_exact_sum_is_zero drops the
+     * zero terms and cross-multiplies: |coef * m * d' * d''| < 2^62 * 2^20 * 2^40 = 2^122 per
+     * term, three terms < 2^124, within 128-bit signed range; the common factor D cancels. */
+    at0_i128 hxn = (at0_i128)c->hx.n * ((at0_i128)c->hy.d * c->hz.d);
+    at0_i128 hyn = (at0_i128)c->hy.n * ((at0_i128)c->hx.d * c->hz.d);
+    at0_i128 Xr, Xi, Yr, Yi;
+    if (s == 0) { Xr = -hxn; Xi = -hyn; Yr = A; Yi = 0; }
+    else        { Xr = A;    Xi = 0;    Yr = hxn; Yi = -hyn; }
+    at0_i128 num[4], den[4];
+    int zr, zi;
+    /* real part */
+    num[0] =  Xr * p0.re.n; den[0] = p0.re.d;
+    num[1] = -Xi * p0.im.n; den[1] = p0.im.d;
+    num[2] =  Yr * p1.re.n; den[2] = p1.re.d;
+    num[3] = -Yi * p1.im.n; den[3] = p1.im.d;
+    if ((st = at0_exact_sum_is_zero(4, num, den, &zr)) != AT0_OK) return st;
+    /* imaginary part */
+    num[0] = Xr * p0.im.n; den[0] = p0.im.d;
+    num[1] = Xi * p0.re.n; den[1] = p0.re.d;
+    num[2] = Yr * p1.im.n; den[2] = p1.im.d;
+    num[3] = Yi * p1.re.n; den[3] = p1.re.d;
+    if ((st = at0_exact_sum_is_zero(4, num, den, &zi)) != AT0_OK) return st;
+    *zero = zr && zi;
     return AT0_OK;
 }
 
diff --git a/research/atemporal/at0/model/at0_exact.c b/research/atemporal/at0/model/at0_exact.c
index a364f8461..f043cdac6 100644
--- a/research/atemporal/at0/model/at0_exact.c
+++ b/research/atemporal/at0/model/at0_exact.c
@@ -113,27 +113,27 @@ at0_status at0_rat_reduce_turn(at0_rat x, at0_rat *out)
 }
 
 /* ---- canonical integer token -------------------------------------------- */
-/* A canonical digit string longer than 18 digits cannot fit the contract limits; it is
+/* Returns 1 for a canonical integer, 0 for a shape error (rule 1: empty, non-digit, "+",
+ * too long) and -1 for a well-formed but noncanonical one (rule 2: leading zeros, "-0").
+ * A canonical digit string longer than 18 digits cannot fit the contract limits; it is
  * parsed as the saturation value AT0_INT_SATURATED (above every limit, not divisible by 10)
  * so that rule 3 refuses it as CASE_INVALID_PARAMETER after the version check, and no
  * int64 arithmetic can overflow. */
 static int parse_canonical_int(const char *s, size_t len, int64_t *out)
 {
-    /* decimal, optional '-', no leading zeros, no '+', no "-0" */
     if (len == 0 || len > 64) return 0;
     size_t i = 0; int neg = 0;
     if (s[0] == '-') { neg = 1; i = 1; if (len == 1) return 0; }
-    if (s[i] == '0' && len - i > 1) return 0;
-    if (neg && s[i] == '0') return 0;
+    for (size_t j = i; j < len; j++) if (!isdigit((unsigned char)s[j])) return 0;
+    int canonical = 1;
+    if (s[i] == '0' && len - i > 1) canonical = 0;    /* leading zero */
+    if (neg && s[i] == '0') canonical = 0;             /* "-0" (and "-0..." ) */
     int64_t v = 0;
     size_t digits = len - i;
-    for (; i < len; i++) {
-        if (!isdigit((unsigned char)s[i])) return 0;
-        if (digits <= 18) v = v * 10 + (s[i] - '0');
-    }
+    for (; i < len; i++) if (digits <= 18) v = v * 10 + (s[i] - '0');
     if (digits > 18) v = AT0_INT_SATURATED;
     *out = neg ? -v : v;
-    return 1;
+    return canonical ? 1 : -1;
 }
 
 at0_status at0_rat_parse(const char *tok, at0_rat *out)
@@ -142,8 +142,10 @@ at0_status at0_rat_parse(const char *tok, at0_rat *out)
     const char *slash = strchr(tok, '/');
     if (!slash) return AT0_CASE_PARSE_ERROR;
     int64_t n, d;
-    if (!parse_canonical_int(tok, (size_t)(slash - tok), &n)) return AT0_CASE_PARSE_ERROR;
-    if (!parse_canonical_int(slash + 1, strlen(slash + 1), &d)) return AT0_CASE_PARSE_ERROR;
+    int cn = parse_canonical_int(tok, (size_t)(slash - tok), &n);
+    int cd = parse_canonical_int(slash + 1, strlen(slash + 1), &d);
+    if (cn == 0 || cd == 0) return AT0_CASE_PARSE_ERROR;      /* shape first (rule 1) */
+    if (cn < 0 || cd < 0) return AT0_CASE_NONCANONICAL;       /* then canonicality (rule 2) */
     if (d < 1) return AT0_CASE_NONCANONICAL;
     int saturated = n == AT0_INT_SATURATED || n == -AT0_INT_SATURATED || d == AT0_INT_SATURATED;
     if (!saturated && i128_gcd(n, d) != 1) return AT0_CASE_NONCANONICAL;   /* covers 0/5 and 2/4; limits are rule 3 */
@@ -163,9 +165,10 @@ at0_status at0_crat_parse(const char *tok, at0_crat *out)
     if (la == 0 || lb == 0 || la >= sizeof a || lb >= sizeof b) return AT0_CASE_PARSE_ERROR;
     memcpy(a, tok + 1, la); a[la] = 0;
     memcpy(b, semi + 1, lb); b[lb] = 0;
-    at0_status st = at0_rat_parse(a, &out->re);
-    if (st != AT0_OK) return st;
-    return at0_rat_parse(b, &out->im);
+    at0_status sa = at0_rat_parse(a, &out->re), sb = at0_rat_parse(b, &out->im);
+    if (sa == AT0_CASE_PARSE_ERROR || sb == AT0_CASE_PARSE_ERROR) return AT0_CASE_PARSE_ERROR;
+    if (sa != AT0_OK) return sa;
+    return sb;
 }
 
 at0_status at0_scaled_parse(const char *tok, at0_scaled *out)
@@ -174,8 +177,10 @@ at0_status at0_scaled_parse(const char *tok, at0_scaled *out)
     const char *at = strchr(tok, '@');
     if (!at) return AT0_CASE_PARSE_ERROR;
     int64_t n, k;
-    if (!parse_canonical_int(tok, (size_t)(at - tok), &n)) return AT0_CASE_PARSE_ERROR;
-    if (!parse_canonical_int(at + 1, strlen(at + 1), &k)) return AT0_CASE_PARSE_ERROR;
+    int cn = parse_canonical_int(tok, (size_t)(at - tok), &n);
+    int ck = parse_canonical_int(at + 1, strlen(at + 1), &k);
+    if (cn == 0 || ck == 0) return AT0_CASE_PARSE_ERROR;
+    if (cn < 0 || ck < 0) return AT0_CASE_NONCANONICAL;
     if (n < 0 || k < 0) return AT0_CASE_NONCANONICAL;
     if (k > 1000) k = 1000;                 /* above every limit; rule 3 refuses it */
     if (n == 0 && k != 0) return AT0_CASE_NONCANONICAL;
@@ -287,3 +292,80 @@ at0_status at0_scaled_from_double_ceil(double x, at0_scaled *out)
     out->n = n; out->k = k;
     return AT0_OK;
 }
+
+/* ---- overflow-free exact tests on in-limit case data ------------------------ */
+/* Every token of a valid case satisfies rule 3 (|n|, d <= 2^20), but values derived from
+ * several tokens with different denominators (|h|, |h| + hz, eigenvector overlaps) have
+ * reduced denominators far beyond 2^62, so they must never pass through at0_rat. The
+ * functions below keep every intermediate as an unreduced 128-bit integer whose bound is
+ * stated at the use site, and verify each product and sum with checked arithmetic:
+ * an exceeded bound is reported as AT0_ERR_OVERFLOW, never wrapped. */
+
+int at0_i128_mul(at0_i128 a, at0_i128 b, at0_i128 *out) { return !__builtin_mul_overflow(a, b, out); }
+int at0_i128_add(at0_i128 a, at0_i128 b, at0_i128 *out) { return !__builtin_add_overflow(a, b, out); }
+
+static int rat_in_token_limits(at0_rat a) { return at0_rat_in_limits(a); }
+
+at0_status at0_rat_norm_exact(at0_rat hx, at0_rat hy, at0_rat hz, at0_rat *norm, int *is_square)
+{
+    /* |h|^2 = (nx^2 (dy dz)^2 + ny^2 (dx dz)^2 + nz^2 (dx dy)^2) / (dx dy dz)^2.
+     * With tokens <= 2^20: each term <= 2^40 * 2^80 = 2^120, the sum <= 3 * 2^120 < 2^122, D = dx dy dz <= 2^60.
+     * The denominator is a perfect square, so |h| is rational iff the numerator is a perfect
+     * square S^2, and then |h| = S / D with S < 2^61 (representable). */
+    if (!norm || !is_square) return AT0_ERR_ARGUMENT;
+    if (!rat_in_token_limits(hx) || !rat_in_token_limits(hy) || !rat_in_token_limits(hz)) return AT0_ERR_OVERFLOW;
+    *is_square = 0;
+    at0_i128 dx = hx.d, dy = hy.d, dz = hz.d, D, t, term, num = 0;
+    if (!at0_i128_mul(dx, dy, &t) || !at0_i128_mul(t, dz, &D)) return AT0_ERR_OVERFLOW;
+    const at0_i128 n[3] = { hx.n, hy.n, hz.n }, other[3] = { dy * dz, dx * dz, dx * dy };
+    for (int i = 0; i < 3; i++) {
+        if (!at0_i128_mul(n[i], other[i], &t)) return AT0_ERR_OVERFLOW;     /* n_i * (D / d_i) */
+        if (!at0_i128_mul(t, t, &term)) return AT0_ERR_OVERFLOW;
+        if (!at0_i128_add(num, term, &num)) return AT0_ERR_OVERFLOW;
+    }
+    at0_i128 S;
+    if (!i128_is_square(num, &S)) return AT0_OK;
+    at0_status st = rat_from_i128(S, D, norm);
+    if (st != AT0_OK) return st;
+    *is_square = 1;
+    return AT0_OK;
+}
+
+at0_status at0_exact_norm_plus_hz(at0_rat hx, at0_rat hy, at0_rat hz, at0_rat h_norm,
+                                  at0_i128 *A, at0_i128 *D)
+{
+    /* a = |h| + hz = (S + nz dx dy) / D with D = dx dy dz and |h| = S / D unreduced:
+     * S <= sqrt3 * 2^60 < 2^61 and |nz dx dy| <= 2^60, so |A| < 2^62. h_norm is the reduced S / D, hence
+     * h_norm.d divides D and S = h_norm.n * (D / h_norm.d). */
+    if (!A || !D) return AT0_ERR_ARGUMENT;
+    if (!rat_in_token_limits(hx) || !rat_in_token_limits(hy) || !rat_in_token_limits(hz)) return AT0_ERR_OVERFLOW;
+    at0_i128 dx = hx.d, dy = hy.d, dz = hz.d, t, d, S, z;
+    if (!at0_i128_mul(dx, dy, &t) || !at0_i128_mul(t, dz, &d)) return AT0_ERR_OVERFLOW;
+    if (h_norm.d < 1 || d % h_norm.d != 0) return AT0_ERR_INTERNAL;
+    if (!at0_i128_mul((at0_i128)h_norm.n, d / h_norm.d, &S)) return AT0_ERR_OVERFLOW;
+    if (!at0_i128_mul((at0_i128)hz.n, dx * dy, &z)) return AT0_ERR_OVERFLOW;
+    if (!at0_i128_add(S, z, A)) return AT0_ERR_OVERFLOW;
+    *D = d;
+    return AT0_OK;
+}
+
+at0_status at0_exact_sum_is_zero(int count, const at0_i128 *num, const at0_i128 *den, int *zero)
+{
+    /* sum_i num[i]/den[i] == 0  <=>  sum_i num[i] * prod_{j != i} den[j] == 0.
+     * Terms with a zero numerator are dropped first so that the products only involve the
+     * denominators of the terms that can contribute. The caller states the bound. */
+    if (!num || !den || !zero || count < 0 || count > 4) return AT0_ERR_ARGUMENT;
+    at0_i128 n[4], d[4]; int m = 0;
+    for (int i = 0; i < count; i++) {
+        if (den[i] < 1) return AT0_ERR_ARGUMENT;
+        if (num[i] != 0) { n[m] = num[i]; d[m] = den[i]; m++; }
+    }
+    at0_i128 acc = 0;
+    for (int i = 0; i < m; i++) {
+        at0_i128 t = n[i];
+        for (int j = 0; j < m; j++) if (j != i && !at0_i128_mul(t, d[j], &t)) return AT0_ERR_OVERFLOW;
+        if (!at0_i128_add(acc, t, &acc)) return AT0_ERR_OVERFLOW;
+    }
+    *zero = acc == 0;
+    return AT0_OK;
+}
diff --git a/research/atemporal/at0/model/at0_hamiltonian.c b/research/atemporal/at0/model/at0_hamiltonian.c
index bc246af79..29cbd5e25 100644
--- a/research/atemporal/at0/model/at0_hamiltonian.c
+++ b/research/atemporal/at0/model/at0_hamiltonian.c
@@ -10,11 +10,11 @@ at0_status at0_hamiltonian_system(const at0_case *c, at0_system_hamiltonian *out
     if (!c || !out) return AT0_ERR_ARGUMENT;
     memset(out, 0, sizeof *out);
     at0_status st;
-    if ((st = at0_rat_sub(c->h0, c->h_norm, &out->eig[0])) != AT0_OK) return st;
-    if ((st = at0_rat_add(c->h0, c->h_norm, &out->eig[1])) != AT0_OK) return st;
     double h0 = at0_rat_to_double(c->h0), hx = at0_rat_to_double(c->hx);
     double hy = at0_rat_to_double(c->hy), hz = at0_rat_to_double(c->hz);
     double r = at0_rat_to_double(c->h_norm);
+    out->eig[0] = h0 - r;
+    out->eig[1] = h0 + r;
     out->hs.m[0][0] = h0 + hz;      out->hs.m[0][1] = hx - I * hy;
     out->hs.m[1][0] = hx + I * hy;  out->hs.m[1][1] = h0 - hz;
     if (at0_rat_is_zero(c->h_norm)) {
@@ -24,9 +24,9 @@ at0_status at0_hamiltonian_system(const at0_case *c, at0_system_hamiltonian *out
         out->vec[1].v[0] = 0.0; out->vec[1].v[1] = 1.0;
         return AT0_OK;
     }
-    at0_rat rpz;
-    if ((st = at0_rat_add(c->h_norm, c->hz, &rpz)) != AT0_OK) return st;
-    if (at0_rat_is_zero(rpz)) {
+    at0_i128 A, D;    /* exact a = |h| + hz = A / D, never a reduced rational (its denominator can exceed 2^62) */
+    if ((st = at0_exact_norm_plus_hz(c->hx, c->hy, c->hz, c->h_norm, &A, &D)) != AT0_OK) return st;
+    if (A == 0) {
         /* h = (0, 0, -|h|): eigenvalue -|h| on |0>, +|h| on |1> */
         out->vec[0].v[0] = 1.0; out->vec[0].v[1] = 0.0;
         out->vec[1].v[0] = 0.0; out->vec[1].v[1] = 1.0;
diff --git a/research/atemporal/at0/model/at0_io.c b/research/atemporal/at0/model/at0_io.c
new file mode 100644
index 000000000..e4190c0f8
--- /dev/null
+++ b/research/atemporal/at0/model/at0_io.c
@@ -0,0 +1,36 @@
+/* File input for the AT-0 candidate engine: reads a case file into memory and hands the
+ * bytes to the validator. This is the only component that touches the file system; the
+ * parser (at0_case.c) and every physics component work on bytes and structs alone. */
+#include "at0_model.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+#define AT0_IO_FILE_CAP (4096 * 256)      /* same byte budget as the parser's line table */
+
+at0_status at0_case_read_file(const char *path, at0_case *out)
+{
+    if (!path || !out) return AT0_ERR_ARGUMENT;
+    FILE *f = fopen(path, "rb");
+    if (!f) return AT0_ERR_IO;
+    size_t cap = 65536, len = 0;
+    uint8_t *buf = malloc(cap);
+    if (!buf) { fclose(f); return AT0_ERR_INTERNAL; }
+    for (;;) {
+        size_t n = fread(buf + len, 1, cap - len, f);
+        len += n;
+        if (n == 0) break;
+        if (len == cap) {
+            if (cap > (size_t)AT0_IO_FILE_CAP) { free(buf); fclose(f); return AT0_CASE_PARSE_ERROR; }
+            cap *= 2;
+            uint8_t *nb = realloc(buf, cap);
+            if (!nb) { free(buf); fclose(f); return AT0_ERR_INTERNAL; }
+            buf = nb;
+        }
+    }
+    int err = ferror(f);
+    fclose(f);
+    if (err) { free(buf); return AT0_ERR_IO; }
+    at0_status st = at0_case_parse(buf, len, out);
+    free(buf);
+    return st;
+}
diff --git a/research/atemporal/at0/model/at0_model.h b/research/atemporal/at0/model/at0_model.h
index 3dad55683..d53389be7 100644
--- a/research/atemporal/at0/model/at0_model.h
+++ b/research/atemporal/at0/model/at0_model.h
@@ -76,6 +76,13 @@ int        at0_scaled_in_limits(at0_scaled s);  /* contract limit k <= 40 */
 double     at0_rat_to_double(at0_rat a);                      /* one correctly-rounded division */
 /* exact test: is a a square of a rational? if yes, *root is the nonnegative root */
 at0_status at0_rat_sqrt_exact(at0_rat a, at0_rat *root, int *is_square);
+/* overflow-free exact helpers for in-limit case data (see at0_exact.c): */
+int        at0_i128_mul(at0_i128 a, at0_i128 b, at0_i128 *out);    /* 1 on success, 0 on overflow */
+int        at0_i128_add(at0_i128 a, at0_i128 b, at0_i128 *out);
+at0_status at0_rat_norm_exact(at0_rat hx, at0_rat hy, at0_rat hz, at0_rat *norm, int *is_square); /* |h| */
+at0_status at0_exact_norm_plus_hz(at0_rat hx, at0_rat hy, at0_rat hz, at0_rat h_norm,
+                                  at0_i128 *A, at0_i128 *D);        /* |h| + hz = A / D, D = dx dy dz */
+at0_status at0_exact_sum_is_zero(int count, const at0_i128 *num, const at0_i128 *den, int *zero);
 /* reduce x into [-1/2, 1/2) exactly: x - round(x) */
 at0_status at0_rat_reduce_turn(at0_rat x, at0_rat *out);
 
@@ -165,7 +172,8 @@ at0_status at0_state_check_finite(const at0_state *s);
 
 /* ---- Hamiltonian construction --------------------------------------------- */
 typedef struct {
-    at0_rat eig[AT0_SYSTEM_DIM];        /* e_0 = h0 - |h|, e_1 = h0 + |h| (exact) */
+    double eig[AT0_SYSTEM_DIM];         /* binary64 values of e_0 = h0 - |h|, e_1 = h0 + |h|; the exact
+                                           spectrum lives in the case (h0, h_norm) and is what the kernel test uses */
     at0_qubit vec[AT0_SYSTEM_DIM];      /* orthonormal eigenvectors (binary64) */
     int degenerate;                     /* |h| == 0 */
     at0_qubit_op hs;                    /* H_S matrix in computational basis */
diff --git a/research/atemporal/at0/model/build.sh b/research/atemporal/at0/model/build.sh
index 3d2a09c41..bea4cfef6 100755
--- a/research/atemporal/at0/model/build.sh
+++ b/research/atemporal/at0/model/build.sh
@@ -12,7 +12,7 @@ if [ "$MODE" = asan ]; then OUT="$HERE/build-asan"; CFLAGS="$CFLAGS -O1 -g -fsan
 else OUT="$HERE/build"; CFLAGS="$CFLAGS -O2"; fi
 CC=${CC:-gcc}
 mkdir -p "$OUT"
-LIB="$HERE/at0_exact.c $HERE/at0_case.c $HERE/at0_state.c $HERE/at0_hamiltonian.c $HERE/at0_constraint.c \
+LIB="$HERE/at0_exact.c $HERE/at0_case.c $HERE/at0_io.c $HERE/at0_state.c $HERE/at0_hamiltonian.c $HERE/at0_constraint.c \
      $HERE/at0_povm.c $HERE/at0_conditional.c $HERE/at0_observable.c $HERE/at0_engine.c $HERE/at0_output.c $ROOT/src/sha256.c"
 # shellcheck disable=SC2086
 $CC $CFLAGS -o "$OUT/at0-model" $HERE/at0_main.c $LIB -lm
diff --git a/research/atemporal/at0/model/tests/.crumb b/research/atemporal/at0/model/tests/.crumb
index b10c7868f..b2e73b31f 100644
--- a/research/atemporal/at0/model/tests/.crumb
+++ b/research/atemporal/at0/model/tests/.crumb
@@ -3,21 +3,21 @@
     "generated": {
       "children": [
         {
-          "digest": "3f458e7cbb850b27968d4de4597067b979707b6230e5259a523d7538006967b6",
-          "last_commit": "547cda8",
+          "digest": "527512e5eaf0bd2d79337efffd7981a50121377c4362e49dce7465c9b4d24aa9",
+          "last_commit": "94059ae",
           "name": "cases",
           "purpose": "AT0_CASE_V1 case files used by the tests; the KAT file is the contract section 6 example byte fo"
         }
       ],
-      "children_root": "sha256:4d31598f44679f12de8b915d8daea2f08fe425951cb1f553554349a0718ea56f",
-      "compiled_at": "2026-10-09T22:41:51Z",
+      "children_root": "sha256:6c973f061a2142f8bb4c9de2b0c9eb2bf1b2c665c72622fc089feddfeee71973",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:e9114c1e9534737dc1a4d49971f6abb3278e4dcf7c5b9c544795c90c8812bccc",
+      "digest": "sha256:9153a6c121ecfbc87b0d7122afbb68c74d80590f6eb96f85e2cc8625e7020aab",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 3,
-      "generated_at_commit": "f5ece3506f5451e4b8e13145a96e758fe0359b86",
-      "source_tree": "sha256:f33d7951bb98df749c5654eea9169eb06cd808c908b5f8d3c931a118110f90f2"
+      "files": 4,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:b97ec203ba9fdbb96af42743e8c5214b46e3275ec53989df284ecf0a3ca5bca1"
     }
   },
   "name": "tests",
diff --git a/research/atemporal/at0/model/tests/cases/.crumb b/research/atemporal/at0/model/tests/cases/.crumb
index 999c6da23..fcede3f97 100644
--- a/research/atemporal/at0/model/tests/cases/.crumb
+++ b/research/atemporal/at0/model/tests/cases/.crumb
@@ -3,14 +3,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-10-09T22:33:14Z",
+      "compiled_at": "2026-10-10T00:22:09Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:3f458e7cbb850b27968d4de4597067b979707b6230e5259a523d7538006967b6",
+      "digest": "sha256:527512e5eaf0bd2d79337efffd7981a50121377c4362e49dce7465c9b4d24aa9",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 1,
-      "generated_at_commit": "547cda8fefd174045da3b7833972ae5d22496878",
-      "source_tree": "sha256:e846c823a32f900e5e0cbd6cd17f13ade7d2ff7bf98d17ffeae31c2d3f41d008"
+      "files": 2,
+      "generated_at_commit": "f21b4d55d4a8ae1fd32ce435126c83eb82ed3b1c",
+      "source_tree": "sha256:9f2c046584945066782603f62c68a0bc61e5a7e2e18eb0a03955d2e52890d58a"
     }
   },
   "name": "cases",
diff --git a/research/atemporal/at0/model/tests/cases/p5-large-rationals.case b/research/atemporal/at0/model/tests/cases/p5-large-rationals.case
new file mode 100644
index 000000000..77acaa6ca
--- /dev/null
+++ b/research/atemporal/at0/model/tests/cases/p5-large-rationals.case
@@ -0,0 +1,38 @@
+OMEGA-AT0-CASE v1
+domain omega.at0.case.v1
+contract AT0_CASE_V1
+case_name at0-p5-large-rationals
+begin semantic
+model_family PAGE_WOOTTERS_FINITE_IDEAL
+energy_unit DIMENSIONLESS_HBAR_1
+clock_dim 2
+clock_energies -7/1048573,7/1048573
+system_dim 2
+system_hamiltonian_pauli 0/1,2/1048573,3/1048573,6/1048573
+interaction NONE
+constraint SUM_HC_HS
+physical_state NULLSPACE_PROJECTION
+reference_clock_label t0
+reference_system_state (1/1048571;0/1),(1/1048569;1/1048567)
+clock_povm COVARIANT_DISCRETE
+povm_tau_turns 1048573/28
+povm_weight 1/1
+clock_label_count 2
+clock_label 0 t0
+clock_label 1 t1
+observables PAULI_X,PAULI_Y,PAULI_Z
+end semantic
+begin acceptance
+control_kind POSITIVE
+expected_outcome PASS
+expected_failure_codes none
+min_bound_kind ESTIMATED
+tol_constraint_residual 1@12
+tol_povm_residual 1@12
+tol_probability 1@12
+tol_zero_probability 1@9
+tol_schrodinger 1@12
+end acceptance
+case_id 46726a3921759525561c49c54697d4b4ef9e5712519eb65c49df2724120f5aec
+acceptance_id a13fb02dd674b8042ef8c0a197f03d58768709f782ba59cd26545eef6d41a228
+end
diff --git a/research/atemporal/at0/model/tests/test_model.c b/research/atemporal/at0/model/tests/test_model.c
index 3e33b9bb9..06f3af461 100644
--- a/research/atemporal/at0/model/tests/test_model.c
+++ b/research/atemporal/at0/model/tests/test_model.c
@@ -118,12 +118,39 @@ static int test_exact_arithmetic(void)
     CHECK(at0_rat_make(INT64_MAX, 1, &r) == AT0_ERR_OVERFLOW, "representability limit");
     OK(at0_rat_make(1000, 1, &r)); OK(at0_rat_mul(r, r, &r)); OK(at0_rat_mul(r, r, &r)); CHECK(r.n == 1000000000000LL, "wide product");
     CHECK(at0_rat_parse("2/4", &r) == AT0_CASE_NONCANONICAL, "2/4");
-    CHECK(at0_rat_parse("-0/1", &r) == AT0_CASE_PARSE_ERROR, "-0/1");
+    CHECK(at0_rat_parse("-0/1", &r) == AT0_CASE_NONCANONICAL, "-0/1 is well formed but noncanonical (qualification D2)");
+    CHECK(at0_rat_parse("04/1", &r) == AT0_CASE_NONCANONICAL, "leading zero numerator");
+    CHECK(at0_rat_parse("1/04", &r) == AT0_CASE_NONCANONICAL, "leading zero denominator");
+    CHECK(at0_rat_parse("04/x", &r) == AT0_CASE_PARSE_ERROR, "shape error wins over canonicality inside a token");
+    CHECK(at0_rat_parse("0/1", &r) == AT0_OK && r.n == 0, "0/1 canonical");
+    at0_crat z;
+    CHECK(at0_crat_parse("(-0/1;1/1)", &z) == AT0_CASE_NONCANONICAL, "-0 inside a complex token");
+    CHECK(at0_crat_parse("(-0/1;1/x)", &z) == AT0_CASE_PARSE_ERROR, "shape error in the other part wins");
     CHECK(at0_rat_parse("+1/1", &r) == AT0_CASE_PARSE_ERROR, "+1/1");
     CHECK(at0_rat_parse("1/0", &r) == AT0_CASE_NONCANONICAL, "1/0");
     at0_scaled s;
     CHECK(at0_scaled_parse("10@13", &s) == AT0_CASE_NONCANONICAL, "10@13");
     CHECK(at0_scaled_parse("0@3", &s) == AT0_CASE_NONCANONICAL, "0@3");
+    CHECK(at0_scaled_parse("04@1", &s) == AT0_CASE_NONCANONICAL, "leading zero scaled");
+    CHECK(at0_scaled_parse("1@04", &s) == AT0_CASE_NONCANONICAL, "leading zero exponent");
+    CHECK(at0_scaled_parse("-0@0", &s) == AT0_CASE_NONCANONICAL, "-0 scaled");
+    /* overflow-free |h| and |h| + hz for in-limit tokens with distinct denominators (qualification D1) */
+    {
+        at0_rat hn; int issq; at0_i128 A, D;
+        OK(at0_rat_norm_exact(R(1, 349524), R(1, 262143), R(0, 1), &hn, &issq));   /* (3, 4) / 1048572 in reduced form */
+        CHECK(issq && hn.n == 5 && hn.d == 1048572, "|h| = 5/1048572, got %lld/%lld", (long long)hn.n, (long long)hn.d);
+        OK(at0_exact_norm_plus_hz(R(1, 349524), R(1, 262143), R(0, 1), hn, &A, &D));
+        CHECK(D == (at0_i128)349524 * 262143 && A == (at0_i128)5 * 87381, "a = |h| + hz over D = dx dy dz: A=%lld D=%lld", (long long)A, (long long)D);
+        OK(at0_rat_norm_exact(R(1, 1048573), R(1, 1048571), R(1, 1048569), &hn, &issq));
+        CHECK(!issq, "three coprime denominators: irrational, decided without overflow");
+        OK(at0_rat_norm_exact(R(2, 1048573), R(3, 1048573), R(6, 1048573), &hn, &issq));
+        CHECK(issq && hn.n == 7 && hn.d == 1048573, "P5 norm 7/1048573");
+        at0_i128 num[4] = { 1, -1, 0, 0 }, den[4] = { 1048573, 1048573, 1, 1 }; int zero;
+        OK(at0_exact_sum_is_zero(4, num, den, &zero)); CHECK(zero, "1/d - 1/d == 0");
+        num[1] = -1; den[1] = 1048571;
+        OK(at0_exact_sum_is_zero(4, num, den, &zero)); CHECK(!zero, "1/d1 - 1/d2 != 0");
+        CHECK(at0_rat_norm_exact(R(AT0_RATIONAL_LIMIT + 1, 1), R(0, 1), R(0, 1), &hn, &issq) == AT0_ERR_OVERFLOW, "out-of-limit input is refused, not wrapped");
+    }
     OK(at0_scaled_parse("1@41", &s)); CHECK(!at0_scaled_in_limits(s), "1@41 parses, rule 3 refuses it");
     OK(at0_scaled_parse("25@2", &s)); CHECK(s.n == 25 && s.k == 2, "25@2");
     /* exact comparison: p = 0.25, b = 1e-15, tol = 1e-9 -> defined */
@@ -375,6 +402,88 @@ static int expect_refusal(const char *name, const char *from, const char *to, at
     return 0;
 }
 
+/* two substitutions in sequence */
+static int expect_refusal2(const char *name, const char *from1, const char *to1, const char *from2, const char *to2, at0_status want)
+{
+    static char text[8192]; at0_case c;
+    memcpy(text, kat_bytes, kat_len); text[kat_len] = 0;
+    const char *from[2] = { from1, from2 }, *to[2] = { to1, to2 };
+    for (int i = 0; i < 2; i++) {
+        char *pos = strstr(text, from[i]);
+        CHECK(pos != NULL, "%s: pattern %d not found", name, i);
+        static char out[8192];
+        size_t head = (size_t)(pos - text);
+        memcpy(out, text, head); out[head] = 0;
+        strcat(out, to[i]); strcat(out, pos + strlen(from[i]));
+        strcpy(text, out);
+    }
+    at0_status st = at0_case_parse((const uint8_t *)text, strlen(text), &c);
+    CHECK(st == want, "%s: got %s, want %s", name, at0_status_name(st), at0_status_name(want));
+    return 0;
+}
+
+/* qualification D1: in-limit tokens with large, distinct denominators must run, not overflow */
+static int test_large_rationals_within_limits(void)
+{
+    static at0_engine_result r;
+    {
+        /* Agent 5's positive case P5 (copied byte for byte into tests/cases) */
+        static uint8_t buf[8192]; size_t len; at0_case c;
+        CHECK(load_file("p5-large-rationals.case", buf, sizeof buf, &len), "cannot read p5 case");
+        OK(at0_case_parse(buf, len, &c));
+        OK(at0_engine_run(&c, &r));
+        CHECK(r.kernel_dim == 2 && r.psi_nonzero, "P5 kernel %d nonzero %d", r.kernel_dim, r.psi_nonzero);
+        double psum = 0;
+        for (int k = 0; k < r.label_count; k++) {
+            psum += r.label[k].clock_probability;
+            for (int a = 0; a < 3; a++)
+                CHECK(fabs(r.label[k].pauli[a][0] + r.label[k].pauli[a][1] - 1.0) <= 1e-14, "P5 label %d axis %d not normalized", k, a);
+        }
+        CHECK(fabs(psum - 1.0) <= 1e-14, "P5 clock probabilities sum %.17g", psum);
+    }
+    {
+        /* N = 2, h = (1/349524, 1/262143, 0) = (3, 4, 0)/1048572: |h| = 5/1048572, three distinct in-limit denominators;
+         * psi0 = ((-3 + 4i), 5) / 1048571 is the exact eigenvector v_0, so <v_1|psi0> = 0 exactly
+         * (the overlap decision must be exact over 128-bit integers, never a reduced rational).
+         * The conditional state is then the stationary eigenstate for every label:
+         * P(Z+) = 25/50 = 1/2, P(X+) = (1 - 3/5)/2 = 1/5, P(Y+) = (1 - 4/5)/2 = 1/10. */
+        at0_case c; spec_two_level(&c, 4, 0);
+        strcpy(c.name, "large-distinct-denominators");
+        c.clock_energies[0] = R(-5, 1048572); c.clock_energies[1] = R(5, 1048572);
+        c.h0 = R(0, 1); c.hx = R(1, 349524); c.hy = R(1, 262143); c.hz = R(0, 1);
+        c.psi0[0].re = R(-3, 1048571); c.psi0[0].im = R(4, 1048571);
+        c.psi0[1].re = R(5, 1048571);  c.psi0[1].im = R(0, 1);
+        c.povm_tau_turns = R(1048572, 40);     /* tau (E_1 - E_0) = 1/4 turn per label step */
+        OK(finalize(&c));
+        CHECK(c.h_norm.n == 5 && c.h_norm.d == 1048572, "|h|");
+        OK(at0_engine_run(&c, &r));
+        CHECK(r.kernel_dim == 2 && r.psi_nonzero, "kernel %d nonzero %d", r.kernel_dim, r.psi_nonzero);
+        for (int k = 0; k < r.label_count; k++) {
+            CHECK(fabs(r.label[k].pauli[2][0] - 0.5) <= 1e-14, "Z+ label %d = %.17g", k, r.label[k].pauli[2][0]);
+            CHECK(fabs(r.label[k].pauli[0][0] - 0.2) <= 1e-14, "X+ label %d = %.17g", k, r.label[k].pauli[0][0]);
+            CHECK(fabs(r.label[k].pauli[1][0] - 0.1) <= 1e-14, "Y+ label %d = %.17g", k, r.label[k].pauli[1][0]);
+        }
+        /* the exact zero decision itself: with energies {-5/1048572, 1/1} only (j = 0, s = 1) is in the
+         * kernel, and <v_1|psi0> = 0 exactly, so Psi = 0 and the engine must say so (the old engine
+         * overflowed here; a wrong "nonzero" would give a tiny junk state instead) */
+        c.clock_energies[1] = R(1, 1);
+        OK(finalize(&c));
+        OK(at0_engine_run(&c, &r));
+        CHECK(r.kernel_dim == 1 && !r.psi_nonzero, "exact zero: kernel %d nonzero %d", r.kernel_dim, r.psi_nonzero);
+        c.clock_energies[1] = R(5, 1048572);
+        /* and the generic (nonzero overlap) branch with three further denominators */
+        c.psi0[0].re = R(1, 1048571); c.psi0[0].im = R(0, 1);
+        c.psi0[1].re = R(1, 1048569); c.psi0[1].im = R(1, 1048567);
+        OK(finalize(&c));
+        OK(at0_engine_run(&c, &r));
+        CHECK(r.psi_nonzero, "generic psi0 gives a nonzero state");
+        double psum = 0;
+        for (int k = 0; k < r.label_count; k++) psum += r.label[k].clock_probability;
+        CHECK(fabs(psum - 1.0) <= 1e-14, "clock probabilities sum %.17g", psum);
+    }
+    return 0;
+}
+
 static int test_invalid_input_refusal(void)
 {
     int f = 0;
@@ -398,6 +507,15 @@ static int test_invalid_input_refusal(void)
     f |= expect_refusal("crlf", "clock_dim 4\n", "clock_dim 4\r\n", AT0_CASE_PARSE_ERROR);
     f |= expect_refusal("missing final lf", "end\n", "end", AT0_CASE_PARSE_ERROR);
     f |= expect_refusal("unknown key", "interaction NONE", "interactions NONE", AT0_CASE_PARSE_ERROR);
+    /* qualification D2: well-formed but noncanonical integers are CASE_NONCANONICAL (rule 1, canonical form) */
+    f |= expect_refusal("R17 leading-zero clock_dim", "clock_dim 4\n", "clock_dim 04\n", AT0_CASE_NONCANONICAL);
+    f |= expect_refusal("R30 negative zero h0", "0/1,0/1,0/1,1/2", "-0/1,0/1,0/1,1/2", AT0_CASE_NONCANONICAL);
+    f |= expect_refusal("leading-zero label count", "clock_label_count 4", "clock_label_count 04", AT0_CASE_NONCANONICAL);
+    f |= expect_refusal("leading-zero label index", "clock_label 0 t0", "clock_label 00 t0", AT0_CASE_NONCANONICAL);
+    f |= expect_refusal("plus sign is a shape error", "povm_weight 1/1", "povm_weight +1/1", AT0_CASE_PARSE_ERROR);
+    f |= expect_refusal("long leading-zero count is still noncanonical", "clock_dim 4\n", "clock_dim 0000000004\n", AT0_CASE_NONCANONICAL);
+    /* within rule 1: a shape error after a noncanonical token still reports the shape error */
+    f |= expect_refusal2("shape error beats canonical form across lines", "clock_dim 4\n", "clock_dim 04\n", "povm_weight 1/1", "povm_weight 1/x", AT0_CASE_PARSE_ERROR);
     f |= expect_refusal("bad label chars", "clock_label 1 t1", "clock_label 1 T1", AT0_CASE_PARSE_ERROR);
     f |= expect_refusal("trailing lines", "end\n", "end\nextra\n", AT0_CASE_PARSE_ERROR);
     f |= expect_refusal("bad failure code with FAIL", "expected_outcome PASS\nexpected_failure_codes none", "expected_outcome FAIL\nexpected_failure_codes NOT_A_CODE", AT0_CASE_ID_MISMATCH);
@@ -473,6 +591,7 @@ int main(int argc, char **argv)
         { "invalid_input_refusal", test_invalid_input_refusal },
         { "repeatability_and_order", test_repeatability_and_order },
         { "review_findings_f1_f5", test_review_findings },
+        { "large_rationals_within_limits", test_large_rationals_within_limits },
     };
     int total = (int)(sizeof tests / sizeof tests[0]), passed = 0;
     for (int i = 0; i < total; i++) {