From 3f657c26151871d8082a7a3d507e378ae4f3d79d Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:13:45 -0400 Subject: [PATCH 1/8] fix: authenticate the accepted spectrum source pin refresh --- scripts/verify_pr_reconciliation.py | 34 ++++++++++++++- tests/test_pr_reconciliation.py | 65 +++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/scripts/verify_pr_reconciliation.py b/scripts/verify_pr_reconciliation.py index de2a019067..6a4d3a09c0 100644 --- a/scripts/verify_pr_reconciliation.py +++ b/scripts/verify_pr_reconciliation.py @@ -33,6 +33,37 @@ def check_batch1047_file(item): require(original.endswith(b'\n') and current.startswith(original), 'Historical Makefile content changed') +def check_frontier890_file(item): + """Authenticate the exact spectrum pin refresh accepted in 02c46c7e. + + Preserve the frozen frontier890 receipt. Sagar Thakrar's refresh changed + only the single_intersection.py source digest in SOURCE.json and RESULT.json; + every other byte, including all 41 mathematical cases, must still match. + Dennis with substantial OpenAI Codex assistance; Apache-2.0. + """ + name = item['integrated_path'] + current = (ROOT / name).read_bytes() + if hashlib.sha256(current).hexdigest() == item['integrated_sha256']: + return + predecessors = { + 'research/single-intersection-spectrum-audit/RESULT.json': + '9cb2210e148b2cce3fe59cf529fbf99f3b663dc7673db2e3969246595692f580', + 'research/single-intersection-spectrum-audit/SOURCE.json': + '610fb9887add31b4f597a39dc58b3beff0e14c91a5fd7ee340c3b2e7d4b0fb4c', + } + require(name in predecessors and item['integrated_sha256'] == predecessors[name], + 'Changed integrated file: ' + name) + old = b'08ddae46e5621a5b4c525b504e67ae655abe9b49461d894feaa7abc89a51847d' + new = b'6874d41b75590369182ed61e0c6da5b547e035e0e43b50ea2b39e1f3861dca6d' + source = 'scripts/experiments/single_intersection.py' + require(hashlib.sha256((ROOT / source).read_bytes()).hexdigest().encode() == new, + 'Changed spectrum successor source') + require(json.loads(current)['source_sha256'][source].encode() == new + and current.count(new) == 1, 'Changed spectrum source pin') + require(hashlib.sha256(current.replace(new, old)).hexdigest() == predecessors[name], + 'Changed spectrum evidence beyond the accepted source pin') + + def check_family_decision(item, decision): """Bind projected ledger state to its authoritative, pinned family decision.""" fields = ('number', 'reviewed_head', 'current_head', 'disposition', @@ -416,8 +447,7 @@ def main(): if item['action'] == 'pending': require(not decision['review_completion']['changed_file_coverage'], 'Incomplete review') if item.get('integrated_sha256'): - require(hashlib.sha256((ROOT / item['integrated_path']).read_bytes()).hexdigest() - == item['integrated_sha256'], 'Changed integrated file: ' + item['integrated_path']) + check_frontier890_file(item) if item['action'] != 'retained': require(bool(item.get('reason')), 'Missing scope or adaptation reason') print('PASS frontier890 batch: reviewed sources, finite replays, scoped claims and closure bindings') diff --git a/tests/test_pr_reconciliation.py b/tests/test_pr_reconciliation.py index db6b7a2ac2..1971754add 100644 --- a/tests/test_pr_reconciliation.py +++ b/tests/test_pr_reconciliation.py @@ -121,6 +121,71 @@ def read_text(path, *args, **kwargs): checker.main() +class SpectrumRefresh(unittest.TestCase): + def setUp(self): + coverage = json.loads((ROOT / 'research/community-frontier890-audit/CONTENT-COVERAGE.json').read_bytes()) + self.items = [deepcopy(item) for row in coverage['pull_requests'].values() + for item in row['files'] if item.get('integrated_path') in { + 'research/single-intersection-spectrum-audit/RESULT.json', + 'research/single-intersection-spectrum-audit/SOURCE.json'}] + self.old = b'08ddae46e5621a5b4c525b504e67ae655abe9b49461d894feaa7abc89a51847d' + self.new = b'6874d41b75590369182ed61e0c6da5b547e035e0e43b50ea2b39e1f3861dca6d' + + def test_exact_accepted_refresh_and_original_bytes_pass(self): + self.assertEqual(len(self.items), 2) + for item in self.items: + checker.check_frontier890_file(item) + current = (ROOT / item['integrated_path']).read_bytes() + original = current.replace(self.new, self.old) + self.assertEqual(sha256(original).hexdigest(), item['integrated_sha256']) + with patch.object(Path, 'read_bytes', return_value=original): + checker.check_frontier890_file(item) + + def test_any_other_proof_or_metadata_edit_is_rejected(self): + for item in self.items: + current = (ROOT / item['integrated_path']).read_bytes() + for mutated in (current.replace(b'"assignment_seed": 65', b'"assignment_seed": 66'), + current + b' ', current.replace(self.new, b'0' * 64), + current + self.new): + self.assertNotEqual(mutated, current) + original_read = Path.read_bytes + def read(path): + return mutated if path == ROOT / item['integrated_path'] else original_read(path) + with patch.object(Path, 'read_bytes', read), self.assertRaises(ValueError): + checker.check_frontier890_file(item) + + def test_changed_mathematical_case_is_rejected(self): + item = next(item for item in self.items if item['integrated_path'].endswith('RESULT.json')) + current = (ROOT / item['integrated_path']).read_bytes() + mutated = current.replace(b'"binary_rank": 3,', b'"binary_rank": 4,', 1) + self.assertNotEqual(current, mutated) + original_read = Path.read_bytes + def read(path): + return mutated if path == ROOT / item['integrated_path'] else original_read(path) + with patch.object(Path, 'read_bytes', read), self.assertRaisesRegex(ValueError, 'beyond'): + checker.check_frontier890_file(item) + + def test_forged_historical_pin_is_rejected(self): + for item in self.items: + item['integrated_sha256'] = '0' * 64 + with self.assertRaisesRegex(ValueError, 'Changed integrated file'): + checker.check_frontier890_file(item) + + def test_successor_helper_drift_is_rejected(self): + original_read = Path.read_bytes + def read(path): + return b'changed helper' if path == ROOT / 'scripts/experiments/single_intersection.py' else original_read(path) + with patch.object(Path, 'read_bytes', read): + for item in self.items: + with self.assertRaisesRegex(ValueError, 'Changed spectrum successor source'): + checker.check_frontier890_file(item) + + def test_unrelated_file_changes_still_fail(self): + item = {'integrated_path': 'CONTRIBUTING.md', 'integrated_sha256': '0' * 64} + with self.assertRaisesRegex(ValueError, 'Changed integrated file'): + checker.check_frontier890_file(item) + + class ReviewCompletion(unittest.TestCase): def setUp(self): self.decision = { From c58dc836c8993ef09ad0415baede96baf80940a4 Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:15:55 -0400 Subject: [PATCH 2/8] fix: retain source binding after isolated runner assertion safety update --- scripts/verify_pr_reconciliation.py | 26 ++++++++++++++++-- tests/test_pr_reconciliation.py | 41 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/scripts/verify_pr_reconciliation.py b/scripts/verify_pr_reconciliation.py index 6a4d3a09c0..dc99dec226 100644 --- a/scripts/verify_pr_reconciliation.py +++ b/scripts/verify_pr_reconciliation.py @@ -64,6 +64,29 @@ def check_frontier890_file(item): 'Changed spectrum evidence beyond the accepted source pin') +def check_batch932_file(item): + """Bind the exact assertion-safety update accepted in 2b7dc6cf. + + Credit woklerx for keeping assertions enabled in child research processes. + These two exact successor blobs are an explicit maintenance adaptation, + not permission to change any other bytes or the frozen batch932 receipt. + """ + name = item['integrated_path'] + digest = hashlib.sha256((ROOT / name).read_bytes()).hexdigest() + if digest == item['integrated_sha256']: + return + successors = { + 'scripts/run_isolated_tests.py': ( + '96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1', + 'b1c645e815a6abfbfdc2d77c4121c543ed0ca958095e97e1181d64e84cac0ed8'), + 'tests/test_isolated_test_runner.py': ( + '628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac', + '8262f36202e426b849a925123ff789843115d5e564962710c31ab14f84c88067'), + } + require(name in successors and successors[name] == (item['integrated_sha256'], digest), + 'Changed integrated file: ' + name) + + def check_family_decision(item, decision): """Bind projected ledger state to its authoritative, pinned family decision.""" fields = ('number', 'reviewed_head', 'current_head', 'disposition', @@ -474,8 +497,7 @@ def main(): if item['action'] == 'pending': require(not decision['review_completion']['changed_file_coverage'], 'Incomplete review') if item.get('integrated_sha256'): - require(hashlib.sha256((ROOT / item['integrated_path']).read_bytes()).hexdigest() - == item['integrated_sha256'], 'Changed integrated file: ' + item['integrated_path']) + check_batch932_file(item) if item['action'] != 'retained': require(bool(item.get('reason')), 'Missing scope or adaptation reason') print('PASS batch932 batch: reviewed sources, finite replays, scoped claims and closure bindings') diff --git a/tests/test_pr_reconciliation.py b/tests/test_pr_reconciliation.py index 1971754add..87f5027edb 100644 --- a/tests/test_pr_reconciliation.py +++ b/tests/test_pr_reconciliation.py @@ -186,6 +186,47 @@ def test_unrelated_file_changes_still_fail(self): checker.check_frontier890_file(item) +class AssertionSafetyRefresh(unittest.TestCase): + def setUp(self): + coverage = json.loads((ROOT / 'research/community-batch932-audit/CONTENT-COVERAGE.json').read_bytes()) + self.items = [deepcopy(item) for row in coverage['pull_requests'].values() + for item in row['files'] if item.get('integrated_path') in { + 'scripts/run_isolated_tests.py', 'tests/test_isolated_test_runner.py'}] + + def test_exact_accepted_successors_pass(self): + self.assertEqual(len(self.items), 2) + for item in self.items: + checker.check_batch932_file(item) + + def test_assertion_guard_removal_and_other_byte_edits_fail(self): + original_read = Path.read_bytes + for item in self.items: + current = (ROOT / item['integrated_path']).read_bytes() + mutations = [current + b' '] + if item['integrated_path'].startswith('scripts/'): + mutations.append(current.replace(b"env.pop('PYTHONOPTIMIZE', None)", b'pass')) + for mutated in mutations: + self.assertNotEqual(current, mutated) + def read(path): + return mutated if path == ROOT / item['integrated_path'] else original_read(path) + with patch.object(Path, 'read_bytes', read), self.assertRaises(ValueError): + checker.check_batch932_file(item) + + def test_forged_predecessor_and_cross_file_successor_fail(self): + for item in self.items: + item['integrated_sha256'] = '0' * 64 + with self.assertRaises(ValueError): + checker.check_batch932_file(item) + other = (ROOT / self.items[1]['integrated_path']).read_bytes() + with patch.object(Path, 'read_bytes', return_value=other), self.assertRaises(ValueError): + checker.check_batch932_file(self.items[0]) + + def test_unrelated_file_still_needs_exact_bytes(self): + item = {'integrated_path': 'CONTRIBUTING.md', 'integrated_sha256': '0' * 64} + with self.assertRaises(ValueError): + checker.check_batch932_file(item) + + class ReviewCompletion(unittest.TestCase): def setUp(self): self.decision = { From 7ef00f0692774daeea6e369f142dc398775de46b Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:18:39 -0400 Subject: [PATCH 3/8] fix: use authenticated reconciliation replay in the aggregate audit --- .github/workflows/community-tooling799.yml | 9 +++++++++ scripts/verify_pr_reconciliation.py | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/community-tooling799.yml b/.github/workflows/community-tooling799.yml index 2fed4190c8..dbedc44d9a 100644 --- a/.github/workflows/community-tooling799.yml +++ b/.github/workflows/community-tooling799.yml @@ -11,6 +11,10 @@ on: - 'research/sw4-owner-optimality/**' - 'research/pr695-digest-audit/**' - 'scripts/verify_pr_reconciliation.py' + - 'scripts/replay_historical_check.py' + - 'scripts/historical-ci-inputs/**' + - 'tests/test_pr_reconciliation.py' + - 'tests/test_historical_check.py' - 'tests/test_reconciliation_archive.py' - '.github/workflows/community-tooling799.yml' pull_request: @@ -22,6 +26,10 @@ on: - 'research/sw4-owner-optimality/**' - 'research/pr695-digest-audit/**' - 'scripts/verify_pr_reconciliation.py' + - 'scripts/replay_historical_check.py' + - 'scripts/historical-ci-inputs/**' + - 'tests/test_pr_reconciliation.py' + - 'tests/test_historical_check.py' - 'tests/test_reconciliation_archive.py' - '.github/workflows/community-tooling799.yml' permissions: @@ -53,6 +61,7 @@ jobs: - name: Current ledger and archive integrity controls run: | python -B scripts/verify_pr_reconciliation.py + python -B -m unittest discover -s tests -p 'test_historical_check.py' -v python -B -m unittest discover -s tests -p 'test_*reconciliation*.py' -v python -B -O -m unittest discover -s tests -p 'test_*reconciliation*.py' -v - run: git diff --exit-code diff --git a/scripts/verify_pr_reconciliation.py b/scripts/verify_pr_reconciliation.py index dc99dec226..483117fffd 100644 --- a/scripts/verify_pr_reconciliation.py +++ b/scripts/verify_pr_reconciliation.py @@ -8,6 +8,8 @@ import tempfile import json import zipfile +import subprocess +import sys ROOT = Path(__file__).resolve().parents[1] AUDIT = ROOT / 'research/pr-reconciliation-20261012' @@ -625,7 +627,10 @@ def main(): runpy.run_path(str(historical_five), run_name='__main__') reconciliation92 = ROOT / 'research/community-reconciliation92-audit/verify.py' if reconciliation92.exists(): - runpy.run_path(str(reconciliation92), run_name='__main__') + # The original checker binds the pre-PR154 Makefile. Reuse the + # authenticated isolated replay rather than weakening that pin. + subprocess.run([sys.executable, '-B', str(ROOT / 'scripts/replay_historical_check.py'), + 'reconciliation92'], cwd=ROOT, check=True) third100 = ROOT / 'research/community-reconciliation-third100-audit/verify.py' if third100.exists(): runpy.run_path(str(third100), run_name='__main__') From 7428274cc7b4a9d9b8bc89a8cd118e1d728d726f Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 14:20:45 -0400 Subject: [PATCH 4/8] ci: run scoped reconciliation checks on contributor branches --- .github/workflows/community-tooling799.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/community-tooling799.yml b/.github/workflows/community-tooling799.yml index dbedc44d9a..b0e57b08cf 100644 --- a/.github/workflows/community-tooling799.yml +++ b/.github/workflows/community-tooling799.yml @@ -1,8 +1,8 @@ name: Community exact tooling and scoped audits on: workflow_dispatch: + # Keep these path-scoped checks available on contributor fork branches. push: - branches: [main] paths: - 'research/clifford-state-performance/**' - 'research/gram-prefix-performance/**' From c58c177852c4e146bad711f8f211a6b005ed76d3 Mon Sep 17 00:00:00 2001 From: Dennys <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:16:00 -0400 Subject: [PATCH 5/8] fix: replay frozen skip-clone checks with authenticated PR53 source Keep the PR53 SOURCE.json, original acceptance suite, frozen certificate, producer, selected frontier and updated live exclusion circuit unchanged. Run both the clones CI group and the affected isolated unittest module in temporary tracked-file snapshots with the exact predecessor script retained in research/exclusion-embedding-masks/baseline.py, preserving all other live inputs. Permit only the historically pinned byte hash or Wentao Li's exact reviewed support-mask successor; reject unrelated source drift and corrupted baseline bytes in negative controls. Retain all existing CI diff gates. Predecessors: PR53 skip-clones by Chafik Boukhalfa and collaborators; Wentao Li's accepted ExclusionCircuit support-mask optimizations #2001. Prepared by Dennis (antunishdPursuit) with substantial OpenAI Codex assistance. Apache-2.0; no new mathematical acceptance claim. --- .github/workflows/verify.yml | 3 ++- scripts/replay_historical_check.py | 36 +++++++++++++++++++++++++++++- scripts/run_isolated_tests.py | 16 +++++++++++-- tests/test_historical_check.py | 29 ++++++++++++++++++++++++ tests/test_isolated_test_runner.py | 8 +++++++ 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 4446616e87..0b88bd2639 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -37,7 +37,8 @@ jobs: - name: Check arithmetic, source hashes, finite identities, and patches run: | if [ "${{ matrix.group }}" = clones ]; then - make skip-clones-verify split-skip-producer + python -B scripts/replay_historical_check.py skip-clones + make split-skip-producer python -B scripts/replay_historical_check.py split-skip else make verify-${{ matrix.group }} diff --git a/scripts/replay_historical_check.py b/scripts/replay_historical_check.py index ef23ca1a13..0a04783d8b 100644 --- a/scripts/replay_historical_check.py +++ b/scripts/replay_historical_check.py @@ -48,6 +48,34 @@ } +# Keep PR53's frozen source pin intact while replaying against the reviewed +# successor of the faster exclusion support-mask checker. Original exact bytes +# are retained by the linked baseline package (Wentao Li / VictorLiwentao). +# Dennis with substantial OpenAI Codex assistance; Apache-2.0. +CONFIG['skip-clones'] = { + 'manifest': 'research/skip-clones/SOURCE.json', + 'field': 'files', + 'path': 'scripts/exclusion_circuit.py', + 'input_from_root': True, + 'input': 'research/exclusion-embedding-masks/baseline.py', + 'sha256': 'b253f9d7318becda1c1f3b24e2287ed44a9c27fcea00cf9d531afb950d0457a0', + 'accepted_live_sha256': [ + 'f9fbcd6e85e442cbd0926ac0887414e20735b2dc923d2d5822c803ceb46726d3', + ], + 'commands': [ + ['research/skip-clones/producer.py'], + ['research/skip-clones/witness.py', '--output', + 'research/skip-clones/certificate.json'], + ['-m', 'unittest', 'discover', '-s', 'tests', + '-p', 'test_skip_clones.py', '-v'], + ], +} +CONFIG['skip-clones-tests'] = { + **CONFIG['skip-clones'], + 'commands': [CONFIG['skip-clones']['commands'][-1]], +} + + def require(condition, message): if not condition: raise ValueError(message) @@ -67,7 +95,13 @@ def authenticated_input(root, config, inputs=INPUTS): require(entry.get('representation') == 'bytes', 'Expected exact byte representation') entry = entry.get('sha256') require(entry == config['sha256'], 'Missing or changed predecessor source pin') - data = safe_path(inputs, config['input']).read_bytes() + # A replay must not hide an unrelated live source mutation. + if 'accepted_live_sha256' in config: + live = hashlib.sha256(safe_path(root, config['path']).read_bytes()).hexdigest() + require(live in (config['sha256'], *config['accepted_live_sha256']), + 'Unrecognized live source update: ' + config['path']) + input_root = root if config.get('input_from_root') else inputs + data = safe_path(input_root, config['input']).read_bytes() require(hashlib.sha256(data).hexdigest() == entry, 'Changed historical input') if config.get('preserve_prefix'): require(data.endswith(b'\n') and safe_path(root, config['path']).read_bytes().startswith(data), diff --git a/scripts/run_isolated_tests.py b/scripts/run_isolated_tests.py index d95ff0740d..e923a69198 100644 --- a/scripts/run_isolated_tests.py +++ b/scripts/run_isolated_tests.py @@ -10,6 +10,8 @@ --workers controls the width). Every module keeps the exact sequential command and its captured stdout/stderr bytes are replayed in sorted module order, so the combined receipts match a sequential run module for module. +For PR53 skip-clones, the unchanged module command runs in a temporary +copy with its authenticated frozen source instead of the optimized successor. """ import argparse from concurrent.futures import ThreadPoolExecutor @@ -22,7 +24,7 @@ def module_command(python, tests_dir, name): - """The one command every module runs, unchanged from the sequential runner.""" + """Default unchanged command for a test module.""" return [python, '-m', 'unittest', 'discover', '-s', str(tests_dir), '-p', name, '-v'] @@ -45,7 +47,17 @@ def run_modules(files, python=None, tests_dir=None, cwd=None, workers=None): env.pop('PYTHONOPTIMIZE', None) def run_one(path): - result = subprocess.run(module_command(python, tests_dir, path.name), + command = module_command(python, tests_dir, path.name) + # Run this frozen package's original tests in its authenticated overlay. + # Other test modules continue to exercise the live checkout unchanged. + if (path.name == 'test_skip_clones.py' + and Path(tests_dir).resolve() == (ROOT / 'tests').resolve() + and Path(cwd).resolve() == ROOT.resolve() + and (ROOT / 'research/skip-clones/SOURCE.json').is_file() + and (ROOT / 'scripts/replay_historical_check.py').is_file()): + command = [python, '-B', str(ROOT / 'scripts/replay_historical_check.py'), + 'skip-clones-tests'] + result = subprocess.run(command, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return path, result.returncode, result.stdout, result.stderr diff --git a/tests/test_historical_check.py b/tests/test_historical_check.py index cc4921d825..dccb7bb711 100644 --- a/tests/test_historical_check.py +++ b/tests/test_historical_check.py @@ -90,6 +90,35 @@ def test_makefile_append_is_allowed_but_original_prefix_mutation_rejects(self): with self.assertRaisesRegex(ValueError, 'prefix changed'): checker.authenticated_input(root, config, inputs) + def test_skip_clone_frozen_source_replay_binding(self): + config = checker.CONFIG['skip-clones'] + predecessor = (ROOT / config['input']).read_bytes() + pins = json.loads((ROOT / config['manifest']).read_bytes()) + self.assertEqual(hashlib.sha256(predecessor).hexdigest(), config['sha256']) + self.assertEqual(pins['files'][config['path']], config['sha256']) + self.assertEqual(checker.authenticated_input(ROOT, config), predecessor) + suite = checker.CONFIG['skip-clones-tests'] + self.assertEqual(suite['sha256'], config['sha256']) + self.assertEqual(suite['commands'], config['commands'][-1:]) + + def test_skip_clone_overlay_rejects_unknown_live_and_corrupt_baseline(self): + with tempfile.TemporaryDirectory() as td: + root, inputs, config, paths = self.fixture(td) + original = (inputs / 'old.txt').read_bytes() + (root / 'baseline.txt').write_bytes(original) + current = hashlib.sha256((root / 'input.txt').read_bytes()).hexdigest() + config.update(input='baseline.txt', input_from_root=True, + accepted_live_sha256=[current]) + self.assertEqual(checker.authenticated_input(root, config, inputs), original) + (root / 'input.txt').write_bytes(b'unreviewed source edit\\n') + with self.assertRaisesRegex(ValueError, 'Unrecognized live source update'): + checker.authenticated_input(root, config, inputs) + (root / 'input.txt').write_bytes(original) + self.assertEqual(checker.authenticated_input(root, config, inputs), original) + (root / 'baseline.txt').write_bytes(b'changed frozen evidence\\n') + with self.assertRaisesRegex(ValueError, 'Changed historical input'): + checker.authenticated_input(root, config, inputs) + def test_real_snapshots_match_unchanged_predecessor_pins(self): for name, config in checker.CONFIG.items(): with self.subTest(package=name): diff --git a/tests/test_isolated_test_runner.py b/tests/test_isolated_test_runner.py index 18ff944711..d1fae1fdee 100644 --- a/tests/test_isolated_test_runner.py +++ b/tests/test_isolated_test_runner.py @@ -131,6 +131,14 @@ def test_default_invocation_keeps_receipt_and_summary(self): self.assertFalse(any(line.startswith('PASS all') for line in lines)) self.assertIn('Failed modules: test_b_fail.py', result.stderr.decode()) + def test_same_named_synthetic_clone_test_still_fails(self): + # A name alone must not trigger the production historical overlay. + box = self.sandbox({'test_skip_clones.py': FAIL_MODULE}) + result = box.run('--workers', '1') + self.assertNotEqual(result.returncode, 0) + self.assertIn('deliberate negative control', result.stderr.decode()) + self.assertIn('Failed modules: test_skip_clones.py', result.stderr.decode()) + def test_inherited_optimization_cannot_hide_verifier_assertions(self): # Research tests call verifiers that still use Python assert. The # outer runner itself may be optimized, but its checks must not be. From 72f071327f8417ee41a5ec942299a5ab8799b27f Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:51:09 -0400 Subject: [PATCH 6/8] fix: bind the historical clone runner extension to its exact sources --- scripts/verify_pr_reconciliation.py | 13 +++++++++---- tests/test_pr_reconciliation.py | 11 +++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/verify_pr_reconciliation.py b/scripts/verify_pr_reconciliation.py index 483117fffd..d0a73966d1 100644 --- a/scripts/verify_pr_reconciliation.py +++ b/scripts/verify_pr_reconciliation.py @@ -67,11 +67,13 @@ def check_frontier890_file(item): def check_batch932_file(item): - """Bind the exact assertion-safety update accepted in 2b7dc6cf. + """Bind exact assertion-safety and historical replay runner successors. Credit woklerx for keeping assertions enabled in child research processes. These two exact successor blobs are an explicit maintenance adaptation, not permission to change any other bytes or the frozen batch932 receipt. + Also authenticate the exact PR53 replay adapter and its test from c58c1778; + this extension retains the earlier assertion guard and every module. """ name = item['integrated_path'] digest = hashlib.sha256((ROOT / name).read_bytes()).hexdigest() @@ -80,12 +82,15 @@ def check_batch932_file(item): successors = { 'scripts/run_isolated_tests.py': ( '96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1', - 'b1c645e815a6abfbfdc2d77c4121c543ed0ca958095e97e1181d64e84cac0ed8'), + ('b1c645e815a6abfbfdc2d77c4121c543ed0ca958095e97e1181d64e84cac0ed8', + '05839996482058359b2ab8087d7d96e76934bd03d79981df9b99447e8ed09331')), 'tests/test_isolated_test_runner.py': ( '628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac', - '8262f36202e426b849a925123ff789843115d5e564962710c31ab14f84c88067'), + ('8262f36202e426b849a925123ff789843115d5e564962710c31ab14f84c88067', + '6f5ad20a5f174be0aab874cf524cba01c5401dafa46dd176999bad43ab566522')), } - require(name in successors and successors[name] == (item['integrated_sha256'], digest), + require(name in successors and successors[name][0] == item['integrated_sha256'] + and digest in successors[name][1], 'Changed integrated file: ' + name) diff --git a/tests/test_pr_reconciliation.py b/tests/test_pr_reconciliation.py index 87f5027edb..91fe99956e 100644 --- a/tests/test_pr_reconciliation.py +++ b/tests/test_pr_reconciliation.py @@ -198,6 +198,17 @@ def test_exact_accepted_successors_pass(self): for item in self.items: checker.check_batch932_file(item) + def test_historical_adapter_cannot_be_disabled(self): + item = next(item for item in self.items if item['integrated_path'].startswith('scripts/')) + current = (ROOT / item['integrated_path']).read_bytes() + mutated = current.replace(b"path.name == 'test_skip_clones.py'", b'False') + self.assertNotEqual(current, mutated) + original_read = Path.read_bytes + def read(path): + return mutated if path == ROOT / item['integrated_path'] else original_read(path) + with patch.object(Path, 'read_bytes', read), self.assertRaises(ValueError): + checker.check_batch932_file(item) + def test_assertion_guard_removal_and_other_byte_edits_fail(self): original_read = Path.read_bytes for item in self.items: From 92276c22f6f419bbefd870bf2bb373bc41b0c643 Mon Sep 17 00:00:00 2001 From: Dennis <122734610+antunishdPursuit@users.noreply.github.com> Date: Wed, 14 Oct 2026 15:53:25 -0400 Subject: [PATCH 7/8] fix: authenticate every frozen split-skip helper in isolated replays --- scripts/historical-ci-inputs/README.md | 12 ++++- scripts/replay_historical_check.py | 42 +++++++++++++++--- tests/test_historical_check.py | 61 ++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 8 deletions(-) diff --git a/scripts/historical-ci-inputs/README.md b/scripts/historical-ci-inputs/README.md index c438694334..60fc82c1e2 100644 --- a/scripts/historical-ci-inputs/README.md +++ b/scripts/historical-ci-inputs/README.md @@ -3,7 +3,7 @@ These are exact Git blobs, not new source pins or changes to the selected result. The maintenance launcher `scripts/replay_historical_check.py` verifies each blob against its unchanged predecessor manifest, copies tracked working files into a -temporary tree, replaces just the declared historical input there, and executes +temporary tree, replaces only the declared historical inputs there, and executes the original checkers. It works with shallow CI checkouts and changes no live source file. The live Makefile must still preserve its entire authenticated historical prefix; appended targets are allowed, prefix mutations reject. All other inputs remain the current tracked working @@ -19,6 +19,16 @@ reproducibility gate as well as protecting the live checkout. | `Makefile` | `Makefile` | `b84ba67156a01f9c2cb34fe1e3cb1dcdeab00d9c` | `research/community-reconciliation92-audit/MANIFEST.json` | | `audit_fused_block.py` | `scripts/audit_fused_block.py` | `6e564879f51ae16f23d392e9e196c605f36d90df` | `research/split-skip/SOURCE.json` | +The split-skip replay restores all three exact helpers named by its unchanged +manifest: the fused-block snapshot above, the exclusion circuit preserved in +`research/exclusion-embedding-masks/baseline.py`, and the shared-point circuit +preserved in `research/shared-point-digest/baseline.py`. The latter two are +Wentao Li's retained baselines for the accepted support-mask and digest +optimizations. Both also match the PR53 parent `3ffd4021995c959ac02d12920e0279ae97dd03c7`. +Each replacement and reviewed live successor is independently authenticated; +missing pins, corrupted baselines, duplicate paths, untracked dependencies and +unknown live source changes reject before copying. No original checker is edited. + Use `python3 -B scripts/replay_historical_check.py r420` (add `--native` for C++17/Boost), `reconciliation92`, or `split-skip`. These check historical finite constructions/provenance; they do not recertify the current selected supplier or diff --git a/scripts/replay_historical_check.py b/scripts/replay_historical_check.py index 0a04783d8b..0f5f964395 100644 --- a/scripts/replay_historical_check.py +++ b/scripts/replay_historical_check.py @@ -76,6 +76,25 @@ } +# The split-skip manifest binds three historical helpers. Restore each exact +# dependency, retaining Wentao Li's two optimized live successors unchanged. +CONFIG['split-skip']['accepted_live_sha256'] = [ + '6fe64f886309d9154e33a3d67a16e8714cebc424a7a248b3080f8cab7d94179b', +] +CONFIG['split-skip']['additional_inputs'] = [ + {**CONFIG['skip-clones'], 'manifest': 'research/split-skip/SOURCE.json'}, + { + 'manifest': 'research/split-skip/SOURCE.json', 'field': 'files', + 'path': 'scripts/shared_point_circuit.py', 'input_from_root': True, + 'input': 'research/shared-point-digest/baseline.py', + 'sha256': 'c9bb7a5df92d260a4e3ad532b53e26936730d7c93f7facfb0784957c1e81c8ba', + 'accepted_live_sha256': [ + 'f5abbf6d61f3c10349416a3e1a1ed038bbd1279ed223367f2df549de46dd7ea5', + ], + }, +] + + def require(condition, message): if not condition: raise ValueError(message) @@ -116,9 +135,16 @@ def tracked_paths(root): def materialize(root, destination, config, paths, inputs=INPUTS): """Copy tracked working bytes only; never share writable links with the checkout.""" - data = authenticated_input(root, config, inputs) - require(config['path'] in paths and config['manifest'] in paths, - 'Historical input or manifest is not tracked') + configurations = [config, *config.get('additional_inputs', [])] + replacements = {} + for entry in configurations: + require(entry['path'] not in replacements, 'Duplicate historical replacement') + data = authenticated_input(root, entry, inputs) + require(entry['path'] in paths and entry['manifest'] in paths, + 'Historical input or manifest is not tracked') + if entry.get('input_from_root'): + require(entry['input'] in paths, 'Historical baseline is not tracked') + replacements[entry['path']] = data require(not destination.exists(), 'Replay destination already exists') destination.mkdir(parents=True) expected = {} @@ -129,10 +155,12 @@ def materialize(root, destination, config, paths, inputs=INPUTS): target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(source, target) expected[name] = hashlib.sha256(target.read_bytes()).hexdigest() - safe_path(destination, config['path']).write_bytes(data) - expected[config['path']] = config['sha256'] - # Authenticate again in the copied tree before executing any checker. - authenticated_input(destination, config, inputs) + for entry in configurations: + safe_path(destination, entry['path']).write_bytes(replacements[entry['path']]) + expected[entry['path']] = entry['sha256'] + # Authenticate every replacement again before executing any checker. + for entry in configurations: + authenticated_input(destination, entry, inputs) return expected diff --git a/tests/test_historical_check.py b/tests/test_historical_check.py index dccb7bb711..0f9c8f732d 100644 --- a/tests/test_historical_check.py +++ b/tests/test_historical_check.py @@ -119,6 +119,67 @@ def test_skip_clone_overlay_rejects_unknown_live_and_corrupt_baseline(self): with self.assertRaisesRegex(ValueError, 'Changed historical input'): checker.authenticated_input(root, config, inputs) + def multi_fixture(self, temporary): + root, inputs, config, paths = self.fixture(temporary) + original = b'second historical dependency\n' + (inputs / 'second.txt').write_bytes(original) + (root / 'second.py').write_bytes(b'current optimized dependency\n') + digest = hashlib.sha256(original).hexdigest() + pins = json.loads((root / 'manifest.json').read_bytes()) + pins['files']['second.py'] = digest + (root / 'manifest.json').write_text(json.dumps(pins)) + config['additional_inputs'] = [dict( + manifest='manifest.json', field='files', path='second.py', + input='second.txt', sha256=digest)] + return root, inputs, config, paths + ['second.py'] + + def test_multiple_overlays_preserve_live_bytes_and_each_output_gate(self): + with tempfile.TemporaryDirectory() as td: + root, inputs, config, paths = self.multi_fixture(td) + before = {name: (root / name).read_bytes() for name in paths} + target = Path(td) / 'copy' + expected = checker.materialize(root, target, config, paths, inputs) + self.assertEqual((target / 'input.txt').read_bytes(), (inputs / 'old.txt').read_bytes()) + self.assertEqual((target / 'second.py').read_bytes(), (inputs / 'second.txt').read_bytes()) + checker.verify_unchanged(target, expected) + for name in ('input.txt', 'second.py', 'unrelated.py'): + original = (target / name).read_bytes() + (target / name).write_bytes(original + b'corruption') + with self.subTest(path=name), self.assertRaisesRegex(ValueError, 'Replay changed'): + checker.verify_unchanged(target, expected) + (target / name).write_bytes(original) + self.assertEqual({name: (root / name).read_bytes() for name in paths}, before) + + def test_corrupt_additional_input_rejects_before_copy(self): + with tempfile.TemporaryDirectory() as td: + root, inputs, config, paths = self.multi_fixture(td) + (inputs / 'second.txt').write_bytes(b'corrupt baseline') + target = Path(td) / 'copy' + with self.assertRaisesRegex(ValueError, 'Changed historical input'): + checker.materialize(root, target, config, paths, inputs) + self.assertFalse(target.exists()) + + def test_duplicate_and_untracked_dependencies_reject_before_copy(self): + with tempfile.TemporaryDirectory() as td: + root, inputs, config, paths = self.multi_fixture(td) + target = Path(td) / 'copy' + with self.assertRaisesRegex(ValueError, 'not tracked'): + checker.materialize(root, target, config, paths[:-1], inputs) + config['additional_inputs'].append(dict(config['additional_inputs'][0])) + with self.assertRaisesRegex(ValueError, 'Duplicate'): + checker.materialize(root, target, config, paths, inputs) + self.assertFalse(target.exists()) + + def test_all_split_skip_dependencies_match_frozen_manifest(self): + config = checker.CONFIG['split-skip'] + entries = [config, *config['additional_inputs']] + self.assertEqual({entry['path'] for entry in entries}, { + 'scripts/audit_fused_block.py', 'scripts/exclusion_circuit.py', + 'scripts/shared_point_circuit.py'}) + for entry in entries: + with self.subTest(path=entry['path']): + checker.authenticated_input(ROOT, entry) + def test_real_snapshots_match_unchanged_predecessor_pins(self): for name, config in checker.CONFIG.items(): with self.subTest(package=name): From 3747d54462d5d77ced63682a2f75154523a0447f Mon Sep 17 00:00:00 2001 From: antunishdPursuit <122734610+antunishdPursuit@users.noreply.github.com> Date: Thu, 15 Oct 2026 01:51:31 -0400 Subject: [PATCH 8/8] Evaluate selected PR1094 successor replay on Windows --- .../selected1094-windows-successor/README.md | 123 ++++++ .../SOURCES.json | 162 ++++++++ .../selected1094-windows-successor/TASK.json | 98 +++++ .../VALIDATION.json | 150 ++++++++ .../VERIFY.json | 43 +++ .../selected1094-windows-successor/verify.py | 353 ++++++++++++++++++ 6 files changed, 929 insertions(+) create mode 100644 research/selected1094-windows-successor/README.md create mode 100644 research/selected1094-windows-successor/SOURCES.json create mode 100644 research/selected1094-windows-successor/TASK.json create mode 100644 research/selected1094-windows-successor/VALIDATION.json create mode 100644 research/selected1094-windows-successor/VERIFY.json create mode 100644 research/selected1094-windows-successor/verify.py diff --git a/research/selected1094-windows-successor/README.md b/research/selected1094-windows-successor/README.md new file mode 100644 index 0000000000..b1ec0020c9 --- /dev/null +++ b/research/selected1094-windows-successor/README.md @@ -0,0 +1,123 @@ +# Selected PR1094 final stage: Windows successor evaluation + +A separately versioned, source-bound wrapper executes the selected final stage +on native Windows. It applies only PR2316's two relative-path key conversions +in memory; the original supplier files, archives and selected record are unchanged. +This is a portability receipt, with no new kappa or full-theorem claim. + +## Result and exact scope + +The unchanged selected entry point rejects Windows paths at `Submission file +inventory or hash changed`, before creating output. The successor completes all +11 PR1087 strict stages and returns selected kappa `0.001672660197076918`. +Its input is the ten archived `slots/local` files, each authenticated against +the PR1042 receipt. Earlier cold ancestry is not rebuilt. + +The [execution receipt](VALIDATION.json) records Windows, interpreter and timing. +All 105 output files are checked against the reviewed PR1094 archive: + +| Class on this Windows run | Files | Required equality | +|---|---:|---| +| Bytes | 88 | Exact bytes, including all 22 gzip outputs | +| Logs | 11 | Exact bytes after CRLF to LF conversion | +| Invoice | 1 | Every JSON key and value, preserving value types; dictionary order may differ | +| Assembly and admission receipts | 2 | Every value except the invoice hash, which must match each actual invoice | +| Independent T16 receipt | 1 | Every value after relocating exactly six input-path keys | +| Stage receipts | 2 | Every value except nonnegative finite wall times and log hashes; hashes must match actual logs, whose normalized contents are compared | + +In particular, **ASSEMBLY.json is not byte-identical** to the selected archive. +Its sole differing leaf is `input_sha256.fresh_invoice`: the invoice has the +same typed JSON content but a different dictionary order. Separately, Windows +log CRLF bytes change the log hashes in both stage receipts. The checker follows +those dependencies; it never simply discards hash fields. No gzip waiver is used. +The six independent input digests agree after mapping their Windows/POSIX paths. + +## Successor delta and source binding + +The authenticated `research/complex-t16-rare-pattern-exchanges/verify.py` has only +these two substitutions before compilation: + +```python +str(f.relative_to(P)) # replaced by f.relative_to(P).as_posix() +str(f.relative_to(source)) # replaced by f.relative_to(source).as_posix() +``` + +The original path remains `__file__`, so its exact original package inventory +and archived source manifest remain enforced. The source hash and exact one-match +count for each substitution are checked. `compile(..., optimize=0)` preserves +all original assertions even when this evaluation is invoked with `-O`. +The strict subprocesses run without `-O` or inherited `PYTHONOPTIMIZE`. +Only the new package writes files; replay outputs live in temporary directories. +[SOURCES.json](SOURCES.json) pins all 22 direct inputs to canonical main +`0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`. + +The comparison permits no global path-string replacement, arbitrary volatile +keys or blanket hash exclusions. Sixteen corruption controls cover invoice and +assembly proof values (including integer-to-boolean changes and duplicate keys), +invoice links, independent input pins and unmapped paths, log content and links, +kappa, invalid timing, gzip bytes, missing/extra output, changed original source +and an undeclared timing field. Outputs must return to their positive +comparison after the controls. + +## Reproduce + +From the repository root, with Python 3.12 and only the standard library: + +```sh +python3.12 scripts/research_package.py --package research/selected1094-windows-successor --check-only +python3.12 scripts/research_package.py --package research/selected1094-windows-successor +python3.12 -I -O -B research/selected1094-windows-successor/verify.py --report /absolute/path/receipt.json +``` + +The registered command deliberately exercises an optimized parent. Its successor +and all inherited strict checks retain assertions. The package can replay on other +platforms, but only native Windows is evidenced here. A later environment with an +unexplained output difference must fail rather than broaden normalization. + +## Overlap and limitations + +This follows [PR2316](https://github.com/CrocSwap/integer-mult-bounds/pull/2316) +head `1b732744b66cc3461559d52349ae07fa31d444f8`, which checked the inventory +guards only and explicitly requested a separately versioned successor replay. +The earlier [final-stage portability audit](../selected-final-stage-portability/README.md) +covered macOS and left Windows unrun. This contribution adds actual native Windows +execution and an explicit dependency-aware comparison of the resulting receipts. +It does not claim discovery of the two-conversion repair. + +[Discussion 2333](https://github.com/CrocSwap/integer-mult-bounds/discussions/2333) +is the canonical investigation. [TASK.json](TASK.json) records priority revision 4, +the fresh overlap search and the deliberate handoff override after the initial +P104 candidate proved covered. Search coverage is not proof of novelty. + +This is neither a cold selected replay nor independent verification of the +multiplication theorem, stock envelope or precision assumptions. The inherited +strict verifier checks its own transitive inputs; this package pins its direct +inputs rather than claiming an independently complete transitive manifest. +The selected reproduction command remains unchanged and still rejects Windows +inventory keys. No selected frontier, historical source or policy is altered. + +## Open next questions + +The structured questions in [TASK.json](TASK.json) give first steps and blockers: + +1. Execute complete native Windows cold ancestry with immutable source pins. + This would test construction before the archived PR1042 inputs; it is outside + this bounded final-stage evaluation. +2. Maintainers can review a new portable entry point and canonical invoice + serialization. Adoption requires a separately versioned policy decision; + this evaluation does not modify the selected record. + +## Credit + +PR2316: josecarlosgonzalezroque-design, with OpenAI Codex, for the manifest-key +failure and proposed delta. Selected PR1094: Rohan Arun, using Jeremy Kothe's +PR1087 strict verifier and the retained PR1018/1005/869/799/741 lineage. +Douglas Colkitt supplied the selected replay receipts and archives. +JosieElliston's final-stage portability audit supplied the comparison scope and +archived-input binding pattern. Maxime Fleury and Antoine Olivier supplied the +repository's regenerated-container comparison guidance. Their source-specific +notices remain unchanged; no predecessor code is vendored here. + +New work: Dennis / antunishdPursuit, with substantial OpenAI Codex assistance in +investigation, implementation, execution, self-review and writing. No independent +human review claimed. Apache-2.0. diff --git a/research/selected1094-windows-successor/SOURCES.json b/research/selected1094-windows-successor/SOURCES.json new file mode 100644 index 0000000000..538427a176 --- /dev/null +++ b/research/selected1094-windows-successor/SOURCES.json @@ -0,0 +1,162 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "e8870e5917057d59b730eb14721a778639eca050", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7" + }, + { + "path": "research/community-frontier1042-audit/RESULT.json", + "usage": "input", + "git_blob": "8182d0818c0cbda7e52c10120f15b2c3a2c8f933", + "sha256": "bf12c6ed3b412539638b76addb40591a631609b2ab9e5ee0db1f6bbe067d0ec0" + }, + { + "path": "research/community-frontier1042-audit/selected-replay.tar.gz", + "usage": "input", + "git_blob": "6f4dc6fe7631d8aacf8081fcaecf32197181685b", + "sha256": "22c3f4dce4b897a1d423d1388801933e288b6a6b1906cb15e1b16a5eb68db754" + }, + { + "path": "research/community-frontier1094-audit/ASSEMBLY.json", + "usage": "input", + "git_blob": "5fd676df060f3b450782fdf5ff5f6beb63a5eeb0", + "sha256": "1122cb3a575f8c788345fc1bf4c108ac7c3250fb81a5988671f5eb04b3ab3045" + }, + { + "path": "research/community-frontier1094-audit/REPLAY.json", + "usage": "input", + "git_blob": "2cfb7fffa7cd78f418be16c13224c3206b6d0183", + "sha256": "ce0678fa7abaab221de74baeace0c6696d5ea23a36719a58cff230215a06aae7" + }, + { + "path": "research/community-frontier1094-audit/RESULT.json", + "usage": "input", + "git_blob": "131d9c96a54632ae385ced4138fd7f30ad448a3e", + "sha256": "1e3e47e9ec24bcb6fb5f703b7fce0aab658d84ff72bfae5da3ae429d17b6e752" + }, + { + "path": "research/community-frontier1094-audit/SELECTED-SOURCE.json", + "usage": "input", + "git_blob": "6a75493790b4eff9c4a98051ef8b01d6aad0d5a8", + "sha256": "79b3de5db3dbcb9829789ba58e9e45758926031e2a7d80667a08429d369be53b" + }, + { + "path": "research/community-frontier1094-audit/STAGES.json", + "usage": "input", + "git_blob": "a92499421609e4cdb5630f2697d2bad4b5a42a83", + "sha256": "72ad3ba266488da6bb6a41be404700dcea183a85002a5428df0033685c56d8be" + }, + { + "path": "research/community-frontier1094-audit/selected-replay.tar.gz", + "usage": "input", + "git_blob": "c24daf067f9c543421d89ca2eeaa4eb78a57fb6f", + "sha256": "f1da80610bf33c58527f18ad63b4350d0b864e1d4486141ee17ac9bed4d529d6" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/CANDIDATE.json", + "usage": "input", + "git_blob": "d80e967cb9ee9003ace480474399b4e5ee16f7d1", + "sha256": "e5fe28718bd517bbb2e9cd377778bf76bd89012b71e48889784ea45e4dfd7dd4" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/MANIFEST.json", + "usage": "input", + "git_blob": "3216666bd231516f8d2387e3096d6a5bd413b519", + "sha256": "16a964621e718c8da4c859ccbb280c3c00816ca72874e955910fdf0ef27a0adc" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/MOVES.json", + "usage": "input", + "git_blob": "a0d272b433b05eead7d0b7bbf2962a84faf854e5", + "sha256": "d902f129f4c66e4bfe0e1a2e2c602ed71022d11ed938bfa801a087bb8b3b0d1a" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/OWNERS.json.gz", + "usage": "input", + "git_blob": "d3ba33d7e703a3229d9fb8a360f69d2f318bbb70", + "sha256": "87902c528dfab7d503dcf8a784260e3ab6fb7424c418a1820f7261f25be7b6bc" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/PRICE.json", + "usage": "input", + "git_blob": "f0e765d35128eef8079bdb90c2ebe25db9c9b7ba", + "sha256": "08372c20bee19530083ba15d3a95ce019df68679bae8a52a77fbe8d9c311fc5c" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/PROFILE.json", + "usage": "input", + "git_blob": "7acbdeb81015d4681b5773489369a2a8b0d46d79", + "sha256": "cf539f314584ee0b6d7102d2344be96a63defa88b9d9ab6ffe05cddd6c13a874" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/README.md", + "usage": "input", + "git_blob": "f205b7132243aedcb2aa85110a44f0c8cd1e4fe1", + "sha256": "da542711a6a3eb01ce1ebdf8f28a748e6195512687f61d003b95ac5ff281a7b2" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/SOURCE.json", + "usage": "input", + "git_blob": "1e43afd08c060373b6fde3c775c23c180cb6a794", + "sha256": "4cfd44cebfe88f4450294239fbea8feecb564338dc3027b76065227f5d19cb6f" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/VALIDATION.json", + "usage": "input", + "git_blob": "cf1de72638625b8d0845ce2756d68d97f7e55f42", + "sha256": "93d2f78759a7fdfaeb1023387d85f059a7db285b8767ef2c3692a0c21ea3e1c5" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/data/OWNERS.json.gz", + "usage": "input", + "git_blob": "d3ba33d7e703a3229d9fb8a360f69d2f318bbb70", + "sha256": "87902c528dfab7d503dcf8a784260e3ab6fb7424c418a1820f7261f25be7b6bc" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/data/PLAN.json", + "usage": "input", + "git_blob": "f1bec76e8e9b7a1f09c1e05cb6cce973b6e59f1b", + "sha256": "7bd786ba8e66408f02aa9ef446eaf20c1bfe981ea2e4dd1e5a929f0aa7767bc0" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/data/SPEC.json", + "usage": "input", + "git_blob": "af013ccc2975d9d575d116f8a463cc947f220c8d", + "sha256": "8cb51f25a5da4a29d3783853025b73ff1f452429d4fdb30c599e598bcab0e71d" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/upstream1087.tar.gz", + "usage": "input", + "git_blob": "2970ef79b0441e937449bed30f68f2e0558186ba", + "sha256": "d4acf04daef85d4514f80ec5fcd2492d0c60e5d6c49fa71b3e6523f8db2dea86" + }, + { + "path": "research/complex-t16-rare-pattern-exchanges/verify.py", + "usage": "input", + "git_blob": "9d471cf90835bc91d32bb0216c2bb867011a7420", + "sha256": "b8c2f76b305c5c9ceb42df203deef564857d17f1f8182d0745dda9ab96e3d4de" + } + ], + "predecessors": [ + { + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/2316", + "head": "1b732744b66cc3461559d52349ae07fa31d444f8", + "role": "Path-key diagnosis and requested successor handoff; no code vendored." + }, + { + "path": "research/selected-final-stage-portability", + "base": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "role": "Comparison scope and archived-input binding pattern; comparator not imported." + } + ] +} diff --git a/research/selected1094-windows-successor/TASK.json b/research/selected1094-windows-successor/TASK.json new file mode 100644 index 0000000000..6cf5fefcd2 --- /dev/null +++ b/research/selected1094-windows-successor/TASK.json @@ -0,0 +1,98 @@ +{ + "schema_version": 1, + "task_id": "portable-replay", + "priority_revision": 4, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "original_card": { + "id": "portable-replay", + "question": "Can one reproducible environment or artifact-comparison failure be repaired?", + "starting_points": [ + "research/gzip-container-reproducibility/README.md", + "docs/ci-verification.md" + ], + "methods": [ + "Reproduce one portability failure and add a minimal cross-environment fix.", + "Audit one canonical-payload comparison for omitted proof-relevant fields." + ], + "acceptance_gate": "Preserve immutable source hashes and proof-relevant content; a different compressed byte stream alone is not a mathematical mismatch.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the gzip-container reproducibility examples and distinguish frozen source bytes from regenerated payloads.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Reproduce one specific mismatch or audit one canonical comparison for omitted proof-relevant fields.", + "bottleneck_link": "Portable exact checks prevent environment failures from blocking valid contributions.", + "allowed_variations": [ + "One interpreter/version mismatch or one payload field comparison." + ], + "scope_change_triggers": [ + "Removing immutable-source pins because generated compressed bytes differ." + ], + "overlap_terms": [ + "gzip container", + "reproducibility", + "canonical payload" + ] + }, + "scope_status": "refined", + "actual_scope": "Execute a separately versioned two-path-key successor of the selected PR1094 final stage on native Windows, using archived hash-bound PR1042 local inputs; compare all 105 outputs and validate changed receipt hash links.", + "scope_change_reason": "Live PR2316 explicitly requests a successor execution after inventory admission. The first P104 candidate was abandoned before research because fresh overlap showed its terminal-cut floor and several chronological models already covered. This is a deliberate portable-replay handoff override, not a random allocation or new P104 result.", + "bottleneck_link": "Verifier engineering side result: distinguish Windows serialization differences from changed proof content in the selected supplier final-stage replay. This does not improve the binding complex budget.", + "budget_minutes": 60, + "stop_rule": "One final-stage replay and full output comparison; stop on an unexplained difference. No cold ancestry, supplier redesign, frozen-source edits, or selected-frontier changes.", + "outcome": "completed", + "evidence": "VALIDATION.json records native Windows CPython 3.12.14 execution, original guard failure, all eleven successor strict stages, 105-file comparison, and deliberate corruption rejections.", + "author": "Dennis / antunishdPursuit, with OpenAI Codex", + "ai_assistance": "Substantial OpenAI Codex assistance in investigation, implementation, execution, review and writing; self-reviewed only. No independent human review claimed.", + "open_questions": [ + { + "question": "Does complete native Windows cold ancestry also pass without editing frozen suppliers?", + "why_it_matters": "Archived PR1042 local inputs establish final-stage portability only; earlier supplier construction may have additional platform assumptions.", + "first_step": "Authenticate the selected ancestry and run its cold baseline in an isolated output tree; report the first failure without waiving source pins.", + "blocked_by": "Outside this bounded final-stage evaluation; full ancestry is substantially more expensive." + }, + { + "question": "Should maintainers adopt a separately versioned portable entry point and a canonical invoice serialization?", + "why_it_matters": "The original selected entry point still fails its Windows manifest guard, and receipt byte equality fails despite equal invoice values.", + "first_step": "Review this successor and PR2316, then decide a new wrapper version and source-binding policy.", + "blocked_by": "Maintainer adoption; this contribution does not alter the selected record or frozen source." + } + ], + "selection": { + "mode": "explicit-handoff-override", + "portable_card_seed": "45d9e8944dbee9d5ce0f27f6ac8213ed", + "prior_p104_scope_key": "72dfbf0708467ad34793", + "priority_revision": 4, + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2333" + }, + "overlap": { + "open_prs": 546, + "discussion_records": 1049, + "pr_snapshot_utc": "2026-10-15T05:37:50Z", + "discussion_snapshot_utc": "2026-10-15T05:39:46Z", + "complete_pagination": true, + "warnings": [], + "search_terms": [ + "Windows", + "2316", + "manifest admission" + ], + "predecessors": [ + { + "pr": 2316, + "head": "1b732744b66cc3461559d52349ae07fa31d444f8", + "adds": "Two guarded in-memory inventory-key conversions, but no downstream replay." + }, + { + "package": "research/selected-final-stage-portability", + "adds": "Five CPython versions on macOS; Windows expressly unrun; this evaluation retains its all-file comparison objective but handles exact Windows receipt dependencies." + } + ], + "limitations": "Literal-term search is not proof of novelty; manual reading of the handoff and relevant packages also informed scope." + } +} diff --git a/research/selected1094-windows-successor/VALIDATION.json b/research/selected1094-windows-successor/VALIDATION.json new file mode 100644 index 0000000000..3b620dbd67 --- /dev/null +++ b/research/selected1094-windows-successor/VALIDATION.json @@ -0,0 +1,150 @@ +{ + "python": "3.12.14 (main, Sep 1 2026, 14:17:39) [MSC v.1944 64 bit (AMD64)]", + "platform": "Windows-11-10.0.26200-SP0", + "seconds": 42.188, + "result": { + "status": "PASS_SELECTED1094_WINDOWS_SUCCESSOR", + "kappa": "0.001672660197076918", + "stages": 11, + "original_observation": "submission inventory rejected before output creation", + "comparison": { + "counts": { + "bytes": 88, + "checked-invoice-digest": 2, + "checked-stage-logs-and-timings": 2, + "crlf-only": 11, + "json-key-order-or-format": 1, + "six-relocated-input-paths": 1 + }, + "classes": { + "ADMISSION-CONTROLS.json": "checked-invoice-digest", + "ASSEMBLY.json": "checked-invoice-digest", + "BIT-SUPPLIER-CONTROLS.json": "bytes", + "INDEPENDENT-T16.json": "six-relocated-input-paths", + "REPLAY.json": "checked-stage-logs-and-timings", + "STAGES.json": "checked-stage-logs-and-timings", + "admission-controls.log": "crlf-only", + "assembly.log": "crlf-only", + "audit.log": "crlf-only", + "bind.log": "crlf-only", + "bind8.log": "crlf-only", + "bit-supplier-controls.log": "crlf-only", + "emit.log": "crlf-only", + "global/BINDING.json": "bytes", + "global/PLAN.json": "bytes", + "global/audit/ASYNC-AUDIT.json": "bytes", + "global/audit/GLOBAL-PREFIX.json": "bytes", + "global/audit/IDLE-REMAINDER-FRAMES.json": "bytes", + "global/audit/OWNERS-AND-PROFILE.json": "bytes", + "global/audit/PREFIX-AND-INVOICE.json": "json-key-order-or-format", + "global/base/providers/gauge44/CANONICAL-WORD.json.gz": "bytes", + "global/base/providers/gauge44/CLIFFORD-RECIPES.json": "bytes", + "global/base/providers/gauge44/CLIFFORD-REVIEW.json": "bytes", + "global/base/providers/gauge44/FULL-WORD.json.gz": "bytes", + "global/base/providers/gauge44/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "global/base/providers/gauge44/LOCAL-CHECKS.json": "bytes", + "global/base/providers/gauge44/LOCAL-PROGRAMS.json.gz": "bytes", + "global/base/providers/gauge44/RESIDUAL-ADAPTERS.json": "bytes", + "global/base/providers/gauge44/SCALAR-FRAME-AUDIT.json": "bytes", + "global/base/providers/gauge44/WRAPPER-CHECKS.json": "bytes", + "global/base/split-centres/CANONICAL-WORD.json.gz": "bytes", + "global/base/split-centres/CLIFFORD-RECIPES.json": "bytes", + "global/base/split-centres/CLIFFORD-REVIEW.json": "bytes", + "global/base/split-centres/GLOBAL-TEMPLATE.json.gz": "bytes", + "global/base/split-centres/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "global/base/split-centres/INDEPENDENT-REPLAY.json": "bytes", + "global/base/split-centres/INTEGRATION.json": "bytes", + "global/base/split-centres/LOCAL-CHECKS.json": "bytes", + "global/base/split-centres/LOCAL-PROGRAMS.json.gz": "bytes", + "global/base/split-centres/RESIDUAL-ADAPTERS.json": "bytes", + "global/base/split-centres/SCALAR-FRAME-AUDIT.json": "bytes", + "global/base/split-centres/WRAPPER-CHECKS.json": "bytes", + "global/base/work/complex-nine-native/DATA-PHASES.json": "bytes", + "global/hosted/ACTUAL-SIGMAS.json.gz": "bytes", + "global/hosted/GLOBAL-TEMPLATE.json.gz": "bytes", + "global/hosted/HOSTED.json": "bytes", + "global/hosted/IDLE-REMAINDER-FRAMES.json.gz": "bytes", + "global8/BINDING.json": "bytes", + "global8/PLAN.json": "bytes", + "global8/base/providers/gauge44/CANONICAL-WORD.json.gz": "bytes", + "global8/base/providers/gauge44/CLIFFORD-RECIPES.json": "bytes", + "global8/base/providers/gauge44/CLIFFORD-REVIEW.json": "bytes", + "global8/base/providers/gauge44/FULL-WORD.json.gz": "bytes", + "global8/base/providers/gauge44/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "global8/base/providers/gauge44/LOCAL-CHECKS.json": "bytes", + "global8/base/providers/gauge44/LOCAL-PROGRAMS.json.gz": "bytes", + "global8/base/providers/gauge44/RESIDUAL-ADAPTERS.json": "bytes", + "global8/base/providers/gauge44/SCALAR-FRAME-AUDIT.json": "bytes", + "global8/base/providers/gauge44/WRAPPER-CHECKS.json": "bytes", + "global8/base/split-centres/CANONICAL-WORD.json.gz": "bytes", + "global8/base/split-centres/CLIFFORD-RECIPES.json": "bytes", + "global8/base/split-centres/CLIFFORD-REVIEW.json": "bytes", + "global8/base/split-centres/GLOBAL-TEMPLATE.json.gz": "bytes", + "global8/base/split-centres/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "global8/base/split-centres/INDEPENDENT-REPLAY.json": "bytes", + "global8/base/split-centres/INTEGRATION.json": "bytes", + "global8/base/split-centres/LOCAL-CHECKS.json": "bytes", + "global8/base/split-centres/LOCAL-PROGRAMS.json.gz": "bytes", + "global8/base/split-centres/RESIDUAL-ADAPTERS.json": "bytes", + "global8/base/split-centres/SCALAR-FRAME-AUDIT.json": "bytes", + "global8/base/split-centres/WRAPPER-CHECKS.json": "bytes", + "global8/base/work/complex-nine-native/DATA-PHASES.json": "bytes", + "independent-t16.log": "crlf-only", + "invoice.log": "crlf-only", + "lift/GLOBAL-TEMPLATE.json.gz": "bytes", + "lift/PARENT-LIFT-RECEIPT.json": "bytes", + "lift/PLAN.json": "bytes", + "lift16.log": "crlf-only", + "parent16/complex-global/base/split-centres/CANONICAL-WORD.json.gz": "bytes", + "parent16/complex-global/base/split-centres/CLIFFORD-RECIPES.json": "bytes", + "parent16/complex-global/base/split-centres/CLIFFORD-REVIEW.json": "bytes", + "parent16/complex-global/base/split-centres/GLOBAL-TEMPLATE.json.gz": "bytes", + "parent16/complex-global/base/split-centres/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "parent16/complex-global/base/split-centres/INDEPENDENT-REPLAY.json": "bytes", + "parent16/complex-global/base/split-centres/INTEGRATION.json": "bytes", + "parent16/complex-global/base/split-centres/LOCAL-CHECKS.json": "bytes", + "parent16/complex-global/base/split-centres/LOCAL-PROGRAMS.json.gz": "bytes", + "parent16/complex-global/base/split-centres/RESIDUAL-ADAPTERS.json": "bytes", + "parent16/complex-global/base/split-centres/SCALAR-FRAME-AUDIT.json": "bytes", + "parent16/complex-global/base/split-centres/WRAPPER-CHECKS.json": "bytes", + "parent16/complex-global/base/work/complex-nine-native/DATA-PHASES.json": "bytes", + "parent558/complex-global/base/split-centres/CANONICAL-WORD.json.gz": "bytes", + "parent558/complex-global/base/split-centres/CLIFFORD-RECIPES.json": "bytes", + "parent558/complex-global/base/split-centres/CLIFFORD-REVIEW.json": "bytes", + "parent558/complex-global/base/split-centres/GLOBAL-TEMPLATE.json.gz": "bytes", + "parent558/complex-global/base/split-centres/INDEPENDENT-LOCAL-REPLAY.json": "bytes", + "parent558/complex-global/base/split-centres/INDEPENDENT-REPLAY.json": "bytes", + "parent558/complex-global/base/split-centres/INTEGRATION.json": "bytes", + "parent558/complex-global/base/split-centres/LOCAL-CHECKS.json": "bytes", + "parent558/complex-global/base/split-centres/LOCAL-PROGRAMS.json.gz": "bytes", + "parent558/complex-global/base/split-centres/RESIDUAL-ADAPTERS.json": "bytes", + "parent558/complex-global/base/split-centres/SCALAR-FRAME-AUDIT.json": "bytes", + "parent558/complex-global/base/split-centres/WRAPPER-CHECKS.json": "bytes", + "parent558/complex-global/base/work/complex-nine-native/DATA-PHASES.json": "bytes", + "restore-parent.log": "crlf-only" + }, + "files": 105, + "gzip_byte_identical": 22 + }, + "corruptions_rejected": [ + "invoice-proof-value", + "invoice-integer-to-boolean", + "duplicate-invoice-key", + "assembly-proof-value", + "invoice-link", + "independent-input-digest", + "unmapped-input-path", + "stage-log-content", + "stage-log-link", + "replay-kappa", + "invalid-timing", + "gzip-output", + "missing-output", + "extra-output", + "changed-original-script", + "undeclared-timing-field" + ], + "assembly_byte_identical": false, + "scope": "Selected final stage with archived PR1042 local inputs; not cold ancestry or theorem verification" + } +} diff --git a/research/selected1094-windows-successor/VERIFY.json b/research/selected1094-windows-successor/VERIFY.json new file mode 100644 index 0000000000..d607f3b550 --- /dev/null +++ b/research/selected1094-windows-successor/VERIFY.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/community-frontier1042-audit/RESULT.json", + "research/community-frontier1042-audit/selected-replay.tar.gz", + "research/community-frontier1094-audit/ASSEMBLY.json", + "research/community-frontier1094-audit/REPLAY.json", + "research/community-frontier1094-audit/RESULT.json", + "research/community-frontier1094-audit/SELECTED-SOURCE.json", + "research/community-frontier1094-audit/STAGES.json", + "research/community-frontier1094-audit/selected-replay.tar.gz", + "research/complex-t16-rare-pattern-exchanges/CANDIDATE.json", + "research/complex-t16-rare-pattern-exchanges/MANIFEST.json", + "research/complex-t16-rare-pattern-exchanges/MOVES.json", + "research/complex-t16-rare-pattern-exchanges/OWNERS.json.gz", + "research/complex-t16-rare-pattern-exchanges/PRICE.json", + "research/complex-t16-rare-pattern-exchanges/PROFILE.json", + "research/complex-t16-rare-pattern-exchanges/README.md", + "research/complex-t16-rare-pattern-exchanges/SOURCE.json", + "research/complex-t16-rare-pattern-exchanges/VALIDATION.json", + "research/complex-t16-rare-pattern-exchanges/data/OWNERS.json.gz", + "research/complex-t16-rare-pattern-exchanges/data/PLAN.json", + "research/complex-t16-rare-pattern-exchanges/data/SPEC.json", + "research/complex-t16-rare-pattern-exchanges/upstream1087.tar.gz", + "research/complex-t16-rare-pattern-exchanges/verify.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 480, + "checks": "Authenticate immutable inputs, reproduce original Windows guard rejection, compile only two path-key conversions with optimize=0, run all eleven strict stages from archived PR1042 local inputs, compare every output with typed JSON equality and explicit hash-link/path/timing checks, reject deliberate corruptions." + } + ] +} diff --git a/research/selected1094-windows-successor/verify.py b/research/selected1094-windows-successor/verify.py new file mode 100644 index 0000000000..bc35c1f8c6 --- /dev/null +++ b/research/selected1094-windows-successor/verify.py @@ -0,0 +1,353 @@ +#!/usr/bin/env python3 +"""Source-bound PR1094 successor replay and explicit Windows receipt comparison. + +Apache-2.0. Dennis / antunishdPursuit, substantial OpenAI Codex assistance. +Predecessors: PR2316 (josecarlosgonzalezroque-design), Rohan Arun's PR1094, +Jeremy Kothe's PR1087, Douglas Colkitt's receipts, JosieElliston's portability audit. +""" +import argparse +import copy +import hashlib +import json +import math +import os +from pathlib import Path, PurePosixPath, PureWindowsPath +import platform +import subprocess +import sys +import tarfile +import tempfile +import time + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +PACKAGE = ROOT / 'research/complex-t16-rare-pattern-exchanges' +A1042 = ROOT / 'research/community-frontier1042-audit' +A1094 = ROOT / 'research/community-frontier1094-audit' +KAPPA = '0.001672660197076918' +DELTA = [('str(f.relative_to(P))', 'f.relative_to(P).as_posix()'), + ('str(f.relative_to(source))', 'f.relative_to(source).as_posix()')] + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def parsed(raw): + def pairs(items): + value = {} + for key, item in items: + require(key not in value, 'duplicate JSON key') + value[key] = item + return value + return json.loads(raw, object_pairs_hook=pairs) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(',', ':'), allow_nan=False) + + +def read_json(path): + return parsed(path.read_bytes()) + + +def authenticate(): + rows = read_json(HERE / 'SOURCES.json')['files'] + for row in rows: + if row['usage'] == 'input': + require(sha((ROOT / row['path']).read_bytes()) == row['sha256'], + 'immutable input changed: ' + row['path']) + selected = read_json(A1094 / 'SELECTED-SOURCE.json')['files'] + for p in PACKAGE.rglob('*'): + if p.is_file() and '__pycache__' not in p.parts: + require(selected[p.relative_to(ROOT).as_posix()] == sha(p.read_bytes()), + 'not the selected supplier input') + + +def successor(raw): + original = read_json(HERE / 'SOURCES.json')['files'] + pin = next(r['sha256'] for r in original if r['path'] == + 'research/complex-t16-rare-pattern-exchanges/verify.py') + require(sha(raw) == pin, 'successor original script pin mismatch') + text = raw.decode('utf-8') + for old, new in DELTA: + require(text.count(old) == 1, 'successor delta is no longer exactly two substitutions') + text = text.replace(old, new) + # optimize=0 preserves every original assert, including __debug__, under -O. + return compile(text, str(PACKAGE / 'verify.py'), 'exec', optimize=0) + + +def extract(archive, destination, prefix=None): + destination.mkdir(parents=True) + with tarfile.open(archive) as stream: + members = [m for m in stream if prefix is None or m.name.startswith(prefix)] + for member in members: + require(member.isfile() or member.isdir(), 'nonregular archive member') + require((destination / member.name).resolve().is_relative_to(destination.resolve()), + 'unsafe archive path') + stream.extractall(destination, members=members, filter='data') + + +def inventory(root): + return {p.relative_to(root).as_posix(): p for p in root.rglob('*') + if p.is_file() and '__pycache__' not in p.parts} + + +def lf(raw): + return raw.replace(b'\r\n', b'\n') + + +def path_keys(document, work, local): + value = copy.deepcopy(document) + pins = value['input_sha256'] + normalized = {} + for key, digest in pins.items(): + # Only this receipt's six absolute input-path keys may be relocated. + windows = PureWindowsPath(key).is_absolute() + path = PureWindowsPath(key) if windows else PurePosixPath(key) + matches = [] + for token, base in [('', work), ('', local)]: + parent = PureWindowsPath(base) if windows else PurePosixPath(base) + try: + tail = path.relative_to(parent) + except ValueError: + continue + require('..' not in tail.parts, 'noncanonical receipt path') + matches.append(token + '/' + tail.as_posix()) + require(len(matches) == 1, 'unmapped or ambiguous receipt path') + name = matches[0] + require(name not in normalized, 'receipt path collision') + normalized[name] = digest + require(len(normalized) == 6, 'expected six independent input pins') + value['input_sha256'] = normalized + return value + + +def stage_rows(rows, directory): + require(isinstance(rows, list) and len(rows) == 11, 'expected eleven stages') + value = copy.deepcopy(rows) + for row in value: + # Resolve receipt links against the actual output rather than ignoring hashes. + name = row['name'] + '.log' + require('/' not in name and '\\' not in name, 'invalid stage name') + raw = (directory / name).read_bytes() + require(row['log_sha256'] == sha(raw), 'stage log digest mismatch') + seconds = row['seconds'] + require(type(seconds) in (int, float) and math.isfinite(seconds) and seconds >= 0, + 'invalid stage timing') + row['seconds'] = '' + row['log_sha256'] = sha(lf(raw)) + return value + + +def compare(ref, run, ref_work, ref_local, run_work, run_local): + left, right = inventory(ref), inventory(run) + require(set(left) == set(right) and len(left) == 105, 'output inventory mismatch') + classes = {} + for name in sorted(left): + a, b = left[name].read_bytes(), right[name].read_bytes() + if a == b: + classes[name] = 'bytes' + continue + if name.endswith('.log') and lf(a) == lf(b): + classes[name] = 'crlf-only' + continue + if name == 'global/audit/PREFIX-AND-INVOICE.json': + require(canonical(parsed(a)) == canonical(parsed(b)), 'invoice proof content changed') + classes[name] = 'json-key-order-or-format' + elif name in ('ASSEMBLY.json', 'ADMISSION-CONTROLS.json'): + ja, jb = parsed(a), parsed(b) + invoice = 'global/audit/PREFIX-AND-INVOICE.json' + for doc, files in [(ja, left), (jb, right)]: + require(doc['input_sha256']['fresh_invoice'] == sha(files[invoice].read_bytes()), + 'fresh invoice digest mismatch') + doc['input_sha256']['fresh_invoice'] = '' + require(canonical(ja) == canonical(jb), 'assembly/admission changed beyond checked invoice digest') + classes[name] = 'checked-invoice-digest' + elif name == 'INDEPENDENT-T16.json': + require(canonical(path_keys(parsed(a), ref_work, ref_local)) == + canonical(path_keys(parsed(b), run_work, run_local)), + 'independent receipt changed beyond relocated input paths') + classes[name] = 'six-relocated-input-paths' + elif name in ('STAGES.json', 'REPLAY.json'): + ja, jb = parsed(a), parsed(b) + if name == 'REPLAY.json': + ja['stages'] = stage_rows(ja['stages'], ref) + jb['stages'] = stage_rows(jb['stages'], run) + else: + ja, jb = stage_rows(ja, ref), stage_rows(jb, run) + require(canonical(ja) == canonical(jb), 'stage receipt changed beyond checked logs/timings') + classes[name] = 'checked-stage-logs-and-timings' + else: + raise ValueError('unexplained output difference: ' + name) + # Check links even when two corrupted receipts happen to match byte-for-byte. + for directory in (ref, run): + stages, replay = read_json(directory / 'STAGES.json'), read_json(directory / 'REPLAY.json') + require(canonical(stages) == canonical(replay['stages']), 'stage receipt disagreement') + stage_rows(stages, directory) + require(replay['kappa_decimal'] == KAPPA, 'unexpected kappa') + for name in ('ASSEMBLY.json', 'ADMISSION-CONTROLS.json'): + require(read_json(directory / name)['input_sha256']['fresh_invoice'] == + sha((directory / 'global/audit/PREFIX-AND-INVOICE.json').read_bytes()), + 'fresh invoice digest mismatch') + counts = {key: list(classes.values()).count(key) for key in sorted(set(classes.values()))} + return {'counts': counts, 'classes': classes, 'files': len(classes), + 'gzip_byte_identical': sum(name.endswith('.gz') and cls == 'bytes' + for name, cls in classes.items())} + + +def controls(ref, run, arguments): + rejected = [] + def mutate(name, change, label): + path = run / name + old = path.read_bytes() + path.write_bytes(change(old)) + try: + compare(ref, run, *arguments) + except (ValueError, KeyError, json.JSONDecodeError): + rejected.append(label) + else: + raise ValueError('corruption accepted: ' + label) + finally: + path.write_bytes(old) + def edit(fn): + def apply(raw): + value = json.loads(raw) + fn(value) + return (json.dumps(value, indent=2) + '\n').encode() + return apply + mutate('global/audit/PREFIX-AND-INVOICE.json', + edit(lambda d: d.update({'corrupt_proof_value': 1})), 'invoice-proof-value') + mutate('global/audit/PREFIX-AND-INVOICE.json', + edit(lambda d: d['selected_calls'][0].update({'stage': False})), 'invoice-integer-to-boolean') + mutate('global/audit/PREFIX-AND-INVOICE.json', + lambda raw: b'{\"status\": \"duplicate\",' + raw[1:], 'duplicate-invoice-key') + mutate('ASSEMBLY.json', edit(lambda d: d.update({'corrupt_proof_value': 1})), 'assembly-proof-value') + mutate('ADMISSION-CONTROLS.json', + edit(lambda d: d['input_sha256'].update({'fresh_invoice': '0'*64})), 'invoice-link') + mutate('INDEPENDENT-T16.json', edit(lambda d: d['input_sha256'].update( + {next(iter(d['input_sha256'])): '0'*64})), 'independent-input-digest') + mutate('INDEPENDENT-T16.json', edit(lambda d: d['input_sha256'].update( + {'/unmapped/extra': '0'*64})), 'unmapped-input-path') + mutate('restore-parent.log', lambda raw: raw + b'ALTERED\n', 'stage-log-content') + mutate('STAGES.json', edit(lambda d: d[0].update({'log_sha256': '0'*64})), 'stage-log-link') + mutate('REPLAY.json', edit(lambda d: d.update({'kappa_decimal': '0.01'})), 'replay-kappa') + mutate('REPLAY.json', edit(lambda d: d['stages'][0].update({'seconds': -1})), 'invalid-timing') + gz = next(name for name in inventory(run) if name.endswith('.gz')) + mutate(gz, lambda raw: raw + b'corrupt', 'gzip-output') + path = run / 'restore-parent.log' + old = path.read_bytes() + path.unlink() + try: + try: + compare(ref, run, *arguments) + except ValueError: + rejected.append('missing-output') + else: + raise ValueError('missing output accepted') + finally: + path.write_bytes(old) + extra = run / 'unexpected-control' + extra.write_bytes(b'extra') + try: + try: + compare(ref, run, *arguments) + except ValueError: + rejected.append('extra-output') + else: + raise ValueError('extra output accepted') + finally: + extra.unlink() + try: + successor((PACKAGE / 'verify.py').read_bytes() + b'\n') + except ValueError: + rejected.append('changed-original-script') + else: + raise ValueError('changed original accepted') + # No CR characters, path-like strings or volatile fields outside declared sites are waived. + mutate('ASSEMBLY.json', edit(lambda d: d.update({'seconds': 1})), 'undeclared-timing-field') + return rejected + + +def evaluate(work): + authenticate() + extract(A1042 / 'selected-replay.tar.gz', work / 'in1042', 'slots/local/') + local = work / 'in1042/slots/local' + bound = {name: digest for name, digest in read_json(A1042 / 'RESULT.json')['artifacts'].items() + if name.startswith('slots/local/')} + require(len(bound) == 10 and set(bound) == {'slots/local/'+p.name for p in local.iterdir()}, + 'PR1042 input inventory mismatch') + for name, digest in bound.items(): + require(sha((work / 'in1042' / name).read_bytes()) == digest, 'PR1042 input digest mismatch') + extract(A1094 / 'selected-replay.tar.gz', work / 'reference') + ref = work / 'reference/candidate/strict' + for name in ('RESULT.json', 'STAGES.json'): + require((work/'reference'/name).read_bytes() == (A1094/name).read_bytes(), 'reference receipt changed') + require((ref/'REPLAY.json').read_bytes() == (A1094/'REPLAY.json').read_bytes(), 'reference replay changed') + require((ref/'ASSEMBLY.json').read_bytes() == (A1094/'ASSEMBLY.json').read_bytes(), 'reference assembly changed') + result = read_json(A1094/'RESULT.json') + require(result['baseline_receipt_sha256'] == sha((A1042/'RESULT.json').read_bytes()), 'wrong baseline receipt') + stage = [s for s in result['stages'] if s['name'] == 'rare-pattern-exchanges'] + require(len(stage) == 1 and stage[0]['script_sha256'] == sha((PACKAGE/'verify.py').read_bytes()), 'wrong stage source') + env = dict(os.environ, PYTHONDONTWRITEBYTECODE='1') + env.pop('PYTHONOPTIMIZE', None) + # Reproduce the unchanged failure before executing the successor on Windows. + original = 'not run on non-Windows' + if os.name == 'nt': + failed = work/'original-must-not-exist' + run = subprocess.run([sys.executable, '-I', '-B', str(PACKAGE/'verify.py'), '--main',str(ROOT), + '--local',str(local),'--work',str(failed)], capture_output=True, env=env, timeout=30) + require(run.returncode != 0 and b'AssertionError: Submission file inventory or hash changed' in run.stderr + and not failed.exists(), 'original Windows failure no longer reproduced') + original = 'submission inventory rejected before output creation' + out = work/'run' + log = work/'successor.log' + with log.open('wb') as stream: + run = subprocess.run([sys.executable, '-I', '-B', str(HERE/'verify.py'), '--stage', + '--local',str(local),'--work',str(out)], env=env, stdout=stream, + stderr=subprocess.STDOUT, timeout=240) + require(run.returncode == 0, 'successor failed: '+log.read_text(errors='replace')[-5000:]) + require(log.read_text().endswith('PASS_T16_RARE_PATTERN_EXCHANGES '+KAPPA+'\n'), 'missing successor success') + arguments = ['/private/tmp/batch1099-selected/candidate', '/private/tmp/batch1047-selected/slots/local', + str(out), str(local)] + comparison = compare(ref, out/'strict', *arguments) + rejected = controls(ref, out/'strict', arguments) + require(compare(ref, out/'strict', *arguments) == comparison, 'controls did not restore outputs') + authenticate() + return {'status':'PASS_SELECTED1094_WINDOWS_SUCCESSOR', 'kappa':KAPPA, 'stages':11, + 'original_observation':original, 'comparison':comparison, 'corruptions_rejected':rejected, + 'assembly_byte_identical':(ref/'ASSEMBLY.json').read_bytes() == (out/'strict/ASSEMBLY.json').read_bytes(), + 'scope':'Selected final stage with archived PR1042 local inputs; not cold ancestry or theorem verification'} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--stage', action='store_true', help=argparse.SUPPRESS) + parser.add_argument('--local', type=Path) + parser.add_argument('--work', type=Path) + parser.add_argument('--report', type=Path) + args = parser.parse_args() + if args.stage: + require(args.local is not None and args.work is not None, 'stage paths required') + authenticate() + code = successor((PACKAGE/'verify.py').read_bytes()) + sys.argv = [str(PACKAGE/'verify.py'),'--main',str(ROOT),'--local',str(args.local),'--work',str(args.work)] + exec(code, {'__name__':'__main__','__file__':str(PACKAGE/'verify.py')}) + return + start = time.monotonic() + with tempfile.TemporaryDirectory(prefix='selected1094-successor-') as temp: + result = evaluate(Path(temp).resolve()) + if args.report: + args.report.write_text(json.dumps({'python':sys.version, 'platform':platform.platform(), + 'seconds':round(time.monotonic()-start,3),'result':result},indent=2)+'\n',encoding='utf-8',newline='\n') + print(result['status'], 'stages=11 files=105 controls='+str(len(result['corruptions_rejected'])), + json.dumps(result['comparison']['counts'],sort_keys=True), flush=True) + + +if __name__ == '__main__': + main()