// verify-is-the-voynich-manuscript-a-hoax.mjs: checks every number /strata/is-the-voynich-manuscript-a-hoax/
// states, by re-running the page's own code (machines.mjs, which imports the companion layer's engine.mjs)
// on the texts the page serves, recomputing the figures from the page's data file, re-scoring all 27
// pre-registered predictions, and testing that the measures respond as they should.
//
//   node verify-is-the-voynich-manuscript-a-hoax.mjs
//
// Needs only Node 18+. Inside the repository it tests the local files; from an empty directory it downloads
// machines.mjs, engine.mjs, index.html and the data from https://artwaste.land (the bytes your browser runs)
// into a temporary folder and tests those. Inside the repository it also checks research/voynich-machines/
// (the generator's own source, and every run the page summarises, when the cache from gen-sc.sh exists).
// Exit 0 = every check passed.

import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { dirname, join } from 'node:path';
import { createHash } from 'node:crypto';
import { tmpdir } from 'node:os';

const here = dirname(fileURLToPath(import.meta.url));
const slug = 'is-the-voynich-manuscript-a-hoax', sib = 'is-the-voynich-manuscript-a-language';
const LOCAL = existsSync(join(here, 'public/strata', slug, 'machines.mjs'));
const root = LOCAL ? join(here, 'public/strata') : join(tmpdir(), 'aw-voynich-hoax');
async function get(path) {                       // path relative to /strata/
  const p = join(root, path); if (existsSync(p) && LOCAL) return readFileSync(p);
  const r = await fetch('https://artwaste.land/strata/' + path); if (!r.ok) throw new Error(`${path}: HTTP ${r.status}`);
  const b = Buffer.from(await r.arrayBuffer()); mkdirSync(dirname(p), { recursive: true }); writeFileSync(p, b); return b;
}
console.error(`files: ${LOCAL ? root : 'https://artwaste.land/strata/ (copied to ' + root + ')'}`);
await get(`${sib}/engine.mjs`); await get(`${slug}/machines.mjs`);
const M = await import(pathToFileURL(join(root, slug, 'machines.mjs')).href);
const { E } = M;
const ZL = (await get(`${sib}/data/ZL3b-n.txt`)).toString('utf8');
const PUB = (await get(`${slug}/data/sc-published-seed19.txt`)).toString('utf8');
const NORULE = (await get(`${slug}/data/sc-rule-removed-seed19.txt`)).toString('utf8');
const D = JSON.parse(await get(`${slug}/data/machines.json`));
const GIB = JSON.parse(await get(`${slug}/data/gibberish.json`));
const HTML = (await get(`${slug}/index.html`)).toString('utf8').replace(/\s+/g, ' ');

let fails = 0, passes = 0;
const ok = (c, msg) => { if (c) passes++; else fails++; console.log((c ? 'PASS  ' : 'FAIL  ') + msg); };
const says = s => HTML.includes(s);
const sha = b => createHash('sha256').update(b).digest('hex');
const med = a => { const v = [...a].sort((x, y) => x - y); return v.length % 2 ? v[v.length >> 1] : (v[v.length / 2 - 1] + v[v.length / 2]) / 2; };
const K = ['h2', 'sameRatio', 'oneRatio', 'lastInfo', 'firstInfo'];
const r4 = x => Math.round(x * 1e4) / 1e4;
const f2 = x => x.toFixed(2), f3 = x => x.toFixed(3);
const range = (a, k, f) => `${f(Math.min(...a.map(r => r[k])))} to ${f(Math.max(...a.map(r => r[k])))}`;
const Fm = D.families;

// ── 1. the served texts are the ones named ──────────────────────────────────
ok(sha(ZL) === 'bf5b6d4ac1e3a51b1847a9c388318d609020441ccd56984c901c32b09beccafc', 'the manuscript is ZL 3b (sha256 bf5b6d4a...)');
ok(sha(PUB) === '1e954a17b157e83f04ea21353ba877f70084b828b812fab3944347ac2888dc11', 'sc-published-seed19.txt is the generated_text.txt in Timm\'s repository (sha256 1e954a17...)');
ok(GIB.samples.length === 38 && /Gaskell and Bowern 2022/.test(GIB.source) && /modified MIT/.test(GIB.source), 'gibberish.json holds the 38 public transcriptions, with their licence');

