// verify-a-fork-is-not-a-space.mjs
//
// The page claims that three published records declare very small spaces, and it claims a
// scorecard against a prediction sealed before the evidence existed. Both kinds of claim are
// checked here, from the committed extracts, with nothing taken on the page's word.
//
//   node research/a-fork-is-not-a-space/verify-a-fork-is-not-a-space.mjs
//   node research/a-fork-is-not-a-space/verify-a-fork-is-not-a-space.mjs --mutate
//
// --mutate is not decoration. It plants a fault behind each class of assertion and requires the
// suite to go red, because an assertion that cannot fail is a sentence, not a check.
//
// WHAT THIS FILE DOES NOT CHECK, stated here so the page's own limits section is not the only
// place it appears: it recomputes the three records measured in this repository. It does NOT
// recompute the figures the scouting pass measured (the ClinicalTrials.gov occupancy, the EU
// residue register, the bridge inventory product and the rest). Those carry a "how" of "scout"
// in candidates.json, and this verifier asserts only that the page never promotes one of them
// into a headline.

import { readFileSync, existsSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { createHash } from 'node:crypto';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { measure, histMedian, histStats } from './measure.mjs';
import { buildPayload } from './build-page-data.mjs';
import { jpSpaceSize } from './build-extract.mjs';

const HERE = dirname(fileURLToPath(import.meta.url));
const ROOT = join(HERE, '../..');
const PAGE = join(ROOT, 'public/strata/a-fork-is-not-a-space');

// ── running this from outside, which is the only run that proves anything about a reader ─────
//
// This repository is private. A reader who follows the command on the page has the four programs
// from /checks/ and nothing else, so every file those programs read has to be fetchable from the
// public site or the page's offer is false. This corpus has already paid for that lesson once:
// 463 built pages printed a command naming a file no reader could obtain, and every gate was
// green throughout, because every gate ran from inside.
//
// So: if an input is missing, fetch the served copy and write it where the program expects it,
// printing each fetch. Inside a checkout nothing is fetched and nothing is written.
// AW_ORIGIN exists so this can be pointed at a mirror or at a local copy of the built site, which
// is how the fetch half was tested before the live bytes existed. It changes WHERE the inputs come
// from and nothing about what is asserted over them, and the run prints every URL it fetched, so a
// reader can always see which bytes were checked.
const ORIGIN = process.env.AW_ORIGIN || 'https://artwaste.land';
const SITE = `${ORIGIN}/strata/a-fork-is-not-a-space`;
// One URL can be the source of more than one path, because several inputs are deliberately kept
// in two places: the research copy the programs read, and the served copy beside the page. They
// are byte-identical by construction and the generator's --check proves it, so the fetch happens
// once and the bytes are written to every path that should hold them.
const PUB = 'public/strata/a-fork-is-not-a-space';
const R = 'research/a-fork-is-not-a-space';
const W = 'oversight/waves/2026-09-13-foreign-instruments-backwards';
const LANES = ['law', 'physical', 'text', 'standards', 'free', 'engines'];
const NEEDED = [
  // The trailing slash matters. This site answers /strata/<slug>/index.html with a 307, which is
  // how an earlier recipe here silently wrote zero-byte files.
  [`${SITE}/`, [`${PUB}/index.html`]],
  [`${SITE}/app.js`, [`${PUB}/app.js`]],
  [`${SITE}/data.js`, [`${PUB}/data.js`]],
  [`${SITE}/data/ussc-fy2023-ranges.csv`, [`${PUB}/data/ussc-fy2023-ranges.csv`, `${R}/data/ussc-fy2023-ranges.csv`]],
  [`${SITE}/data/measured.json`, [`${PUB}/data/measured.json`, `${R}/data/measured.json`]],
  [`${SITE}/data/sources.json`, [`${PUB}/data/sources.json`, `${R}/data/sources.json`]],
  [`${SITE}/data/candidates.json`, [`${PUB}/data/candidates.json`, `${R}/candidates.json`]],
  [`${SITE}/data/frontmatter.md`, [`${PUB}/data/frontmatter.md`, 'src/content/strata/a-fork-is-not-a-space.md']],
  [`${SITE}/data/PREDICTION.md`, [`${PUB}/data/PREDICTION.md`, `${W}/PREDICTION.md`]],
  [`${ORIGIN}/strata/what-the-adapter-had-to-invent/refusals.json`,
    ['oversight/waves/2026-09-10-foreign-instruments/refusals.json']],
];

const { mkdirSync, writeFileSync } = await import('node:fs');
let FETCHED = 0;
for (const [url, rels] of NEEDED) {
  const missing = rels.filter((rel) => !existsSync(join(ROOT, rel)));
  if (!missing.length) continue;
  if (FETCHED === 0) console.log('running outside a checkout; fetching the inputs this check reads:');
  const res = await fetch(url);
  if (!res.ok) { console.error(`  ${url} -> HTTP ${res.status}. Cannot continue.`); process.exit(1); }
  const buf = Buffer.from(await res.arrayBuffer());
  if (!buf.length) { console.error(`  ${url} -> zero bytes. Cannot continue.`); process.exit(1); }
  for (const rel of missing) {
    const path = join(ROOT, rel);
    mkdirSync(dirname(path), { recursive: true });
    writeFileSync(path, buf);
  }
  console.log(`  ${url}  ->  ${missing.join(', ')}  (${buf.length} bytes)`);
  FETCHED++;
}
const OUTSIDE = FETCHED > 0;
if (OUTSIDE) console.log(`fetched ${FETCHED} file(s). Nothing else leaves this directory.\n`);

const html = readFileSync(join(PAGE, 'index.html'), 'utf8');
const app = readFileSync(join(PAGE, 'app.js'), 'utf8');
const dataJs = readFileSync(join(PAGE, 'data.js'), 'utf8');
const frontmatter = readFileSync(join(ROOT, 'src/content/strata/a-fork-is-not-a-space.md'), 'utf8');

let assertions = 0;
const failures = [];
// Assertions an outside run genuinely cannot make. Never silently: they are printed.
const SKIPPED = [];
function check(cond, what) {
  assertions++;
  if (!cond) failures.push(what);
}
function equal(got, want, what) {
  assertions++;
  const a = JSON.stringify(got), b = JSON.stringify(want);
  if (a !== b) failures.push(`${what}: got ${a}, want ${b}`);
}

const M = measure();
const byId = Object.fromEntries(M.families.map((f) => [f.id, f]));
const P = buildPayload();

// English number words, because the prose spells small counts and the check has to read what the
// reader reads rather than a convenient digit form.
const WORDS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
  'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen',
  'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four',
  'twenty-five', 'twenty-six', 'twenty-seven', 'twenty-eight', 'twenty-nine'];
