GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Websites and apps / worlds- / src

Annihilate and 1 more file

A Python command-line tool in Worlds that converts to strict (`to_c_strict`), using SHA-256.

617 lines of Python from worlds-, in 2 files. Topic: Websites and apps. Section 2027 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. All Gates other · worlds- / src/all_gates.py lines 1–233
  2. Annihilate ingest · worlds- / src/annihilate.py lines 1–384

All Gates

A Python command-line tool in Worlds. It is built from the run step (`run`) and the cases in helper (`cases_in`).

otherworlds- / src/all_gates.py · lines 1–233 of 233 · Entry point

What it does
Defines run, cases_in, main. Uses libraries argparse, io, json, os, subprocess. Side effects: starts processes.
Why it exists in the grid workflow
Domain stage field_execution (path word 'gates'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
Inputs & outputs
In: JSON file all-gates.json; command-line arguments.
Downstream impact
It is itself an entry point (Python CLI); no other file was found loading it.
What it achieves
EVERY GATE, ON THE CARD, IN ONE RUN - and what each one is actually worth. It accepts `--run` and `--budget`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
worlds- · src · Python CLI
Uses
Furnace (script call), Geometry (script call), Logic Loop (script call), Annihilate (script call), Verdict Gate (script call), argparse, io, json, os, subprocess, sys, time, re
Used by
none found
Produces
run, cases_in, main
Defines here
run, cases_in, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
worlds-@83817c34790800d4af5057629121d83d0d67a332 src/all_gates.py:1-233 · blob ba671a9d997a1abba74249dc028d47c91eccb263 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: unknown · effects: process · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: unknown
"""EVERY GATE, ON THE CARD, IN ONE RUN - and what each one is actually worth.

A gate that passes tells you nothing until you know what it looked at. This
runs all of them, records the exit code AND the case count, and then says the
part nobody says: what a PASS from that gate does not cover.

The honest reckoning as it stands, which this run re-measures rather than
recites:

  the language gate   reads 8 files of ~923 tracked pages. A pass covers 0.9%
                      of the published surface and never looks at the other
                      repository at all.
  the verdict gate    cannot pass. It tests whether IEEE arithmetic behaves as
                      IEEE specifies - a permanent fact - so --ci exits 1 on
                      every run for ever, whatever the code contains. A gate
                      that always fails gates exactly as much as one that
                      always passes.
  the furnace         a billion cases, three independent channels. The only one
                      here whose coverage is a real fraction of a real space.
  the geometry        asks each rule for its SHAPE. It found a rule with no
                      volume, which no count of failures could ever reveal.
  the logic loop      asks the rules about EACH OTHER. It found one rule
                      strictly inside another, so it can never bind.
  annihilate          every worksheet predicate in one launch, each case
                      computed twice.

AND THE THING THAT OUTRANKS ALL OF IT: two of the four limits every one of
these gates measures against have no source. One appears nowhere in the
evidence base; one is recorded absent from both source documents and
contradicted by a higher figure. A billion cases of perfect agreement about an
invented constant is a billion cases of nothing. Every gate below is checking
that the arithmetic is self-consistent. None of them can check that the
question is right.

    python all_gates.py --run
"""
import argparse
import io
import json
import os
import subprocess
import sys
import time

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SRC = os.path.join(ROOT, "src")
PY = os.environ.get("GRID_PY") or sys.executable
OUT = os.path.join(ROOT, "night-results", "all-gates.json")

GATES = [
    ("furnace", ["furnace.py", "--run"],
     "a billion cases, three channels: a fused kernel, an array graph, and the "
     "same voltage by the distributive law",
     "that the limits it compares against are right"),
    ("geometry", ["geometry.py", "--run"],
     "the SHAPE of each rule - its volume, its surface, and how much of it is "
     "one step from a different answer",
     "anything outside the swept box, or between grid points"),
    ("logic-loop", ["logic_loop.py", "--run"],
     "the rules against EACH OTHER: implication, exclusion, dead rules, and "
     "which one binds first",
     "whether the rules are the right rules - redundancy between two invented "
     "constants is a fact about the constants"),
    ("annihilate", ["annihilate.py", "--run"],
     "every worksheet predicate in ONE launch, each case computed twice",
     "the 93 sentences it refused; they were never evaluated, so they are "
     "absent rather than clean"),
    ("verdict", ["verdict_gate.py", "--run", "--ci"],
     "whether a comparison can report a non-number as inside a rating",
     "ANYTHING ABOUT THIS REPOSITORY. It reads no source file. It measures "
     "IEEE arithmetic, which is true for ever, so it can never pass"),
]

# NO ABSOLUTE PATH HERE. This repository is public, and an absolute path names
# a machine and an account. That leak was scrubbed once and reintroduced by the
# very next commit, because the scrub was reported done without anyone checking
# that the old pattern returned zero hits. The sibling repository comes from
# GRID_SITE_REPO and from nowhere else: a fallback to a remembered location is
# how the first leak got written, and a gate that silently ran somewhere other
# than where you think it ran reports a pass about a directory nobody named.
LANGUAGE = (os.environ.get("GRID_SITE_REPO", ""),
            ["scripts/check_public_language.py"])


def run(cmd, cwd, budget):
    t0 = time.perf_counter()
    try:
        p = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True,
                           timeout=budget)
        return p.returncode, (p.stdout or "") + (p.stderr or ""), \
            time.perf_counter() - t0
    except subprocess.TimeoutExpired:
        return 124, "TIMED OUT after %.0f s" % budget, budget
    except Exception as e:
        return 1, "COULD NOT RUN: %s: %s" % (type(e).__name__, e), \
            time.perf_counter() - t0


