From 9cf6099edca4e1c559287927db4290417fefea0a Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:45:49 -0700 Subject: [PATCH 1/2] Repair #314: require authentic named D5/C6 rejection contracts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dylan Roy — delegated AI engineering. Author OpenAI / GPT-6 Astra Pro, lm006-continuation-wrapper-repair-20261005. Source cut 2f8b6f372be383d752e9dd30d38234faa977243c; intervening #305/#313 additions are disjoint. Preserve all original scientific checker, manifest, output and proof bytes. Adapt only genuine D5/Palm AssertionError origins and messages to a strict process report; preserve factorial native JSON with an exact failure set. Reject unrelated crashes, bad output/types, stderr and timeouts. Retain original source checks and full ordered controls; full-history full-repository tests run in both modes. Local final 14-method suite passed normally/optimized, 232 committed temporary shell fixtures per mode. Same suite rejects original wrappers in 169 subcases in each mode. All 48 native baseline/control processes characterized and six authentic repaired replay sequences passed. Hosted candidate execution and nonauthor review remain required. No self-merge or scientific/status/formal-alignment promotion. --- .github/workflows/c6-factorial-moment.yml | 21 +- .github/workflows/c6-palm-route.yml | 21 +- .github/workflows/d5-dimension-lift.yml | 21 +- .../REPLAY_SCOPE.md | 109 ++++++ tests/test_d5_c6_workflows.py | 309 ++++++++++++++++++ tools/d5_c6_replay.py | 164 ++++++++++ 6 files changed, 615 insertions(+), 30 deletions(-) create mode 100644 reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md create mode 100644 tests/test_d5_c6_workflows.py create mode 100644 tools/d5_c6_replay.py diff --git a/.github/workflows/c6-factorial-moment.yml b/.github/workflows/c6-factorial-moment.yml index 6d3a14155..1612b7e70 100644 --- a/.github/workflows/c6-factorial-moment.yml +++ b/.github/workflows/c6-factorial-moment.yml @@ -5,6 +5,8 @@ name: C6 factorial-moment candidate checks paths: - 'frontiers/c6_factorial_moment_20260929/**' - '.github/workflows/c6-factorial-moment.yml' + - 'tools/d5_c6_replay.py' + - 'tests/**' workflow_dispatch: permissions: @@ -18,16 +20,23 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: persist-credentials: false + fetch-depth: 0 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Full repository regression suite in both Python modes + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -v + python -B -O -S -m unittest discover -s tests -v - name: Verify sources, replay both modes, reject mutants env: PYTHONDONTWRITEBYTECODE: '1' run: | set -euo pipefail python -B -S - <<'PY' - import hashlib, json, pathlib, subprocess, sys + import hashlib, json, pathlib + from tools.d5_c6_replay import replay root = pathlib.Path('frontiers/c6_factorial_moment_20260929').resolve() manifest = json.loads((root / 'SOURCE_FILES.json').read_text())['files'] present = sorted(p.name for p in root.iterdir()) @@ -45,15 +54,7 @@ jobs: expected = (root / 'RESULTS.json').read_bytes() mutants = ['wrong-elimination', 'touching-balls', 'no-log', 'short-remainder'] for flags in (['-B', '-S'], ['-B', '-O', '-S']): - out = subprocess.run([sys.executable, *flags, script], - check=True, capture_output=True, timeout=300).stdout - if out != expected: - raise RuntimeError('output differs from RESULTS.json under ' + ' '.join(flags)) - for m in mutants: - rc = subprocess.run([sys.executable, *flags, script, '--mutant', m], - capture_output=True, timeout=300).returncode - if rc != 1: - raise RuntimeError('mutant ' + m + ' not rejected') + replay(script, expected, mutants, 'factorial', flags, timeout=300) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code diff --git a/.github/workflows/c6-palm-route.yml b/.github/workflows/c6-palm-route.yml index 9dba863a2..efe847996 100644 --- a/.github/workflows/c6-palm-route.yml +++ b/.github/workflows/c6-palm-route.yml @@ -5,6 +5,8 @@ name: C6 Palm-route checks paths: - 'frontiers/c6_palm_route_20260929/**' - '.github/workflows/c6-palm-route.yml' + - 'tools/d5_c6_replay.py' + - 'tests/**' workflow_dispatch: permissions: @@ -18,16 +20,23 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: persist-credentials: false + fetch-depth: 0 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Full repository regression suite in both Python modes + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -v + python -B -O -S -m unittest discover -s tests -v - name: Verify sources, replay both modes, reject mutants env: PYTHONDONTWRITEBYTECODE: '1' run: | set -euo pipefail python -B -S - <<'PY' - import hashlib, json, pathlib, subprocess, sys + import hashlib, json, pathlib + from tools.d5_c6_replay import replay root = pathlib.Path('frontiers/c6_palm_route_20260929').resolve() manifest = json.loads((root / 'SOURCE_FILES.json').read_text())['files'] present = sorted(p.name for p in root.iterdir()) @@ -46,15 +55,7 @@ jobs: mutants = ['no-slab', 'weak-zeta', 'lambda-too-large', 'series-ratio', 'factorial-power', 'schur-upper', 'forget-mark-power'] for flags in (['-B', '-S'], ['-B', '-O', '-S']): - out = subprocess.run([sys.executable, *flags, script], - check=True, capture_output=True, timeout=600).stdout - if out != expected: - raise RuntimeError('output differs from RESULTS.json under ' + ' '.join(flags)) - for m in mutants: - rc = subprocess.run([sys.executable, *flags, script, '--mutant', m], - capture_output=True, timeout=600).returncode - if rc != 1: - raise RuntimeError('mutant ' + m + ' not rejected') + replay(script, expected, mutants, 'palm', flags, timeout=600) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code diff --git a/.github/workflows/d5-dimension-lift.yml b/.github/workflows/d5-dimension-lift.yml index 06a9c445b..c22bf2935 100644 --- a/.github/workflows/d5-dimension-lift.yml +++ b/.github/workflows/d5-dimension-lift.yml @@ -5,6 +5,8 @@ name: D5 dimension-lift checks paths: - 'frontiers/d5_dimension_lift_20260929/**' - '.github/workflows/d5-dimension-lift.yml' + - 'tools/d5_c6_replay.py' + - 'tests/**' workflow_dispatch: permissions: @@ -18,16 +20,23 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with: persist-credentials: false + fetch-depth: 0 - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Full repository regression suite in both Python modes + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -v + python -B -O -S -m unittest discover -s tests -v - name: Verify sources, replay both modes, reject mutants env: PYTHONDONTWRITEBYTECODE: '1' run: | set -euo pipefail python -B -S - <<'PY' - import hashlib, json, pathlib, subprocess, sys + import hashlib, json, pathlib + from tools.d5_c6_replay import replay root = pathlib.Path('frontiers/d5_dimension_lift_20260929').resolve() manifest = json.loads((root / 'SOURCE_FILES.json').read_text())['files'] present = sorted(p.name for p in root.iterdir()) @@ -47,15 +56,7 @@ jobs: 'row-operation-third', 'euler-coefficient', 'adjugate-sign', 'one-soft-direction', 'flat-shell', 'weight-one-less-power'] for flags in (['-B', '-S'], ['-B', '-O', '-S']): - out = subprocess.run([sys.executable, *flags, script], - check=True, capture_output=True, timeout=600).stdout - if out != expected: - raise RuntimeError('output differs from RESULTS.json under ' + ' '.join(flags)) - for m in mutants: - rc = subprocess.run([sys.executable, *flags, script, '--mutant', m], - capture_output=True, timeout=600).returncode - if rc != 1: - raise RuntimeError('mutant ' + m + ' not rejected') + replay(script, expected, mutants, 'd5', flags, timeout=600) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code diff --git a/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md b/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md new file mode 100644 index 000000000..305b6a0fa --- /dev/null +++ b/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md @@ -0,0 +1,109 @@ +# D5/C6 named-rejection workflow repair + +Dylan Roy - delegated AI engineering work. Actual author: OpenAI / GPT-6 Astra +Pro, `lm006-continuation-wrapper-repair-20261005`. Scientific effect **NONE**; +shared-account/provider organizational-independence credit **0**. This addresses +Math-#314, under pickup 6007256016 and contract clarification 6007291547. It does +not modify the scientific checkers, their proof packets, manifests or outputs. +Current execution and review dispositions belong to the PR's source-bound record. + +## Why an adapter is necessary + +The original three workflows accepted any mutant process exiting 1, including +an unrelated RuntimeError; they also ignored baseline stderr. D5 and C6 Palm +intentionally raise uncaught AssertionError through their own `require` function. +Factorial instead emits JSON with an exact failed-check set. Requiring empty +stderr and JSON directly from every unchanged original CLI would reject genuine +D5/Palm controls. The repair translates only their authentic assertion carrier. + +`tools/d5_c6_replay.py` runs the full original script in a fresh child process. +For D5/Palm it accepts only an exact AssertionError class, argument message, +checker filename and final `(check_group, require)` traceback pair. It then emits +an identified JSON rejection with empty stderr. Output preceding the exception +is not suppressed and therefore fails the parent. All other exceptions propagate +as failures. The parent requires exit 1, empty stderr and an exact typed JSON +record. Normal completion is not rejection. + +Factorial retains its original JSON output. The parent requires exactly its +baseline object/scope/check schema, exactly one mapped false check, all remaining +checks true, and `passed` false. Duplicate keys, nonfinite numbers, floats, +coerced Boolean/integer values, missing/extra fields and trailing data fail. +Every baseline must exit 0, reproduce the frozen RESULTS.json bytes and have +empty stderr. The complete ordered mutant inventory is mandatory in both modes. + +The original workflow membership/size/hash checks and final tracked Git-diff +check are retained. This is not a general sandbox or an authenticity guarantee +against a malicious replacement of an entire reviewed repository. A process +protocol does not prove the mathematical claim tested by a finite checker. + +## Authentic source cut and measured contracts + +Repository `d6g8k5htny-coder/Math-`, source cut +`2f8b6f372be383d752e9dd30d38234faa977243c`. + +| Family | Unchanged checker path | Git blob | +|---|---|---| +| D5 | `frontiers/d5_dimension_lift_20260929/lift_exact_check.py` | `460efe46126bb1b7b45954a7a8e0ef2f8e93c739` | +| Palm | `frontiers/c6_palm_route_20260929/palm_exact_check.py` | `6b0c73baeeb2ac566160e23cc405daec07eb7585` | +| Factorial | `frontiers/c6_factorial_moment_20260929/c6_check.py` | `0adaf6382e89af8ce2537c994013d0c5e05b011d` | + +All three original baselines and every mutant were actually executed normally +and under optimization: 48 native processes total. The 10 D5 and 7 Palm messages +and originating groups agree across modes and are recorded in the helper and +independently in the test fixtures. The 4 factorial failures are respectively +ELIMINATION, PACKING, RADIAL and REMAINDER. The unmodified baseline identities are: + +| Family | Bytes | RESULTS.json SHA-256 | +|---|---:|---| +| D5 | 5184 | `ae9ca864ff9db1f239910fa7c349c297aa1b5ffbd9863786ca20a61a6c1814e5` | +| Palm | 2775 | `7812de453ff1efd77ffc2431874243713615ce4fcc0e55f2beae991e24f6f6bc` | +| Factorial | 285 | `82ef312659552ef7fd783e188961df62088764ef79f575e3b29720585f32109f` | + +The predecessor workflow blobs, used for red-phase controls, are respectively +`06a9c445bc8ae7b4af78bdb1ddee41f533e3a7db`, +`9dba863a2c1c155d8fa267da2de9cc91d8bce186`, and +`6d3a141555d4ed98f9ab9c1e6ff36e00683282da`. + +## Regression and hosted execution boundary + +```sh +python -B -S -m unittest discover -s tests -p test_d5_c6_workflows.py -v +python -B -O -S -m unittest discover -s tests -p test_d5_c6_workflows.py -v +``` + +The suite has 14 methods. Its workflow tests use 232 real committed temporary +Git repositories per outer mode, with hash-consistent synthetic checker/output +fixtures. They execute the entire original or repaired verification shell step, +including its membership/hash checks and final Git-diff command. No subprocess +is mocked. Every one of the 21 named mutant stages is targeted separately in +both child modes. Additional helper tests verify baseline/mutant timeout stages, +unknown-label exits, inventory completeness and strict JSON types. + +The fixture scripts are not scientific evidence. They deliberately use small +synthetic baselines where no numerical reproduction claim is being made. A +predecessor replay can use the current test file with `WORKFLOW_SOURCE_ROOT` +pointing to a checkout containing the original three workflow blobs; the helper +unit tests still use the current helper while those workflow fixtures execute +the original shell code. Expected failures demonstrate the old admission defect. + +All three workflows now run full repository `tests/` discovery in both outer +Python modes, with explicit fail-fast shell settings. Full-history checkout is +needed by the existing historical proof-reachability tests. Trigger paths cover +the helper and `tests/**`; existing action SHAs, Python 3.11.16, original process +timeouts, job timeouts, permissions and mathematical packet paths are unchanged. + +Local source copies were authenticated before execution. Complete local GitHub +checkout was unavailable, so local full-repository discovery and original full +packet-membership verification are not claimed. Dedicated hosted jobs must run +the full repository tests and actual complete scientific packets at the tested +candidate. A general green formal/downstream check alone does not establish that +these three dedicated workflows executed. A later source/base requires its own +applicable checks; old receipts must not be rebound. + +## Nonclaims + +No D5/C6 theorem, Gaussian regression step, continuum argument, Palm law, global +closure, formal alignment, Lean source, scientific register or prize is changed. +Nonauthor technical review and eligible nonauthor/nonreader integration remain +separate from this author-side repair and its tests. The exact historical proof +and checker bytes remain available without edits or retrospective acceptance. diff --git a/tests/test_d5_c6_workflows.py b/tests/test_d5_c6_workflows.py new file mode 100644 index 000000000..863facdb2 --- /dev/null +++ b/tests/test_d5_c6_workflows.py @@ -0,0 +1,309 @@ +"""Actual shell/subprocess controls for three frozen D5/C6 checker interfaces. + +Fixtures have self-consistent manifests and a real committed Git tree. They are +synthetic protocol tests, not mathematical evidence. Set WORKFLOW_SOURCE_ROOT to +an original source checkout to demonstrate pre-repair failures with this suite. +""" +from pathlib import Path +import hashlib +from concurrent.futures import ThreadPoolExecutor +import json +import os +import shutil +import subprocess +import sys +import tempfile +import textwrap +import unittest + +ROOT = Path(os.environ.get('WORKFLOW_SOURCE_ROOT', Path(__file__).resolve().parents[1])) +HERE = Path(__file__).resolve().parents[1] +HELPER = Path('tools/d5_c6_replay.py') +TEST_PATH = 'tests/test_d5_c6_workflows.py' +CONFIG = { + 'd5': ('d5-dimension-lift', 'd5_dimension_lift_20260929', 'lift_exact_check.py'), + 'palm': ('c6-palm-route', 'c6_palm_route_20260929', 'palm_exact_check.py'), + 'factorial': ('c6-factorial-moment', 'c6_factorial_moment_20260929', 'c6_check.py'), +} +# Independent expectations characterized from the unchanged source CLIs in both +# Python modes. Test fixtures do not import the implementation's contract table. +CONTRACTS = { + 'd5': { + 'drop-frobenius-order': ('check_x', 'two-soft-direction exterior inequality failed in d=3'), + 'drop-s0-block': ('check_g', 'frame rank drop in d=2'), + 'drop-a4-column': ('check_g', 'frame rank drop in d=2'), + 'degree-four': ('check_r', 'degree-four axis rank is not d'), + 'row-operation-third': ('check_ro', 'height row has a negative power of s'), + 'euler-coefficient': ('check_eu', 'Euler identity remainder is not minus the quartic part'), + 'adjugate-sign': ('check_tb', 'block determinant identity failed'), + 'one-soft-direction': ('check_l', 'pin region I ledger is not r^3'), + 'flat-shell': ('check_l', 'shell sum is not bounded by the dyadic constants'), + 'weight-one-less-power': ('check_w', 'pin weight is not integrable in d=2'), + }, + 'palm': { + 'no-slab': ('check_pk', 'retained ball within zeta_0/2 of the witness sphere'), + 'weak-zeta': ('check_pk', 'zeta_0 exceeds eta_j/8'), + 'lambda-too-large': ('check_ex', 'Markov term does not decay in d=2'), + 'series-ratio': ('check_tl', 'no index makes the series ratio fall below 2^(-1/(4d)) for d=2 p=1'), + 'factorial-power': ('check_pw', '(N)_q <= N Psi^(q-1) fails at N=3 Psi=5 q=2'), + 'schur-upper': ('check_sc', 'Schur complement is not bounded above by c I'), + 'forget-mark-power': ('check_lg', 'R1 region II absorption power is not 6+3d in d=2'), + }, + 'factorial': { + 'wrong-elimination': 'ELIMINATION', 'touching-balls': 'PACKING', + 'no-log': 'RADIAL', 'short-remainder': 'REMAINDER', + }, +} +FACTORIAL_BASE = { + 'object': 'CL-C6-FACTORIAL-20260929-v1', + 'checks': dict.fromkeys(['ELIMINATION', 'CAP_ATTAINED', 'REMAINDER', 'PACKING', 'RADIAL'], True), + 'passed': True, + 'scope': 'finite identities and one quadrature only; the analytic proof is PROOF.md', +} + + +def script_source(family, behavior, target, mode): + baseline = json.dumps(FACTORIAL_BASE if family == 'factorial' else + {'fixture': family, 'passed': True}, sort_keys=True).encode() + b'\n' + start = f'''import json, sys +from pathlib import Path +FAMILY={family!r} +BEHAVIOR={behavior!r} +TARGET={target!r} +MODE={mode!r} +CONTRACTS={CONTRACTS[family]!r} +BASELINE={baseline!r} +if len(sys.argv)==1: + if BEHAVIOR=='baseline_stderr' and sys.flags.optimize==MODE: + sys.stderr.write('unexpected baseline stderr\\n') + if BEHAVIOR=='baseline_wrong': + sys.stdout.buffer.write(b'wrong baseline\\n') + elif BEHAVIOR=='baseline_exit': + sys.stdout.buffer.write(BASELINE) + raise SystemExit(1) + else: + sys.stdout.buffer.write(BASELINE) + raise SystemExit(0) +MUT=sys.argv[sys.argv.index('--mutant')+1] +if MUT not in CONTRACTS: raise SystemExit(2) +ACTIVE=MUT==TARGET and sys.flags.optimize==MODE +if ACTIVE and BEHAVIOR=='crash': raise RuntimeError('not the intended rejection') +if ACTIVE and BEHAVIOR=='empty': raise SystemExit(1) +if ACTIVE and BEHAVIOR=='exit_zero': raise SystemExit(0) +if ACTIVE and BEHAVIOR=='stderr': sys.stderr.write('unexpected mutant stderr\\n') +if ACTIVE and BEHAVIOR=='prefix': sys.stdout.write('unexpected prefix\\n') +''' + if family == 'factorial': + start += '''doc=json.loads(BASELINE) +doc['checks'][CONTRACTS[MUT]]=False +doc['passed']=False +if ACTIVE: + if BEHAVIOR=='wrong_check': + doc['checks']=dict.fromkeys(doc['checks'], True) + doc['checks']['CAP_ATTAINED']=False + elif BEHAVIOR=='extra_failure': doc['checks']['CAP_ATTAINED']=False + elif BEHAVIOR=='boolean_int': doc['passed']=0 + elif BEHAVIOR=='check_int': doc['checks'][CONTRACTS[MUT]]=0 + elif BEHAVIOR=='extra_key': doc['unexpected']=True + elif BEHAVIOR=='missing_key': del doc['scope'] + elif BEHAVIOR=='object': doc['object']='other packet' + elif BEHAVIOR=='scope': doc['scope']='unbounded mathematical acceptance' +raw=json.dumps(doc,sort_keys=True) +if ACTIVE: + if BEHAVIOR=='duplicate': raw=raw[:-1]+',"passed":false}' + elif BEHAVIOR=='nested_duplicate': raw=raw.replace('"CAP_ATTAINED": true','"CAP_ATTAINED":true,"CAP_ATTAINED":true') + elif BEHAVIOR=='nan': raw=raw.replace('"passed": false','"passed": NaN') + elif BEHAVIOR=='infinity': raw=raw.replace('"passed": false','"passed": Infinity') + elif BEHAVIOR=='overflow': raw=raw.replace('"passed": false','"passed": 1e999') + elif BEHAVIOR=='floating_zero': raw=raw.replace('"passed": false','"passed": 0.0') + elif BEHAVIOR=='malformed': raw='not JSON' + elif BEHAVIOR=='trailing': raw+=' unexpected' +print(raw) +raise SystemExit(1) +''' + else: + start += '''MESSAGE=CONTRACTS[MUT][1] +if ACTIVE and BEHAVIOR=='wrong_message': MESSAGE='wrong assertion' +class OtherAssertion(AssertionError): pass +def require(ok,message): + if not ok: + if ACTIVE and BEHAVIOR=='subclass': raise OtherAssertion(message) + raise AssertionError(message) +def wrong_group(): require(False,MESSAGE) +''' + for group in sorted({v[0] for v in CONTRACTS[family].values()}): + start += f'def {group}(): require(False,MESSAGE)\n' + start += '''if ACTIVE and BEHAVIOR=='wrong_group': wrong_group() +if ACTIVE and BEHAVIOR=='direct_assertion': raise AssertionError(MESSAGE) +if ACTIVE and BEHAVIOR=='other_file': + exec(compile('def require(ok,message):\\n raise AssertionError(message)\\nrequire(False,MESSAGE)', '', 'exec')) +globals()[CONTRACTS[MUT][0]]() +''' + return start.encode(), baseline + + +def shell_step(family): + workflow = (ROOT / '.github/workflows' / (CONFIG[family][0] + '.yml')).read_text() + start = workflow.index(" set -euo pipefail\n", workflow.index(" - name: Verify sources, replay both modes, reject mutants")) + end = workflow.index(' git diff --exit-code', start) + len(' git diff --exit-code') + return textwrap.dedent(workflow[start:end]) + '\n' + + +def run_fixture(family, behavior='valid', target=None, mode=0): + target = target or next(iter(CONTRACTS[family])) + with tempfile.TemporaryDirectory(prefix='d5-c6-protocol-') as td: + root = Path(td) + packet = root / 'frontiers' / CONFIG[family][1] + packet.mkdir(parents=True) + source, baseline = script_source(family, behavior, target, mode) + payloads = {CONFIG[family][2]: source, 'RESULTS.json': baseline, 'NOTE.md': b'Synthetic protocol fixture, not mathematics.\n'} + for name, raw in payloads.items(): (packet / name).write_bytes(raw) + manifest = {'files': [{'path': name, 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()} + for name, raw in sorted(payloads.items())]} + (packet / 'SOURCE_FILES.json').write_text(json.dumps(manifest)) + # The predecessor workflows do not have/use the helper; that is not an + # error in the red-phase fixture. Candidate workflows copy their helper. + if (ROOT / HELPER).exists(): + (root / HELPER).parent.mkdir(parents=True) + shutil.copyfile(ROOT / HELPER, root / HELPER) + env = dict(os.environ, PYTHONDONTWRITEBYTECODE='1', PYTHONPATH='') + env.pop('PYTHONOPTIMIZE', None) + for cmd in (['git', 'init', '-q'], ['git', 'add', '.'], + ['git', '-c', 'user.name=Protocol Fixture', '-c', 'user.email=fixture@example.invalid', + '-c', 'commit.gpgsign=false', 'commit', '-qm', 'synthetic test sources']): + subprocess.run(cmd, cwd=root, env=env, check=True, capture_output=True) + if behavior == 'bad_manifest': + manifest['files'][0]['sha256']='0'*64 + (packet/'SOURCE_FILES.json').write_text(json.dumps(manifest)) + elif behavior == 'extra_file': (packet/'extra.txt').write_text('extra') + elif behavior == 'symlink': + p=packet/'NOTE.md'; p.unlink(); p.symlink_to(packet/'RESULTS.json') + elif behavior == 'dirty_tree': (root/'tracked-dirty').write_text('first') + if behavior == 'dirty_tree': + subprocess.run(['git','add','tracked-dirty'],cwd=root,check=True,capture_output=True) + (root/'tracked-dirty').write_text('changed') + result = subprocess.run(['bash', '-c', shell_step(family)], cwd=root, env=env, + capture_output=True, timeout=30) + return result + + +class WorkflowProtocolTests(unittest.TestCase): + def verify(self, family, behavior, success=False, targets=None, modes=(0, 1)): + jobs=[(family, behavior, target, mode) for mode in modes + for target in targets or [next(iter(CONTRACTS[family]))]] + # Independent committed temporary repositories; assertions stay in the + # unittest thread. No shared checker globals or test-result mutation. + with ThreadPoolExecutor(max_workers=4) as pool: + results=list(pool.map(lambda args: run_fixture(*args), jobs)) + for (_, _, target, mode), result in zip(jobs, results): + with self.subTest(family=family, behavior=behavior, target=target, mode=mode): + if success: + self.assertEqual(result.returncode,0,result.stderr.decode(errors='replace')) + self.assertEqual(result.stderr,b'') + else: + self.assertNotEqual(result.returncode,0,'bad result admitted: '+result.stdout.decode(errors='replace')) + + def test_valid_native_failure_carriers(self): + for family in CONFIG: self.verify(family,'valid',True) + + def test_every_named_mutant_crash_is_rejected(self): + for family in CONFIG: self.verify(family,'crash',targets=CONTRACTS[family]) + + def test_baseline_stderr_is_rejected(self): + for family in CONFIG: self.verify(family,'baseline_stderr') + + def test_every_named_mutant_wrong_exit_is_rejected(self): + for family in CONFIG: self.verify(family,'exit_zero',targets=CONTRACTS[family]) + + def test_invalid_mutant_output(self): + for family in CONFIG: + for behavior in ('empty','stderr','prefix'): + self.verify(family,behavior) + + def test_assertion_identity_and_origin(self): + for family in ('d5','palm'): + for behavior in ('wrong_message','wrong_group','direct_assertion','other_file','subclass'): + self.verify(family,behavior) + + def test_factorial_exact_failure_set_and_types(self): + for behavior in ('wrong_check','extra_failure','boolean_int','check_int','extra_key','missing_key','object','scope'): + self.verify('factorial',behavior,targets=CONTRACTS['factorial']) + + def test_strict_factorial_json(self): + for behavior in ('duplicate','nested_duplicate','nan','infinity','overflow','floating_zero','malformed','trailing'): + self.verify('factorial',behavior) + + def test_existing_baseline_and_source_guards(self): + for family in CONFIG: + for behavior in ('baseline_wrong','baseline_exit','bad_manifest','extra_file','symlink','dirty_tree'): + self.verify(family,behavior,modes=(0,)) + + def test_all_workflows_run_regressions_and_track_inputs(self): + for family in CONFIG: + text=(ROOT/'.github/workflows'/(CONFIG[family][0]+'.yml')).read_text() + with self.subTest(family=family): + self.assertIn("- 'tools/d5_c6_replay.py'",text) + self.assertIn("- 'tests/**'",text) + self.assertIn('fetch-depth: 0',text) + self.assertIn('python -B -S -m unittest discover -s tests -v',text) + self.assertIn('python -B -O -S -m unittest discover -s tests -v',text) + self.assertIn("python-version: '3.11.16'",text) + self.assertNotIn('continue-on-error',text) + + +class ReplayHelperTests(unittest.TestCase): + def load_helper(self): + import importlib.util + spec=importlib.util.spec_from_file_location('d5_c6_under_test', HERE / HELPER) + module=importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + def test_timeout_is_never_a_rejection(self): + helper=self.load_helper() + flags=['-B','-O','-S'] if sys.flags.optimize else ['-B','-S'] + with tempfile.TemporaryDirectory() as td: + script=Path(td)/'checker.py' + for family in CONFIG: + baseline=json.dumps(FACTORIAL_BASE if family=='factorial' else {'fixture':family}).encode()+b'\n' + for phase in ('baseline','mutant'): + script.write_text('import sys,time\nBASE='+repr(baseline)+'\n'+ + ("time.sleep(3)\n" if phase=='baseline' else '')+ + "if len(sys.argv)==1:\n sys.stdout.buffer.write(BASE)\n raise SystemExit(0)\n"+ + "time.sleep(3)\n") + with self.subTest(family=family,phase=phase): + with self.assertRaises(subprocess.TimeoutExpired) as caught: + helper.replay(script,baseline,list(CONTRACTS[family]),family,flags,timeout=0.5) + command=caught.exception.cmd + is_mutant='--mutant' in command or '--assertion' in command + self.assertEqual(is_mutant,phase=='mutant',command) + + def test_control_inventory_cannot_drop_or_add_labels(self): + helper=self.load_helper() + for family in CONFIG: + names=list(CONTRACTS[family]) + for labels in (names[:-1],names+['unknown'],list(reversed(names))): + with self.subTest(family=family,labels=labels): + with self.assertRaisesRegex(ValueError,'inventory'): + helper.replay('unused',b'',labels,family,['-B','-S'],1) + + def test_unknown_adapter_labels_exit_two(self): + for family in ('d5','palm'): + cp=subprocess.run([sys.executable,'-B','-S',str(HERE/HELPER), + '--assertion',family,'unused','unknown'],capture_output=True,timeout=5) + with self.subTest(family=family): + self.assertEqual(cp.returncode,2) + self.assertEqual(cp.stdout,b'') + self.assertIn(b'unknown mutant',cp.stderr) + + def test_protocol_does_not_coerce_boolean_or_accept_duplicates(self): + helper=self.load_helper() + self.assertFalse(helper.exact_value({'passed':0},{'passed':False})) + self.assertTrue(helper.exact_value({'passed':False},{'passed':False})) + for raw in (b'{"x":1,"x":1}',b'{"x":NaN}',b'{"x":1e999}',b'{"x":0.0}',b'{} trailing'): + with self.subTest(raw=raw): + with self.assertRaises(ValueError): helper.strict_json(raw) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/d5_c6_replay.py b/tools/d5_c6_replay.py new file mode 100644 index 000000000..70c5a13d5 --- /dev/null +++ b/tools/d5_c6_replay.py @@ -0,0 +1,164 @@ +"""Fail-closed process contracts for the unchanged D5/C6 finite checkers. + +The workflows authenticate packet membership and bytes before calling replay. +D5 and Palm deliberately raise AssertionError; their child adapter recognizes +only the measured message AND the original require/caller traceback origin. +Factorial keeps its native JSON result, with its exact single failed check. +This is an execution protocol, not a sandbox or a mathematical acceptance test. +""" +from __future__ import annotations + +import argparse +import json +from pathlib import Path +import runpy +import subprocess +import sys + + +ASSERTIONS = { + 'd5': { + 'drop-frobenius-order': ('check_x', 'two-soft-direction exterior inequality failed in d=3'), + 'drop-s0-block': ('check_g', 'frame rank drop in d=2'), + 'drop-a4-column': ('check_g', 'frame rank drop in d=2'), + 'degree-four': ('check_r', 'degree-four axis rank is not d'), + 'row-operation-third': ('check_ro', 'height row has a negative power of s'), + 'euler-coefficient': ('check_eu', 'Euler identity remainder is not minus the quartic part'), + 'adjugate-sign': ('check_tb', 'block determinant identity failed'), + 'one-soft-direction': ('check_l', 'pin region I ledger is not r^3'), + 'flat-shell': ('check_l', 'shell sum is not bounded by the dyadic constants'), + 'weight-one-less-power': ('check_w', 'pin weight is not integrable in d=2'), + }, + 'palm': { + 'no-slab': ('check_pk', 'retained ball within zeta_0/2 of the witness sphere'), + 'weak-zeta': ('check_pk', 'zeta_0 exceeds eta_j/8'), + 'lambda-too-large': ('check_ex', 'Markov term does not decay in d=2'), + 'series-ratio': ('check_tl', 'no index makes the series ratio fall below 2^(-1/(4d)) for d=2 p=1'), + 'factorial-power': ('check_pw', '(N)_q <= N Psi^(q-1) fails at N=3 Psi=5 q=2'), + 'schur-upper': ('check_sc', 'Schur complement is not bounded above by c I'), + 'forget-mark-power': ('check_lg', 'R1 region II absorption power is not 6+3d in d=2'), + }, +} +FACTORIAL_FAILURES = { + 'wrong-elimination': 'ELIMINATION', 'touching-balls': 'PACKING', + 'no-log': 'RADIAL', 'short-remainder': 'REMAINDER', +} +FACTORIAL_CHECKS = {'ELIMINATION', 'CAP_ATTAINED', 'REMAINDER', 'PACKING', 'RADIAL'} + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def strict_json(raw): + """Reject duplicates, nonfinite numbers, and floats (none is in this protocol).""" + def unique(pairs): + result = {} + for key, value in pairs: + require(key not in result, 'duplicate JSON key: ' + key) + result[key] = value + return result + + def invalid_number(value): + raise ValueError('non-integer protocol number: ' + value) + + return json.loads(raw.decode('utf-8'), object_pairs_hook=unique, + parse_constant=invalid_number, parse_float=invalid_number) + + +def exact_value(actual, expected): + """JSON structural equality without bool/int or integer/float coercion.""" + if type(actual) is not type(expected): + return False + if isinstance(expected, dict): + return actual.keys() == expected.keys() and all( + exact_value(actual[key], value) for key, value in expected.items()) + if isinstance(expected, list): + return len(actual) == len(expected) and all( + exact_value(a, b) for a, b in zip(actual, expected)) + return actual == expected + + +def assertion_report(family, mutant): + caller, message = ASSERTIONS[family][mutant] + return {'schema': 1, 'family': family, 'mutant': mutant, + 'failed_check': caller, 'message': message, 'passed': False, + 'scientific_effect': 'NONE'} + + +def assertion_child(family, script, mutant): + """Run one authenticated script in a fresh process without editing it.""" + require(family in ASSERTIONS and mutant in ASSERTIONS[family], 'unknown assertion control') + script = Path(script) + require(script.is_file() and not script.is_symlink(), 'regular checker file required') + script = script.resolve() + caller, message = ASSERTIONS[family][mutant] + sys.argv = [str(script), '--mutant', mutant] + try: + runpy.run_path(str(script), run_name='__main__') + except AssertionError as exc: + frames = [] + tb = exc.__traceback__ + while tb is not None: + frames.append((tb.tb_frame.f_code.co_filename, tb.tb_frame.f_code.co_name)) + tb = tb.tb_next + if (type(exc) is not AssertionError or exc.args != (message,) or + frames[-2:] != [(str(script), caller), (str(script), 'require')]): + raise # A different crash/assertion is NOT an intended rejection. + # Earlier stdout/stderr is deliberately not suppressed: the parent will + # reject it as extra output, malformed JSON, or nonempty stderr. + print(json.dumps(assertion_report(family, mutant), sort_keys=True)) + return 1 + return 0 # A mutant that completes normally must fail the parent's check. + + +def replay(script, expected, mutants, family, flags, timeout): + """Exact baseline, then every named rejection, with real child processes.""" + contract = FACTORIAL_FAILURES if family == 'factorial' else ASSERTIONS.get(family) + require(contract is not None and list(mutants) == list(contract), 'control inventory mismatch') + require(tuple(flags) in (('-B', '-S'), ('-B', '-O', '-S')), 'unexpected Python flags') + baseline = subprocess.run([sys.executable, *flags, str(script)], + capture_output=True, timeout=timeout) + require(baseline.returncode == 0 and baseline.stderr == b'' and baseline.stdout == expected, + 'baseline failed or stdout/stderr differs under ' + ' '.join(flags)) + reference = None + if family == 'factorial': + reference = strict_json(expected) + require(type(reference) is dict and set(reference) == {'object', 'checks', 'passed', 'scope'}, + 'factorial baseline schema mismatch') + require(reference['object'] == 'CL-C6-FACTORIAL-20260929-v1' and + reference['scope'] == 'finite identities and one quadrature only; the analytic proof is PROOF.md' and + reference['passed'] is True and type(reference['checks']) is dict and + set(reference['checks']) == FACTORIAL_CHECKS and + all(value is True for value in reference['checks'].values()), + 'factorial baseline identity/checks mismatch') + for mutant in mutants: + if family == 'factorial': + command = [sys.executable, *flags, str(script), '--mutant', mutant] + wanted = dict(reference, checks=dict(reference['checks']), passed=False) + wanted['checks'][FACTORIAL_FAILURES[mutant]] = False + else: + command = [sys.executable, *flags, str(Path(__file__).resolve()), + '--assertion', family, str(script), mutant] + wanted = assertion_report(family, mutant) + result = subprocess.run(command, capture_output=True, timeout=timeout) + require(result.returncode == 1 and result.stderr == b'', + family + '/' + mutant + ': unexpected exit/stderr (not intended rejection)') + require(exact_value(strict_json(result.stdout), wanted), + family + '/' + mutant + ': wrong rejection identity, fields, types, or failed-check set') + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--assertion', choices=sorted(ASSERTIONS), required=True) + parser.add_argument('script', type=Path) + parser.add_argument('mutant') + args = parser.parse_args() + if args.mutant not in ASSERTIONS[args.assertion]: + parser.error('unknown mutant for assertion family') + return assertion_child(args.assertion, args.script, args.mutant) + + +if __name__ == '__main__': + raise SystemExit(main()) From 3ee7c32ee0ad2745798164cccb2e658f47756036 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 5 Oct 2026 19:04:19 -0700 Subject: [PATCH 2/2] Resolve AUD-321-ASSERTION-PREFIX-01 with exact adapter output bytes Author OpenAI / GPT-6 Astra Pro, lm006-continuation-wrapper-repair-20261005, Dylan Roy delegated engineering. Applies only the three-file delta released by xAI review6007778258 at9cf6099e: exact D5/Palm adapter stdout, whitespace-prefix rejection fixtures, native-factorial-formatting positive control and scope/count update. Three workflow command lines, original scientific sources and formal/gate bytes unchanged. Fresh local amended16-method suite passes in both outer modes,238 real committed shell fixtures per mode. New whitespace tests fail exactly4 subcases against the preceding helper; all six genuine adapted baseline/all-mutant replay sequences pass. These are author validations, not successor review. Prior CI belongs to9cf6099e; fresh current-candidate execution and bounded delta review remain required. No self-merge or scientific promotion. --- reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md | 5 +++-- tests/test_d5_c6_workflows.py | 9 +++++++++ tools/d5_c6_replay.py | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md b/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md index 305b6a0fa..005715f7b 100644 --- a/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md +++ b/reviews/d5_c6_workflow_repair_20261005/REPLAY_SCOPE.md @@ -19,7 +19,8 @@ D5/Palm controls. The repair translates only their authentic assertion carrier. `tools/d5_c6_replay.py` runs the full original script in a fresh child process. For D5/Palm it accepts only an exact AssertionError class, argument message, checker filename and final `(check_group, require)` traceback pair. It then emits -an identified JSON rejection with empty stderr. Output preceding the exception +an identified JSON rejection with empty stderr. The parent also requires the +adapter's exact serialized bytes, including its single final newline. Output preceding the exception is not suppressed and therefore fails the parent. All other exceptions propagate as failures. The parent requires exit 1, empty stderr and an exact typed JSON record. Normal completion is not rejection. @@ -71,7 +72,7 @@ python -B -S -m unittest discover -s tests -p test_d5_c6_workflows.py -v python -B -O -S -m unittest discover -s tests -p test_d5_c6_workflows.py -v ``` -The suite has 14 methods. Its workflow tests use 232 real committed temporary +The suite has 16 methods. Its workflow tests use 238 real committed temporary Git repositories per outer mode, with hash-consistent synthetic checker/output fixtures. They execute the entire original or repaired verification shell step, including its membership/hash checks and final Git-diff command. No subprocess diff --git a/tests/test_d5_c6_workflows.py b/tests/test_d5_c6_workflows.py index 863facdb2..8291a46af 100644 --- a/tests/test_d5_c6_workflows.py +++ b/tests/test_d5_c6_workflows.py @@ -92,6 +92,7 @@ def script_source(family, behavior, target, mode): if ACTIVE and BEHAVIOR=='exit_zero': raise SystemExit(0) if ACTIVE and BEHAVIOR=='stderr': sys.stderr.write('unexpected mutant stderr\\n') if ACTIVE and BEHAVIOR=='prefix': sys.stdout.write('unexpected prefix\\n') +if ACTIVE and BEHAVIOR=='whitespace': sys.stdout.write(' \\n\\t') ''' if family == 'factorial': start += '''doc=json.loads(BASELINE) @@ -109,6 +110,7 @@ def script_source(family, behavior, target, mode): elif BEHAVIOR=='object': doc['object']='other packet' elif BEHAVIOR=='scope': doc['scope']='unbounded mathematical acceptance' raw=json.dumps(doc,sort_keys=True) +if ACTIVE and BEHAVIOR=='formatting': raw=json.dumps(doc,indent=2,sort_keys=False) if ACTIVE: if BEHAVIOR=='duplicate': raw=raw[:-1]+',"passed":false}' elif BEHAVIOR=='nested_duplicate': raw=raw.replace('"CAP_ATTAINED": true','"CAP_ATTAINED":true,"CAP_ATTAINED":true') @@ -209,6 +211,13 @@ def test_valid_native_failure_carriers(self): def test_every_named_mutant_crash_is_rejected(self): for family in CONFIG: self.verify(family,'crash',targets=CONTRACTS[family]) + def test_assertion_whitespace_output_is_rejected(self): + for family in ('d5','palm'): + self.verify(family,'whitespace') + + def test_factorial_valid_json_formatting_is_accepted(self): + self.verify('factorial','formatting',True) + def test_baseline_stderr_is_rejected(self): for family in CONFIG: self.verify(family,'baseline_stderr') diff --git a/tools/d5_c6_replay.py b/tools/d5_c6_replay.py index 70c5a13d5..73b50992f 100644 --- a/tools/d5_c6_replay.py +++ b/tools/d5_c6_replay.py @@ -145,6 +145,9 @@ def replay(script, expected, mutants, family, flags, timeout): result = subprocess.run(command, capture_output=True, timeout=timeout) require(result.returncode == 1 and result.stderr == b'', family + '/' + mutant + ': unexpected exit/stderr (not intended rejection)') + if family != 'factorial': + require(result.stdout == (json.dumps(wanted, sort_keys=True) + '\n').encode('utf-8'), + family + '/' + mutant + ': extra or noncanonical assertion-carrier stdout') require(exact_value(strict_json(result.stdout), wanted), family + '/' + mutant + ': wrong rejection identity, fields, types, or failed-check set')