const comma = (n) => Number(n).toLocaleString('en-US');

// ── 1. the arithmetic of the summary statistics, independent of the data ─────────────────────
function assertStatistics() {
  equal(histMedian({ 1: 1 }), 1, 'median of a single value');
  equal(histMedian({ 2: 4 }), 2, 'median of one repeated value');
  equal(histMedian({ 1: 1, 3: 1 }), 1, 'lower-median convention on an even count');
  equal(histMedian({ 1: 1, 2: 1, 3: 1 }), 2, 'median of three');
  equal(histMedian({}), null, 'median of nothing is not a number');
  const s = histStats({ 2: 3, 5: 1 });
  equal([s.n, s.min, s.max, s.mean], [4, 2, 5, 2.75], 'histStats over a weighted histogram');
}

// ── 2. the spin-parity parser, against strings taken from the record ─────────────────────────
// A run enumerates every spin between its endpoints; a list enumerates its members; a single
// bracketed value enumerates nothing and must return null, because that is the whole finding.
function assertJpParser() {
  equal(jpSpaceSize('(5/2:13/2)+'), 5, 'a run of half-integer spins');
  equal(jpSpaceSize('(7/2:11/2)-'), 3, 'a shorter run');
  equal(jpSpaceSize('(1/2:17/2)+'), 9, 'the widest run in the sample');
  equal(jpSpaceSize('(3/2,5/2)+'), 2, 'a two-member list');
  equal(jpSpaceSize('(5/2)+'), null, 'a single bracketed value is not a set');
  equal(jpSpaceSize('(13/2+)'), null, 'a single value with the parity inside is not a set');
  equal(jpSpaceSize('9/2+'), null, 'a settled assignment is not a set');
  equal(jpSpaceSize(''), null, 'an absent assignment is not a set');
  equal(jpSpaceSize('(2:4)+'), 3, 'a run of integer spins');
}