// ── 2. the page's live figures, re-measured here, match the data file ─────────
const VL = M.voynichLines(ZL);
const zl = M.measureLong(M.asEva(VL)), pub = M.measureLong(M.asEva(M.selfCitationLines(PUB))), sc0 = M.measureLong(M.asEva(M.selfCitationLines(NORULE)));
for (const k of K) ok(r4(zl[k]) === D.voynich.zl[k], `manuscript ${k} ${f3(zl[k])} = machines.json`);
for (const k of K) ok(r4(pub[k]) === D.published[k], `published generator run ${k} ${f3(pub[k])} = machines.json`);
for (const k of K) ok(r4(sc0[k]) === Fm.SC0[18][k], `rule-removed seed 19 ${k} ${f3(sc0[k])} = machines.json SC0 seed 19`);
ok(Fm.SC0[18].seed === 19 && D.families.SC[18].seed === 19, 'seed indexing: row 18 is seed 19');
{ let same = true;
  for (let s = 1; s <= 20; s++) { const mk = M.measureLong(M.asEva(M.markovLines(VL, s))), sh = M.measureLong(M.asEva(M.shuffledLines(VL, s)));
    for (const k of K) { if (r4(mk[k]) !== Fm.MK[s - 1][k]) same = false; if (r4(sh[k]) !== Fm.SH[s - 1][k]) same = false; } }
  ok(same, 'all 20 word-chain and 20 shuffle runs, regenerated here, reproduce machines.json exactly'); }

// ── 3. the prose states what the data says ───────────────────────────────────
ok(says(`(${f2(Fm.SH[0].h2)} against ${f2(D.voynich.zl.h2)} bits)`), `status: shuffle h2 ${f2(Fm.SH[0].h2)} (seed 1, the page's default) against ${f2(D.voynich.zl.h2)}`);
const mSC = k => med(Fm.SC.map(r => r[k])), mSC0 = k => med(Fm.SC0.map(r => r[k])), mP = k => med(Fm.SC0P100.map(r => r[k]));
ok(says(`falls from ${f3(mSC('lastInfo'))} to ${f3(mSC0('lastInfo'))}`), `status: line end falls from ${f3(mSC('lastInfo'))} to ${f3(mSC0('lastInfo'))} (medians of 20)`);
ok(says(`it stays at ${f3(mP('lastInfo'))}`), `status: with copying at 100%, ${f3(mP('lastInfo'))}`);
const allGen = [...Fm.SC, ...Fm.SC0, ...Fm.SC0P100, ...Fm.SCNR];
ok(says(`${f3(D.voynich.zl.firstInfo)} in the manuscript, ${range(allGen, 'firstInfo', f3)} in every run of the generator`), `status: line start ${range(allGen, 'firstInfo', f3)} over all 80 generator runs`);
ok(Math.max(...Fm.MK.map(r => r.firstInfo), ...Fm.SH.map(r => r.firstInfo), ...Fm.MK.map(r => r.lastInfo), ...Fm.SH.map(r => r.lastInfo)) < 0.005, 'chain and shuffle line edges are "about zero" (all below 0.005)');
ok(Math.max(...Fm.VC.map(r => r.firstInfo)) > 0.1 && says('The cipher keeps each Latin book\'s own lines'), 'the cipher is not called about zero: its line start reaches ' + f3(Math.max(...Fm.VC.map(r => r.firstInfo))));
ok(says(`the generator ${range(Fm.SC, 'sameRatio', f2)}, about chance,`) && says(`The word chain overshoots, ${range(Fm.MK, 'sameRatio', f2)}`), `status: doubled words, generator ${range(Fm.SC, 'sameRatio', f2)}, chain ${range(Fm.MK, 'sameRatio', f2)}`);
ok(says(`the manuscript ${f2(D.voynich.zl.sameRatio)} times the shuffled rate`), 'status: manuscript doubled-word ratio');
{ const n = Fm.SCNR.filter(r => r.sameRatio > D.voynich.zl.sameRatio).length;
  ok(says(`with that rule taken out, ${range(Fm.SCNR, 'sameRatio', f2)}, around the manuscript`) && says(`The doubled words came back: ${range(Fm.SCNR, 'sameRatio', f2)} times the shuffled rate, above the manuscript's in ${n} of the 20`) && n === 17,
    `repeat rule removed: doubled words ${range(Fm.SCNR, 'sameRatio', f2)}, above the manuscript in ${n} of 20`);
  ok(Math.min(...Fm.SCNR.map(r => r.lastInfo)) > 0.1, 'the repeat-rule-removed runs keep the line-end rule (line end above 0.1 in every seed)'); }
