From 4ad81bf5555c0d01f1cad1366bd108d5a8c8a930 Mon Sep 17 00:00:00 2001 From: abrichr Date: Thu, 27 Aug 2026 18:29:16 -0400 Subject: [PATCH] test(fixtures): run the byte check on every matching builder test_public_fixtures_match_the_source_generator_byte_for_byte gated the regeneration on Python 3.12 and returned early otherwise. The CI 3.10 and 3.11 lanes carry SQLite 3.53.1 and SQLAlchemy 2.0.52, which are exactly the required versions, so their early return skipped the inner guard assertion too and the test verified nothing on two of the three lanes. The same Python gate skipped both tamper tests there. The committed bytes do not depend on the Python version. CPython 3.10.20, 3.11.15 and 3.12.13, each carrying SQLite 3.53.1 and SQLAlchemy 2.0.52, regenerate all ten committed artifacts with identical sha256 digests, so the determinants the provenance builder block names are complete. Select on those two versions alone: a matching builder always regenerates and compares, and a non-matching builder always asserts that the generator refuses to write. Neither path returns without an assertion. Co-Authored-By: Claude Opus 5 --- tests/test_synthetic_fixtures.py | 57 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/tests/test_synthetic_fixtures.py b/tests/test_synthetic_fixtures.py index dc8375a..9feea87 100644 --- a/tests/test_synthetic_fixtures.py +++ b/tests/test_synthetic_fixtures.py @@ -7,7 +7,6 @@ import shutil import sqlite3 import struct -import sys import zipfile from pathlib import Path @@ -148,18 +147,22 @@ def test_public_fixture_is_synthetic_sealed_and_exactly_bound( def _is_the_reference_builder() -> bool: """Report whether this interpreter regenerates the committed bytes exactly. - Python 3.12 with the required SQLite and SQLAlchemy is the one environment - that `test_public_fixtures_match_the_source_generator_byte_for_byte` proves - reproduces every committed byte. A tamper test is only meaningful there: on - any other builder a raised `generated bytes are stale` could report the - builder rather than the tamper. + The determinants are the ones the provenance `builder` block names: this + repository's writer code plus the required SQLite and SQLAlchemy versions. + The Python version is not among them. CPython 3.10.20, 3.11.15 and 3.12.13, + each carrying SQLite 3.53.1 and SQLAlchemy 2.0.52, regenerate all ten + committed artifacts identically, so every lane whose libraries match runs + the byte check and the tamper tests rather than skipping them. + + A tamper test is meaningful only on a matching builder: elsewhere a raised + `generated bytes are stale` could report the builder rather than the tamper. """ import sqlalchemy - return sys.version_info[:2] == (3, 12) and ( - sqlite3.sqlite_version, - sqlalchemy.__version__, - ) == (REQUIRED_SQLITE_VERSION, REQUIRED_SQLALCHEMY_VERSION) + return (sqlite3.sqlite_version, sqlalchemy.__version__) == ( + REQUIRED_SQLITE_VERSION, + REQUIRED_SQLALCHEMY_VERSION, + ) REFERENCE_BUILDER_ONLY = pytest.mark.skipif( @@ -175,24 +178,26 @@ def _copy_committed_fixtures(destination: Path) -> Path: def test_public_fixtures_match_the_source_generator_byte_for_byte() -> None: - import sqlalchemy + """Every lane asserts one of the two outcomes, and none asserts nothing. - if sys.version_info[:2] != (3, 12): - actual = (sqlite3.sqlite_version, sqlalchemy.__version__) - expected = (REQUIRED_SQLITE_VERSION, REQUIRED_SQLALCHEMY_VERSION) - if actual != expected: - with pytest.raises(RuntimeError, match="synthetic capture generation requires"): - check_generated( - spec_root=CAPTURE_ROOT / "specs", - output_root=CAPTURE_ROOT, - generator_path=GENERATOR, - ) + A matching builder regenerates the committed bytes and compares them. A + non-matching builder cannot reproduce them, so it asserts that the + generator refuses to write instead of emitting bytes it cannot certify. + """ + if _is_the_reference_builder(): + check_generated( + spec_root=CAPTURE_ROOT / "specs", + output_root=CAPTURE_ROOT, + generator_path=GENERATOR, + ) return - check_generated( - spec_root=CAPTURE_ROOT / "specs", - output_root=CAPTURE_ROOT, - generator_path=GENERATOR, - ) + + with pytest.raises(RuntimeError, match="synthetic capture generation requires"): + check_generated( + spec_root=CAPTURE_ROOT / "specs", + output_root=CAPTURE_ROOT, + generator_path=GENERATOR, + ) @REFERENCE_BUILDER_ONLY