// ── 3. the three records ─────────────────────────────────────────────────────────────────────
function assertRecords() {
  const g = byId['ground-state-jp'];
  check(g.assigned > 2000, 'the ground-state sweep covers a real chart of nuclides');
  check(g.tentative > 0, 'the sweep found assignments the evaluation flags as uncertain');
  equal(g.stats.median, 1, 'the median declared ground-state space is one');
  equal(g.flaggedNamingOne + g.tentativeEnumerated, g.tentative,
    'flagged assignments split into those naming one and those naming more');
  check(g.tentativeEnumerated > 0,
    'some flagged assignments DO enumerate: the first draft of this page said none, and was wrong');
  check(g.flaggedNamingOne / g.tentative > 0.9,
    'the great majority of flagged assignments still name a single candidate');
  check(g.stats.max <= 4, 'the largest declared ground-state set in the whole chart is tiny');
  // Doubt and multiplicity are different marks, so the counts must not be forced to coincide.
  check(g.enumerated >= g.tentativeEnumerated,
    'enumerating assignments include the ones that are not also bracketed');

  const k = byId['ketiv-qere'];
  equal([k.stats.min, k.stats.max], [2, 2], 'every ketiv and qere locus declares exactly two');
  equal(k.exactlyTwo.num, k.stats.n, 'the count of two-reading loci is the whole apparatus');
  equal(k.exactlyTwo.pct, 100, 'the share declaring exactly two is all of them');
  equal(k.books, 39, 'the apparatus was counted over the whole canon in this edition');

  const u = byId['guideline-range'];
  equal(u.rows, 64124, 'the sentencing extract holds every record in the datafile');
  check(u.usable > 55000 && u.usable < u.rows, 'usable records are most but not all of the file');
  equal(u.usable + u.incomplete, u.rows, 'usable and incomplete partition the file');
  check(u.stats.min === 1, 'the smallest declared range is a single month');
  check(u.outside.pct > 50, 'the imposed sentence is outside the declared range more often than not');
  equal(u.below.num + u.above.num, u.outside.num, 'below and above partition outside');
  equal(u.below.num + u.above.num + u.within.num, u.usable, 'the three positions partition the usable records');
  check(u.atMinOfWithin.num + u.atMaxOfWithin.num <= u.within.num, 'endpoint counts fit inside the within count');
}

// ── 4. the page prints only what this repository computed ────────────────────────────────────
// Each entry is a literal string that must appear in the page, built from a computed value. A
// figure that drifts fails here rather than reaching a reader.
function surfaceClaims() {
  const g = byId['ground-state-jp'], k = byId['ketiv-qere'], u = byId['guideline-range'];
  const e = byId['tentative-jp'];
  const f = P.forward, b = P.backward;
  return [
    [html, `Of ${comma(g.tentative)} uncertain nuclide ground-state assignments, ${comma(g.flaggedNamingOne)} name a single candidate`,
      'meta description: the flagged count and the single-candidate count'],
    [html, `the largest set in the whole chart is ${WORDS[g.stats.max]}`, 'meta description: the largest set, spelled'],
    [html, `all ${comma(k.stats.n)} Masoretic apparatus entries`, 'meta description: the apparatus count'],
    [html, `${comma(k.stats.n)} apparatus entries`, 'body: the apparatus count'],
    [app, `all ${comma(k.stats.n)} entries at once`, 'floor note: the apparatus count'],
    [html, `${WORDS[f.scouted]} such collisions`, 'body: the forward scouted count, spelled'],
    [html, `${capital(WORDS[f.refused])} were refused`, 'body: the forward refused count, spelled'],
    [html, `${WORDS[f.built]} that were built`, 'body: the forward built count, spelled'],
    [html, `${capital(WORDS[b.scouted])} candidates were scouted`, 'body: the backward scouted count, spelled'],
    [html, `${capital(WORDS[b.refused])} were refused`, 'body: the backward refused count, spelled'],
    [html, `six of\nnineteen and zero of twenty-nine`, 'limits: the two rates, spelled'],
    // The page owns its own correction. If this sentence goes, the page has quietly stopped
    // saying that an earlier draft of its program reported the opposite finding.
    [html, 'A parser that knew one notation nearly shipped the opposite finding',
      'limits: the page records the parser error against itself'],
    [html, 'reported that zero flagged ground states name an alternative',
      'limits: the page states what the wrong number was'],
  ];
}
const capital = (s) => s[0].toUpperCase() + s.slice(1);