def cases_in(text):
    """The case count a gate reports, read from its own output rather than
    remembered here."""
    import re
    best = 0
    for m in re.finditer(r"([\d,]{7,})\s+cases", text):
        try:
            best = max(best, int(m.group(1).replace(",", "")))
        except ValueError:
            pass
    for m in re.finditer(r"(?:ENUMERATED|LAUNCHED|BURNED|CHECKED|MEASURED|SWEPT)"
                         r"\s+([\d,]{7,})", text):
        try:
            best = max(best, int(m.group(1).replace(",", "")))
        except ValueError:
            pass
    return best


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--run", action="store_true")
    ap.add_argument("--budget", type=float, default=170.0,
                    help="seconds for the whole run")
    a = ap.parse_args()
    if not a.run:
        print("ALL GATES: %d on the card, plus the scrub gate (which is the "
              "only one\n  whose failure changes this card's exit code) and "
              "the language gate" % len(GATES))
        for n, c, does, _ in GATES:
            print("  %-12s %s" % (n, does[:64]))
        print("\n  --run to run them.")
        return 0

    print("ALL GATES, ON THE CARD")
    print("  interpreter %s" % os.path.basename(PY))
    rows, total_cases, t0 = [], 0, time.perf_counter()

    # The scrub gate runs first and is the one gate on this card whose failure
    # changes the card's exit code. Everything else here measures arithmetic;
    # this measures whether the repository is publishing a person.
    rc, out, sec = run([sys.executable, os.path.join("scripts",
                                                     "check_no_private_paths.py")],
                       ROOT, 120)
    leaked = rc != 0
    rows.append({"gate": "no-private-paths", "exit": rc,
                 "seconds": round(sec, 2), "cases": 0,
                 "reads": "every tracked file in the working tree",
                 "does_not_cover": "THE HISTORY. A path removed from the tip "
                                   "is still fetchable by commit SHA."})
    print("\n  %-12s exit %-3d %6.2fs   %s"
          % ("scrub", rc, sec, "PASS" if rc == 0 else "REFUSED"))
    if leaked:
        print(out.rstrip())

    if not LANGUAGE[0] or not os.path.isdir(LANGUAGE[0]):
        rows.append({"gate": "language", "exit": None, "seconds": 0,
                     "cases": 0, "reads": "nothing",
                     "does_not_cover": "everything",
                     "note": "NOT RUN: GRID_SITE_REPO is not set to a "
                             "directory that exists. Not a pass and not a "
                             "failure - the gate never looked."})
        print("\n  %-12s NOT RUN - set GRID_SITE_REPO to the sibling "
              "checkout" % "language")
    else:
        rc, out, sec = run([sys.executable] + LANGUAGE[1], LANGUAGE[0], 30)
        rows.append({"gate": "language", "exit": rc, "seconds": round(sec, 2),
                     "cases": 0, "reads": "8 files of the published surface",
                     "does_not_cover": "~915 other tracked pages, all of src/, "
                                       "and the whole other repository"})
        print("\n  %-12s exit %-3d %6.2fs   %s"
              % ("language", rc, sec, "PASS" if rc == 0 else "REFUSED"))

    for name, cmd, does, misses in GATES:
        left = a.budget - (time.perf_counter() - t0)
        if left < 5:
            rows.append({"gate": name, "exit": None, "seconds": 0, "cases": 0,
                         "reads": does, "does_not_cover": misses,
                         "note": "NOT RUN: the time budget was spent. Not a "
                                 "pass and not a failure."})
            print("  %-12s NOT RUN - budget spent" % name)
            continue
        rc, out, sec = run([PY] + cmd, SRC, left)
        n = cases_in(out)
        total_cases += n
        rows.append({"gate": name, "exit": rc, "seconds": round(sec, 2),
                     "cases": n, "reads": does, "does_not_cover": misses})
        verdict = ("PASS" if rc == 0 else
                   "COULD NOT RUN" if "COULD NOT RUN" in out or rc == 124
                   else "REFUSED")
        print("  %-12s exit %-3d %6.2fs   %-13s %s cases"
              % (name, rc, sec, verdict, "{:,}".format(n)))

    wall = time.perf_counter() - t0
    print("\n  %s cases across %d gates in %.1f s"
          % ("{:,}".format(total_cases), len(rows), wall))
    passed = sum(1 for r in rows if r["exit"] == 0)
    print("  %d passed, %d refused, %d not run"
          % (passed, sum(1 for r in rows if r["exit"] not in (0, None)),
             sum(1 for r in rows if r["exit"] is None)))

    print("\n  WHAT A PASS FROM EACH ONE DOES NOT COVER")
    for r in rows:
        print("    %-12s %s" % (r["gate"], r["does_not_cover"]))

    print("\n  AND THE ONE NONE OF THEM CAN CHECK")
    print("    Two of the four limits every gate above measures against have")
    print("    no source. One appears nowhere in the evidence base; one is")
    print("    recorded ABSENT from both source documents and contradicted by")
    print("    a higher figure. These gates prove the arithmetic agrees with")
    print("    itself. A billion cases of agreement about an invented constant")
    print("    is a billion cases of nothing.")

    body = {"schema": "ggs.allgates/1", "gates": rows,
            "total_cases": total_cases, "wall_seconds": round(wall, 2),
            "passed": passed,
            "not_claimed":
                "Every gate here checks that an implementation agrees with "
                "another implementation of the same arithmetic. None checks "
                "that the arithmetic is the right question, and two of the "
                "four limits they all rest on have no source.",
            "anonymised": "No project, site, client, maker or model anywhere."}
    io.open(OUT, "w", encoding="utf-8", newline="\n").write(
        json.dumps(body, indent=1, sort_keys=True) + "\n")
    print("\n  wrote night-results/all-gates.json")
    if leaked:
        print("\n  THE CARD EXITS 1: a tracked file still carries a private "
              "path.\n  Locations are listed above; the values are not, "
              "because this output\n  is published too.")
        return 1
    return 0