ok(says(`stayed near the books at ${range(Fm.VC, 'h2', f2)}`), `cipher h2 ${range(Fm.VC, 'h2', f2)}`);
ok(Fm.VC.length === 12 && Fm.VC.every(v => D.books.find(b => b.shelfmark === v.shelfmark)?.language === 'Latin') && D.books.filter(b => b.language === 'Latin').length === 12, 'the cipher family is the twelve Latin books among the fifty');
ok(says(`(at most ${f2(Math.max(...D.books.map(b => b.sameRatio)))} times)`), 'books: most repetitive at 0.37');
{ const g = L => { const nb = E.neighbourSimilarity([M.asEva(L)], 408, 10); return nb.same / nb.nullSame; };
  const zg = g(VL), mg = Array.from({ length: 20 }, (_, i) => g(M.markovLines(VL, i + 1)));
  ok(says(`the manuscript scores ${f2(zg)} and the chain ${f2(Math.min(...mg))} to ${f2(Math.max(...mg))} over twenty seeds, every one below it`) && mg.every(x => x < zg),
    `against a whole-text shuffle: manuscript ${f2(zg)}, chain ${f2(Math.min(...mg))} to ${f2(Math.max(...mg))}, all below`); }
{ const info = E.linePositionInfo(M.asEva(VL), 'last'); const t = g => info.top.find(q => q.g === g);
  ok(says(`on their line ${Math.round(100 * t('m').share)}% of the time, words ending in <span class="eva">g</span> ${Math.round(100 * t('g').share)}%, where the average word is last ${Math.round(100 * info.base)}% of the time`),
    `line-final shares: m ${Math.round(100 * t('m').share)}%, g ${Math.round(100 * t('g').share)}%, base ${Math.round(100 * info.base)}%`); }
ok(says(`${range(Fm.SC, 'lastInfo', f3)} over twenty seeds with the rule, ${range(Fm.SC0, 'lastInfo', f3)} without, ${range(Fm.SC0P100, 'lastInfo', f3)} without it and with copying from the same place on an earlier line turned up to its maximum`), 'line-end ranges for the three generator families');
{ const ends = t => M.selfCitationLines(t).flat().filter(w => /[mg]$/.test(w)).length;
  ok(ends(NORULE) === 0 && ends(PUB) > 500, `with the rule removed no word ends in m or g (served seed 19: ${ends(NORULE)}; published run: ${ends(PUB)})`); }
ok(says(`and with them it reaches <span data-v="pubFirst">${f3(D.published.firstInfo)}</span>`) && says(`The manuscript's is <span data-v="zlFirst">${f3(D.voynich.zl.firstInfo)}</span>`), 'fallback text of live spans matches the data (line start)');
for (const [v, x] of [['zlH2', f2(D.voynich.zl.h2)], ['shH2', f2(Fm.SH[0].h2)], ['zlSame', f2(D.voynich.zl.sameRatio)], ['pubSame', f2(D.published.sameRatio)], ['pubOne', f2(D.published.oneRatio)], ['zlOne', f2(D.voynich.zl.oneRatio)], ['zlLast', f3(D.voynich.zl.lastInfo)], ['pubLast', f3(D.published.lastInfo)], ['sc0Last', f3(Fm.SC0[18].lastInfo)]])
  ok(says(`data-v="${v}">${x}<`), `fallback text for ${v} is ${x}`);