// The two rendered sources are held in mutable bindings so the mutation suite can doctor one and
// watch the suite go red. Nothing else reassigns them.
let HTML = html;
let APP = app;

function assertSurface() {
  for (const [source, needle, what] of surfaceClaims()) {
    const hay = (source === html ? HTML : APP).replace(/\s+/g, ' ');
    check(hay.includes(needle.replace(/\s+/g, ' ')), `${what}: the page does not carry "${needle}"`);
  }
}

// The figures the prose leaves to app.js are named by a data-f attribute, and every one of them
// has to be filled by app.js. A span the renderer forgot would show a literal question mark.
function assertDeferredFigures() {
  const wanted = [...HTML.matchAll(/data-f="([a-zA-Z]+)"/g)].map((m) => m[1]);
  check(wanted.length >= 8, 'the page defers a real number of figures to the renderer');
  for (const key of new Set(wanted)) {
    check(APP.includes(`put('${key}'`), `app.js never fills data-f="${key}"`);
  }
}

// ── 5. the scout-measured figures may appear, but never as a headline ────────────────────────
function assertScoutFiguresAreLabelled() {
  const cand = JSON.parse(readFileSync(join(HERE, 'candidates.json'), 'utf8'));
  const pass = cand.candidates.find((c) => c.mode === 'PASS');
  check(!!pass, 'exactly one candidate passed to build');
  equal(cand.candidates.filter((c) => c.mode === 'PASS').length, 1, 'only one candidate passed');
  // The survivor's numbers appear in the body. They must also be marked as a scouting
  // measurement both in the manifest and in the prose the reader sees.
  equal(pass.how, 'scout', 'the survivor\'s space size is recorded as scout-measured');
  check(HTML.includes('A scouting pass measured'), 'the page attributes the survivor\'s numbers to the scouting pass');
  check(HTML.includes('recorded here unbuilt rather than claimed'), 'the page says the survivor was not built');
  // Every candidate must name a scout file that exists, so no row is unfalsifiable. The reports
  // are not served (see build-page-data.mjs for why), so an outside run cannot make this one and
  // says so rather than passing it.
  if (OUTSIDE) {
    SKIPPED.push('the scouting reports: they are in the repository and the repository is private');
  } else {
    for (const c of cand.candidates) {
      check(existsSync(join(ROOT, 'oversight/waves/2026-09-13-foreign-instruments-backwards', c.scout)),
        `${c.id} names a scout report that is not in the repository`);
    }
  }
}

