﻿--- mqg_test28_runner.py
+++ mqg_test30_runner.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
-"""MQG test 28 runner: the powers <J+^m>, m = 1..7, at theta = 0.25, mu = 2.5, N = 640, to t = 760, written 2026-12-01.
+"""MQG test 30 runner: the powers <J+^m>, m = 1..7, at theta = 0.15, mu = 3.0, N = 1280, to t = 600, written 2026-12-02.
 
-Computes the 5 rows of MQG_TEST_28_PUBLIC_PLAN (MQG28-01 to MQG28-05, one per TWA replicate). The exact powers
+Computes the 5 rows of MQG_TEST_30_PUBLIC_PLAN (MQG30-01 to MQG30-05, one per TWA replicate). The exact powers
 <J+^m>(t) come from mqg_moments.exact_powers, the block algorithm of the Paper 2 solver (mqg_step2_robustness.py,
 imported unchanged); they are computed once and cached. Each row draws a gaussian TWA ensemble with the solver's
 sampling and equations (mqg_moments.twa_powers) and, for every m, forms
@@ -19,9 +19,10 @@
   * A smoke mode (--smoke-theta, --smoke-tmax, --sizes) runs at another angle and size with a short window, to test
     the pipeline only, and writes only to --output-dir. Its rows are marked smoke and the scorer refuses them.
 The running mean of D_m (width 30) is saved for every row and rank in series/<run_id>.npz, as in test 24.
-This file differs from mqg_test9T_runner.py (doi:10.5281/zenodo.24671433) only in the state (theta = 0.25, mu = 2.5,
-N = 640), the window (T_MAX = 760), the seeds, the plan spectral time and orbit norms, the run labels and the file names.
-It does not score. The frozen scoring rules are in mqg_test28_score.py.
+This file differs from mqg_test28_runner.py (doi:10.5281/zenodo.24728778) only in the state (theta = 0.15, mu = 3.0,
+N = 1280), the window (T_MAX = 600), the seeds, the plan spectral time and orbit norms, the run labels, the file names, and
+a default= handler for NumPy scalars in the JSON writes (lesson of test 19).
+It does not score. The frozen scoring rules are in mqg_test30_score.py.
 """
 from pathlib import Path
 import argparse, csv, hashlib, importlib.util, json, math, platform, sys
@@ -29,10 +30,10 @@
 import numpy as np
 
 BASE = Path('/content/drive/MyDrive/P2_KAPPA_PREREGISTRATION')
-THETA, MU, SIZES, MMAX = 0.25, 2.5, (640,), 7
-REPLICATES, SEED0, T_MAX = 5, 20272801, 760.0
-PLAN_TSPEC = {640: 383.14}
-PLAN_NORMS = {1: 1.021701, 2: 1.424277, 3: 2.227323, 4: 3.686943, 5: 6.308354, 6: 11.026792, 7: 19.562974}
+THETA, MU, SIZES, MMAX = 0.15, 3.0, (1280,), 7
+REPLICATES, SEED0, T_MAX = 5, 20273001, 600.0
+PLAN_TSPEC = {1280: 434.51}
+PLAN_NORMS = {1: 0.884066, 2: 1.152190, 3: 1.724591, 4: 2.755142, 5: 4.565319, 6: 7.741142, 7: 13.334649}
 
 
 def load(path, name):
@@ -70,9 +71,9 @@
     if smoke and abs(args.smoke_theta - THETA) < 1e-9:
         raise SystemExit('STOP: a smoke test must not use the test angle.')
     if not args.deposit_doi.strip():
-        raise SystemExit('STOP: give --deposit-doi of the deposited public plan before any test-28 row.')
+        raise SystemExit('STOP: give --deposit-doi of the deposited public plan before any test-30 row.')
     theta = args.smoke_theta if smoke else THETA
-    out = Path(args.output_dir) if args.output_dir else BASE / 'mqg_test28'
+    out = Path(args.output_dir) if args.output_dir else BASE / 'mqg_test30'
 
     inp = Path(args.input_dir)
     rv_path, solver_path, mm_path = (inp / 'p2_development_runner_colab_v2.py', inp / 'mqg_step2_robustness.py',
@@ -125,7 +126,7 @@
             print(f'exact step N={N} done, largest norm deviation {normdev:.1e}', flush=True)
         for rep in range(1, REPLICATES + 1):
             i += 1
-            row = dict(run_id=f'MQG28-{i:02d}', theta=theta, mu=MU, N=N, replicate=rep, seed=SEED0 + i - 1)
+            row = dict(run_id=f'MQG30-{i:02d}', theta=theta, mu=MU, N=N, replicate=rep, seed=SEED0 + i - 1)
             rows.append(row)
             rec_path = rec_dir / f"{row['run_id']}.json"
             if rec_path.exists():
@@ -148,16 +149,16 @@
                        twa_variance_check=tw['var_check'], qfi_twa_t0=float(tw['qfi'][0]), ranks=per_m,
                        series_file=f"series/{row['run_id']}.npz",
                        completed_utc=datetime.now(timezone.utc).isoformat(), **env)
-            rec_path.write_text(json.dumps(rec, indent=2, sort_keys=True), encoding='utf-8')
+            rec_path.write_text(json.dumps(rec, indent=2, sort_keys=True, default=lambda x: x.item()), encoding='utf-8')
             summary = ' '.join(f"m{m}:{per_m[str(m)]['censor_type'][0]}"
                                f"{'' if per_m[str(m)].get('t_b') is None else '=%.2f' % per_m[str(m)]['t_b']}"
                                for m in range(1, MMAX + 1))
             print(f"{row['run_id']}: N={N} rep={rep} {summary}", flush=True)
 
-    recs = [json.loads(p.read_text()) for p in sorted(rec_dir.glob('MQG28-*.json'))]
+    recs = [json.loads(p.read_text()) for p in sorted(rec_dir.glob('MQG30-*.json'))]
     cols = ['run_id', 'N', 'replicate', 'seed', 'm', 'censor_type', 't_b', 'lower_bound', 'upper_bound',
             'max_running_excess', 't_at_max', 'T_max', 'completed_utc']
-    with (out / 'mqg_test28_returntimes.csv').open('w', newline='', encoding='utf-8') as f:
+    with (out / 'mqg_test30_returntimes.csv').open('w', newline='', encoding='utf-8') as f:
         w = csv.DictWriter(f, fieldnames=cols)
         w.writeheader()
         for r in recs:
@@ -167,10 +168,10 @@
                                 censor_type=d.get('censor_type'), t_b=d.get('t_b'), lower_bound=d.get('lower_bound'),
                                 upper_bound=d.get('upper_bound'), max_running_excess=d['max_running_excess'],
                                 t_at_max=d['t_at_max'], T_max=r['T_max'], completed_utc=r['completed_utc']))
-    (out / 'mqg_test28_status.json').write_text(json.dumps(dict(
+    (out / 'mqg_test30_status.json').write_text(json.dumps(dict(
         rows_completed=len(recs), rows_required=len(rows), python=sys.version, platform=platform.platform(),
-        updated_utc=datetime.now(timezone.utc).isoformat(), **env), indent=2), encoding='utf-8')
-    print(f'MQG test 28 rows completed: {len(recs)}/{len(rows)}. Not scored here.')
+        updated_utc=datetime.now(timezone.utc).isoformat(), **env), indent=2, default=lambda x: x.item()), encoding='utf-8')
+    print(f'MQG test 30 rows completed: {len(recs)}/{len(rows)}. Not scored here.')
 
 
 if __name__ == '__main__':
