# MQG test 21: Colab cells (RUN with scoring, then VERIFY)

The smoke test was run on 19 November 2026 (Colab, Python 3.13.18, NumPy 2.4.6) before deposit; its log is smoke_log.txt.

Each cell: open colab.research.google.com, click New notebook, paste the cell, type the record number where shown, click the run button.

## Cell 1: RUN and SCORE (after the plan is published as v1.0; about 15 to 30 minutes on the free CPU)

```python
RECORD = ''          # the number at the end of the Zenodo /records/ link of the plan, v1.0
import subprocess, sys, os, json, hashlib, urllib.request, shutil, glob
import numpy as np
if np.__version__ != '2.4.6':
    subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', 'numpy==2.4.6'], check=True)
    os.kill(os.getpid(), 9)          # Colab restarts; run this cell again
rec = json.load(urllib.request.urlopen(f'https://zenodo.org/api/records/{RECORD}'))
import scipy; print('NumPy', np.__version__, '| SciPy', scipy.__version__)
doi = rec['doi']; print('DOI', doi, '| version', rec['metadata'].get('version'), '|', rec['metadata']['title'])
assert rec['metadata']['title'].endswith('(public plan)')
B = '/content/mqg_test21'; os.makedirs(B, exist_ok=True)
need = ('mqg_test21_runner.py', 'mqg_test21_score.py', 'mqg_step2_robustness.py', 'MQG_TEST_21_PUBLIC_PLAN.md')
for f in rec['files']:
    if f['key'] in need:
        data = urllib.request.urlopen(f['links']['self']).read()
        assert hashlib.md5(data).hexdigest() == f['checksum'].split(':')[1], f['key']
        open(f"{B}/{f['key']}", 'wb').write(data); print('checked', f['key'])
O = f'{B}/out'
p = subprocess.Popen([sys.executable, '-u', f'{B}/mqg_test21_runner.py', '--deposit-doi', doi, '--output-dir', O,
                      '--step2', f'{B}/mqg_step2_robustness.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
for line in p.stdout: print(line, end='')
p.wait(); print('exit code', p.returncode)
r = subprocess.run([sys.executable, f'{B}/mqg_test21_score.py', O, '--json', f'{O}/mqg_test21_score.json'],
                   capture_output=True, text=True)
print(r.stdout, r.stderr); open(f'{O}/score_output.txt', 'w').write(r.stdout + r.stderr)
with open(f'{O}/MANIFEST_MD5.txt', 'w') as m:
    for f in sorted(glob.glob(f'{O}/**/*', recursive=True)):
        if os.path.isfile(f) and not f.endswith('MANIFEST_MD5.txt'):
            m.write(f'{hashlib.md5(open(f, "rb").read()).hexdigest()}  {os.path.relpath(f, O)}\n')
shutil.make_archive('/content/MQG_TEST_21_RESULTS', 'zip', O)
from google.colab import files; files.download('/content/MQG_TEST_21_RESULTS.zip')
```

Expected: four "checked" lines, the guard lines ending in "ALL 36 ROWS WRITTEN", "exit code 0", the five rule lines, and a download of MQG_TEST_21_RESULTS.zip. If Colab disconnects, run the cell again; it starts over (rows are kept only in this session).

## Cell 2: VERIFY (after the results are published as v2.0)

```python
PLAN = ''            # the record number of v1.0 (same as in Cell 1)
import json, urllib.request
v1 = json.load(urllib.request.urlopen(f'https://zenodo.org/api/records/{PLAN}'))
new = json.load(urllib.request.urlopen(f'https://zenodo.org/api/records/{PLAN}/versions/latest'))
old = {f['key']: f['checksum'] for f in v1['files']}
now = {f['key']: f['checksum'] for f in new['files']}
bad = [k for k in old if now.get(k) != old[k]]
print('v1.0 files:', len(old), '| latest version:', new['metadata'].get('version'), '| changed or missing:', bad or 'none')
print('ALL v1.0 FILES UNCHANGED' if not bad else 'CHECK FAILED')
```