// ── 6. the prediction was sealed before the evidence ─────────────────────────────────────────
// This is the one claim a reader cannot check by reading, so it is checked against git: the
// commit carrying PREDICTION.md must be strictly older than every commit that carries a scouting
// artifact in the same directory, and the prediction commit must not itself touch one.
function assertSeal() {
  const dir = 'oversight/waves/2026-09-13-foreign-instruments-backwards';
  let log;
  try {
    log = execFileSync('git', ['log', '--reverse', '--format=%H %ct', '--name-only', '--', dir],
      { cwd: ROOT, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
  } catch {
    // The seal is a claim about commit ORDER, and commit order lives in a repository. A reader
    // running this from the published bytes has the prediction and the results but not the
    // history that separates them, so this is the one assertion an outside run cannot make. It
    // is reported as not checkable rather than quietly counted as a pass.
    SKIPPED.push('the seal: commit order is not visible outside a checkout of the repository');
    return;
  }
  const commits = [];
  let cur = null;
  for (const line of log.split('\n')) {
    const m = /^([0-9a-f]{40}) (\d+)$/.exec(line.trim());
    if (m) { cur = { sha: m[1], t: Number(m[2]), files: [] }; commits.push(cur); continue; }
    if (cur && line.trim()) cur.files.push(line.trim());
  }
  check(commits.length > 0, 'the wave directory has a history');
  const sealIdx = commits.findIndex((c) => c.files.some((f) => f.endsWith('PREDICTION.md')));
  check(sealIdx >= 0, 'PREDICTION.md is in the history');
  if (sealIdx < 0) return;
  const seal = commits[sealIdx];
  const isArtifact = (f) => f.includes('/scouts/') || f.endsWith('RESULT.md');
  check(!seal.files.some(isArtifact), 'the sealing commit carries no scouting artifact');
  for (const c of commits) {
    if (c.sha === seal.sha) continue;
    if (c.files.some(isArtifact)) {
      check(c.t >= seal.t, `a scouting artifact landed at or before the seal (${c.sha.slice(0, 8)})`);
    }
  }
}

// ── 7. the generated module is what its generator produces ───────────────────────────────────
function assertGenerated() {
  try {
    execFileSync(process.execPath, [join(HERE, 'build-page-data.mjs'), '--check'],
      { cwd: ROOT, stdio: ['ignore', 'pipe', 'pipe'] });
    assertions++;
  } catch (e) {
    check(false, 'data.js or the served extract has drifted from its generator');
  }
  const served = readFileSync(join(PAGE, 'data/ussc-fy2023-ranges.csv'));
  const research = readFileSync(join(HERE, 'data/ussc-fy2023-ranges.csv'));
  const h = (b) => createHash('sha256').update(b).digest('hex');
  equal(h(served), h(research), 'the served extract is byte-identical to the research copy');
}

// ── 8. the scorecard is scored from the counts, not from memory ──────────────────────────────
function assertScorecard() {
  const by = Object.fromEntries(P.predictions.map((p) => [p.id, p]));
  equal(by.B1.value, 0, 'B1 is scored at the backward build rate');
  check(by.B1.verdict.startsWith('CONFIRMED'), 'B1 is confirmed by its own test');
  check(by.B2.value < by.B2.against, 'B2: the backward mode A share really is the smaller one');
  check(by.B2.verdict.includes('WRONG ON THE MECHANISM'), 'B2 records that its reasoning failed');
  check(by.B3.value > by.B3.against, 'B3: B and D really did take a larger share');
  equal(by.B4.verdict, 'REFUTED', 'B4 is recorded as refuted');
  equal(by.B5.verdict, 'UNRESOLVED', 'B5 is recorded as unresolved rather than quietly dropped');
  // The sealed file must actually contain the claims the scorecard says it sealed.
  const pred = readFileSync(join(ROOT, 'oversight/waves/2026-09-13-foreign-instruments-backwards/PREDICTION.md'), 'utf8');
  for (const id of ['B1', 'B2', 'B3', 'B4', 'B5']) {
    check(pred.includes(`**${id}.`), `PREDICTION.md carries ${id}`);
  }
  // The sealed file is wrapped prose, so compare on collapsed whitespace and with the markdown
  // emphasis stripped: a line break inside the sentence is not a change to the sentence.
  const flat = pred.replace(/\*\*/g, '').replace(/\s+/g, ' ');
  check(flat.includes('at or below 50%'), 'PREDICTION.md states B1\'s threshold as it is scored');
  check(flat.includes('strictly below 23.1%'), 'PREDICTION.md states B2\'s threshold as it is scored');
  check(flat.includes('larger share of backward refusals than their forward share of 38.5%'),
    'PREDICTION.md states B3\'s threshold as it is scored');
}

// ── 9. the page's own prose, and this project's dash rule ────────────────────────────────────
function assertNoForbiddenDashes() {
  // The entity is built rather than written, so that this file can look for it without being an
  // instance of it. An earlier draft failed its own check for exactly that reason.
  const entity = '&' + 'mdash;';
  for (const [name, text] of [['index.html', html], ['app.js', app], ['data.js', dataJs],
    ['frontmatter', frontmatter], ['this verifier', readFileSync(fileURLToPath(import.meta.url), 'utf8')]]) {
    check(!text.includes(String.fromCodePoint(0x2014)), `em dash in ${name}`);
    check(!text.includes(entity), `em dash entity in ${name}`);
    check(!text.includes(' ' + String.fromCodePoint(0x2013) + ' '), `spaced en dash in ${name}`);
  }
}

function fullSuite() {
  assertions = 0; failures.length = 0; SKIPPED.length = 0;
  assertStatistics();
  assertJpParser();
  assertRecords();
  assertSurface();
  assertDeferredFigures();
  assertScoutFiguresAreLabelled();
  assertSeal();
  assertGenerated();
  assertScorecard();
  assertNoForbiddenDashes();
  return { assertions, failures: failures.slice() };
}

// ── the mutation suite ───────────────────────────────────────────────────────────────────────
// Each mutation doctors one real input, runs the WHOLE suite, and requires it to go red. The
// bindings are restored in a finally, so a mutation that throws cannot leave the suite poisoned.
// The planted faults are scored in their own lists rather than through check(), because every
// mustCatch re-runs fullSuite and fullSuite resets the shared failure list. An earlier draft used
// check() here and the last mutation's deliberate failure was reported as a real one.
function mutationSuite() {
  const caught = [];
  const unguarded = [];
  function mustCatch(name, doctor) {
    const h = HTML, a = APP;
    let red;
    try { doctor(); red = fullSuite().failures.length > 0; }
    finally { HTML = h; APP = a; }
    (red ? caught : unguarded).push(name);
  }

  const k = byId['ketiv-qere'];
  mustCatch('the apparatus count, one higher everywhere on the page',
    () => { HTML = HTML.replaceAll(comma(k.stats.n), comma(k.stats.n + 1)); });
  mustCatch('the apparatus count in the floor note only',
    () => { APP = APP.replace(`all ${comma(k.stats.n)} entries`, `all ${comma(k.stats.n + 1)} entries`); });
  mustCatch('the forward built count, spelled',
    () => { HTML = HTML.replace('six that were built', 'seven that were built'); });
  mustCatch('the backward scouted count, spelled',
    () => { HTML = HTML.replace('Twenty-nine candidates', 'Thirty candidates'); });
  mustCatch('the flagged ground-state count in the meta description',
    () => { HTML = HTML.replace('Of 938 uncertain', 'Of 939 uncertain'); });
  mustCatch('the single-candidate count in the meta description',
    () => { HTML = HTML.replace('877 name a single candidate', '878 name a single candidate'); });
  mustCatch('the page\'s own record of the parser error',
    () => { HTML = HTML.replace('A parser that knew one notation nearly shipped the opposite finding', 'Everything was right first time'); });
  mustCatch('a deferred figure the renderer stops filling',
    () => { APP = APP.replace("put('outsidePct'", "put('outsidePctXX'"); });
  mustCatch('the sentence attributing the survivor to the scouting pass',
    () => { HTML = HTML.replace('A scouting pass measured', 'We measured'); });
  mustCatch('the sentence saying the survivor was not built',
    () => { HTML = HTML.replace('recorded here unbuilt rather than claimed', 'built and confirmed'); });
  // Restore the suite to its true state before returning, so the caller sees the repository and
  // not the wreckage of the last planted fault.
  const clean = fullSuite();
  return { caught, unguarded, leftover: clean.failures };
}

const mode = process.argv[2] || '';
const run = fullSuite();
if (run.failures.length) {
  for (const f of run.failures) console.log('  ✗ ' + f);
  console.log(`FAIL: ${run.failures.length} of ${run.assertions} assertions`);
  process.exit(1);
}
if (mode === '--mutate') {
  const { caught, unguarded, leftover } = mutationSuite();
  for (const n of unguarded) console.log('  ✗ UNGUARDED mutation: ' + n);
  for (const f of leftover) console.log('  ✗ ' + f);
  if (unguarded.length || leftover.length) process.exit(1);
  console.log(`PASS: ${caught.length} planted mutations caught`);
  for (const n of caught) console.log('caught: ' + n);
} else {
  const g = byId['ground-state-jp'], k = byId['ketiv-qere'], u = byId['guideline-range'];
  for (const s of SKIPPED) console.log('  \u25cb NOT CHECKABLE HERE: ' + s);
  console.log(`PASS: ${run.assertions} assertions${SKIPPED.length ? ', ' + SKIPPED.length + ' not checkable outside a checkout' : ''}. `
    + `${g.tentative} flagged ground states, ${g.enumerated} naming an alternative; `
    + `${k.stats.n} apparatus entries, every one declaring exactly ${k.stats.max}; `
    + `${u.usable.toLocaleString('en-US')} guideline ranges, median ${u.stats.median} months, `
    + `${u.outside.pct.toFixed(1)}% of sentences outside.`);
}