// short scale
const S = D.short, gb = S.GB.filter(g => g.pairs);
ok(gb.length === 36 && S.GB.filter(g => !g.windows.length).map(g => g.id).join() === 'DC_23,DC_24', '36 samples have a 150-word window; DC_23 and DC_24 do not');
const words = GIB.samples.map(g => S.GB.find(q => q.id === g.id).words);
ok(says(`Their samples run from ${Math.min(...words)} to ${Math.max(...words)} words`), `sample sizes ${Math.min(...words)} to ${Math.max(...words)} words`);
const obs = gb.reduce((s, g) => s + g.same, 0), exp = gb.reduce((s, g) => s + g.expSame, 0);
ok(says(`${Math.round(obs)} against ${Math.round(exp)} expected`), `people doubled words: ${Math.round(obs)} against ${exp.toFixed(1)}`);
const above = gb.filter(g => g.same > g.expSame).length, zero = gb.filter(g => g.same === 0).length;
ok(says(`Nine of the 36 samples double words more often than their shuffle would; 23 never do it at all`) && above === 9 && zero === 23, `${above} samples above chance, ${zero} never`);
{ const d = gb.find(g => g.id === 'DC_20'); const top = [...gb].sort((a, b) => (b.same - b.expSame) - (a.same - a.expSame))[0];
  ok(top.id === 'DC_20' && Math.round(d.same) === 9 && d.expSame.toFixed(1) === '1.6' && says('DC_20, wrote nine doubled words where 1.6 were expected'), 'DC_20: 9 against 1.6, the largest excess'); }
ok(says(`The manuscript at this scale: ${Math.round(S.voynich.same)} against ${Math.round(S.voynich.expSame)}.`), `manuscript windows: ${Math.round(S.voynich.same)} against ${S.voynich.expSame.toFixed(1)}`);
const W = a => a.flatMap(t => t.windows);
const gw = W(gb), bw = W(S.books), vw = S.voynich.windows;
ok(says(`(median ${f2(med(gw.map(w => w.h2)))} bits against ${f2(med(bw.map(w => w.h2)))} for book windows)`), `window h2: people ${f3(med(gw.map(w => w.h2)))}, books ${f3(med(bw.map(w => w.h2)))}`);
ok(says(`stands ${f3(med(gw.map(w => w.first)))} above its floor at the start and ${f3(med(gw.map(w => w.last)))} at the end; book windows ${f3(med(bw.map(w => w.first)))} and ${f3(med(bw.map(w => w.last)))}; the manuscript's windows ${f3(med(vw.map(w => w.first)))} and ${f3(med(vw.map(w => w.last)))}`), 'window line-edge medians, people, books, manuscript');
{ const r = med(gw.map(w => w.first)) / med(vw.map(w => w.first)); ok(r > 0.07 && r < 0.13, `"about a tenth": people's line-start excess is ${r.toFixed(2)} of the manuscript's`); }
{ const vm = med(vw.map(w => w.first)); const reach = gb.filter(g => med(g.windows.map(w => w.first)) >= vm).map(g => g.id);
  ok(reach.join() === 'DC_38,DC_42' && says('Two of the 36 samples reach the manuscript\'s median at the line start'), `samples reaching the manuscript's line-start median: ${reach.join(', ')}`);
  const meta = join(here, 'research/voynich-machines/upstream/gaskell-bowern-metadata.csv');
  if (existsSync(meta)) ok(/Gibberish - DC_42,1,Experimenter/.test(readFileSync(meta, 'utf8')) && /Gibberish - DC_38,0,2019 class/.test(readFileSync(meta, 'utf8')), 'metadata.csv: DC_42 is an Experimenter sample, DC_38 a 2019-class one');
  else console.log('SKIP  who wrote DC_38 and DC_42 (needs research/voynich-machines/upstream/, inside the repository)'); }
{ const pr = gb.reduce((s, g) => s + g.same, 0) / gb.reduce((s, g) => s + g.expSame, 0), br = S.books.reduce((s, b) => s + b.same, 0) / S.books.reduce((s, b) => s + b.expSame, 0);
  ok(says(`at ${f2(br)} times their shuffled rate, the people at ${f2(pr)}`), `window doubled-word ratio: books ${f2(br)}, people ${f2(pr)}`); }
ok(says(`which gives ${W(S.SC.slice(0, 1)).length.toLocaleString('en-US')} windows`) && says(`a thinned sample of ${bw.length.toLocaleString('en-US')} windows`), `window counts: generator ${W(S.SC.slice(0, 1)).length}, books ${bw.length}`);
{ const w = M.measureShort(M.asEva(M.markovLines(VL, 1))).windows; const a = med(w.map(x => x.lastInfo)), b = med(w.map(x => x.firstInfo));
  ok(says('the line-blind word chain scored 0.05 to 0.09 here') && a >= 0.045 && a < 0.095 && b >= 0.045 && b < 0.095, `before the floor, the word chain's median window scores ${f3(a)} (end) and ${f3(b)} (start): "0.05 to 0.09"`); }
{ const n = VL.reduce((s, l) => s + l.length, 0); ok(says('The manuscript\'s running text is about 35,000 words') && n > 34000 && n < 36000, `the manuscript's paragraph text is ${n} clean words ("about 35,000")`); }