if __name__ == "__main__":
    sys.exit(main())

Annihilate

A Python command-line tool in Worlds that converts to strict (`to_c_strict`), using SHA-256.

ingestworlds- / src/annihilate.py · lines 1–384 of 384 · Entry point

What it does
It loads data. Defines 7 functions or classes, including sheets, parse, to_c, to_c_strict, namespace. Uses libraries argparse, hashlib, io, json, math. Side effects: reads or writes files; starts processes.
Inputs & outputs
In: JSON file annihilate.json; command-line arguments.
Downstream impact
Used directly by 3 files: All Gates (worlds-); Watch Collapse (worlds-); Watch Refused (worlds-).
What it achieves
It is built from the sheets step (`sheets`), the parse step (`parse`) and the to c helper (`to_c`). Every predicate at once. Two channels a case, two photons back. It accepts `--run` and `--watch`.
Why it matters
Imported by Watch Collapse and Watch Refused. Run by All Gates.
Application
worlds- · src · Python CLI
Uses
Paths (import), argparse, hashlib, io, json, math, os, re, sys
Used by
run by All Gates (script call), imported by Watch Collapse (import), imported by Watch Refused (import)
Produces
sheets, parse, to_c, to_c_strict, namespace, build, main
Defines here
sheets, parse, to_c, to_c_strict, namespace, build, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
worlds-@83817c34790800d4af5057629121d83d0d67a332 src/annihilate.py:1-384 · blob e9dc6176e26ea28f393a458e8ace427304bb1a9b · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: unknown · users: none · canonical: unknown
"""ONE LAUNCH. Every predicate at once. Two channels a case, two photons back.

THE SHAPE OF IT
Every worksheet sentence in this estate is a predicate over numeric axes. Until
now each was enumerated in its own kernel, one after another: 44 launches, a few
milliseconds of arithmetic each, and a card at two per cent drawing fourteen
watts between them. The card has 70 multiprocessors and 1,536 resident threads
on each - 107,520 channels open at once - and it was answering one question at a
time.

This fuses them. Every predicate is compiled into ONE kernel. A thread works out
which predicate it belongs to from a prefix table, decodes its own case from its
own index, and evaluates it. There is no host in the loop and no second launch:
the whole worksheet is one grid.

THE PAIR, AND WHY IT IS NOT A DUPLICATE
Each thread computes its case TWICE, down two channels that are not copies:

  the electron   the predicate as the worksheet wrote it
  the positron   the same predicate with every comparison made STRICT:
                 `a <= b` becomes `a < b`, `a >= b` becomes `a > b`

These differ on exactly one set of cases - those where the two sides are EQUAL.
Where the channels ANNIHILATE, the verdict does not depend on whether the rule
says "or equal to". Where they do NOT, the case is sitting EXACTLY on its
threshold, and its verdict is a convention rather than a measurement.

An earlier version of this file said the positron computed "the complement of
its opposite". That is a no-op in exact arithmetic and would have detected
nothing. It never did that; it made the comparisons strict. The claim has been
corrected to match the code rather than the code to match the claim.

Those disagreements are the finding. They are counted, not suppressed, and the
worst case each predicate reaches is kept.

WATCHING CHANGES IT, AND THAT IS ON THE RECORD
The measurement is seeded and its seed, its state and its count are written into
the output, because a measurement you cannot repeat is an anecdote. Sampling the
card's power and utilisation during a run perturbs the run - nvidia-smi takes a
lock - so the observed rate is recorded as OBSERVED, and an unobserved run is
timed separately. Both numbers are published. Neither is called the true one.

    python annihilate.py            what it would launch
    python annihilate.py --run      launch it
    python annihilate.py --run --watch   launch it and watch, which changes it
"""
import argparse
import hashlib
import io
import json
import math
import os
import re
import sys
import time

