diff --git a/research/bands/ladder.py b/research/bands/ladder.py index ab20ad7a8..ee3c100da 100644 --- a/research/bands/ladder.py +++ b/research/bands/ladder.py @@ -258,13 +258,7 @@ def name(self) -> str: @property def label(self) -> str: - """A decimal rendering for reading. The exact endpoints are ``name``. - - NON-CERTIFYING. This is the only float path on the band object: the - endpoints are exact rationals and `name` prints them as such. A decimal - rendering is for a human reading a report, and no bound may be taken - from it. - """ + """A decimal rendering for reading. The exact endpoints are ``name``.""" return f"[{float(self.r_lo):.6f}, {float(self.r_hi):.6f}]" @property @@ -556,8 +550,6 @@ def format_report(kappa: F = DISPLAYED_KAPPA, prec: int = 40, out: List[str] = [] out.append("H5 rung ladder -- published point certifications (line: %s)" % line) out.append("=" * 72) - out.append("Every decimal below is a NON-CERTIFYING display of an exact value;") - out.append("the returned objects carry the exact rationals. Read those for a bound.") for p in points_for_line(line): dg = p.totals_digest[:16] + "..." if p.totals_digest else "(no digest quoted)" out.append(f" r = {float(p.r):<10.6f} I_hi/r^3 = {float(p.value):<12.4f}" diff --git a/tests/test_noncertifying.py b/tests/test_noncertifying.py index 031b91e03..3038acacd 100644 --- a/tests/test_noncertifying.py +++ b/tests/test_noncertifying.py @@ -11,6 +11,7 @@ """ from __future__ import annotations +import hashlib import os import subprocess import sys @@ -187,12 +188,60 @@ def test_the_repository_passes_and_actually_found_float_sites(): def test_the_known_float_bearing_modules_are_labelled_or_declared(): - """The eight that were unlabelled when the checker landed.""" - for rel in ("research/bands/ladder.py", "research/rn/moment_envelope.py", + """The eight that were unlabelled when the checker landed. + + ``research/bands/ladder.py`` was labelled in-file until the pin + reconciliation below moved it into ``DECLARED``; see that test for why. + """ + for rel in ("research/rn/moment_envelope.py", "tests/test_rn_moment_envelope.py"): with open(os.path.join(ROOT, rel), encoding="utf-8") as f: assert NCC.LABEL in f.read(), rel for rel in ("tools/registers_import.py", "tools/drive_index.py", "tests/test_bridge.py", "tests/test_hermite_envelope.py", - "tests/test_lpw_headline.py"): + "tests/test_lpw_headline.py", "research/bands/ladder.py"): assert rel in NCC.DECLARED, rel + + +#: The bytes two certificates on the ``chatgpt/drive-github-hardening-20260919`` +#: lane bind as a source identity. Recorded here so an edit to the file fails +#: loudly in this repository rather than silently in theirs. +LADDER_PINNED_SHA256 = \ + "9ea576708e146aa54fdc3c6859274d2c35a81218438bcdb34283afe9f79ac0c5" +LADDER_PINNED_BYTES = 26286 + + +def test_ladder_py_still_matches_the_digest_two_certificates_pin(): + """A cross-lane byte binding, made visible from inside this repository. + + ``research/parallel/h3/candidate.json`` and + ``research/rn/candidates/inner_wedge_20260920_v1.json`` on the hardening + lane record this file's SHA-256 as a source identity of their certificates, + and ``tools/twelve_project_check.py`` there fails closed on a mismatch. + Nothing in *this* repository said so, so commit ``4cc0f7a`` added a + NON-CERTIFYING docstring and two ``format_report`` lines, changed the bytes, + and broke a binding no checker here could see -- 19 failures in a merged + tree, none of them reproducible on either branch alone. + + The label now lives in ``NCC.DECLARED`` instead and the bytes are back. + This control is the part that keeps it that way: it is a repository-side + record of somebody else's dependency. + + If this fails, the file was edited. That is not forbidden -- but it + invalidates two certificates' provenance, so re-pin both JSON files on the + hardening lane in the same change, or revert the edit. Do not simply + update the constant here; the constant is not the authority, their pins are. + """ + path = os.path.join(ROOT, "research", "bands", "ladder.py") + raw = open(path, "rb").read() + assert len(raw) == LADDER_PINNED_BYTES, ( + f"{len(raw)} bytes, pinned at {LADDER_PINNED_BYTES}") + assert hashlib.sha256(raw).hexdigest() == LADDER_PINNED_SHA256 + + +def test_negative_control_a_changed_ladder_is_caught(): + """Flipping one byte must fail the pin, or the control above is decoration.""" + raw = open(os.path.join(ROOT, "research", "bands", "ladder.py"), "rb").read() + mutated = raw + b"\n" + assert hashlib.sha256(mutated).hexdigest() != LADDER_PINNED_SHA256 + assert len(mutated) != LADDER_PINNED_BYTES diff --git a/tools/noncertifying_check.py b/tools/noncertifying_check.py index 615a32d58..37da3cd4e 100644 --- a/tools/noncertifying_check.py +++ b/tools/noncertifying_check.py @@ -79,6 +79,20 @@ "tests/test_lpw_headline.py": "one `parse_decimal(6.239e-44)`, a negative control asserting a float " "literal is refused where an exact decimal string is required.", + "research/bands/ladder.py": + "`AdjacentBand.label` renders the exact endpoints as decimals for a " + "human reading a report, and `format_report` prints them; the endpoints " + "themselves are exact rationals and `name` prints them as such, so no " + "bound passes through either. DECLARED here rather than labelled in the " + "file because these bytes are content-pinned: " + "`research/parallel/h3/candidate.json` and " + "`research/rn/candidates/inner_wedge_20260920_v1.json` on the " + "`chatgpt/drive-github-hardening-20260919` lane bind this file by " + "SHA-256 (`9ea57670…`, 26286 bytes) as a source identity of their " + "certificates. An in-file label changes those bytes and breaks the " + "binding, and re-pinning is a judgement about their certificates' " + "provenance rather than ours to make. The label therefore lives here, " + "where it costs them nothing.", }