// ── 4. the pre-registration, re-scored ───────────────────────────────────────
{ const score = [];
  const side = (fam, k, want) => { const m = med(Fm[fam].map(r => r[k])), v = D.voynich.zl[k], nb = Math.min(...D.books.map(b => Math.abs(b[k] - m))); score.push({ fam, k, m, held: (Math.abs(m - v) < nb ? 'manuscript' : 'books') === want }); };
  const test = (fam, k, f) => { const m = med(Fm[fam].map(r => r[k])); score.push({ fam, k, m, held: f(m) }); };
  [['h2', 'manuscript'], ['sameRatio', 'manuscript'], ['oneRatio', 'manuscript'], ['lastInfo', 'books'], ['firstInfo', 'manuscript']].forEach(([k, w]) => side('SC', k, w));
  [['h2', 'manuscript'], ['sameRatio', 'manuscript'], ['oneRatio', 'manuscript']].forEach(([k, w]) => side('MK', k, w));
  test('MK', 'lastInfo', m => m < 0.02); test('MK', 'firstInfo', m => m < 0.02);
  test('VC', 'h2', m => m >= 2.0 && m <= 2.8); ['sameRatio', 'oneRatio', 'lastInfo', 'firstInfo'].forEach(k => side('VC', k, 'books'));
  side('SH', 'h2', 'manuscript'); test('SH', 'sameRatio', m => m >= 0.9 && m <= 1.1); test('SH', 'oneRatio', m => m >= 0.9 && m <= 1.1); test('SH', 'lastInfo', m => m < 0.01); test('SH', 'firstInfo', m => m < 0.01);
  score.push({ fam: 'GB', k: 'same', held: obs / exp > 1 }); score.push({ fam: 'GB', k: 'h2', held: med(gw.map(w => w.h2)) < med(bw.map(w => w.h2)) });
  let worst = 0; for (const k of K) { const d = Math.abs(D.voynich.it[k] - D.voynich.zl[k]) / D.voynich.zl[k]; worst = Math.max(worst, d); score.push({ fam: 'IT', k, held: d <= 0.10 }); }
  const held = score.filter(s => s.held).length, failed = score.filter(s => !s.held).map(s => `${s.fam} ${s.k}`);
  ok(score.length === 27 && held === 22, `27 predictions re-scored: ${held} held; failed: ${failed.join(', ')}`);
  ok(failed.join() === 'SC firstInfo,MK oneRatio,VC h2,GB same,GB h2', 'the five failures are the five the page tags failed');
  ok((HTML.match(/<span class="tag bad">failed<\/span>/g) || []).length === 5, 'the table tags five rows failed');
  ok(says(`largest difference ${(100 * worst).toFixed(1)}%`), `second transliteration: largest difference ${(100 * worst).toFixed(1)}%`);
  ok(says('Twenty-two held and five failed') && says('22 held, 5 failed'), 'the prose count agrees');
  const sc = n => f3(med(Fm.SC.map(r => r[n])));
  ok(says(`<td class="n" data-l="Result">${sc('h2')}, manuscript</td>`) && says(`${sc('sameRatio')}, manuscript`) && says(`${sc('oneRatio')}, manuscript`) && says(`${sc('lastInfo')}, books`) && says(`${sc('firstInfo')}, books`), 'generator rows of the table carry the medians');
  const nearest = D.books.reduce((a, b) => Math.abs(b.lastInfo - med(Fm.SC.map(r => r.lastInfo))) < Math.abs(a.lastInfo - med(Fm.SC.map(r => r.lastInfo))) ? b : a);
  ok(nearest.language === 'Castilian' && nearest.verse === 'prose', `the book nearest the generator's line end is ${nearest.shelfmark} (Castilian prose), as the page says`); }