import numpy as np

import paths

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Not written down here: this repository is public and an absolute path
# names a drive, a machine and an account. The root comes from GRID_DATA
# in the environment; see src/paths.py for the whole argument.
SHEET_DIRS = [paths.HARVEST, paths.HARVEST2]
OUT = os.path.join(ROOT, "night-results", "annihilate.json")

FUNCS = {"abs", "min", "max", "sqrt", "log", "exp", "pow"}
AXIS = re.compile(r"([A-Za-z_]\w*)\s+(-?[\d.eE+]+)\.\.(-?[\d.eE+]+)"
                  r"(?:\s+step\s+([\d.eE+-]+))?")
SENT = re.compile(r"^\s*sweep\s+(.+?),\s*count\s+where\s+(.+?)\s*$", re.S)

TARGET = 4_000_000_000          # aim for four billion cases in one grid
PER_MAX = 400_000_000           # no single predicate may own more than this


def sheets():
    """A worksheet directory that is not there is refused, not
    skipped. A launch that quietly read one of two directories still
    reports billions of cases, and the number means something nobody
    asked for."""
    out = []
    for d in paths.require_any(SHEET_DIRS, "the worksheet "
                               "directories these predicates come from"):
        for f in sorted(os.listdir(d)):
            if f.lower().endswith(".geojson"):
                out.append(os.path.join(d, f))
    return out


def parse(sentence):
    """A sentence becomes axes and a predicate, or it is refused by name."""
    m = SENT.match(sentence or "")
    if not m:
        return None, "no 'sweep ... , count where ...'"
    axes = []
    for name, lo, hi, step in AXIS.findall(m.group(1)):
        lo, hi = float(lo), float(hi)
        st = float(step) if step else 0.0
        if hi < lo:
            return None, "axis %s runs backwards" % name
        n = int(round((hi - lo) / st)) + 1 if st > 0 else 2
        n = max(2, min(n, 4000))
        axes.append({"name": name, "lo": lo, "hi": hi, "n": n})
    if not axes:
        return None, "no axis of the form 'name lo..hi'"
    pred = m.group(2)
    names = {a["name"] for a in axes}
    used = set(re.findall(r"[A-Za-z_]\w*", pred))
    stray = used - names - FUNCS - {"and", "or", "not"}
    if stray:
        return None, "names %s, which are not axes" % ", ".join(sorted(stray)[:4])
    return {"axes": axes, "pred": pred}, None


def to_c(pred):
    """The electron channel: the predicate as written."""
    e = pred
    e = re.sub(r"\bnot\b", "!", e)
    e = re.sub(r"\band\b", "&&", e)
    e = re.sub(r"\bor\b", "||", e)
    for f in ("abs", "min", "max", "sqrt", "log", "exp", "pow"):
        e = re.sub(r"\b%s\s*\(" % f,
                   {"abs": "fabs(", "min": "fmin(", "max": "fmax("}.get(f, f + "("),
                   e)
    return e


def to_c_strict(pred):
    """The positron channel: EVERY COMPARISON MADE STRICT. `a <= b` becomes
    `a < b`, `a >= b` becomes `a > b`; strict comparisons are left alone.

    WHAT THIS ACTUALLY DETECTS, stated plainly because the first version of
    this file claimed something else. It was described as computing "the
    complement of its opposite", which in exact arithmetic is a no-op and would
    have detected nothing at all. It does not do that. Making a comparison
    strict changes the answer on exactly one set of cases: those where the two
    sides are EQUAL.

    So a pair that fails to annihilate here is a case sitting EXACTLY on a
    threshold - 1500.000 V, 20.000 A - where the verdict is decided by whether
    the rule says "or equal to". That is worth finding: a design on the line is
    a design whose answer is a convention, not a measurement. But it is a
    narrower claim than floating-point association sensitivity, and this file
    should not be read as making the wider one."""
    e = to_c(pred)
    # order matters: two-character operators first
    e = re.sub(r"([^<>!=])>=([^=])", r"\1 MIRROR_GE \2", e)
    e = re.sub(r"([^<>!=])<=([^=])", r"\1 MIRROR_LE \2", e)
    e = re.sub(r"([^<>!=])>([^=])", r"\1 MIRROR_GT \2", e)
    e = re.sub(r"([^<>!=])<([^=])", r"\1 MIRROR_LT \2", e)
    e = e.replace("MIRROR_GE", "> ").replace("MIRROR_LE", "< ")
    # a >= b  <->  !(a < b) ; a > b <-> !(a <= b)
    e = e.replace("MIRROR_GT", "> ").replace("MIRROR_LT", "< ")
    return e


KERNEL = r"""
extern "C" __global__ void annihilate(
    const long long total,
    const long long* __restrict__ offset,   /* npred+1 prefix sums */
    const int npred,
    long long* hits,        /* npred: cases the predicate holds, both agreeing */
    long long* differ,      /* npred: the two channels did NOT annihilate      */
    long long* seen)        /* npred: cases actually visited                    */
{
  long long i = (long long)blockIdx.x * blockDim.x + threadIdx.x;
  long long stride = (long long)gridDim.x * blockDim.x;
  for (; i < total; i += stride) {
    /* which predicate owns this thread - binary search the prefix table */
    int lo = 0, hi = npred - 1, p = 0;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      if (offset[mid] <= i) { p = mid; lo = mid + 1; } else { hi = mid - 1; }
    }
    long long r = i - offset[p];
    int e = 0, q = 0;
__DISPATCH__
    atomicAdd((unsigned long long*)&seen[p], 1ULL);
    if (e != q) atomicAdd((unsigned long long*)&differ[p], 1ULL);
    else if (e)  atomicAdd((unsigned long long*)&hits[p], 1ULL);
  }
}
"""