// ── 5. the measures respond as they should ───────────────────────────────────
{ // re-apply the generator's line-final table by hand to the rule-removed text: the line end comes back
  const TABLE = { ol: 'om', or: 'om', al: 'am', ar: 'am', om: 'og', am: 'ag', im: 'mg', in: 'n', iin: 'im', iiin: 'im' };
  const L = M.selfCitationLines(NORULE).map(l => l.map((w, i) => { if (i !== l.length - 1) return w; for (const [a, b] of Object.entries(TABLE).sort((x, y) => y[0].length - x[0].length)) if (w.endsWith(a)) return w.slice(0, -a.length) + b; return w; }));
  const back = M.measureLong(M.asEva(L)).lastInfo;
  ok(back > 0.05 && sc0.lastInfo < 0.01, `rewriting each line's last word by the table restores a line end: ${f3(sc0.lastInfo)} -> ${f3(back)}`); }
{ const L = VL.map(l => l.length > 1 ? [...l.slice(1), l[0]] : l); const moved = M.measureLong(M.asEva(L)).firstInfo;
  ok(moved < zl.firstInfo / 2, `moving each line's first word to its end drops the manuscript's line start: ${f3(zl.firstInfo)} -> ${f3(moved)}`); }
{ const L = VL.map(l => l.flatMap((w, i) => i === 1 ? [w, w] : [w])); const d = M.measureLong(M.asEva(L)).sameRatio;
  ok(d > zl.sameRatio * 2, `doubling one word per line raises the doubled-word ratio: ${f2(zl.sameRatio)} -> ${f2(d)}`); }

// ── 6. inside the repository: the generator's own source, and every run ───────
const R = join(here, 'research/voynich-machines');
if (existsSync(join(R, 'upstream/Glyph.java'))) {
  const G = readFileSync(join(R, 'upstream/Glyph.java'), 'utf8').replace(/\s+/g, ' ');
  const tbl = '{"ol", "om"}, {"or", "om"}, {"al", "am"}, {"ar", "am"}, {"om", "og"}, {"am", "ag"}, {"im", "mg"}, {"in", "n"}, {"iin", "im"}, {"iiin", "im"},';
  ok(G.includes('finalLineReplacementsStrings = { ' + tbl) && says('{"ol", "om"}, {"or", "om"}, {"al", "am"}, {"ar", "am"}, {"om", "og"}, {"am", "ag"}, {"im", "mg"}, {"in", "n"}, {"iin", "im"}, {"iiin", "im"},'),
    'the table on the page is the finalLineReplacementsStrings of upstream Glyph.java, entry for entry');
  const J = readFileSync(join(R, 'upstream/SelfCitationTextGenerator.java'), 'utf8').split('\n');
  ok(/replaceLineFinalGlyph/.test(J[320]) && /\/\/ change last token 'ol' --> 'om'/.test(J[318]) && /tryToTrim\(morphedGroup, availablePlaceInLine/.test(J[263]) && /\/\/ limit repeated words/.test(J.join('\n')) && /useMorphedGroups = rand < 50;/.test(J.join('\n')),
    'SelfCitationTextGenerator.java: the rule is called on line 321, from tryToTrim when a word will not fit; repeats are kept with probability 50');
  ok(says('The special case for the last is on line 321 of the same file'), 'the page names line 321');
} else console.log('SKIP  the generator\'s Java source (needs research/voynich-machines/upstream/, inside the repository)');
if (existsSync(join(R, 'cache/sc0/seed1.txt'))) {
  let exact = true, noMG = true;
  for (const [fam, dir] of [['SC', 'sc'], ['SC0', 'sc0'], ['SC0P100', 'sc0p100'], ['SCNR', 'scnr']]) for (let s = 1; s <= 20; s++) {
    const t = readFileSync(join(R, `cache/${dir}/seed${s}.txt`), 'utf8'); const m = M.measureLong(M.asEva(M.selfCitationLines(t)));
    for (const k of K) if (r4(m[k]) !== Fm[fam][s - 1][k]) exact = false;
    if ((fam === 'SC0' || fam === 'SC0P100') && M.selfCitationLines(t).flat().some(w => /[mg]$/.test(w))) noMG = false;
  }
  ok(exact, 'all 80 generator runs in research/voynich-machines/cache reproduce machines.json exactly');
  ok(noMG, 'no word in any of the 40 rule-removed runs ends in m or g');
} else console.log('SKIP  generator runs (run research/voynich-machines/gen-sc.sh to check all 80)');

console.log(`\n${passes} passed, ${fails} failed`);
process.exit(fails ? 1 : 0);