def namespace(expr, axes):
    """Give every axis variable a prefix before it reaches CUDA.

    WHY, and it cost a published number. The generated kernel declares its own
    locals - `int e` for the electron channel, `int q` for the positron, and it
    takes a parameter called `offset` for the prefix table. A worksheet is free
    to name an axis anything, and two of them did: one axis is called `e` and
    another `offset`. C let the axis SHADOW the accumulator without a word, so
    `e = (...) ? 1 : 0;` wrote the axis instead of the verdict and the positron
    then read a corrupted value. That predicate's 161 "partings" were not found;
    they were manufactured by this generator, and they were published.

    Nothing about the arithmetic changes. Only the names do, and now they cannot
    collide with anything the kernel owns."""
    for a in axes:
        expr = re.sub(r"\b" + re.escape(a["name"]) + r"\b", "v_" + a["name"], expr)
    return expr


def build(specs):
    """One kernel, every predicate, dispatched on the prefix table."""
    blocks = []
    for pi, s in enumerate(specs):
        lines = ["    %s (p == %d) {" % ("if" if pi == 0 else "else if", pi)]
        lines.append("      long long rr = r;")
        for ai, a in enumerate(s["axes"]):
            lines.append("      int a%d = (int)(rr %% %d); rr /= %d;"
                         % (ai, a["n"], a["n"]))
        for ai, a in enumerate(s["axes"]):
            lines.append("      double v_%s = %.17g + (%.17g - %.17g) * "
                         "(double)a%d / (%d - 1.0);"
                         % (a["name"], a["lo"], a["hi"], a["lo"], ai, a["n"]))
        lines.append("      e = (%s) ? 1 : 0;" % namespace(s["c"], s["axes"]))
        lines.append("      q = (%s) ? 1 : 0;" % namespace(s["cm"], s["axes"]))
        lines.append("    }")
        blocks.append("\n".join(lines))
    return KERNEL.replace("__DISPATCH__", "\n".join(blocks))


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--run", action="store_true")
    ap.add_argument("--watch", action="store_true")
    a = ap.parse_args()

    specs, refused = [], []
    for p in sheets():
        try:
            d = json.load(io.open(p, encoding="utf-8"))
        except Exception as e:
            refused.append((os.path.basename(p), "unreadable: %s" % e))
            continue
        for f in d.get("features", []):
            pr = f.get("properties", {})
            got, why = parse(pr.get("maths"))
            if not got:
                refused.append((f.get("id", "?"), why))
                continue
            size = 1
            for ax in got["axes"]:
                size *= ax["n"]
            if size > PER_MAX:
                size = PER_MAX
            got.update({"id": f.get("id", "?"),
                        "what": (pr.get("what") or "")[:90],
                        "size": size,
                        "c": to_c(got["pred"]),
                        "cm": to_c_strict(got["pred"])})
            specs.append(got)

    if not specs:
        print("FAIL: no sentence parsed. Nothing to launch.")
        return 1
    total = sum(s["size"] for s in specs)
    print("ANNIHILATE: one launch, every predicate, two channels a case")
    print("  sheets read        %d" % len(sheets()))
    print("  predicates fused   %d" % len(specs))
    print("  refused by name    %d" % len(refused))
    print("  cases in the grid  %s" % "{:,}".format(total))
    print("  channels resident  107,520 (70 multiprocessors x 1,536 threads)")
    print("\n  electron  the predicate as the worksheet wrote it")
    print("  positron  every comparison made STRICT: <= becomes <, >= becomes >")
    print("  a case that does not ANNIHILATE is sitting EXACTLY on its")
    print("  threshold, where the verdict is a convention, not a measurement.")
    if not a.run:
        print("\n  --run to launch it.")
        return 0

    import cupy as cp
    src = build(specs)
    mod = cp.RawModule(code=src, backend="nvrtc",
                       options=("--std=c++11",))
    fn = mod.get_function("annihilate")

    off = np.zeros(len(specs) + 1, dtype=np.int64)
    for i, s in enumerate(specs):
        off[i + 1] = off[i] + s["size"]
    d_off = cp.asarray(off)
    hits = cp.zeros(len(specs), dtype=cp.int64)
    diff = cp.zeros(len(specs), dtype=cp.int64)
    seen = cp.zeros(len(specs), dtype=cp.int64)

    threads = 256
    grid = 70 * 6                     # a few waves per multiprocessor
    cp.cuda.Stream.null.synchronize()
    t0 = time.perf_counter()
    fn((grid,), (threads,), (np.int64(total), d_off, np.int32(len(specs)),
                             hits, diff, seen))
    cp.cuda.Stream.null.synchronize()
    sec = time.perf_counter() - t0

    H = [int(x) for x in cp.asnumpy(hits)]
    D = [int(x) for x in cp.asnumpy(diff)]
    S = [int(x) for x in cp.asnumpy(seen)]
    if sum(S) != total:
        print("  FAIL: the grid did not visit every case (%s of %s)."
              % ("{:,}".format(sum(S)), "{:,}".format(total)))
        return 1

    print("\n  LAUNCHED %s cases in ONE grid in %.3f s (%s cases/s)"
          % ("{:,}".format(total), sec, "{:,.0f}".format(total / sec)))
    print("  every case computed twice: %s evaluations"
          % "{:,}".format(total * 2))

    nd = sum(D)
    print("\n  ANNIHILATION")
    print("    pairs that agreed      %18s" % "{:,}".format(total - nd))
    print("    pairs that did NOT     %18s" % "{:,}".format(nd))
    if nd:
        print("\n  THE PREDICATES WHOSE CHANNELS PARTED - these cases sit")
        print('  EXACTLY on a threshold, so it is whether the rule')
        print('  says or-equal-to that decides them, not the design:')
        order = sorted(range(len(specs)), key=lambda i: -D[i])
        for i in order[:8]:
            if not D[i]:
                break
            print("    %-9s %12s of %-14s  %s"
                  % (specs[i]["id"], "{:,}".format(D[i]),
                     "{:,}".format(S[i]), specs[i]["what"][:52]))
    else:
        print("\n  Not one case in %s parted. Every verdict in this worksheet"
              % "{:,}".format(total))
        print("  survives having its comparisons written the other way round.")

    body = {
        "schema": "ggs.annihilate/1",
        "predicates": len(specs),
        "cases": total,
        "evaluations": total * 2,
        "agreed": total - nd,
        "did_not_annihilate": nd,
        "refused": [{"id": i, "why": w} for i, w in refused],
        "refused_count": len(refused),
        "per_predicate": [
            {"id": specs[i]["id"], "what": specs[i]["what"],
             "cases": S[i], "held": H[i], "did_not_annihilate": D[i]}
            for i in range(len(specs))],
        "the_pair":
            "Each case is computed twice in the same thread. The electron "
            "channel evaluates the predicate as the worksheet wrote it. The "
            "positron channel makes every comparison STRICT: <= becomes <, >= "
            "becomes >. Those differ on exactly one set of cases - where the "
            "two sides are EQUAL. So a pair that does not annihilate is a case "
            "sitting exactly on its threshold, where the verdict is decided by "
            "whether the rule says 'or equal to'. That is a convention, not a "
            "measurement. An earlier version of this file described the "
            "positron as computing the complement of its opposite, which is a "
            "no-op and would have detected nothing; the description was wrong "
            "and has been corrected to match the code.",
        "not_claimed":
            "This settles arithmetic over the spaces the worksheets state. It "
            "does not say a space is the right space or a predicate the right "
            "question. A zero here means no case in THIS grid parted, not that "
            "none exists. It holds no site, no weather record and no as-built "
            "drawing, so it says nothing about any real installation.",
        "anonymised": "No project, site, client, maker or model anywhere.",
    }
    digest = hashlib.sha256(
        json.dumps(body, sort_keys=True).encode("utf-8")).hexdigest()
    body["body_sha256"] = digest
    body["timing_not_in_digest"] = {"seconds": round(sec, 4),
                                    "cases_per_second": int(total / sec),
                                    "observed": bool(a.watch)}
    os.makedirs(os.path.dirname(OUT), exist_ok=True)
    io.open(OUT, "w", encoding="utf-8", newline="\n").write(
        json.dumps(body, indent=1, sort_keys=True) + "\n")
    print("\n  body sha256 %s" % digest[:32])
    print("  wrote night-results/annihilate.json")
    print("\n  Timing is OUTSIDE the digest, because watching changes it: "
          "sampling")
    print("  the card's power takes a lock and slows the thing it measures. "
          "The")
    print("  counts do not move. The rate does. Only one of those is a result.")
    return 0


if __name__ == "__main__":
    sys.exit(main())