From e710ba569feb5d66f5bac282de689758a9b22111 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 05:37:15 -0700 Subject: [PATCH 01/24] Observe unchanged soft-fold native rejection carriers before defining repair contracts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dylan Roy — delegated AI engineering; OpenAI / GPT-6 Astra Pro, soft-fold-protocol-followthrough-20261006, #322/6016299453. Observation-only prerequisite, not repaired validation or mathematical acceptance. Original source preflight and checker authenticated before any invocation; no scientific source edits. --- .../workflows/soft-fold-protocol-observe.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/soft-fold-protocol-observe.yml diff --git a/.github/workflows/soft-fold-protocol-observe.yml b/.github/workflows/soft-fold-protocol-observe.yml new file mode 100644 index 000000000..856f13860 --- /dev/null +++ b/.github/workflows/soft-fold-protocol-observe.yml @@ -0,0 +1,54 @@ +name: Soft fold protocol observation ONLY +'on': + pull_request: + paths: + - '.github/workflows/soft-fold-protocol-observe.yml' +permissions: + contents: read + pull-requests: read +jobs: + observe: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 + with: + python-version: '3.11.16' + - name: Authenticate original preflight and observe unchanged native CLI + env: + GH_TOKEN: ${{ github.token }} + GH_REPOSITORY: ${{ github.repository }} + PYTHONDONTWRITEBYTECODE: '1' + run: | + set -euo pipefail + python -B -S - <<'PY' + import hashlib, json, pathlib, subprocess, sys, textwrap + workflow = pathlib.Path('.github/workflows/soft-fold-limit.yml').read_bytes() + blob = hashlib.sha1(b'blob %d\0' % len(workflow) + workflow).hexdigest() + if blob != '839b99a47a4b9d0a79525216118717b22bad4614': + raise ValueError('original workflow identity mismatch') + text = workflow.decode('utf-8') + start = text.index(' import base64, hashlib, json, os, pathlib, subprocess, sys, urllib.parse, urllib.request\n') + end = text.index(" script = str(root / 'fold_check.py')\n", start) + exec(compile(textwrap.dedent(text[start:end]), '', 'exec')) + checker = root / 'fold_check.py' + data = checker.read_bytes() + if hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() != 'c2e1e77e9f16bc7c62fbb855b55dc2f72e5a8cc2': + raise ValueError('original checker identity mismatch') + expected = (root / 'RESULTS.json').read_bytes() + for flags in (['-B', '-S'], ['-B', '-O', '-S']): + for label in ('baseline', *manifest['mutants'], 'M99'): + args = [] if label == 'baseline' else ['--mutant', label] + process = subprocess.run([sys.executable, *flags, str(checker), *args], capture_output=True, timeout=600) + print(json.dumps({'observation_only': True, 'intended_rejection_verified': False, + 'flags': flags, 'stage': label, 'returncode': process.returncode, + 'stdout_bytes': len(process.stdout), 'stdout_sha256': hashlib.sha256(process.stdout).hexdigest(), + 'stderr_hex': process.stderr.hex(), 'stderr_sha256': hashlib.sha256(process.stderr).hexdigest()}, sort_keys=True), flush=True) + if label == 'baseline' and (process.returncode != 0 or process.stdout != expected): + raise ValueError('original baseline failed') + subprocess.run(['git', 'diff', '--exit-code'], check=True) + print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False, 'observation_only': True})) + PY From 77b1b76f1c0b4a62e2359e83903c7b86a0c0db53 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 05:55:13 -0700 Subject: [PATCH 02/24] Validate full soft-fold rejection carriers and retire observation workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dylan Roy — delegated AI engineering. Actual author OpenAI / GPT-6 Astra Pro, soft-fold-protocol-followthrough-20261006; #322/6016299453. Fixed native carriers independently measured in pinned-runtime observation37464626067. Entire7599-byte source preflight and137-byte postflight unchanged; all scientific sources/pins/budgets unchanged. Real original full-shell suite gives111 intended assertion failures/zero errors; final147 scenarios pass normally and optimized with no skips. Final delta three engineering files; temporary observer removed from tree, historical evidence retained. No mathematical acceptance, author self-merge or old CI rebinding; separate source review and fresh candidate execution required. --- .github/workflows/soft-fold-limit.yml | 41 ++- .../workflows/soft-fold-protocol-observe.yml | 54 ---- reviews/soft_fold_protocol_20261006/SCOPE.md | 121 +++++++++ tests/test_soft_fold_workflow.py | 243 ++++++++++++++++++ 4 files changed, 395 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/soft-fold-protocol-observe.yml create mode 100644 reviews/soft_fold_protocol_20261006/SCOPE.md create mode 100644 tests/test_soft_fold_workflow.py diff --git a/.github/workflows/soft-fold-limit.yml b/.github/workflows/soft-fold-limit.yml index 839b99a47..5cc7433cd 100644 --- a/.github/workflows/soft-fold-limit.yml +++ b/.github/workflows/soft-fold-limit.yml @@ -5,6 +5,7 @@ name: Soft fold limit exact controls paths: - 'frontiers/soft_fold_limit_20261002/**' - '.github/workflows/soft-fold-limit.yml' + - 'tests/test_soft_fold_workflow.py' # bound merged sources (consumed and cited in SOURCES.json); the cited unmerged sources are bound through the API - 'frontiers/three_fronts_20260924/LIFETIME_REMAINDER.md' - 'imports/lifetime_parent_20260925/UNIFORM_MATRIX_CAP_AND_LIFETIME.md' @@ -37,6 +38,13 @@ jobs: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Exercise complete-shell output contracts in both modes + env: + PYTHONDONTWRITEBYTECODE: '1' + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -p test_soft_fold_workflow.py -v + python -B -O -S -m unittest discover -s tests -p test_soft_fold_workflow.py -v - name: Verify sources, replay both modes, reject mutants env: PYTHONDONTWRITEBYTECODE: '1' @@ -150,17 +158,30 @@ jobs: 'via': where, 'current_ref_checked': now, 'dependency_merged': merged})) script = str(root / 'fold_check.py') expected = (root / 'RESULTS.json').read_bytes() + # Fixed native carriers measured at original checker c2e1e77e in run37464626067. + failures = { + 'M1': b'mutant M1: failing controls F1_model_pins_and_weight\n', + 'M2': b'mutant M2: failing controls F2_lemma_FL2_generic\n', + 'M3': b'mutant M3: failing controls F3_lemma_FL1_window\n', + 'M4': b'mutant M4: failing controls F4_proposition_FL4_certificates\n', + 'M5': b'mutant M5: failing controls F5_theorem_FL_bookkeeping\n', + 'M6': b'mutant M6: failing controls F6_corollaries\n', + 'M7': b'mutant M7: failing controls F4_proposition_FL4_certificates\n', + 'M8': b'mutant M8: failing controls F7_proposition_FL7_identification\n', + } + if type(manifest['mutants']) is not list or manifest['mutants'] != list(failures): + raise RuntimeError('complete ordered M1-M8 inventory required') + stages = [('baseline', [], 0, expected, b'')] + stages += [(m, ['--mutant', m], 1, b'', carrier) for m, carrier in failures.items()] + stages += [('M99', ['--mutant', 'M99'], 2, b'', b'unknown mutant label\n')] 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 manifest['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') - rc = subprocess.run([sys.executable, *flags, script, '--mutant', 'M99'], capture_output=True, timeout=600).returncode - if rc != 2: - raise RuntimeError('unknown mutant label not rejected with exit 2') + for label, args, code, stdout, stderr in stages: + result = subprocess.run([sys.executable, *flags, script, *args], capture_output=True, timeout=600) + if (result.returncode, result.stdout, result.stderr) != (code, stdout, stderr): + raise RuntimeError(label + ': complete exit/stdout/stderr contract differs under ' + ' '.join(flags)) + print(json.dumps({'stage': label, 'flags': flags, 'returncode': result.returncode, + 'stdout_sha256': hashlib.sha256(result.stdout).hexdigest(), + 'stderr_sha256': hashlib.sha256(result.stderr).hexdigest()}, sort_keys=True), flush=True) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code diff --git a/.github/workflows/soft-fold-protocol-observe.yml b/.github/workflows/soft-fold-protocol-observe.yml deleted file mode 100644 index 856f13860..000000000 --- a/.github/workflows/soft-fold-protocol-observe.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Soft fold protocol observation ONLY -'on': - pull_request: - paths: - - '.github/workflows/soft-fold-protocol-observe.yml' -permissions: - contents: read - pull-requests: read -jobs: - observe: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - with: - persist-credentials: false - - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 - with: - python-version: '3.11.16' - - name: Authenticate original preflight and observe unchanged native CLI - env: - GH_TOKEN: ${{ github.token }} - GH_REPOSITORY: ${{ github.repository }} - PYTHONDONTWRITEBYTECODE: '1' - run: | - set -euo pipefail - python -B -S - <<'PY' - import hashlib, json, pathlib, subprocess, sys, textwrap - workflow = pathlib.Path('.github/workflows/soft-fold-limit.yml').read_bytes() - blob = hashlib.sha1(b'blob %d\0' % len(workflow) + workflow).hexdigest() - if blob != '839b99a47a4b9d0a79525216118717b22bad4614': - raise ValueError('original workflow identity mismatch') - text = workflow.decode('utf-8') - start = text.index(' import base64, hashlib, json, os, pathlib, subprocess, sys, urllib.parse, urllib.request\n') - end = text.index(" script = str(root / 'fold_check.py')\n", start) - exec(compile(textwrap.dedent(text[start:end]), '', 'exec')) - checker = root / 'fold_check.py' - data = checker.read_bytes() - if hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() != 'c2e1e77e9f16bc7c62fbb855b55dc2f72e5a8cc2': - raise ValueError('original checker identity mismatch') - expected = (root / 'RESULTS.json').read_bytes() - for flags in (['-B', '-S'], ['-B', '-O', '-S']): - for label in ('baseline', *manifest['mutants'], 'M99'): - args = [] if label == 'baseline' else ['--mutant', label] - process = subprocess.run([sys.executable, *flags, str(checker), *args], capture_output=True, timeout=600) - print(json.dumps({'observation_only': True, 'intended_rejection_verified': False, - 'flags': flags, 'stage': label, 'returncode': process.returncode, - 'stdout_bytes': len(process.stdout), 'stdout_sha256': hashlib.sha256(process.stdout).hexdigest(), - 'stderr_hex': process.stderr.hex(), 'stderr_sha256': hashlib.sha256(process.stderr).hexdigest()}, sort_keys=True), flush=True) - if label == 'baseline' and (process.returncode != 0 or process.stdout != expected): - raise ValueError('original baseline failed') - subprocess.run(['git', 'diff', '--exit-code'], check=True) - print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False, 'observation_only': True})) - PY diff --git a/reviews/soft_fold_protocol_20261006/SCOPE.md b/reviews/soft_fold_protocol_20261006/SCOPE.md new file mode 100644 index 000000000..fa6b59b7d --- /dev/null +++ b/reviews/soft_fold_protocol_20261006/SCOPE.md @@ -0,0 +1,121 @@ +# Soft-fold workflow output contract + +Dylan Roy — delegated AI engineering. Actual author OpenAI / GPT-6 Astra Pro, +`soft-fold-protocol-followthrough-20261006`; #322 pickup6016299453. +Scientific effect NONE; organizational-independence credit0. No author self-merge. + +## Original sources and independently measured carriers + +Source cut11f9127f00ce922e5d39b0da42af76134eb78a21. Original workflow +`.github/workflows/soft-fold-limit.yml`:10578 bytes, Git blob +839b99a47a4b9d0a79525216118717b22bad4614, SHA256 +0aec5cb657a2fa37bab5f77f4f77ca6f978fbd9297a0b56b691b0f93d6ec2c6f. +Checker `frontiers/soft_fold_limit_20261002/fold_check.py` is unchanged blob +c2e1e77e9f16bc7c62fbb855b55dc2f72e5a8cc2. RESULTS is unchanged blob +604c53fadd71312baa3b4bfdbbf1760eddc4ac66. + +An observation-only draft predecessor e710ba569feb5d66f5bac282de689758a9b22111 +first obtained actual pinned-runtime evidence. Original run37464626067/1, +job112272450916, checked out64831bd92336733780928dc40e55db5304025123 +(parents11f9127f+e710ba56), installed CPython3.11.16/Git2.55.0, authenticated +both workflow and checker, executed the exact original complete source preflight, +and ran20 authentic processes. Complete original log read; selected observations +are recorded in PR370/6016447033. No local authentic checker replay is claimed: +Git clone failed DNS and direct source download was unavailable. + +Both baseline invocations exit0 with2903-byte frozen RESULTS stdout, SHA256 +459bbdf3c84b77548e53824df889b13a8ebd0fe6b0d7d7cadf8a4d73821641e9, +and empty stderr. All eight named mutants exit1 with empty stdout and exactly: + +`mutant LABEL: failing controls CONTROL\n` + +|Label|CONTROL| +|---|---| +|M1|F1_model_pins_and_weight| +|M2|F2_lemma_FL2_generic| +|M3|F3_lemma_FL1_window| +|M4|F4_proposition_FL4_certificates| +|M5|F5_theorem_FL_bookkeeping| +|M6|F6_corollaries| +|M7|F4_proposition_FL4_certificates| +|M8|F7_proposition_FL7_identification| + +M4 and M7 name the same control, but their complete label-bearing lines differ. +M99 exits2, empty stdout, exactly `unknown mutant label\n` on stderr. +All ten corresponding stdout/stderr identities match between interpreter modes. +The native main function reports the sorted complete failing-control set, so +an extra failed control is not accepted as the intended single failure. +Observation success alone did not establish a correct validator. Its temporary +workflow is removed from the final proposed tree, retained only in history. + +## Repair and preservation + +Only the existing inline process loop changes behavior. Require the exact ordered +list M1-M8 before children; construct the fixed20-command inventory; compare each +actual exit/stdout/stderr tuple with its independently measured complete contract. +The baseline retains byte-exact RESULTS and now requires empty stderr. Mutants +and M99 require empty stdout and their entire stderr, including the newline. +Whitespace changes are deliberately rejected for these deterministic text CLIs. +No expectations come from the child under validation; no scientific checker or +RESULTS generation, parser adapter, extra production helper/import is introduced. +Launch/timeout exceptions propagate; cwd, capture_output=True,600-second child +budget, both original modes and command arguments are unchanged. Accepted calls +print stream identities. Failure raw-output durability is not newly guaranteed. + +The7599-byte source preflight remains byte-identical, SHA256 +2ad437f73e5f0c27482dd272144deadc2959d85e946c40f0226c51ce6abe5211. +The137-byte final JSON/Git postflight remains byte-identical, SHA256 +752aa03685dbbe54ec40c3e91b8709eb6453c41c146e9636b295b2129c586cdc. +Sizes include YAML indentation. All packet, proof, manifest, result and consumed +or cited dependency bytes remain unchanged. So do action/runtime pins, read-only +permissions and ten-minute job budget. One test trigger and two focused discovery +commands are added. Existing D5/Palm/factorial tests/** triggers provide their +separate complete repository discovery on the actual candidate. + +## Test-first local execution + +Actual CPython3.13.5/Git2.47.3; nine unittest methods,147 distinct committed real-Git +whole-shell scenarios. Full uninterrupted original command:111 intended assertion +failures,0 errors (130.091s). Breakdown:96 named-mutant false admissions,2 baseline +stderr false admissions,8 unknown-label false admissions,4 malformed-inventory +admissions,1 missing-wiring assertion. One valid admission and36 correct rejecting +controls remain. The original executes2504 child commands. + +The unchanged final test file runs against the repaired workflow:9/9 methods, +147/147 expected outcomes in EACH normal/optimized outer mode (68.303s/68.144s). +Each has one valid admission and146 rejections,1444 actual children. No skipped +or partitioned cases and no subprocess mocks. Across the three completed runs: +441 fixture records,882 raw shell streams and5392 child invocations. These are +repetitions of147 scenario types, not441 distinct defects. + +All eight mutant stages and both child modes are targeted. Every protocol +rejection must reach and stop at its exact ordered target; nine source/tree +controls and four malformed inventories must stop before any child. The final +tracked-output mutation reaches all20 invocations before Git rejects it. Real +Git configuration is isolated to temporary environments/commands; no user signing, +hooks or maintenance settings are changed. Synthetic baseline/carriers never +import expectations from production code. + +The local fixtures have nonempty tracked consumed and cited source pins. Their +remote-source arrays are empty; no live API replay is claimed locally. The +original hosted preflight actually resolved consumed #242 as merged, checked +current ref54c6759e8434846941eb5218601dfef69c2c9d98 and source blob +271412dbc96a29590f5f805258e15c9e335cb430 via TREE. The unchanged historical +head/path/blob fallback was not exercised by that observation. The final dedicated +workflow must supply its own actual full-packet candidate execution. + +## Review and integration boundary + +This is engineering validation, not the proof of FL, numerical certification, +a false theorem finding, hostile-source sandbox, bounded-output service, durable +storage guarantee or independent formal alignment. Existing mathematical scope +and status remain. No complete local repository checkout or local Lean execution +is claimed. Original failures and observation-only records remain historical; +old CI cannot be rebound to the successor repair or a later main. + +Require an actual nonauthor engineering review of this final three-file delta, +all applicable fresh dedicated/general checks on its actual candidate, and a +separate eligible nonauthor/nonreader integrator's live ownership/ref/diff/source/ +review/thread reconciliation before ordinary expected-head merge and landed/push +verification. #322 remains open for the broader wrapper class. No new owner +approval, duplicate scientific register, main-tip lock or timer is requested. diff --git a/tests/test_soft_fold_workflow.py b/tests/test_soft_fold_workflow.py new file mode 100644 index 000000000..98d394d66 --- /dev/null +++ b/tests/test_soft_fold_workflow.py @@ -0,0 +1,243 @@ +"""Real whole-shell protocol fixtures; synthetic outputs, not a field theorem.""" +import hashlib +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import textwrap +import unittest + +ROOT = Path(__file__).resolve().parents[1] +WORKFLOW = ROOT / '.github/workflows/soft-fold-limit.yml' +PACKET = 'frontiers/soft_fold_limit_20261002' +MUTANTS = tuple('M' + str(i) for i in range(1, 9)) +STAGES = ('baseline', *MUTANTS, 'M99') +ORDER = [[mode, stage] for mode in (0, 1) for stage in STAGES] +# Independent reference carriers from original hosted job112272450916. +CONTROLS = ('F1_model_pins_and_weight', 'F2_lemma_FL2_generic', + 'F3_lemma_FL1_window', 'F4_proposition_FL4_certificates', + 'F5_theorem_FL_bookkeeping', 'F6_corollaries', + 'F4_proposition_FL4_certificates', 'F7_proposition_FL7_identification') +EXPECTED_STDERR = {m: ('mutant ' + m + ': failing controls ' + c + '\n').encode() + for m, c in zip(MUTANTS, CONTROLS)} +EXPECTED_STDERR.update(baseline=b'', M99=b'unknown mutant label\n') +BASELINE = b'{"synthetic": "soft-fold baseline"}\n' + + +def verification_shell(text): + """Extract only the existing named step, without replacing any source guard.""" + marker = ' - name: Verify sources, replay both modes, reject mutants\n' + if text.count(marker) != 1: + raise ValueError('one original verification step required') + tail = text.split(marker, 1)[1].split(' run: |\n', 1)[1] + lines = [] + for line in tail.splitlines(): + if line and not line.startswith(' '): + break + lines.append(line[10:] if line else '') + if not lines or lines[0] != 'set -euo pipefail': + raise ValueError('original strict shell missing') + return '\n'.join(lines) + '\n' + + +def file_identity(name, data): + return {'path': name, 'bytes': len(data), + 'sha256': hashlib.sha256(data).hexdigest(), + 'git_blob': hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest()} + + +def synthetic_checker(): + return ('import json, os, signal, sys\nfrom pathlib import Path\n' + + 'messages = ' + repr(EXPECTED_STDERR) + '\n' + + 'baseline = ' + repr(BASELINE) + '\n' + textwrap.dedent(r''' + args = sys.argv[1:] + label = 'baseline' if not args else args[1] + mode = sys.flags.optimize + with open(os.environ['SOFT_FOLD_TRACE'], 'a') as stream: + stream.write(json.dumps([mode, label]) + '\n') + code = 0 if label == 'baseline' else 2 if label == 'M99' else 1 + out = baseline if label == 'baseline' else b'' + err = messages[label] + case = os.environ['SOFT_FOLD_CASE'] + if case == 'dirty': + Path(os.environ['SOFT_FOLD_RESULTS']).write_bytes(b'changed after preflight\n') + if mode == int(os.environ['SOFT_FOLD_MODE']) and label == os.environ['SOFT_FOLD_STAGE']: + if case == 'crash': + raise RuntimeError('unrelated synthetic crash') + if case == 'silent': + out = err = b'' + elif case == 'wrong-control': + err = b'unrelated failure reason\n' + elif case == 'extra-stdout': + out += b'unexpected stdout\n' + elif case == 'prefix': + err = b'prefix ' + err + elif case == 'extra-newline': + err += b'\n' + elif case == 'stderr': + err += b'unexpected stderr\n' + elif case == 'garbage': + out = b'not the frozen result\n' + elif case == 'wrong-exit': + code = 1 if label == 'baseline' else 0 + elif case == 'signal': + os.kill(os.getpid(), signal.SIGTERM) + sys.stdout.buffer.write(out) + sys.stderr.buffer.write(err) + sys.exit(code) + ''')) + + +class SoftFoldWorkflowTests(unittest.TestCase): + def run_case(self, case='valid', stage='baseline', mode=0, guard=None): + with tempfile.TemporaryDirectory(prefix='soft-fold-fixture-') as tmp: + home = Path(tmp) + repo = home / 'repo' + packet = repo / PACKET + packet.mkdir(parents=True) + trace = home / 'trace.jsonl' + script = packet / 'fold_check.py' + script.write_text(synthetic_checker(), encoding='utf-8') + (packet / 'RESULTS.json').write_bytes(BASELINE) + manifest = {'files': [file_identity(p.name, p.read_bytes()) for p in sorted(packet.iterdir())], + 'mutants': list(MUTANTS), 'consumed': [], 'cited_only': [], + 'consumed_unmerged': [], 'cited_unmerged': []} + for kind in ('consumed', 'cited_only'): + name = kind + '.txt' + data = ('nonempty synthetic pinned ' + kind + '\n').encode() + (repo / name).write_bytes(data) + manifest[kind] = [file_identity(name, data)] + manifest_path = packet / 'SOURCES.json' + manifest_path.write_text(json.dumps(manifest)) + env = {k: v for k, v in os.environ.items() if not k.startswith('GIT_')} + env.update(HOME=str(home), GIT_CONFIG_NOSYSTEM='1', GIT_CONFIG_GLOBAL=os.devnull, + GIT_AUTHOR_NAME='Fixture', GIT_AUTHOR_EMAIL='fixture@example.invalid', + GIT_COMMITTER_NAME='Fixture', GIT_COMMITTER_EMAIL='fixture@example.invalid', + PYTHONDONTWRITEBYTECODE='1', GH_REPOSITORY='fixture/fixture', GH_TOKEN='unused', + SOFT_FOLD_CASE=case, SOFT_FOLD_STAGE=stage, SOFT_FOLD_MODE=str(mode), + SOFT_FOLD_TRACE=str(trace), SOFT_FOLD_RESULTS=str(packet / 'RESULTS.json')) + env['PATH'] = str(Path(sys.executable).parent) + os.pathsep + env.get('PATH', '') + + def git(*args): + return subprocess.run(['git', '-c', 'commit.gpgsign=false', '-c', 'maintenance.auto=false', + '-c', 'core.hooksPath=' + os.devnull, *args], + cwd=repo, env=env, check=True, capture_output=True, timeout=15) + + git('init', '-q') + git('add', '.') + git('commit', '-qm', 'synthetic authenticated fixture') + if guard == 'packet-hash': + script.write_text(script.read_text() + '\n# changed after manifest\n') + elif guard == 'missing-packet': + (packet / 'RESULTS.json').unlink() + elif guard == 'extra-member': + (packet / 'extra.txt').write_bytes(b'extra') + elif guard == 'packet-symlink': + target = home / 'copy' + target.write_bytes(BASELINE) + (packet / 'RESULTS.json').unlink() + (packet / 'RESULTS.json').symlink_to(target) + elif guard in ('consumed-hash', 'cited-hash'): + (repo / ('consumed.txt' if guard == 'consumed-hash' else 'cited_only.txt')).write_bytes(b'tampered\n') + elif guard == 'consumed-mode': + git('update-index', '--chmod=+x', 'consumed.txt') + git('commit', '-qm', 'wrong tracked mode') + elif guard == 'consumed-missing': + (repo / 'consumed.txt').unlink() + elif guard == 'untracked-pin': + git('rm', '--cached', 'consumed.txt') + git('commit', '-qm', 'untracked consumed file') + elif guard and guard.startswith('inventory-'): + variants = {'inventory-missing': list(MUTANTS[:-1]), + 'inventory-order': list(reversed(MUTANTS)), + 'inventory-duplicate': [*MUTANTS, 'M8'], + 'inventory-object': dict.fromkeys(MUTANTS, 1)} + manifest['mutants'] = variants[guard] + manifest_path.write_text(json.dumps(manifest)) + git('add', '.') + git('commit', '-qm', 'coherent inventory variant') + result = subprocess.run(['bash', '--noprofile', '--norc', '-c', verification_shell(WORKFLOW.read_text())], + cwd=repo, env=env, capture_output=True, timeout=40) + calls = [json.loads(line) for line in trace.read_text().splitlines()] if trace.exists() else [] + if destination := os.environ.get('SOFT_FOLD_SAVE'): + saved = Path(destination) / ('-'.join((case, stage, str(mode), str(guard)))) + saved.mkdir(parents=True, exist_ok=False) + (saved / 'stdout.bin').write_bytes(result.stdout) + (saved / 'stderr.bin').write_bytes(result.stderr) + record = {'case': case, 'stage': stage, 'mode': mode, 'guard': guard, + 'returncode': result.returncode, 'calls': calls, + 'stdout_sha256': hashlib.sha256(result.stdout).hexdigest(), + 'stderr_sha256': hashlib.sha256(result.stderr).hexdigest()} + (saved / 'record.json').write_text(json.dumps(record, sort_keys=True) + '\n') + return result, calls + + def reject_at(self, case, stage, mode): + result, calls = self.run_case(case, stage, mode) + prefix = ORDER[:ORDER.index([mode, stage]) + 1] + self.assertIn([mode, stage], calls, 'targeted command must actually run') + self.assertNotEqual(result.returncode, 0, 'wrong-result admission: ' + repr((case, stage, mode))) + self.assertEqual(calls, prefix, 'failure must stop at exactly its intended stage') + + def test_valid_complete_inventory(self): + result, calls = self.run_case() + self.assertEqual(result.returncode, 0, result.stderr.decode(errors='replace')) + self.assertEqual(calls, ORDER) + + def test_every_named_rejection_requires_its_full_carrier(self): + for case in ('silent', 'crash', 'wrong-control', 'extra-stdout', 'prefix', 'extra-newline'): + for mode in (0, 1): + for stage in MUTANTS: + with self.subTest(case=case, stage=stage, mode=mode): + self.reject_at(case, stage, mode) + + def test_named_wrong_exits(self): + for mode in (0, 1): + for stage in MUTANTS: + with self.subTest(stage=stage, mode=mode): + self.reject_at('wrong-exit', stage, mode) + + def test_baseline_exact_output_and_empty_stderr(self): + for case in ('stderr', 'silent', 'garbage', 'wrong-exit'): + for mode in (0, 1): + with self.subTest(case=case, mode=mode): + self.reject_at(case, 'baseline', mode) + + def test_unknown_complete_diagnostic(self): + for case in ('silent', 'wrong-control', 'extra-stdout', 'prefix', 'wrong-exit', 'signal'): + for mode in (0, 1): + with self.subTest(case=case, mode=mode): + self.reject_at(case, 'M99', mode) + + def test_source_guards_precede_children(self): + for guard in ('packet-hash', 'missing-packet', 'extra-member', 'packet-symlink', + 'consumed-hash', 'cited-hash', 'consumed-mode', 'consumed-missing', 'untracked-pin'): + with self.subTest(guard=guard): + result, calls = self.run_case(guard=guard) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(calls, []) + + def test_ordered_inventory_before_any_child(self): + for guard in ('inventory-missing', 'inventory-order', 'inventory-duplicate', 'inventory-object'): + with self.subTest(guard=guard): + result, calls = self.run_case(guard=guard) + self.assertNotEqual(result.returncode, 0) + self.assertEqual(calls, []) + + def test_final_git_guard_remains_effective(self): + result, calls = self.run_case('dirty') + self.assertNotEqual(result.returncode, 0) + self.assertEqual(calls, ORDER) + self.assertIn(b'changed after preflight', result.stdout) + + def test_focused_suite_is_wired(self): + text = WORKFLOW.read_text() + self.assertIn("- 'tests/test_soft_fold_workflow.py'", text) + for flags in ('-B -S', '-B -O -S'): + self.assertIn('python ' + flags + ' -m unittest discover -s tests -p test_soft_fold_workflow.py -v', text) + + +if __name__ == '__main__': + unittest.main() From fedd0056c18093e8862b7f6ac2860dc04f8133b9 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:09:46 -0700 Subject: [PATCH 03/24] Correct soft-fold inventory validation to preserve the native control mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dylan Roy — delegated AI engineering; actual author OpenAI / GPT-6 Astra Pro, soft-fold-protocol-followthrough-20261006. Fix the concrete author assumption identified by failed dedicated37466840210, not a CI retry. Original SOURCES37b8a38a is an ordered M1:F1...M8:F7 object, not a list. Corrected positive fixture first fails77b1 exactly once per mode; then native-mapping original full suite gives111 intended assertions/zero errors and amended147/147 outcomes pass in both modes. Full7599-byte dependency preflight/137-byte postflight and all scientific bytes unchanged. Old wrong-format fixtures and original failed CI retained. Exact successor review and fresh candidate checks required; no self-merge, source-repin or scientific promotion. --- .github/workflows/soft-fold-limit.yml | 7 ++-- reviews/soft_fold_protocol_20261006/SCOPE.md | 38 +++++++++++++++++--- tests/test_soft_fold_workflow.py | 7 ++-- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.github/workflows/soft-fold-limit.yml b/.github/workflows/soft-fold-limit.yml index 5cc7433cd..944dc39d3 100644 --- a/.github/workflows/soft-fold-limit.yml +++ b/.github/workflows/soft-fold-limit.yml @@ -169,8 +169,11 @@ jobs: 'M7': b'mutant M7: failing controls F4_proposition_FL4_certificates\n', 'M8': b'mutant M8: failing controls F7_proposition_FL7_identification\n', } - if type(manifest['mutants']) is not list or manifest['mutants'] != list(failures): - raise RuntimeError('complete ordered M1-M8 inventory required') + inventory = {'M1': 'F1', 'M2': 'F2', 'M3': 'F3', 'M4': 'F4', + 'M5': 'F5', 'M6': 'F6', 'M7': 'F4', 'M8': 'F7'} + if (type(manifest['mutants']) is not dict or list(manifest['mutants']) != list(inventory) + or manifest['mutants'] != inventory): + raise RuntimeError('complete ordered M1-M8 control mapping required') stages = [('baseline', [], 0, expected, b'')] stages += [(m, ['--mutant', m], 1, b'', carrier) for m, carrier in failures.items()] stages += [('M99', ['--mutant', 'M99'], 2, b'', b'unknown mutant label\n')] diff --git a/reviews/soft_fold_protocol_20261006/SCOPE.md b/reviews/soft_fold_protocol_20261006/SCOPE.md index fa6b59b7d..fd026eeba 100644 --- a/reviews/soft_fold_protocol_20261006/SCOPE.md +++ b/reviews/soft_fold_protocol_20261006/SCOPE.md @@ -50,8 +50,8 @@ workflow is removed from the final proposed tree, retained only in history. ## Repair and preservation -Only the existing inline process loop changes behavior. Require the exact ordered -list M1-M8 before children; construct the fixed20-command inventory; compare each +Only the existing inline process loop changes behavior. Require the exact native +ordered M1-M8 control mapping before children; construct the fixed20-command inventory; compare each actual exit/stdout/stderr tuple with its independently measured complete contract. The baseline retains byte-exact RESULTS and now requires empty stderr. Mutants and M99 require empty stdout and their entire stderr, including the newline. @@ -76,13 +76,13 @@ separate complete repository discovery on the actual candidate. Actual CPython3.13.5/Git2.47.3; nine unittest methods,147 distinct committed real-Git whole-shell scenarios. Full uninterrupted original command:111 intended assertion -failures,0 errors (130.091s). Breakdown:96 named-mutant false admissions,2 baseline +failures,0 errors (132.243s). Breakdown:96 named-mutant false admissions,2 baseline stderr false admissions,8 unknown-label false admissions,4 malformed-inventory admissions,1 missing-wiring assertion. One valid admission and36 correct rejecting controls remain. The original executes2504 child commands. The unchanged final test file runs against the repaired workflow:9/9 methods, -147/147 expected outcomes in EACH normal/optimized outer mode (68.303s/68.144s). +147/147 expected outcomes in EACH normal/optimized outer mode (65.548s/65.565s). Each has one valid admission and146 rejections,1444 actual children. No skipped or partitioned cases and no subprocess mocks. Across the three completed runs: 441 fixture records,882 raw shell streams and5392 child invocations. These are @@ -104,6 +104,36 @@ current ref54c6759e8434846941eb5218601dfef69c2c9d98 and source blob head/path/blob fallback was not exercised by that observation. The final dedicated workflow must supply its own actual full-packet candidate execution. +## Required author correction after the first candidate failed + +Initial published head77b1b76f1c0b4a62e2359e83903c7b86a0c0db53 had a wrong +list-only inventory assumption, mirrored in its synthetic fixtures. Actual +SOURCES.json blob37b8a38a42a2dddbc4b2fdfdbae3a9cd4e28d7a6 stores an ordered +object: M1:F1,M2:F2,M3:F3,M4:F4,M5:F5,M6:F6,M7:F4,M8:F7. The observation +loop had correctly expanded its keys, but the first implementation wrongly +required a list. Dedicated37466840210/1/job112279898907 therefore failed +at that inventory check BEFORE any genuine checker invocation, after its +complete focused suites passed74.486s/73.334s and source preflight succeeded. +This is an author implementation/fixture error, not runner failure or a false +scientific result. Original failed execution is retained in370/6016816642. + +The positive fixture was corrected FIRST to the native object. Its valid-case +test then produced exactly one intended assertion failure and zero errors in +each mode against77b1. Only afterwards the matcher was corrected to validate +the exact dictionary type, key order AND all control values. Missing/reordered +mappings, duplicate-label lists and wrong value types remain rejecting controls. +The original scientific manifest was not edited. The complete147-case local +results above are the successor mapping-based tests, not the older list-fixture +results. The same147 keys and nine methods are retained, with four fixture +construction lines corrected. All earlier list-fixture executions and original +failed CI remain separate historical evidence; none is overwritten as success. + +The correction changes only the inventory predicate/fixed native mapping, the +fixture's native inventory construction and this scope record. Full failure +carriers, source preflight, postflight and all scientific bytes stay unchanged. +An original review of77b1 cannot be represented as final successor review. The +corrected source requires its own applicable fresh CI and exact-source review. + ## Review and integration boundary This is engineering validation, not the proof of FL, numerical certification, diff --git a/tests/test_soft_fold_workflow.py b/tests/test_soft_fold_workflow.py index 98d394d66..cc23e4fb2 100644 --- a/tests/test_soft_fold_workflow.py +++ b/tests/test_soft_fold_workflow.py @@ -14,6 +14,7 @@ WORKFLOW = ROOT / '.github/workflows/soft-fold-limit.yml' PACKET = 'frontiers/soft_fold_limit_20261002' MUTANTS = tuple('M' + str(i) for i in range(1, 9)) +INVENTORY = dict(zip(MUTANTS, ('F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F4', 'F7'))) STAGES = ('baseline', *MUTANTS, 'M99') ORDER = [[mode, stage] for mode in (0, 1) for stage in STAGES] # Independent reference carriers from original hosted job112272450916. @@ -103,7 +104,7 @@ def run_case(self, case='valid', stage='baseline', mode=0, guard=None): script.write_text(synthetic_checker(), encoding='utf-8') (packet / 'RESULTS.json').write_bytes(BASELINE) manifest = {'files': [file_identity(p.name, p.read_bytes()) for p in sorted(packet.iterdir())], - 'mutants': list(MUTANTS), 'consumed': [], 'cited_only': [], + 'mutants': dict(INVENTORY), 'consumed': [], 'cited_only': [], 'consumed_unmerged': [], 'cited_unmerged': []} for kind in ('consumed', 'cited_only'): name = kind + '.txt' @@ -151,8 +152,8 @@ def git(*args): git('rm', '--cached', 'consumed.txt') git('commit', '-qm', 'untracked consumed file') elif guard and guard.startswith('inventory-'): - variants = {'inventory-missing': list(MUTANTS[:-1]), - 'inventory-order': list(reversed(MUTANTS)), + variants = {'inventory-missing': {m: INVENTORY[m] for m in MUTANTS[:-1]}, + 'inventory-order': {m: INVENTORY[m] for m in reversed(MUTANTS)}, 'inventory-duplicate': [*MUTANTS, 'M8'], 'inventory-object': dict.fromkeys(MUTANTS, 1)} manifest['mutants'] = variants[guard] From f8ef14235d9f6ebb71c54a1bd7359fa7f3ef768a Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 06:52:53 -0700 Subject: [PATCH 04/24] Third-order replay: authenticate complete child reports and exact mutant inventory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dylan Roy — delegated AI engineering. Actual author OpenAI / GPT-6 Astra Pro, pr349-followthrough-third-order-protocol-20261006-r4; Math-#322 pickup6017164236. Scientific effect NONE; organizational-independence credit0. Three-file test-first repair. Original numerical/proof/RESULTS/SOURCES/dependencies and 7056-byte source preflight/137-byte postflight are preserved. Full146-case suites pass in both Python modes; exact predecessor yields98 intended failures/mode. Separate nonauthor source review, fresh applicable hosted execution and nonauthor/nonreader guarded integration remain required; no self-merge. --- .github/workflows/third-order-rate.yml | 71 ++++- .../third_order_protocol_20261006/SCOPE.md | 132 ++++++++ tests/test_third_order_rate_workflow.py | 300 ++++++++++++++++++ 3 files changed, 493 insertions(+), 10 deletions(-) create mode 100644 reviews/third_order_protocol_20261006/SCOPE.md create mode 100644 tests/test_third_order_rate_workflow.py diff --git a/.github/workflows/third-order-rate.yml b/.github/workflows/third-order-rate.yml index 85859c3ca..2c89975d8 100644 --- a/.github/workflows/third-order-rate.yml +++ b/.github/workflows/third-order-rate.yml @@ -5,6 +5,7 @@ name: Third-order rate 3/7 exact controls paths: - 'frontiers/third_order_rate_20261001/**' - '.github/workflows/third-order-rate.yml' + - 'tests/test_third_order_rate_workflow.py' # bound merged sources (consumed in SOURCES.json) and the pinned unmerged dependencies - 'frontiers/three_fronts_20260924/LIFETIME_REMAINDER.md' - 'imports/lifetime_parent_20260925/UNIFORM_MATRIX_CAP_AND_LIFETIME.md' @@ -37,6 +38,13 @@ jobs: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Verify complete child contracts in both Python modes + env: + PYTHONDONTWRITEBYTECODE: '1' + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -p test_third_order_rate_workflow.py -v + python -B -O -S -m unittest discover -s tests -p test_third_order_rate_workflow.py -v - name: Verify sources, replay both modes, reject mutants env: PYTHONDONTWRITEBYTECODE: '1' @@ -142,19 +150,62 @@ jobs: now = current(entry) if kind == 'consumed_unmerged' else None print(json.dumps({kind + '_bound': entry['path'], 'git_blob': entry['git_blob'], 'head': entry['head'], 'via': where, 'current_ref_checked': now})) + # Complete typed JSON fingerprints measured from unchanged r37_check.py + # d521770d56d7c59604a949645332820091d69b8e in both Python modes. + # Fixed expectations, never learned from the child executing in this job. + mutants = ['M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8'] + if manifest.get('mutants') != mutants: + raise ValueError('third-order mutant inventory differs from the exact contract') + report_sha256 = { + 'M1': '1c8ee21898e24815a92e25d857eb9ebd1e37e986c2b8e05cde8c517fc85fd783', + 'M2': 'ca947f31b05b42df18711d83ae41b093f0364518daaa05197cc12e2f19139ed4', + 'M3': '1cd08221647a8e4d09103ac4f062041fa87a986a34600d9833389e373d9d3b91', + 'M4': 'ccb57cb465ef6fc3eddddc44152563d8cd60fad742cc58fc6c44b4fe6fca2f82', + 'M5': '359b1200abec0231f68302fb88c62d4df026e4a28fc94e176aada0959a21bc53', + 'M6': '6ef4e23a74fd63529b3482c634626f2cf32529c099ed717bee3556345b29bfc8', + 'M7': 'c18c8977019114dce23b6659d3d82e881bbaafa9c2ddcca2f09de1f67dba8340', + 'M8': '2b6da63037130a77ab2bd87d520b2b724dc28653001d01ee006f829e3ca8b682', + } + def unique_fields(pairs): + result = {} + for key, value in pairs: + if key in result: + raise ValueError('duplicate third-order report field: ' + key) + result[key] = value + return result + + def invalid_number(value): + raise ValueError('floating/nonfinite third-order report number: ' + value) + + def report_digest(raw): + value = json.loads(raw.decode('utf-8'), object_pairs_hook=unique_fields, + parse_float=invalid_number, parse_constant=invalid_number) + canonical = json.dumps(value, sort_keys=True, separators=(',', ':'), + ensure_ascii=False, allow_nan=False).encode('utf-8') + return hashlib.sha256(canonical).hexdigest() + script = str(root / 'r37_check.py') expected = (root / 'RESULTS.json').read_bytes() 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 manifest['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') - rc = subprocess.run([sys.executable, *flags, script, '--mutant', 'M9'], capture_output=True, timeout=600).returncode - if rc != 2: - raise RuntimeError('unknown mutant label not rejected with exit 2') + for mutant in (None, *mutants, 'M9'): + args = [sys.executable, *flags, script] + if mutant is not None: + args.extend(['--mutant', mutant]) + process = subprocess.run(args, capture_output=True, timeout=600) + if mutant is None: + valid = process.returncode == 0 and not process.stderr and process.stdout == expected + elif mutant == 'M9': + valid = (process.returncode == 2 and process.stdout == b'' + and process.stderr == b'unknown mutant label\n') + else: + valid = (process.returncode == 1 and not process.stderr + and report_digest(process.stdout) == report_sha256[mutant]) + if not valid: + raise RuntimeError('third-order child contract mismatch: ' + str(mutant)) + print(json.dumps({'flags': flags, 'mutant': mutant, 'returncode': process.returncode, + 'stdout_sha256': hashlib.sha256(process.stdout).hexdigest(), + 'stderr_sha256': hashlib.sha256(process.stderr).hexdigest(), + 'scientific_effect': 'NONE'}, sort_keys=True)) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code diff --git a/reviews/third_order_protocol_20261006/SCOPE.md b/reviews/third_order_protocol_20261006/SCOPE.md new file mode 100644 index 000000000..2c889ab65 --- /dev/null +++ b/reviews/third_order_protocol_20261006/SCOPE.md @@ -0,0 +1,132 @@ +# Third-order rate workflow: complete child-result contracts + +Dylan Roy — delegated AI engineering. Author/executor: OpenAI / GPT-6 Astra Pro, +`pr349-followthrough-third-order-protocol-20261006-r4`, Math-#322 pickup6017164236. +Scientific effect NONE; source/report exposed; organizational-independence credit0. +No author self-merge. This repairs execution validation, not a mathematical proof. + +## Frozen predecessor and exact scope + +Source cut: `37bd017be7b1a48455fe651977fedc5b7105d188`. + +| Source | Bytes | Git blob | +|---|---:|---| +| .github/workflows/third-order-rate.yml |9922|85859c3ca46faf9b6302427de28aa488e1e13aee| +| frontiers/third_order_rate_20261001/r37_check.py |19191|d521770d56d7c59604a949645332820091d69b8e| +| frontiers/third_order_rate_20261001/RESULTS.json |2234|8a2921cfb82deb8962bd45923ba7559401f020e7| +| frontiers/third_order_rate_20261001/SOURCES.json |11327|1cccc27e4aea99a2a861bc32ebb556eba4a2408e| + +The original workflow accepts named mutants solely by exit1, unknown M9 solely +by exit2, and ignores baseline stderr. The earlier #322 list identified this +path as a candidate; this work supplies its specific executable counterexample +and repair. No scientific packet, proof, original checker, RESULTS, source map, +formal source, theorem annotation, dependency or scientific register changes. + +Only the existing workflow, one new root regression, and this scope are changed. +The 7056-byte original dependency/packet preflight and 137-byte final report/Git +postflight remain byte-identical. The tracked-tree regular-file, source hash, +commit/path/blob API, live dependency-PR drift and untracked-path guards are +retained without alteration. Action pins, Python3.11.16, read-only permissions, +600-second numerical-child and10-minute job budgets are unchanged. + +## Original checker characterization + +Twenty actual native commands completed under local CPython3.13.5: baseline, +M1–M8 and M9 in each normal/optimized Python mode. All ten mode-paired stdout AND +stderr streams are byte-identical. Baseline exactly matches the native RESULTS +blob/SHA256 `7f877f034baaa5b7c8a879a76dd2b825e57869478fdc396897cde1da9bf10ade`. +Named mutants exit1 with empty stderr and full JSON. M9 exits2 with empty stdout +and exactly `unknown mutant label` followed by one LF on stderr. + +| Mutant | Failed check; other checks remain present | +|---|---| +| M1, M2, M6, M8 |R1_exponent_ledger (four different complete reports)| +| M3 |R2_lemma_L (also changes equality_instances to41)| +| M4 |R3_refined_B4| +| M5 |R4_typed_window| +| M7 |R6_C_plus_CE_plus_bookkeeping| + +The repair compares the entire report, not just that failed-check column. +Its eight fixed canonical JSON SHA256 values were measured from the authenticated +unchanged checker before implementation and cross-checked in both modes. They +are not learned from a currently running child. Duplicate keys, floating or +nonfinite numbers, extra/missing/type-confused fields, trailing JSON, wrong +mutant/reason/info and unrelated failures reject. JSON whitespace and key order +are semantically immaterial under canonical serialization. The baseline keeps +its stricter original byte-equality rule and now requires empty stderr. Every +named output also requires empty stderr and exit1; M9 requires its complete +three-part exit/stdout/stderr contract. Manifest mutants must equal the exact +ordered M1–M8 list before the first child. No predicate relies on Python assert. + +The verifier prints each successfully validated child's original stream hashes +and exit; it stops at the first invalid result. Timeout/spawn failures propagate +rather than being mistaken for intended rejection. It is not a hostile-child +sandbox: a malicious executable can print the expected report. Source identity, +process output, mathematical validity and independent alignment remain distinct. +Output-memory/durable-artifact/process-group guarantees are not introduced. + +## Test-first whole-shell evidence + +The same final ten-method test source was run against the exact original and +repaired workflow in BOTH outer Python modes. Each completed suite runs146 +isolated real Git/Bash/Python shell scenarios; no subprocess is mocked. Each +fixture retains a nonempty consumed and cited tracked source, coherent packet +hashes, all20 ordered child slots and final Git-diff validation. Actual children +are synthetic carriers for independently fixed native reports, not numerical +proof computations. Four independent fixtures may execute concurrently; they +share no repo, HOME, trace or process environment. Assertion evaluation remains +in the parent test thread. Optional evidence output is outside fixture repos. + +Predecessor: **98 intended assertion failures, zero test errors, each mode**: +94 undesired report admissions, three incomplete/reordered/duplicate mutant +inventories, and one missing regression-wiring assertion. These are finite +protocol counterexamples, not98 independent mathematical defects. Seventeen +valid/formatting cases and the inherited rejecting exit/source/postflight +controls retain their intended outcomes. + +Candidate: **10/10 methods,146/146 expected outcomes each mode**, no failures, +errors or skips. Seventeen valid/formatting admissions and129 rejections. All +failed targets stop at the precise ordered prefix; preflight guards run before +children and dirty-tree rejection occurs after all20. Full normal/optimized +suite elapsed times were50.490s/41.571s including launch. The two completed +predecessor calls took79.245s/84.323s. Four completed suites retain584 scenario +records,1168 raw shell streams and8144 child trace entries. These counts overlap +and do not represent independent proofs. + +A separate execution of the exact repaired numerical-loop slice ran all20 +GENUINE original checker commands again. Every exit and stdout/stderr hash +matches the pre-repair characterization; final acceptance annotation stays +false. That execution deliberately does not claim the original dependency/API +preflight ran locally. Fresh hosted full workflow execution is still required. + +An initial sequential full-suite tool call stopped after17 completed cases; +there is no final suite summary, and it is excluded. A streaming-execution tool +attempt was unavailable and launched nothing. The independent fixtures were +parallelized without removing any case or weakening a product timeout. Final +complete paired runs use identical test bytes. Initial partial records and the +local execution-driver histories remain in the owner's evidence delivery. + +## Reproduction and integration boundary + +```sh +python -B -S -m unittest discover -s tests -p test_third_order_rate_workflow.py -v +python -B -O -S -m unittest discover -s tests -p test_third_order_rate_workflow.py -v +``` + +The new root-test path triggers the dedicated workflow, which runs both commands +unconditionally before its original verification step. There is no new imported +helper/package-resolution dependency. Local development used an authenticated +selected-source repository after direct GitHub DNS failed, not a full upstream +checkout. The local whole-shell fixtures cover merged-source preflights, not +successful live API retrieval; that code is byte-preserved and the hosted job +must supply its own full-source/current-runtime evidence. No local Lean or new +whole-mathematics review is claimed. + +Source remains frozen for one actual nonauthor engineering read. Required scope: +exact reports and canonical parser, whole original/new shell and source guard +preservation, meaningful counterfactual outcomes and actual hosted bindings. +A distinct eligible nonauthor/nonreader integrator must later reconcile live +refs/queue/full diff/reviews/threads/dependencies and every applicable check, +use ordinary expected-head merge, and read back the landed tree/push evidence. +This author will not merge. #322 remains open for its broader affected class; +#312, soft-fold, equal-height, factorial budget and all other owners keep scope. diff --git a/tests/test_third_order_rate_workflow.py b/tests/test_third_order_rate_workflow.py new file mode 100644 index 000000000..bd73275e0 --- /dev/null +++ b/tests/test_third_order_rate_workflow.py @@ -0,0 +1,300 @@ +"""Whole original verification shell, real Git/Bash/Python; numerical child is a fixture. + +Frozen report deltas were measured from unchanged checker d521770d at37bd017b +in both Python modes BEFORE the repair. They are not learned from a test child. +Successful remote API retrieval is not simulated or claimed by this suite; +all original remote source checks remain in the executed shell unchanged. +""" +from pathlib import Path +import copy +from concurrent.futures import ThreadPoolExecutor +import threading +import hashlib +import json +import os +import shutil +import subprocess +import sys +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +WORKFLOW = ROOT / '.github/workflows/third-order-rate.yml' +PACKET = 'frontiers/third_order_rate_20261001' +MUTANTS = tuple('M'+str(i) for i in range(1, 9)) +SEQUENCE = [(mode, m) for mode in (0, 1) for m in ('baseline', *MUTANTS, 'M9')] +BASELINE_SHA = '7f877f034baaa5b7c8a879a76dd2b825e57869478fdc396897cde1da9bf10ade' +# None below deletes the sole obsolete M2 exponent entry; no native delta sets null. +DELTAS = {'M1': [(('checks', 'R1_exponent_ledger', 'candidate_least'), '4/11'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'F: l rho_f^-2 (finite part)'), '5/11'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'F: rho_f^2'), '6/11'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'F: rho_f^5/l (Lemma F layer)'), '4/11'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: Lemma C+ r^1 kappa^1'), '5/11'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: rho_f^5/l (Lemma O tail)'), '4/11'), + (('checks', 'R1_exponent_ledger', 'elder_least'), '4/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'F: l rho_f^-2 (finite part)'), '5/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'F: rho_f^2'), '6/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'F: rho_f^5/l (Lemma F layer)'), '4/11'), + (('checks', + 'R1_exponent_ledger', + 'elder_terms', + 'F: rho_f^5/l (rejected fold mass, [C7-K] (K2))'), + '4/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'K: Lemma CE+ r^1 kappa^1'), '5/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'K: Lemma CE+ r^2 kappa^3'), '6/11'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'K: Lemma CE+ r^3/2 kappa^2'), '1/2'), + (('checks', 'R1_exponent_ledger', 'elder_terms', "K: rho_f^5/l (Lemma O/O' tail)"), '4/11'), + (('checks', 'R1_exponent_ledger', 'passed'), False), + (('checks', 'R1_exponent_ledger', 'rho_f'), 'l^3/11'), + (('mutant',), 'M1'), + (('passed',), False)], + 'M2': [(('checks', 'R1_exponent_ledger', 'candidate_least'), '2/7'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: Lemma C+ r^1 kappa^1'), None), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: Lemma C+ r^1 kappa^2'), '2/7'), + (('checks', 'R1_exponent_ledger', 'passed'), False), + (('checks', 'R1_exponent_ledger', 'remark1_maxmin', 'drop_linear_cand'), '4/11'), + (('mutant',), 'M2'), + (('passed',), False)], + 'M3': [(('checks', 'R2_lemma_L', 'equality_instances'), 41), + (('checks', 'R2_lemma_L', 'passed'), False), + (('mutant',), 'M3'), + (('passed',), False)], + 'M4': [(('checks', 'R3_refined_B4', 'passed'), False), (('mutant',), 'M4'), (('passed',), False)], + 'M5': [(('checks', 'R4_typed_window', 'passed'), False), (('mutant',), 'M5'), (('passed',), False)], + 'M6': [(('checks', 'R1_exponent_ledger', 'a'), 'l^2/15'), + (('checks', 'R1_exponent_ledger', 'elder_least'), '2/5'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'I: [a,r0*] l^(2/3) a^-2'), '2/5'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'I: [a,r0*] l^(5/3) a^-7'), '11/15'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'I: [rho_c,a] a^4 (log)'), '8/15'), + (('checks', 'R1_exponent_ledger', 'intermediate_least'), '2/5'), + (('checks', 'R1_exponent_ledger', 'passed'), False), + (('mutant',), 'M6'), + (('passed',), False)], + 'M7': [(('checks', 'R6_C_plus_CE_plus_bookkeeping', 'passed'), False), + (('mutant',), 'M7'), + (('passed',), False)], + 'M8': [(('checks', 'R1_exponent_ledger', 'candidate_least'), '1/4'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'J2: rho_c^3'), '3/4'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'J3: l rho_c^-2'), '1/2'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'J3: l^2 rho_c^-7'), '1/4'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'J4: l^2 rho_c^-7'), '1/4'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: Lemma C+ r^1 kappa^0'), '1/2'), + (('checks', 'R1_exponent_ledger', 'candidate_terms', 'K: l^2 rho_c^-7 (upper tail)'), '1/4'), + (('checks', 'R1_exponent_ledger', 'elder_least'), '1/4'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'I: [rho_c,a] l^3 rho_c^-11 (log)'), '1/4'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'J4: l^2 rho_c^-7'), '1/4'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'K: Lemma CE+ r^1 kappa^0'), '1/2'), + (('checks', 'R1_exponent_ledger', 'elder_terms', 'K: l^2 rho_c^-7 (upper tail)'), '1/4'), + (('checks', 'R1_exponent_ledger', 'hypotheses'), False), + (('checks', 'R1_exponent_ledger', 'intermediate_least'), '1/4'), + (('checks', 'R1_exponent_ledger', 'passed'), False), + (('checks', 'R1_exponent_ledger', 'rho_c'), 'l^1/4'), + (('mutant',), 'M8'), + (('passed',), False)]} + + +def identity(path, raw): + return dict(path=path, bytes=len(raw), sha256=hashlib.sha256(raw).hexdigest(), + git_blob=hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()) + + +def native_reports(): + raw = (ROOT/PACKET/'RESULTS.json').read_bytes() + if hashlib.sha256(raw).hexdigest() != BASELINE_SHA: + raise ValueError('test reference baseline changed') + baseline = json.loads(raw) + reports = {'baseline': raw.decode()} + for name, changes in DELTAS.items(): + obj = copy.deepcopy(baseline) + for keys, value in changes: + node = obj + for key in keys[:-1]: + node = node[key] + if value is None: + del node[keys[-1]] + else: + node[keys[-1]] = value + reports[name] = json.dumps(obj, indent=1, sort_keys=True)+'\n' + return reports + + +def verification_shell(): + # Deliberately restricted to this workflow's uniquely named literal run block. + text = WORKFLOW.read_text() + name = ' - name: Verify sources, replay both modes, reject mutants\n' + if text.count(name) != 1: + raise ValueError('verification step not unique') + tail = text.split(name, 1)[1] + block = tail.split(' run: |\n', 1)[1] + return ''.join(line[10:] if line.startswith(' ') else line + for line in block.splitlines(keepends=True)) + + +def fixture_script(reports): + return ('import os,sys,json\nfrom pathlib import Path\nREPORTS = '+repr(reports)+'\n'+r""" +m = sys.argv[2] if len(sys.argv)>2 else 'baseline' +mode = int(sys.flags.optimize) +with open(os.environ['TRACE'], 'a') as f: + f.write(json.dumps([mode,m])+'\n') +out = b'' if m == 'M9' else REPORTS[m].encode() +err = b'unknown mutant label\n' if m == 'M9' else b'' +rc = 2 if m == 'M9' else (0 if m == 'baseline' else 1) +case = os.environ['CASE'] +if m == os.environ['TARGET'] and mode == int(os.environ['TARGET_MODE']): + if case == 'crash': raise RuntimeError('unrelated synthetic failure') + elif case == 'silence': out = err = b'' + elif case == 'stderr': err += b'unexpected warning\n' + elif case == 'wrong_exit': rc = 0 if m != 'baseline' else 1 + elif case == 'wrong_report': out = REPORTS['M2' if m != 'M2' else 'M1'].encode() + elif case == 'wrong_baseline': out += b' ' + elif case == 'unknown_reason': err = b'wrong failure reason\n' + elif case == 'unknown_stdout': out = b'noise\n' + elif case == 'unknown_exit': rc = 1 + else: + obj = json.loads(out) + if case == 'format': + out = (' \n'+json.dumps(obj,ensure_ascii=False,sort_keys=False)+' \n').encode() + elif case == 'duplicate': out = out.replace(b'"passed": false', b'"passed": false, "passed": false', 1) + elif case == 'trailing': out += b'{}' + elif case == 'nonfinite': out = out.replace(b'"passed": false', b'"passed": NaN', 1) + elif case == 'float': out = out.replace(b'6108', b'6108.0', 1) + elif case == 'int_bool': + obj['passed']=0; out=json.dumps(obj).encode() + elif case == 'missing': + del obj['checks']['R5_W_plus_bookkeeping']; out=json.dumps(obj).encode() + elif case == 'extra': + obj['extra']=True; out=json.dumps(obj).encode() + elif case == 'wrong_info': + obj['checks']['R2_lemma_L']['instances']+=1; out=json.dumps(obj).encode() + elif case == 'wrong_mutant': + obj['mutant']='M8'; out=json.dumps(obj).encode() + elif case == 'not_json': out=b'FAILED some other check\n' +if case == 'dirty' and mode==1 and m=='M9': + Path('consumed.txt').write_text('changed after preflight\n') +sys.stdout.buffer.write(out);sys.stderr.buffer.write(err);sys.exit(rc) +""") + + +class ThirdOrderProtocolTests(unittest.TestCase): + counter = 0 + evidence_lock = threading.Lock() + + def run_case(self, case='valid', target='M1', mode=0, guard=None): + with tempfile.TemporaryDirectory(prefix='third-order-test-') as tmp: + home=Path(tmp);repo=home/'repo';repo.mkdir();packet=repo/PACKET;packet.mkdir(parents=True) + reports=native_reports() + (packet/'r37_check.py').write_text(fixture_script(reports)) + (packet/'RESULTS.json').write_text(reports['baseline']) + for name in ('consumed.txt','cited.txt'): + (repo/name).write_text('fixed '+name+'\n') + manifest={'files':[identity(p.name,p.read_bytes()) for p in sorted(packet.iterdir())], + 'mutants':list(MUTANTS),'consumed':[identity('consumed.txt',(repo/'consumed.txt').read_bytes())], + 'cited_only':[identity('cited.txt',(repo/'cited.txt').read_bytes())], + 'consumed_unmerged':[],'cited_unmerged':[]} + if guard=='missing_mutant': manifest['mutants'].pop() + if guard=='duplicate_mutant': manifest['mutants'].append('M1') + if guard=='reordered_mutant': manifest['mutants'].reverse() + (packet/'SOURCES.json').write_text(json.dumps(manifest)) + env={k:v for k,v in os.environ.items() if not k.startswith('GIT_')} + env.update(HOME=str(home),XDG_CONFIG_HOME=str(home/'xdg'),GIT_CONFIG_NOSYSTEM='1', + PYTHONDONTWRITEBYTECODE='1',GH_TOKEN='synthetic-no-network-token', + GH_REPOSITORY='fixture/repo',TRACE=str(home/'trace'),CASE=case, + TARGET=target,TARGET_MODE=str(mode)) + for cmd in (['git','init','-q'],['git','add','.'], + ['git','-c','user.name=Fixture','-c','user.email=f@example.invalid', + '-c','commit.gpgsign=false','commit','-qm','fixture']): + subprocess.run(cmd,cwd=repo,env=env,capture_output=True,check=True,timeout=15) + if guard=='packet_tamper': (packet/'r37_check.py').write_text('# changed\n') + if guard=='packet_missing': (packet/'RESULTS.json').unlink() + if guard=='packet_extra': (packet/'extra.txt').write_text('extra') + if guard=='packet_symlink': + (packet/'r37_check.py').rename(home/'saved.py');(packet/'r37_check.py').symlink_to(home/'saved.py') + if guard=='consumed_tamper': (repo/'consumed.txt').write_text('changed') + if guard=='cited_missing': (repo/'cited.txt').unlink() + if guard=='cited_symlink': + (repo/'cited.txt').rename(home/'saved.txt');(repo/'cited.txt').symlink_to(home/'saved.txt') + shell=verification_shell() + result=subprocess.run(['bash','-c',shell],cwd=repo,env=env,capture_output=True,timeout=45) + trace=[tuple(json.loads(s)) for s in (home/'trace').read_text().splitlines()] if (home/'trace').exists() else [] + # Optional external evidence is never committed or used to choose an expectation. + destination=os.environ.get('THIRD_ORDER_TEST_EVIDENCE') + if destination: + folder=Path(destination);folder.mkdir(parents=True,exist_ok=True) + with type(self).evidence_lock: + type(self).counter+=1;stem=f'{type(self).counter:04d}' + meta={'case':case,'target':target,'mode':mode,'guard':guard, + 'returncode':result.returncode,'trace':trace, + 'stdout_sha256':hashlib.sha256(result.stdout).hexdigest(), + 'stderr_sha256':hashlib.sha256(result.stderr).hexdigest()} + for suffix,raw in [('json',(json.dumps(meta,sort_keys=True)+'\n').encode()), + ('stdout',result.stdout),('stderr',result.stderr)]: + with (folder/f'{stem}.{suffix}').open('xb') as f:f.write(raw) + return result,trace + + def check_cases(self, cases): + # Each case owns its repo, HOME, process environment and external trace. + # Parallelism changes only fixture scheduling, not any verifier command. + with ThreadPoolExecutor(max_workers=4) as pool: + executions = list(pool.map(lambda c: self.run_case(*c[:3]), cases)) + for (case,target,mode,valid), (p,trace) in zip(cases,executions): + with self.subTest(case=case,target=target,mode=mode): + self.assertEqual(p.returncode,0 if valid else 1,(case,target,mode,p.stderr)) + expected=SEQUENCE if valid else SEQUENCE[:SEQUENCE.index((mode,target))+1] + self.assertEqual(trace,expected,(case,target,mode)) + if valid: + self.assertIn(b'"mathematical_acceptance": false',p.stdout) + self.assertEqual(p.stderr,b'') + + def test_valid_and_formatting(self): + self.check_cases([('valid','M1',0,True)]+[ + ('format',target,mode,True) for mode in (0,1) for target in MUTANTS]) + + def test_crash_silence_wrong_report_each_mutant(self): + self.check_cases([(case,target,mode,False) for mode in (0,1) + for target in MUTANTS for case in ('crash','silence','wrong_report')]) + + def test_stderr_and_exit_each_mutant(self): + self.check_cases([(case,target,mode,False) for mode in (0,1) + for target in MUTANTS for case in ('stderr','wrong_exit')]) + + def test_complete_typed_report_and_json(self): + self.check_cases([(case,'M1',mode,False) for mode in (0,1) + for case in ('duplicate','trailing','nonfinite','float','int_bool', + 'missing','extra','wrong_info','wrong_mutant','not_json')]) + + def test_baseline_exact_exit_stdout_and_stderr(self): + self.check_cases([(case,'baseline',mode,False) for mode in (0,1) + for case in ('stderr','wrong_exit','wrong_baseline','silence')]) + + def test_unknown_exact_contract(self): + self.check_cases([(case,'M9',mode,False) for mode in (0,1) + for case in ('silence','unknown_reason','unknown_stdout','unknown_exit','stderr')]) + + def test_source_guards_before_children(self): + for guard in ('packet_tamper','packet_missing','packet_extra','packet_symlink', + 'consumed_tamper','cited_missing','cited_symlink'): + with self.subTest(guard=guard): + p,trace=self.run_case(guard=guard) + self.assertEqual(p.returncode,1);self.assertEqual(trace,[]) + self.assertNotIn(b'"mathematical_acceptance": false',p.stdout) + + def test_exact_mutant_inventory_before_children(self): + for guard in ('missing_mutant','duplicate_mutant','reordered_mutant'): + with self.subTest(guard=guard): + p,trace=self.run_case(guard=guard) + self.assertEqual(p.returncode,1);self.assertEqual(trace,[]) + + def test_postflight_mutation_is_rejected(self): + p,trace=self.run_case('dirty') + self.assertEqual(p.returncode,1);self.assertEqual(trace,SEQUENCE) + self.assertIn(b'diff --git',p.stdout) + + def test_unconditional_two_mode_wiring(self): + text=WORKFLOW.read_text() + self.assertIn(" - 'tests/test_third_order_rate_workflow.py'",text) + for flags in ('-B -S','-B -O -S'): + self.assertIn('python '+flags+' -m unittest discover -s tests -p test_third_order_rate_workflow.py -v',text) + + +if __name__=='__main__': + unittest.main() From 268156ab71fa6bbada01b1e2c21c5c0f51b7d94b Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:18:10 -0700 Subject: [PATCH 05/24] LM006: add source-bound one-dimensional coefficient replay Three engineering files only: replay driver, focused controls and dedicated workflow for the frozen PR380 1024-panel certificate. No proof, result, scientific register, Lean source or parent packet changes. Scientific effect NONE. --- .github/workflows/lm006-oned-coefficient.yml | 60 +++++++++ tests/test_lm006_oned_coefficient_replay.py | 130 +++++++++++++++++++ tools/lm006_oned_coefficient_replay.py | 127 ++++++++++++++++++ 3 files changed, 317 insertions(+) create mode 100644 .github/workflows/lm006-oned-coefficient.yml create mode 100644 tests/test_lm006_oned_coefficient_replay.py create mode 100644 tools/lm006_oned_coefficient_replay.py diff --git a/.github/workflows/lm006-oned-coefficient.yml b/.github/workflows/lm006-oned-coefficient.yml new file mode 100644 index 000000000..2f0fa91e6 --- /dev/null +++ b/.github/workflows/lm006-oned-coefficient.yml @@ -0,0 +1,60 @@ +name: LM006 one-dimensional coefficient replay + +'on': + pull_request: + paths: + - 'coefficients/lm006_wrong_sign_oned_20261006_a62c/**' + - 'coefficients/lm006_wrong_sign_20261006_r20/enclose.py' + - 'reviews/lm006_wrong_sign_asymptotic_20261006/NOTE.md' + - 'tools/lm006_oned_coefficient_replay.py' + - 'tests/test_lm006_oned_coefficient_replay.py' + - '.github/workflows/lm006-oned-coefficient.yml' + push: + branches: [main] + paths: + - 'coefficients/lm006_wrong_sign_oned_20261006_a62c/**' + - 'coefficients/lm006_wrong_sign_20261006_r20/enclose.py' + - 'reviews/lm006_wrong_sign_asymptotic_20261006/NOTE.md' + - 'tools/lm006_oned_coefficient_replay.py' + - 'tests/test_lm006_oned_coefficient_replay.py' + - '.github/workflows/lm006-oned-coefficient.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + numerical-replay: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + mode: [normal, optimized] + name: lm006-oned-coefficient (${{ matrix.mode }}) + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + fetch-depth: 1 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.13.5' + - name: Replay controls and frozen 1024-panel certificate + shell: bash + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/lm006-oned-protocol" + FLAGS="-B -S" + if [ "${{ matrix.mode }}" = optimized ]; then FLAGS="-B -O -S"; fi + python $FLAGS -m unittest discover -s tests -p 'test_lm006_oned_coefficient_replay.py' -v 2>&1 | tee "$RUNNER_TEMP/lm006-oned-protocol/${{ matrix.mode }}.log" + python -B -S tools/lm006_oned_coefficient_replay.py --mode "${{ matrix.mode }}" --output "$RUNNER_TEMP/lm006-oned-${{ matrix.mode }}-${{ github.run_attempt }}" + - name: Preserve success or failure evidence + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: lm006-oned-${{ matrix.mode }}-${{ github.run_id }}-${{ github.run_attempt }} + path: | + ${{ runner.temp }}/lm006-oned-${{ matrix.mode }}-${{ github.run_attempt }}/ + ${{ runner.temp }}/lm006-oned-protocol/ + if-no-files-found: error diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py new file mode 100644 index 000000000..98c1b52bf --- /dev/null +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -0,0 +1,130 @@ +"""Execution/custody controls for the frozen PR380 one-dimensional coefficient.""" +import importlib.util, json, os, subprocess, sys, tempfile, time, unittest +from pathlib import Path + +DRIVER=Path(__file__).resolve().parents[1]/'tools/lm006_oned_coefficient_replay.py' + +class ReplayTests(unittest.TestCase): + def setUp(self): + self.assertTrue(DRIVER.is_file(),'replay implementation missing') + spec=importlib.util.spec_from_file_location('oned_replay',DRIVER) + self.m=importlib.util.module_from_spec(spec);spec.loader.exec_module(self.m) + self.tmp=tempfile.TemporaryDirectory();self.addCleanup(self.tmp.cleanup) + self.root=Path(self.tmp.name)/'repo';self.root.mkdir();self.logs=Path(self.tmp.name)/'logs';self.logs.mkdir() + + def fixture(self): + pins={} + for name in self.m.PINS: + p=self.root/name;p.parent.mkdir(parents=True,exist_ok=True);p.write_bytes(('fixture:'+name+'\n').encode()) + pins[name]=self.m.git_blob(p.read_bytes()) + return pins + + def child(self, code, expected=b'ok\n', timeout=3, name='child'): + return self.m.run_step([sys.executable,'-B','-S','-c',code],self.root,self.logs,name,expected,'exact',timeout) + + def test_snapshot_and_exact_packet_membership(self): + pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) + self.assertEqual(set(ids),set(pins)) + extra=self.root/self.m.PACKET/'extra';extra.write_text('x') + with self.assertRaisesRegex(self.m.ReplayError,'packet_membership'): self.m.validate_snapshot(self.root,pins) + + def test_changed_missing_and_symlink_sources_rejected(self): + pins=self.fixture();name=next(iter(pins));p=self.root/name;old=p.read_bytes() + p.write_bytes(old+b'x') + with self.assertRaisesRegex(self.m.ReplayError,'source_identity'): self.m.validate_snapshot(self.root,pins) + p.unlink() + with self.assertRaisesRegex(self.m.ReplayError,'source_missing'): self.m.validate_snapshot(self.root,pins) + p.write_bytes(old); outside=Path(self.tmp.name)/'outside';outside.write_bytes(old);p.unlink();p.symlink_to(outside) + with self.assertRaisesRegex(self.m.ReplayError,'source_symlink'): self.m.validate_snapshot(self.root,pins) + + def test_path_validation(self): + for name in ('../x','/x','a/../b','a//b','a\\b','a/./b',''): + with self.assertRaises(self.m.ReplayError): self.m.source_file(self.root,name) + + def test_success_process_record(self): + row=self.child("print('ok')");self.assertEqual(row['status'],'PASS');self.assertFalse(row['timed_out']) + self.assertEqual((self.logs/'child.stdout').read_bytes(),b'ok\n') + + def test_wrong_exit_output_and_stderr_rejected(self): + cases=[("raise RuntimeError('x')",'unexpected_exit'),('pass','stdout_mismatch'),("print('bad')",'stdout_mismatch'),("import sys;print('ok');print('w',file=sys.stderr)",'unexpected_stderr')] + for i,(code,reason) in enumerate(cases): + with self.assertRaisesRegex(self.m.ReplayError,reason): self.child(code,name='bad'+str(i)) + + def test_timeout_retains_partial_evidence(self): + with self.assertRaisesRegex(self.m.ReplayError,'timeout'): + self.child("import sys,time;print('s',flush=True);print('e',file=sys.stderr,flush=True);time.sleep(10)",timeout=.2) + row=json.loads((self.logs/'child.process.json').read_text());self.assertTrue(row['timed_out']);self.assertEqual(row['failure'],'timeout') + + def test_existing_evidence_not_overwritten(self): + self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") + self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) + + def test_test_report_contract_requires_all_named_passes(self): + good=('\n'.join(n+' (test_oned.OneDimensionalTests.'+n+') ... ok' for n in self.m.TEST_NAMES)+'\n\n'+'-'*70+'\nRan 15 tests in 0.001s\n\nOK\n').encode() + self.m.check_output(b'',good,None,'tests') + for bad in (good.replace(b' ... ok',b' ... FAIL',1),good+b'noise',good.replace(b'Ran 15',b'Ran 0')): + with self.assertRaisesRegex(self.m.ReplayError,'test_report_mismatch'): self.m.check_output(b'',bad,None,'tests') + + def test_exact_output_contract_is_byte_exact(self): + want=b'{"panels":1024,"independently_reviewed":false}\n';self.m.check_output(want,b'',want,'exact') + for bad in (b'',want+b'\n',want.replace(b'false',b'true')): + with self.assertRaisesRegex(self.m.ReplayError,'stdout_mismatch'): self.m.check_output(bad,b'',want,'exact') + + def test_host_identity(self): + h='1'*40;env={'GITHUB_ACTIONS':'true','GITHUB_REPOSITORY':self.m.REPOSITORY,'GITHUB_SHA':h,'GITHUB_RUN_ID':'1','GITHUB_RUN_ATTEMPT':'2'} + self.m.host_identity(h,env) + env['GITHUB_SHA']='2'*40 + with self.assertRaisesRegex(self.m.ReplayError,'host_identity'): self.m.host_identity(h,env) + + def test_invalid_cli(self): + for args in ([],['--mode','bad','--output','x'],['--mode','normal','--output','x','--panels','2048']): + p=subprocess.run([sys.executable,'-B','-S',str(DRIVER),*args],capture_output=True);self.assertEqual(p.returncode,2) + + def test_workflow_contract(self): + wf=DRIVER.parents[1]/'.github/workflows/lm006-oned-coefficient.yml';self.assertTrue(wf.is_file(),'workflow missing') + text=wf.read_text() + for phrase in ('permissions:\n contents: read','fail-fast: false','mode: [normal, optimized]','if: always()',"python-version: '3.13.5'",'persist-credentials: false','if-no-files-found: error'): + self.assertIn(phrase,text) + self.assertNotIn('continue-on-error:',text);self.assertNotIn('pull_request_target:',text) + + + def synthetic_project(self, bad_test=False, output='synthetic', mutate=False): + import shutil + previous=os.environ.get('GITHUB_ACTIONS') + self.addCleanup(lambda: os.environ.pop('GITHUB_ACTIONS',None) if previous is None else os.environ.__setitem__('GITHUB_ACTIONS',previous)) + os.environ['GITHUB_ACTIONS']='false' + pins=self.fixture(); packet=self.root/self.m.PACKET + (packet/'RESULTS.json').write_text('synthetic\n') + methods='\n'.join(' def '+n+'(self): self.assertTrue('+('False' if bad_test and i==0 else 'True')+')' for i,n in enumerate(self.m.TEST_NAMES)) + (packet/'test_oned.py').write_text('import unittest\nclass OneDimensionalTests(unittest.TestCase):\n'+methods+'\n') + suffix="\nfrom pathlib import Path;Path('NOTE.md').write_text('changed')" if mutate else '' + (packet/'oned.py').write_text("import sys\nassert sys.argv[1:]==['--panels','1024']\nprint("+repr(output)+")"+suffix+'\n') + for name in self.m.EXECUTION_FILES: + d=self.root/name;d.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(DRIVER.parents[1]/name,d) + subprocess.run(['git','init','-q'],cwd=self.root,check=True);subprocess.run(['git','add','.'],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','fixture'],cwd=self.root,check=True) + spec=importlib.util.spec_from_file_location('fixture_driver',self.root/self.m.EXECUTION_FILES[0]);mod=importlib.util.module_from_spec(spec);spec.loader.exec_module(mod) + mod.PINS={n:mod.git_blob((self.root/n).read_bytes()) for n in pins} + return mod + + def test_complete_orchestration_real_subprocesses(self): + mod=self.synthetic_project();out=Path(self.tmp.name)/'ok';receipt=mod.execute(self.root,out,'optimized') + self.assertEqual(receipt['status'],'PASS');self.assertEqual(set(receipt['steps']),{'tests','coefficient'});self.assertEqual((out/'coefficient.stdout').read_bytes(),b'synthetic\n') + + def test_failed_tests_stop_before_coefficient(self): + mod=self.synthetic_project(bad_test=True);out=Path(self.tmp.name)/'badtests' + with self.assertRaisesRegex(mod.ReplayError,'unexpected_exit'): mod.execute(self.root,out,'normal') + self.assertFalse((out/'coefficient.stdout').exists());self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + + def test_wrong_output_cannot_pass(self): + mod=self.synthetic_project(output='wrong');out=Path(self.tmp.name)/'wrong' + with self.assertRaisesRegex(mod.ReplayError,'stdout_mismatch'): mod.execute(self.root,out,'normal') + row=json.loads((out/'receipt.json').read_text());self.assertEqual(row['steps']['tests']['record']['status'],'PASS');self.assertEqual(row['steps']['coefficient']['record']['status'],'FAIL') + + def test_postflight_source_drift_rejected(self): + mod=self.synthetic_project(mutate=True);out=Path(self.tmp.name)/'drift' + with self.assertRaisesRegex(mod.ReplayError,'source_identity'): mod.execute(self.root,out,'normal') + self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + +if __name__=='__main__': unittest.main() diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py new file mode 100644 index 000000000..8715ffa31 --- /dev/null +++ b/tools/lm006_oned_coefficient_replay.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +"""Replay the frozen PR380 one-dimensional LM006 coefficient certificate. + +Standard library / POSIX only. Execution/custody interlock, not theorem acceptance. +""" +import argparse, hashlib, json, os, re, signal, subprocess, sys, time +from pathlib import Path, PurePosixPath + +REPOSITORY='d6g8k5htny-coder/Math-' +SOURCE_COMMIT='8fe14358a1ee5d7ef7d7e20520391f62f432fe04' +PACKET='coefficients/lm006_wrong_sign_oned_20261006_a62c' +EXECUTION_FILES=('tools/lm006_oned_coefficient_replay.py','tests/test_lm006_oned_coefficient_replay.py','.github/workflows/lm006-oned-coefficient.yml') +PINS={ + PACKET+'/NOTE.md':'db27645e62bf846835b1daeb6c51f1eb3b417f1e', + PACKET+'/oned.py':'5015dee3a660b67c42ccab13a976626e6e2d02cc', + PACKET+'/test_oned.py':'62e54422726f1caffab62e2e3fe38d297013e52d', + PACKET+'/RESULTS.json':'506833403f2dee91553d1a8dfc6eef6ee5c8faf8', + PACKET+'/SOURCES.json':'a6de8d4113cedf548b17c750da406f8aa6705eb4', + PACKET+'/PRIOR_WORK.md':'1fb9afde1490b8e86c3b1d453f1c16a45b35a352', + 'coefficients/lm006_wrong_sign_20261006_r20/enclose.py':'e680ddb7aa0abd4b6aab2cac6a54c1ff28efc782', + 'reviews/lm006_wrong_sign_asymptotic_20261006/NOTE.md':'ea914c1b8e0b8180b645f3f626e2081ab87700b9'} +DEPENDENCIES=('coefficients/lm006_wrong_sign_20261006_r20/enclose.py','reviews/lm006_wrong_sign_asymptotic_20261006/NOTE.md') +TEST_NAMES=('test_cli', 'test_conditional_formula_against_positive_integral', 'test_error_tail_and_quotient_attachment', 'test_exact_fourth_derivative_algebra', 'test_interval_arithmetic', 'test_invalid_resolution', 'test_low_resolution_is_genuine_enclosure', 'test_nonzero_integrand_and_scaling', 'test_parent_authentication', 'test_product_derivative_identity', 'test_reduction_from_truncated_moments', 'test_simpson_weights_and_error', 'test_tail_exact_series', 'test_tail_is_present_and_small', 'test_tail_sanity_and_domain') +MAX_STREAM_BYTES=4*1024*1024 + +class ReplayError(ValueError): pass + +def require(ok,reason): + if not ok: raise ReplayError(reason) +def sha256(raw): return hashlib.sha256(raw).hexdigest() +def git_blob(raw): return hashlib.sha1(b'blob %d\0'%len(raw)+raw).hexdigest() + +def source_file(root,relative): + require(type(relative) is str and relative and '\\' not in relative and not relative.startswith('/') and all(x not in ('','.','..') for x in relative.split('/')),'unsafe_path') + p=Path(root) + for part in PurePosixPath(relative).parts: + p=p/part; require(not p.is_symlink(),'source_symlink') + require(p.is_file(),'source_missing'); return p + +def validate_snapshot(root,pins=None): + pins=PINS if pins is None else pins; result={} + for name,expected in pins.items(): + raw=source_file(root,name).read_bytes(); actual=git_blob(raw) + require(actual==expected,'source_identity: '+name) + result[name]={'bytes':len(raw),'sha256':sha256(raw),'git_blob':actual} + names=sorted(Path(n).name for n in pins if n.startswith(PACKET+'/')) + require(sorted(p.name for p in (Path(root)/PACKET).iterdir())==names,'packet_membership') + return result + +def check_output(stdout,stderr,expected,kind): + if kind=='tests': + prefix='\n'.join(n+' (test_oned.OneDimensionalTests.'+n+') ... ok' for n in TEST_NAMES).encode() + pattern=re.escape(prefix+b'\n\n'+b'-'*70)+rb'\nRan 15 tests in [0-9]+(?:\.[0-9]+)?s\n\nOK\n' + require(stdout==b'' and re.fullmatch(pattern,stderr) is not None,'test_report_mismatch'); return + require(kind=='exact','unknown_contract'); require(stderr==b'','unexpected_stderr'); require(stdout==expected,'stdout_mismatch') + +def write_json(path,value): + with Path(path).open('x',encoding='utf-8',newline='\n') as f: json.dump(value,f,sort_keys=True,indent=2,allow_nan=False);f.write('\n') + +def run_step(argv,cwd,logs,name,expected,kind,timeout=900): + require(os.name=='posix','posix_required');require(re.fullmatch(r'[a-z][a-z0-9_-]*',name) is not None,'unsafe_step_name') + logs=Path(logs); out=logs/(name+'.stdout');err=logs/(name+'.stderr');proc=logs/(name+'.process.json') + require(not any(p.exists() or p.is_symlink() for p in (out,err,proc)),'step_evidence_exists') + start=time.monotonic_ns();record={'command':list(map(str,argv)),'returncode':None,'timed_out':False,'status':'FAIL','timeout_seconds':timeout};failure=None + with out.open('xb') as so,err.open('xb') as se: + try: + child=subprocess.Popen(argv,cwd=cwd,stdout=so,stderr=se,start_new_session=True,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'}) + try: record['returncode']=child.wait(timeout=timeout) + except subprocess.TimeoutExpired: + record['timed_out']=True;failure='timeout' + try: os.killpg(child.pid,signal.SIGKILL) + except ProcessLookupError: pass + record['returncode']=child.wait(timeout=5) + except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) + record['elapsed_ns']=time.monotonic_ns()-start;sizes=(out.stat().st_size,err.stat().st_size) + if max(sizes)>MAX_STREAM_BYTES: failure=failure or 'output_too_large';record.update(stdout_bytes=sizes[0],stderr_bytes=sizes[1]) + else: + a,b=out.read_bytes(),err.read_bytes();record.update(stdout_bytes=len(a),stderr_bytes=len(b),stdout_sha256=sha256(a),stderr_sha256=sha256(b)) + if failure is None: + try: require(record['returncode']==0,'unexpected_exit');check_output(a,b,expected,kind) + except ReplayError as exc: failure=str(exc) + if failure is None: record['status']='PASS' + else: record['failure']=failure + write_json(proc,record) + if failure is not None: raise ReplayError(failure) + return record + +def git(root,*args): + p=subprocess.run(['git',*args],cwd=root,capture_output=True,timeout=30);require(p.returncode==0,'git_command_failed');return p.stdout.decode('ascii').strip() +def git_head(root): + h=git(root,'rev-parse','HEAD');require(re.fullmatch('[0-9a-f]{40}',h) is not None,'invalid_git_head');return h + +def execution_sources(root,head): + result={} + for name in EXECUTION_FILES: + raw=source_file(root,name).read_bytes();committed=git(root,'rev-parse',head+':'+name);require(committed==git_blob(raw),'execution_source_drift');result[name]={'git_blob':committed,'sha256':sha256(raw),'bytes':len(raw)} + return result + +def host_identity(head,env): + if env.get('GITHUB_ACTIONS')=='true': + require(env.get('GITHUB_REPOSITORY')==REPOSITORY and env.get('GITHUB_SHA')==head,'host_identity') + for k in ('GITHUB_RUN_ID','GITHUB_RUN_ATTEMPT'): require(re.fullmatch('[1-9][0-9]*',env.get(k,'')) is not None,'host_identity') + +def execute(root,output,mode): + root,output=Path(root).resolve(),Path(output).resolve();require(mode in ('normal','optimized'),'invalid_mode');require(not output.is_relative_to(root),'evidence_inside_source');require(not output.exists(),'evidence_exists');output.mkdir(parents=True) + receipt={'schema_version':1,'object':'LM006-ONED-COEFFICIENT-REPLAY','repository':REPOSITORY,'source_commit':SOURCE_COMMIT,'mode':mode,'scientific_acceptance':False,'formal_verification':False,'status':'FAIL','steps':{},'run_id':os.environ.get('GITHUB_RUN_ID'),'run_attempt':os.environ.get('GITHUB_RUN_ATTEMPT'),'event':os.environ.get('GITHUB_EVENT_NAME')} + try: + before=validate_snapshot(root);head=git_head(root);receipt['tested_commit']=head;host_identity(head,os.environ);receipt['execution_sources']=execution_sources(root,head);receipt['sources']=before + require(Path(__file__).resolve()==root/EXECUTION_FILES[0],'driver_location');require(git(root,'status','--porcelain','--untracked-files=no')=='','tracked_source_dirty') + packet=root/PACKET;flags=['-B']+(['-O'] if mode=='optimized' else [])+['-S'] + specs=[('tests',['-m','unittest','test_oned','-v'],None,'tests'),('coefficient',['oned.py','--panels','1024'],(packet/'RESULTS.json').read_bytes(),'exact')] + for name,args,expected,kind in specs: + try: run_step([sys.executable,*flags,*args],packet,output,name,expected,kind) + finally: + p=output/(name+'.process.json') + if p.is_file(): receipt['steps'][name]={'process_sha256':sha256(p.read_bytes()),'record':json.loads(p.read_bytes())} + require(validate_snapshot(root)==before,'source_changed_during_execution');require(execution_sources(root,head)==receipt['execution_sources'],'execution_source_drift');require(git_head(root)==head,'head_changed_during_execution');require(git(root,'status','--porcelain','--untracked-files=no')=='','tracked_source_dirty');receipt['status']='PASS' + except Exception as exc: receipt['failure']=type(exc).__name__+': '+str(exc);raise + finally: write_json(output/'receipt.json',receipt) + return receipt + +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('--root',type=Path,default=Path('.'));p.add_argument('--output',type=Path,required=True);p.add_argument('--mode',choices=('normal','optimized'),required=True);a=p.parse_args() + try: result=execute(a.root,a.output,a.mode) + except Exception as exc: print('LM006_ONED_REPLAY_FAIL: '+type(exc).__name__+': '+str(exc),file=sys.stderr);return 1 + print(json.dumps(result,sort_keys=True,indent=2,allow_nan=False));return 0 +if __name__=='__main__': raise SystemExit(main()) From 6a5aa322d9fdfa3faf5e4699e62f70a38cc162ba Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:27:43 -0700 Subject: [PATCH 06/24] LM006 replay: retain evidence when post-kill wait also times out Handle the secondary TimeoutExpired after SIGKILL and add a deterministic regression ensuring FAIL process evidence and stream digests are still written. No numerical, proof, workflow or scientific-status change. --- tests/test_lm006_oned_coefficient_replay.py | 169 ++++++++++++++++++++ tools/lm006_oned_coefficient_replay.py | 3 +- 2 files changed, 171 insertions(+), 1 deletion(-) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 98c1b52bf..b7eaabb85 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -1,5 +1,6 @@ """Execution/custody controls for the frozen PR380 one-dimensional coefficient.""" import importlib.util, json, os, subprocess, sys, tempfile, time, unittest +from unittest import mock from pathlib import Path DRIVER=Path(__file__).resolve().parents[1]/'tools/lm006_oned_coefficient_replay.py' @@ -55,6 +56,174 @@ def test_timeout_retains_partial_evidence(self): self.child("import sys,time;print('s',flush=True);print('e',file=sys.stderr,flush=True);time.sleep(10)",timeout=.2) row=json.loads((self.logs/'child.process.json').read_text());self.assertTrue(row['timed_out']);self.assertEqual(row['failure'],'timeout') + + def test_secondary_timeout_still_writes_process_record(self): + class Stuck: + pid=424242 + def __init__(self,*args,**kwargs): + kwargs['stdout'].write(b'started\\n');kwargs['stdout'].flush() + kwargs['stderr'].write(b'partial\\n');kwargs['stderr'].flush() + self.calls=0 + def wait(self,timeout=None): + self.calls+=1 + raise subprocess.TimeoutExpired(['fake'],timeout) + with mock.patch.object(self.m.subprocess,'Popen',Stuck), mock.patch.object(self.m.os,'killpg') as kill: + with self.assertRaisesRegex(self.m.ReplayError,'timeout'): + self.m.run_step(['fake'],self.root,self.logs,'stuck',b'','exact',.1) + kill.assert_called_once_with(424242,self.m.signal.SIGKILL) + row=json.loads((self.logs/'stuck.process.json').read_text()) + self.assertEqual((row['status'],row['failure'],row['timed_out'],row['returncode']),('FAIL','timeout',True,None)) + self.assertIn('did not finish',row['detail']) + self.assertEqual((self.logs/'stuck.stdout').read_bytes(),b'started\\n') + self.assertEqual((self.logs/'stuck.stderr').read_bytes(),b'partial\\n') + self.assertRegex(row['stdout_sha256'],'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") + self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) + + def test_test_report_contract_requires_all_named_passes(self): + good=('\n'.join(n+' (test_oned.OneDimensionalTests.'+n+') ... ok' for n in self.m.TEST_NAMES)+'\n\n'+'-'*70+'\nRan 15 tests in 0.001s\n\nOK\n').encode() + self.m.check_output(b'',good,None,'tests') + for bad in (good.replace(b' ... ok',b' ... FAIL',1),good+b'noise',good.replace(b'Ran 15',b'Ran 0')): + with self.assertRaisesRegex(self.m.ReplayError,'test_report_mismatch'): self.m.check_output(b'',bad,None,'tests') + + def test_exact_output_contract_is_byte_exact(self): + want=b'{"panels":1024,"independently_reviewed":false}\n';self.m.check_output(want,b'',want,'exact') + for bad in (b'',want+b'\n',want.replace(b'false',b'true')): + with self.assertRaisesRegex(self.m.ReplayError,'stdout_mismatch'): self.m.check_output(bad,b'',want,'exact') + + def test_host_identity(self): + h='1'*40;env={'GITHUB_ACTIONS':'true','GITHUB_REPOSITORY':self.m.REPOSITORY,'GITHUB_SHA':h,'GITHUB_RUN_ID':'1','GITHUB_RUN_ATTEMPT':'2'} + self.m.host_identity(h,env) + env['GITHUB_SHA']='2'*40 + with self.assertRaisesRegex(self.m.ReplayError,'host_identity'): self.m.host_identity(h,env) + + def test_invalid_cli(self): + for args in ([],['--mode','bad','--output','x'],['--mode','normal','--output','x','--panels','2048']): + p=subprocess.run([sys.executable,'-B','-S',str(DRIVER),*args],capture_output=True);self.assertEqual(p.returncode,2) + + def test_workflow_contract(self): + wf=DRIVER.parents[1]/'.github/workflows/lm006-oned-coefficient.yml';self.assertTrue(wf.is_file(),'workflow missing') + text=wf.read_text() + for phrase in ('permissions:\n contents: read','fail-fast: false','mode: [normal, optimized]','if: always()',"python-version: '3.13.5'",'persist-credentials: false','if-no-files-found: error'): + self.assertIn(phrase,text) + self.assertNotIn('continue-on-error:',text);self.assertNotIn('pull_request_target:',text) + + + def synthetic_project(self, bad_test=False, output='synthetic', mutate=False): + import shutil + previous=os.environ.get('GITHUB_ACTIONS') + self.addCleanup(lambda: os.environ.pop('GITHUB_ACTIONS',None) if previous is None else os.environ.__setitem__('GITHUB_ACTIONS',previous)) + os.environ['GITHUB_ACTIONS']='false' + pins=self.fixture(); packet=self.root/self.m.PACKET + (packet/'RESULTS.json').write_text('synthetic\n') + methods='\n'.join(' def '+n+'(self): self.assertTrue('+('False' if bad_test and i==0 else 'True')+')' for i,n in enumerate(self.m.TEST_NAMES)) + (packet/'test_oned.py').write_text('import unittest\nclass OneDimensionalTests(unittest.TestCase):\n'+methods+'\n') + suffix="\nfrom pathlib import Path;Path('NOTE.md').write_text('changed')" if mutate else '' + (packet/'oned.py').write_text("import sys\nassert sys.argv[1:]==['--panels','1024']\nprint("+repr(output)+")"+suffix+'\n') + for name in self.m.EXECUTION_FILES: + d=self.root/name;d.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(DRIVER.parents[1]/name,d) + subprocess.run(['git','init','-q'],cwd=self.root,check=True);subprocess.run(['git','add','.'],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','fixture'],cwd=self.root,check=True) + spec=importlib.util.spec_from_file_location('fixture_driver',self.root/self.m.EXECUTION_FILES[0]);mod=importlib.util.module_from_spec(spec);spec.loader.exec_module(mod) + mod.PINS={n:mod.git_blob((self.root/n).read_bytes()) for n in pins} + return mod + + def test_complete_orchestration_real_subprocesses(self): + mod=self.synthetic_project();out=Path(self.tmp.name)/'ok';receipt=mod.execute(self.root,out,'optimized') + self.assertEqual(receipt['status'],'PASS');self.assertEqual(set(receipt['steps']),{'tests','coefficient'});self.assertEqual((out/'coefficient.stdout').read_bytes(),b'synthetic\n') + + def test_failed_tests_stop_before_coefficient(self): + mod=self.synthetic_project(bad_test=True);out=Path(self.tmp.name)/'badtests' + with self.assertRaisesRegex(mod.ReplayError,'unexpected_exit'): mod.execute(self.root,out,'normal') + self.assertFalse((out/'coefficient.stdout').exists());self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + + def test_wrong_output_cannot_pass(self): + mod=self.synthetic_project(output='wrong');out=Path(self.tmp.name)/'wrong' + with self.assertRaisesRegex(mod.ReplayError,'stdout_mismatch'): mod.execute(self.root,out,'normal') + row=json.loads((out/'receipt.json').read_text());self.assertEqual(row['steps']['tests']['record']['status'],'PASS');self.assertEqual(row['steps']['coefficient']['record']['status'],'FAIL') + + def test_postflight_source_drift_rejected(self): + mod=self.synthetic_project(mutate=True);out=Path(self.tmp.name)/'drift' + with self.assertRaisesRegex(mod.ReplayError,'source_identity'): mod.execute(self.root,out,'normal') + self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + +if __name__=='__main__': unittest.main() +) + self.assertRegex(row['stderr_sha256'],'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") + self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) + + def test_test_report_contract_requires_all_named_passes(self): + good=('\n'.join(n+' (test_oned.OneDimensionalTests.'+n+') ... ok' for n in self.m.TEST_NAMES)+'\n\n'+'-'*70+'\nRan 15 tests in 0.001s\n\nOK\n').encode() + self.m.check_output(b'',good,None,'tests') + for bad in (good.replace(b' ... ok',b' ... FAIL',1),good+b'noise',good.replace(b'Ran 15',b'Ran 0')): + with self.assertRaisesRegex(self.m.ReplayError,'test_report_mismatch'): self.m.check_output(b'',bad,None,'tests') + + def test_exact_output_contract_is_byte_exact(self): + want=b'{"panels":1024,"independently_reviewed":false}\n';self.m.check_output(want,b'',want,'exact') + for bad in (b'',want+b'\n',want.replace(b'false',b'true')): + with self.assertRaisesRegex(self.m.ReplayError,'stdout_mismatch'): self.m.check_output(bad,b'',want,'exact') + + def test_host_identity(self): + h='1'*40;env={'GITHUB_ACTIONS':'true','GITHUB_REPOSITORY':self.m.REPOSITORY,'GITHUB_SHA':h,'GITHUB_RUN_ID':'1','GITHUB_RUN_ATTEMPT':'2'} + self.m.host_identity(h,env) + env['GITHUB_SHA']='2'*40 + with self.assertRaisesRegex(self.m.ReplayError,'host_identity'): self.m.host_identity(h,env) + + def test_invalid_cli(self): + for args in ([],['--mode','bad','--output','x'],['--mode','normal','--output','x','--panels','2048']): + p=subprocess.run([sys.executable,'-B','-S',str(DRIVER),*args],capture_output=True);self.assertEqual(p.returncode,2) + + def test_workflow_contract(self): + wf=DRIVER.parents[1]/'.github/workflows/lm006-oned-coefficient.yml';self.assertTrue(wf.is_file(),'workflow missing') + text=wf.read_text() + for phrase in ('permissions:\n contents: read','fail-fast: false','mode: [normal, optimized]','if: always()',"python-version: '3.13.5'",'persist-credentials: false','if-no-files-found: error'): + self.assertIn(phrase,text) + self.assertNotIn('continue-on-error:',text);self.assertNotIn('pull_request_target:',text) + + + def synthetic_project(self, bad_test=False, output='synthetic', mutate=False): + import shutil + previous=os.environ.get('GITHUB_ACTIONS') + self.addCleanup(lambda: os.environ.pop('GITHUB_ACTIONS',None) if previous is None else os.environ.__setitem__('GITHUB_ACTIONS',previous)) + os.environ['GITHUB_ACTIONS']='false' + pins=self.fixture(); packet=self.root/self.m.PACKET + (packet/'RESULTS.json').write_text('synthetic\n') + methods='\n'.join(' def '+n+'(self): self.assertTrue('+('False' if bad_test and i==0 else 'True')+')' for i,n in enumerate(self.m.TEST_NAMES)) + (packet/'test_oned.py').write_text('import unittest\nclass OneDimensionalTests(unittest.TestCase):\n'+methods+'\n') + suffix="\nfrom pathlib import Path;Path('NOTE.md').write_text('changed')" if mutate else '' + (packet/'oned.py').write_text("import sys\nassert sys.argv[1:]==['--panels','1024']\nprint("+repr(output)+")"+suffix+'\n') + for name in self.m.EXECUTION_FILES: + d=self.root/name;d.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(DRIVER.parents[1]/name,d) + subprocess.run(['git','init','-q'],cwd=self.root,check=True);subprocess.run(['git','add','.'],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','fixture'],cwd=self.root,check=True) + spec=importlib.util.spec_from_file_location('fixture_driver',self.root/self.m.EXECUTION_FILES[0]);mod=importlib.util.module_from_spec(spec);spec.loader.exec_module(mod) + mod.PINS={n:mod.git_blob((self.root/n).read_bytes()) for n in pins} + return mod + + def test_complete_orchestration_real_subprocesses(self): + mod=self.synthetic_project();out=Path(self.tmp.name)/'ok';receipt=mod.execute(self.root,out,'optimized') + self.assertEqual(receipt['status'],'PASS');self.assertEqual(set(receipt['steps']),{'tests','coefficient'});self.assertEqual((out/'coefficient.stdout').read_bytes(),b'synthetic\n') + + def test_failed_tests_stop_before_coefficient(self): + mod=self.synthetic_project(bad_test=True);out=Path(self.tmp.name)/'badtests' + with self.assertRaisesRegex(mod.ReplayError,'unexpected_exit'): mod.execute(self.root,out,'normal') + self.assertFalse((out/'coefficient.stdout').exists());self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + + def test_wrong_output_cannot_pass(self): + mod=self.synthetic_project(output='wrong');out=Path(self.tmp.name)/'wrong' + with self.assertRaisesRegex(mod.ReplayError,'stdout_mismatch'): mod.execute(self.root,out,'normal') + row=json.loads((out/'receipt.json').read_text());self.assertEqual(row['steps']['tests']['record']['status'],'PASS');self.assertEqual(row['steps']['coefficient']['record']['status'],'FAIL') + + def test_postflight_source_drift_rejected(self): + mod=self.synthetic_project(mutate=True);out=Path(self.tmp.name)/'drift' + with self.assertRaisesRegex(mod.ReplayError,'source_identity'): mod.execute(self.root,out,'normal') + self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + +if __name__=='__main__': unittest.main() +) + + def test_existing_evidence_not_overwritten(self): self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py index 8715ffa31..04bcf9344 100644 --- a/tools/lm006_oned_coefficient_replay.py +++ b/tools/lm006_oned_coefficient_replay.py @@ -70,7 +70,8 @@ def run_step(argv,cwd,logs,name,expected,kind,timeout=900): record['timed_out']=True;failure='timeout' try: os.killpg(child.pid,signal.SIGKILL) except ProcessLookupError: pass - record['returncode']=child.wait(timeout=5) + try: record['returncode']=child.wait(timeout=5) + except subprocess.TimeoutExpired: record['detail']='process-group termination did not finish in 5 seconds' except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) record['elapsed_ns']=time.monotonic_ns()-start;sizes=(out.stat().st_size,err.stat().st_size) if max(sizes)>MAX_STREAM_BYTES: failure=failure or 'output_too_large';record.update(stdout_bytes=sizes[0],stderr_bytes=sizes[1]) From ed58c25c70777570a9048936656b3d41d5e59568 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:29:30 -0700 Subject: [PATCH 07/24] LM006 replay: repair cleanup regression syntax Restore the existing evidence-nonoverwrite test and complete both digest assertions in the new secondary-timeout regression. No driver/workflow/numerical change. --- tests/test_lm006_oned_coefficient_replay.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index b7eaabb85..f26e02b39 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -63,9 +63,7 @@ class Stuck: def __init__(self,*args,**kwargs): kwargs['stdout'].write(b'started\\n');kwargs['stdout'].flush() kwargs['stderr'].write(b'partial\\n');kwargs['stderr'].flush() - self.calls=0 def wait(self,timeout=None): - self.calls+=1 raise subprocess.TimeoutExpired(['fake'],timeout) with mock.patch.object(self.m.subprocess,'Popen',Stuck), mock.patch.object(self.m.os,'killpg') as kill: with self.assertRaisesRegex(self.m.ReplayError,'timeout'): @@ -76,7 +74,11 @@ def wait(self,timeout=None): self.assertIn('did not finish',row['detail']) self.assertEqual((self.logs/'stuck.stdout').read_bytes(),b'started\\n') self.assertEqual((self.logs/'stuck.stderr').read_bytes(),b'partial\\n') - self.assertRegex(row['stdout_sha256'],'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + self.assertRegex(row['stdout_sha256'],r'^[0-9a-f]{64}$') + self.assertRegex(row['stderr_sha256'],r'^[0-9a-f]{64}$') + + def test_existing_evidence_not_overwritten(self): + self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) From 089d87ace030e755511a04735c42c1f91911d4c1 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:32:20 -0700 Subject: [PATCH 08/24] LM006 replay: restore clean focused suite with cleanup regression Rebuild from the last green 16-test source and add exactly one deterministic secondary-timeout evidence test. No driver, workflow, or numerical change. --- tests/test_lm006_oned_coefficient_replay.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index f26e02b39..ecafafc03 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -56,13 +56,14 @@ def test_timeout_retains_partial_evidence(self): self.child("import sys,time;print('s',flush=True);print('e',file=sys.stderr,flush=True);time.sleep(10)",timeout=.2) row=json.loads((self.logs/'child.process.json').read_text());self.assertTrue(row['timed_out']);self.assertEqual(row['failure'],'timeout') - def test_secondary_timeout_still_writes_process_record(self): class Stuck: pid=424242 def __init__(self,*args,**kwargs): - kwargs['stdout'].write(b'started\\n');kwargs['stdout'].flush() - kwargs['stderr'].write(b'partial\\n');kwargs['stderr'].flush() + kwargs['stdout'].write(b'started\\n') + kwargs['stdout'].flush() + kwargs['stderr'].write(b'partial\\n') + kwargs['stderr'].flush() def wait(self,timeout=None): raise subprocess.TimeoutExpired(['fake'],timeout) with mock.patch.object(self.m.subprocess,'Popen',Stuck), mock.patch.object(self.m.os,'killpg') as kill: @@ -74,11 +75,7 @@ def wait(self,timeout=None): self.assertIn('did not finish',row['detail']) self.assertEqual((self.logs/'stuck.stdout').read_bytes(),b'started\\n') self.assertEqual((self.logs/'stuck.stderr').read_bytes(),b'partial\\n') - self.assertRegex(row['stdout_sha256'],r'^[0-9a-f]{64}$') - self.assertRegex(row['stderr_sha256'],r'^[0-9a-f]{64}$') - - def test_existing_evidence_not_overwritten(self): - self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + self.assertRegex(row['stdout_sha256'],r'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) @@ -151,7 +148,7 @@ def test_postflight_source_drift_rejected(self): if __name__=='__main__': unittest.main() ) - self.assertRegex(row['stderr_sha256'],'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} + self.assertRegex(row['stderr_sha256'],r'^[0-9a-f]{64} self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") self.assertEqual(before,{p.name:p.read_bytes() for p in self.logs.iterdir()}) @@ -225,7 +222,6 @@ def test_postflight_source_drift_rejected(self): if __name__=='__main__': unittest.main() ) - def test_existing_evidence_not_overwritten(self): self.child("print('ok')");before={p.name:p.read_bytes() for p in self.logs.iterdir()} with self.assertRaisesRegex(self.m.ReplayError,'step_evidence_exists'): self.child("print('changed')") From f21bba95f6150313d2b5caa44b62e44c92cdcdd8 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:03:44 -0500 Subject: [PATCH 09/24] Emit exact source-bound elder cusp mutant reports --- frontiers/elder_cusp_parity_20261002/ecp_check.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontiers/elder_cusp_parity_20261002/ecp_check.py b/frontiers/elder_cusp_parity_20261002/ecp_check.py index 82e8e035e..af539e876 100644 --- a/frontiers/elder_cusp_parity_20261002/ecp_check.py +++ b/frontiers/elder_cusp_parity_20261002/ecp_check.py @@ -4,7 +4,7 @@ Standard library only; exact rationals throughout; deterministic (a fixed linear congruential generator). Output: RESULTS.json (sorted keys), byte-identical under -O. Usage: python3 -B -S ecp_check.py # exit 0, prints RESULTS.json - python3 -B -S ecp_check.py --mutant M3 # exit 1 (only its control fails) + python3 -B -S ecp_check.py --mutant M3 # exit 1, exact JSON names its sole failed control unknown mutant label -> exit 2 Controls @@ -799,6 +799,10 @@ def main(argv): ok = all(res['controls'].values()) if MUT is None: print(json.dumps(res, indent=1, sort_keys=True)) + else: + print(json.dumps({'failed_controls': [name for name, passed in res['controls'].items() if not passed], + 'mutant': MUT, 'scientific_effect': 'NONE'}, + sort_keys=True, separators=(',', ':'))) return 0 if ok else 1 From cb494468c8540266cd0839a9586f00fdf73bdb54 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:03:47 -0500 Subject: [PATCH 10/24] Refresh elder cusp checker source identity --- frontiers/elder_cusp_parity_20261002/SOURCES.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontiers/elder_cusp_parity_20261002/SOURCES.json b/frontiers/elder_cusp_parity_20261002/SOURCES.json index 72bb0aa83..8e943e6b2 100644 --- a/frontiers/elder_cusp_parity_20261002/SOURCES.json +++ b/frontiers/elder_cusp_parity_20261002/SOURCES.json @@ -195,8 +195,8 @@ }, { "path": "ecp_check.py", - "bytes": 38573, - "sha256": "673c553c629cb09fdead24b7ae2a390ec55ed6a197007bc5e5c0e1c53525a177" + "bytes": 38847, + "sha256": "f6b7d134cc69d7a6d3cd9442d23fd0f86584f7d20553fcc61eab453e4176642f" }, { "path": "RESULTS.json", From e5d5ad17e6fbbf7e876021167ec5ae51bb6036eb Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:03:49 -0500 Subject: [PATCH 11/24] Bind elder cusp workflow to exact child protocol --- .github/workflows/elder-cusp-parity.yml | 46 ++++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/elder-cusp-parity.yml b/.github/workflows/elder-cusp-parity.yml index 29be167a6..974eb10f0 100644 --- a/.github/workflows/elder-cusp-parity.yml +++ b/.github/workflows/elder-cusp-parity.yml @@ -5,6 +5,7 @@ name: Elder cusp kernel parity exact controls paths: - 'frontiers/elder_cusp_parity_20261002/**' - '.github/workflows/elder-cusp-parity.yml' + - 'tests/test_elder_cusp_parity_workflow.py' # bound merged sources (consumed and cited in SOURCES.json); the cited unmerged sources are bound through the API - 'frontiers/three_fronts_20260924/LIFETIME_REMAINDER.md' - 'imports/lifetime_parent_20260925/UNIFORM_MATRIX_CAP_AND_LIFETIME.md' @@ -143,17 +144,44 @@ jobs: 'via': where, 'current_ref_checked': now})) script = str(root / 'ecp_check.py') expected = (root / 'RESULTS.json').read_bytes() + manifest_mutants = {'M1': 'X3', 'M2': 'X4', 'M3': 'X5', 'M4': 'X2', + 'M5': 'X1', 'M6': 'X3', 'M7': 'X6'} + if manifest['mutants'] != manifest_mutants: + raise ValueError('mutant inventory differs from the source-bound protocol') + failed_controls = { + 'M1': 'X3_pinned_fields_and_Omega_a', + 'M2': 'X4_Q1_identities_and_parity', + 'M3': 'X5_first_order_bookkeeping', + 'M4': 'X2_model_ridge_and_edges', + 'M5': 'X1_lemma_Q_prime_and_CE', + 'M6': 'X3_pinned_fields_and_Omega_a', + 'M7': 'X6_corollary_and_ledgers', + } 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: + out = subprocess.run([sys.executable, *flags, script], capture_output=True, timeout=600) + if out.returncode != 0: + raise RuntimeError('baseline exit differs from 0 under ' + ' '.join(flags)) + if out.stdout != expected: raise RuntimeError('output differs from RESULTS.json under ' + ' '.join(flags)) - for m in manifest['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') - rc = subprocess.run([sys.executable, *flags, script, '--mutant', 'M99'], capture_output=True, timeout=600).returncode - if rc != 2: - raise RuntimeError('unknown mutant label not rejected with exit 2') + if out.stderr: + raise RuntimeError('baseline stderr under ' + ' '.join(flags)) + for m in manifest_mutants: + out = subprocess.run([sys.executable, *flags, script, '--mutant', m], + capture_output=True, timeout=600) + report = (json.dumps({'failed_controls': [failed_controls[m]], 'mutant': m, + 'scientific_effect': 'NONE'}, + sort_keys=True, separators=(',', ':')) + '\n').encode() + if out.returncode != 1 or out.stdout != report or out.stderr: + raise RuntimeError('mutant ' + m + ' not rejected with exact control report') + out = subprocess.run([sys.executable, *flags, script, '--mutant', 'M99'], + capture_output=True, timeout=600) + if out.returncode != 2 or out.stdout or out.stderr != b'unknown mutant label\n': + raise RuntimeError('unknown mutant label not rejected with exact protocol') print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code + - name: Full-shell protocol regression tests in both modes + run: | + set -euo pipefail + python -B -S -m unittest discover -s tests -p 'test_elder_cusp_parity_workflow.py' -v + python -B -O -S -m unittest discover -s tests -p 'test_elder_cusp_parity_workflow.py' -v From b79a0c29985fcb598a261910cac15ddf8209dda3 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 20 Oct 2026 10:03:51 -0500 Subject: [PATCH 12/24] Add full-shell elder cusp protocol regressions --- tests/test_elder_cusp_parity_workflow.py | 306 +++++++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100644 tests/test_elder_cusp_parity_workflow.py diff --git a/tests/test_elder_cusp_parity_workflow.py b/tests/test_elder_cusp_parity_workflow.py new file mode 100644 index 000000000..6a21ff3f8 --- /dev/null +++ b/tests/test_elder_cusp_parity_workflow.py @@ -0,0 +1,306 @@ +"""Real-shell elder-cusp protocol tests with committed SYNTHETIC fixtures. + +No mathematical packet is replayed here. Real checker children record their +interpreter flags; the complete workflow block retains source and Git guards. +""" +from __future__ import annotations + +import hashlib +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import unittest + +WORKFLOW = Path(__file__).resolve().parents[1] / '.github/workflows/elder-cusp-parity.yml' +PACKET = Path('frontiers/elder_cusp_parity_20261002') +FAILED_CONTROLS = { + 'M1': 'X3_pinned_fields_and_Omega_a', + 'M2': 'X4_Q1_identities_and_parity', + 'M3': 'X5_first_order_bookkeeping', + 'M4': 'X2_model_ridge_and_edges', + 'M5': 'X1_lemma_Q_prime_and_CE', + 'M6': 'X3_pinned_fields_and_Omega_a', + 'M7': 'X6_corollary_and_ledgers', +} +LABELS = tuple(FAILED_CONTROLS) +MANIFEST_MUTANTS = { + 'M1': 'X3', 'M2': 'X4', 'M3': 'X5', 'M4': 'X2', + 'M5': 'X1', 'M6': 'X3', 'M7': 'X6', +} +BASELINE = { + 'object': 'SYNTHETIC-ELDER-CUSP-PROTOCOL-FIXTURE', + 'passed': True, + 'scope': 'workflow engineering fixture only; no mathematical assertion', +} + + +def mutant_report(label): + return (json.dumps({ + 'failed_controls': [FAILED_CONTROLS[label]], + 'mutant': label, + 'scientific_effect': 'NONE', + }, sort_keys=True, separators=(',', ':')) + '\n').encode() + + +# This is a real child process, never a mocked subprocess API or interpreter. +CHILD = r'''import json, os, pathlib, sys +FAILED_CONTROLS = ''' + repr(FAILED_CONTROLS) + r''' +args = sys.argv[1:] +label = args[-1] if '--mutant' in args else 'baseline' +event = {'label': label, 'argv': args, + 'interpreter_flags': sys.orig_argv[1:sys.orig_argv.index(sys.argv[0])], + 'optimize': sys.flags.optimize, 'no_site': sys.flags.no_site, + 'dont_write_bytecode': sys.dont_write_bytecode} +with open(os.environ['ECP_EVENTS'], 'a', encoding='utf-8') as stream: + stream.write(json.dumps(event)+'\n') +selected = label == os.environ.get('ECP_TARGET') and str(sys.flags.optimize) == os.environ.get('ECP_MODE') +kind = os.environ.get('ECP_KIND', 'valid') if selected else 'valid' +if kind == 'crash': raise RuntimeError('synthetic unrelated crash') +if kind == 'silent': sys.exit(1) +if label == 'baseline': + out = (pathlib.Path(__file__).parent/'RESULTS.json').read_bytes() + if kind == 'baseline-wrong': out = b'synthetic wrong baseline bytes\n' + if kind == 'stderr': print('synthetic unexpected stderr', file=sys.stderr) + sys.stdout.buffer.write(out) + sys.exit(1 if kind == 'baseline-exit' else 0) +if label == 'M99': + stdout = b'' + stderr = b'unknown mutant label\n' + rc = 2 + if kind == 'unknown-stdout': stdout = b'unexpected output\n' + if kind == 'unknown-wrong-stderr': stderr = b'unrelated exit two\n' + if kind == 'unknown-no-stderr': stderr = b'' + if kind == 'unknown-exit-one': rc = 1 + if kind == 'unknown-exit-zero': rc = 0 + sys.stdout.buffer.write(stdout) + sys.stderr.buffer.write(stderr) + sys.exit(rc) +emitted = label +control = FAILED_CONTROLS[label] +if kind == 'wrong-label': emitted = 'M2' if label == 'M1' else 'M1' +if kind == 'wrong-control': + control = 'X2_model_ridge_and_edges' if control == 'X1_lemma_Q_prime_and_CE' else 'X1_lemma_Q_prime_and_CE' +value = {'failed_controls': [control], 'mutant': emitted, 'scientific_effect': 'NONE'} +if kind == 'extra-field': value['extra'] = 'unexpected' +out = (json.dumps(value, sort_keys=True, separators=(',', ':')) + '\n').encode() +if kind == 'baseline-json': out = (pathlib.Path(__file__).parent/'RESULTS.json').read_bytes() +if kind == 'missing-newline': out = out.rstrip(b'\n') +if kind == 'prefix-noise': out = b'unexpected prefix\n' + out +if kind == 'suffix-noise': out += b'unexpected suffix\n' +if kind == 'stderr': print('synthetic unexpected stderr', file=sys.stderr) +sys.stdout.buffer.write(out) +sys.exit({'exit-zero': 0, 'exit-two': 2}.get(kind, 1)) +''' + + +def report_bytes(value): + return (json.dumps(value, indent=2, sort_keys=True) + '\n').encode() + + +def workflow_shell(text): + name = ' - name: Verify sources, replay both modes, reject mutants\n' + if text.count(name) != 1: + raise ValueError('expected one named protocol step') + tail = text.split(name, 1)[1].split(' - ', 1)[0] + marker = ' run: |\n' + if tail.count(marker) != 1: + raise ValueError('expected named literal run block') + lines = tail.split(marker, 1)[1].splitlines(keepends=True) + if any(line.strip() and not line.startswith(' ') for line in lines): + raise ValueError('unexpected run-block indentation') + shell = ''.join(line[10:] if line.startswith(' ') else line for line in lines) + if not shell.startswith('set -euo pipefail\n') or not shell.endswith('git diff --exit-code\n'): + raise ValueError('incomplete protocol shell') + return shell + + +class ElderCuspParityWorkflow(unittest.TestCase): + @classmethod + def setUpClass(cls): + if not shutil.which('git') or not shutil.which('bash'): + raise RuntimeError('these workflow tests require Git and Bash') + cls.workflow = WORKFLOW.read_text(encoding='utf-8') + cls.shell = workflow_shell(cls.workflow) + + def run_fixture(self, kind='valid', target='baseline', mode=0): + with tempfile.TemporaryDirectory(prefix='elder-cusp-protocol-') as temp: + outer = Path(temp) + repo = outer / 'repo' + packet = repo / PACKET + packet.mkdir(parents=True) + executable_dir = outer / 'bin' + executable_dir.mkdir() + (executable_dir / 'python').symlink_to(sys.executable) + env = {key: value for key, value in os.environ.items() + if not key.startswith(('GIT_', 'PYTHON', 'ECP_')) and key not in ('BASH_ENV', 'ENV')} + env.update(PATH=str(executable_dir) + os.pathsep + os.environ.get('PATH', ''), + GIT_CONFIG_NOSYSTEM='1', GIT_CONFIG_GLOBAL=os.devnull, + GIT_TERMINAL_PROMPT='0', PYTHONDONTWRITEBYTECODE='1', + GH_TOKEN='unused', GH_REPOSITORY='unused/unused', + ECP_KIND=kind, ECP_TARGET=target, ECP_MODE=str(mode), + ECP_EVENTS=str(outer / 'events.jsonl')) + + def git(*args): + proc = subprocess.run(['git', '-c', 'gc.auto=0', *args], cwd=repo, + env=env, capture_output=True, timeout=15) + self.assertEqual(proc.returncode, 0, proc.stderr.decode(errors='replace')) + return proc.stdout + + payloads = {'ecp_check.py': CHILD.encode(), 'RESULTS.json': report_bytes(BASELINE)} + for name, data in payloads.items(): + (packet / name).write_bytes(data) + manifest = { + 'synthetic_fixture': True, + 'files': [{'path': name, 'bytes': len(data), 'sha256': hashlib.sha256(data).hexdigest()} + for name, data in sorted(payloads.items())], + 'consumed': [], 'cited_only': [], 'consumed_unmerged': [], 'cited_unmerged': [], + 'mutants': MANIFEST_MUTANTS, + } + (packet / 'SOURCES.json').write_bytes(report_bytes(manifest)) + (repo / 'marker.txt').write_bytes(b'original\n') + if kind == 'hash-only': + data = payloads['ecp_check.py'] + (packet / 'ecp_check.py').write_bytes(b'X' + data[1:]) + elif kind == 'size-only': + row = next(item for item in manifest['files'] if item['path'] == 'ecp_check.py') + row['bytes'] += 1 + (packet / 'SOURCES.json').write_bytes(report_bytes(manifest)) + elif kind == 'missing': + (packet / 'RESULTS.json').unlink() + elif kind == 'extra': + (packet / 'extra.txt').write_bytes(b'extra\n') + elif kind == 'symlink': + (packet / 'RESULTS.json').unlink() + (outer / 'results.json').write_bytes(payloads['RESULTS.json']) + (packet / 'RESULTS.json').symlink_to(outer / 'results.json') + git('init', '-q') + git('add', '.') + git('-c', 'user.name=Protocol fixture', '-c', 'user.email=fixture@example.invalid', + 'commit', '-qm', 'Synthetic protocol fixture only') + head = git('rev-parse', 'HEAD') + if kind == 'dirty': + (repo / 'marker.txt').write_bytes(b'intentionally dirty\n') + before = {p.relative_to(repo).as_posix(): p.read_bytes() + for p in repo.rglob('*') if p.is_file() and '.git' not in p.parts} + proc = subprocess.run(['bash', '-c', self.shell], cwd=repo, env=env, + capture_output=True, timeout=30) + after = {p.relative_to(repo).as_posix(): p.read_bytes() + for p in repo.rglob('*') if p.is_file() and '.git' not in p.parts} + self.assertEqual(before, after, 'workflow changed fixture payload bytes') + self.assertEqual(git('rev-parse', 'HEAD'), head) + events_path = outer / 'events.jsonl' + events = [json.loads(line) for line in events_path.read_text().splitlines()] if events_path.exists() else [] + return proc, events + + @staticmethod + def event(label, mode): + return {'label': label, 'argv': [] if label == 'baseline' else ['--mutant', label], + 'interpreter_flags': ['-B', '-S'] if mode == 0 else ['-B', '-O', '-S'], + 'optimize': mode, 'no_site': 1, 'dont_write_bytecode': True} + + @classmethod + def sequence(cls): + return [cls.event(label, mode) + for mode in (0, 1) for label in ('baseline', *LABELS, 'M99')] + + def assert_refusal(self, kind, target, mode, diagnostic): + proc, events = self.run_fixture(kind, target, mode) + self.assertNotEqual(proc.returncode, 0, (kind, target, mode, proc.stdout, proc.stderr)) + self.assertNotIn(b'"mathematical_acceptance": false', proc.stdout) + self.assertIn(diagnostic, proc.stderr) + index = self.sequence().index(self.event(target, mode)) + self.assertEqual(events, self.sequence()[:index + 1]) + + def check_mutants(self, kind): + for mode in (0, 1): + for label in LABELS: + with self.subTest(kind=kind, mode=mode, label=label): + self.assert_refusal(kind, label, mode, b'mutant ' + label.encode()) + + def test_valid_protocol_reaches_both_modes(self): + proc, events = self.run_fixture() + self.assertEqual(proc.returncode, 0, proc.stderr) + self.assertEqual(proc.stdout, b'{"scientific_effect": "NONE", "mathematical_acceptance": false}\n') + self.assertEqual(proc.stderr, b'') + self.assertEqual(events, self.sequence()) + + def test_unrelated_crash_is_not_a_mutant_rejection(self): + self.check_mutants('crash') + + def test_silent_exit_one_is_not_a_mutant_rejection(self): + self.check_mutants('silent') + + def test_complete_label_and_control_report_bytes_are_required(self): + for kind in ('wrong-label', 'wrong-control', 'extra-field', 'baseline-json', + 'missing-newline', 'prefix-noise', 'suffix-noise'): + self.check_mutants(kind) + + def test_mutant_stderr_is_not_accepted(self): + self.check_mutants('stderr') + + def test_wrong_mutant_exit_is_not_accepted(self): + for kind in ('exit-zero', 'exit-two'): + self.check_mutants(kind) + + def test_unknown_label_protocol_is_exact(self): + for kind in ('unknown-stdout', 'unknown-wrong-stderr', 'unknown-no-stderr', + 'unknown-exit-one', 'unknown-exit-zero'): + for mode in (0, 1): + with self.subTest(kind=kind, mode=mode): + self.assert_refusal(kind, 'M99', mode, b'unknown mutant label') + + def test_baseline_stderr_is_not_accepted(self): + for mode in (0, 1): + with self.subTest(mode=mode): + self.assert_refusal('stderr', 'baseline', mode, b'baseline stderr') + + def test_baseline_stdout_remains_exact(self): + for mode in (0, 1): + with self.subTest(mode=mode): + self.assert_refusal('baseline-wrong', 'baseline', mode, b'output differs from RESULTS.json') + + def test_baseline_nonzero_stops_before_mutants(self): + for mode in (0, 1): + with self.subTest(mode=mode): + self.assert_refusal('baseline-exit', 'baseline', mode, b'baseline exit') + + def test_manifest_and_source_guards_precede_checker_execution(self): + for kind, diagnostic in [('hash-only', b'packet file identity mismatch'), + ('size-only', b'packet file identity mismatch'), + ('missing', b'packet tree differs'), ('extra', b'packet tree differs'), + ('symlink', b'symlink')]: + with self.subTest(kind=kind): + proc, events = self.run_fixture(kind) + self.assertNotEqual(proc.returncode, 0) + self.assertIn(diagnostic, proc.stderr) + self.assertEqual(events, []) + + def test_final_git_guard_still_refuses_dirty_fixture(self): + proc, events = self.run_fixture('dirty') + self.assertNotEqual(proc.returncode, 0) + self.assertIn(b'diff --git', proc.stdout) + self.assertEqual(events, self.sequence()) + + def test_existing_workflow_execution_contract_is_preserved(self): + self.assertIn(" - 'frontiers/elder_cusp_parity_20261002/**'\n", self.workflow) + self.assertIn(' workflow_dispatch:\n', self.workflow) + self.assertIn('permissions:\n contents: read\n pull-requests: read\n', self.workflow) + self.assertIn('timeout-minutes: 10\n', self.workflow) + self.assertIn('actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1', self.workflow) + self.assertIn('persist-credentials: false', self.workflow) + self.assertIn('actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97', self.workflow) + self.assertIn("PYTHONDONTWRITEBYTECODE: '1'", self.workflow) + + def test_protocol_tests_are_wired_for_both_outer_modes(self): + self.assertIn(" - 'tests/test_elder_cusp_parity_workflow.py'\n", self.workflow) + self.assertIn("python -B -S -m unittest discover -s tests -p 'test_elder_cusp_parity_workflow.py' -v", self.workflow) + self.assertIn("python -B -O -S -m unittest discover -s tests -p 'test_elder_cusp_parity_workflow.py' -v", self.workflow) + self.assertIn("python-version: '3.11.16'", self.workflow) + + +if __name__ == '__main__': + unittest.main() From 82c9004c2a6472a3913292e92543d21fbab174ef Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:06:50 -0500 Subject: [PATCH 13/24] Add real Git and loaded-driver custody controls before repair Test replacement-ref relabelling, ambient Git redirection, and an API module claiming a committed driver successor. Preserve all original seventeen methods and the previous native successes as historical observations. These new controls are expected to fail on the unmodified driver. --- tests/test_lm006_oned_coefficient_replay.py | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index d9c9d9322..f192589e6 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -151,4 +151,41 @@ def wait(self,timeout=None): self.assertEqual(row[side+'_bytes'],len(value)) self.assertEqual(row[side+'_sha256'],self.m.sha256(value)) + + def test_git_replacement_cannot_relabel_a_frozen_blob(self): + mod=self.synthetic_project() + relative=self.m.PACKET+'/NOTE.md' + expected=(self.root/relative).read_text().strip() + original=mod.git_head(self.root) + (self.root/relative).write_text('replacement source bytes\n') + subprocess.run(['git','add',relative],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','replacement target'],cwd=self.root,check=True) + replacement=mod.git_head(self.root) + subprocess.run(['git','replace',original,replacement],cwd=self.root,check=True) + self.assertEqual(mod.git(self.root,'show',original+':'+relative),expected) + + def test_ambient_git_environment_cannot_redirect_source_checks(self): + from unittest.mock import patch + mod=self.synthetic_project() + own=mod.git_head(self.root) + foreign=Path(self.tmp.name)/'foreign';foreign.mkdir() + (foreign/'foreign.txt').write_text('different committed repository\n') + subprocess.run(['git','init','-q'],cwd=foreign,check=True) + subprocess.run(['git','add','.'],cwd=foreign,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','foreign'],cwd=foreign,check=True) + with patch.dict(os.environ,{'GIT_DIR':str(foreign/'.git'),'GIT_WORK_TREE':str(foreign)}): + self.assertEqual(mod.git_head(self.root),own) + + def test_loaded_driver_cannot_claim_a_later_committed_source(self): + mod=self.synthetic_project() + driver=self.root/self.m.EXECUTION_FILES[0] + driver.write_bytes(driver.read_bytes()+b'\n# committed after this module was loaded\n') + subprocess.run(['git','add',self.m.EXECUTION_FILES[0]],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','source successor'],cwd=self.root,check=True) + out=Path(self.tmp.name)/'loaded-drift' + with self.assertRaisesRegex(mod.ReplayError,'loaded_driver_drift'): + mod.execute(self.root,out,'normal') + self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') + self.assertFalse((out/'tests.stdout').exists()) + if __name__=='__main__': unittest.main() From 68cf855bcc953cad6c4a7ac8f04d201d2ccf7949 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:20:49 -0500 Subject: [PATCH 14/24] Bind LM006 execution to immutable Git and loaded driver bytes Sanitize ambient Git configuration, disable replacement refs, and check loaded source in both execution snapshots. Preserve the seventeen original tests and three actual RED controls; add a real three-source-mutant harness with strict target/mode/reason checks. Register scoped tools and decisions. Actual optimized RED retained; no guard-fix pass is inferred. --- .../DECISIONS.md | 9 +++ .../GOVERNANCE.md | 14 +++++ .../README.md | 10 ++++ tests/test_lm006_oned_coefficient_replay.py | 56 +++++++++++++++++++ tools/lm006_oned_coefficient_replay.py | 14 ++++- 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 reviews/cbz_wrapper_composition_20261029/DECISIONS.md create mode 100644 reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md diff --git a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md new file mode 100644 index 000000000..7ee1db744 --- /dev/null +++ b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md @@ -0,0 +1,9 @@ +# Append-only wrapper decision ledger + +[2026-10-29T19:41:28Z] [phase2] [layerB+C] [compose] Retain PR370/379/385/492 source heads as additional parents of59d009. Use their bounded engineering deltas on main e877, adopt authenticated17-method LM006 recovery and current3.11.16/action pins. Reversible. Evidence: PR533/treeb2642e. + +[2026-10-29T19:41:28Z] [phase2] [layerC] [execution workaround] Managed shell requests stopped returning observations. Create separate native GitHub candidate for actual hosted execution; assume no local merge or test completed. No remote merge/ref rewrite. Reversible. Evidence: PR533 exact Actions checkouts and observations. + +[2026-10-29 20:20:44 UTC] [phase2] [layerA+B] [repair custody] Optimized20-method RED82c9004 has exactly3 intended failures: ambient Git, replacement refs, imported driver successor. Add sanitized Git and loaded-source guards, retain original tests, add actual3-source-mutant controls in both modes. Reversible. Evidence: run40946125351/job123701825783 and artifact12928953745. Normal original-driver RED remained queued and is not claimed. + +[2026-10-29 20:20:44 UTC] [phase2] [layerB] [register] Add local GOVERNANCE and exact commands/self-verification boundaries. Final federation canonical registry adoption remains part of integration. Reversible. Evidence: source-local registry and PR533 observations. diff --git a/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md new file mode 100644 index 000000000..346d22bbd --- /dev/null +++ b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md @@ -0,0 +1,14 @@ +# Wrapper tool registry and operational rules + +Source-local registry for federation criterion9. Main's canonical GOVERNANCE.md is the federation entry point. The active owner CBZ directive supersedes old approval, family and external-review gates. Admission uses truthful source-bound observations, self-review and actual automated gates. No placeholders, axiom injection, weakened bounds, silently removed failing tests, vacuous proof promotion or unobserved green is permitted. + +| Tool | Purpose and exact usage | Self-verification / boundary | +|---|---|---| +| .github/workflows/soft-fold-limit.yml | Exact baseline, ordered M1–M8 failure messages and unknown-label protocol, with original source/API guards; paired9-method commands in README. | Real whole-shell cases reject wrong status/reason/streams/source/order. Historical scoped observations are at59d009; later source heads require their own observations. | +| .github/workflows/third-order-rate.yml | Typed canonical reports, exact8-mutant inventory and original source guards; paired10-method commands in README. | Full-shell controls cover crashes, silence, wrong reports, duplicate/nonfinite/float/type-confused JSON and source/postflight drift. Original7056-byte preflight prefix retained. | +| .github/workflows/elder-cusp-parity.yml and ecp_check.py | Labelled mutant/control protocol with unchanged RESULTS bytes and mathematical control values; paired14-method commands. | Full-shell cases exercise complete child contracts and source/postflight guards. No bound changes or mathematical acceptance. | +| tools/lm006_oned_coefficient_replay.py | Bind8 mathematical input pins and3 execution sources; run15 named tests and exact1024-panel output; paired21-method tests plus normal/optimized CLI commands in README. | All17 original methods retained;3 real-Git/API controls added, plus actual3-source-mutant harness. Each mode must pass all21 and kill3/3 intended mutants with mode, target, exit and reason checks. Original optimized-driver RED has exactly3 failures; guard-fix runs were pending at preparation. | + +All tools: maintenance owner none — self-contained. These tools serve criteria5,7,9 and operational source custody; they do not admit new mathematical theorems. + +Layer B rule (2026-10-29 20:20:44 UTC): custody Git commands remove inherited GIT_* overrides, ignore global/system config, disable replacement refs and lazy fetching. Loaded driver bytes are checked before/after execution. Synthetic fixtures and source mutants are operational evidence; scientific packet/result bytes and all original test methods are preserved. diff --git a/reviews/cbz_wrapper_composition_20261029/README.md b/reviews/cbz_wrapper_composition_20261029/README.md index 9c76ec5b4..0fb45ffa0 100644 --- a/reviews/cbz_wrapper_composition_20261029/README.md +++ b/reviews/cbz_wrapper_composition_20261029/README.md @@ -32,3 +32,13 @@ The three dedicated exact-control workflows also run authentic baseline/mutant c ## Operational decision The managed shell execution service stopped returning observations while preparing the local composition. A separate native GitHub tree/commit is used to obtain genuine hosted execution without assuming a local merge or test completed. No remote merge, ref rewrite, source deletion, protection change, or old result relabelling is performed. Central federation tool registration remains in main's GOVERNANCE.md and TOOLING.md; this README supplies source-local use and verification boundaries for the composed candidate. + +## Custody repair after the first scoped successes + +The five targeted jobs passed at head59d0094ee388946de24b934ed3bca96ac73c4191 / tested merge3f127c6f492b0b498e3097bdd20525cee68918e5. Those exact historical observations are recorded in PR533 comment6506952638. Review then found that LM006's Git helper honored replacement refs and ambient Git redirection, and an imported driver could label its later committed file as the code that ran. + +Three real-Git/API controls produced an actual optimized RED at head82c9004c2a6472a3913292e92543d21fbab174ef, run40946125351/job123701825783:20 methods, exactly3 intended assertion failures, zero errors. The normal original-driver RED remained queued when this repair was prepared and is not claimed. The observed failure artifact is12928953745, GitHub ZIP SHA2561dc4b8b1fe8ec1c763b208827ddd3171221db2d54d078721c1ebdf06b110d251. + +The driver now sanitizes its Git environment, disables replacement objects, and checks loaded driver bytes inside both execution-source snapshots. The focused suite has21 methods, preserving all original17. For each new guard, it also runs a clean target baseline and an actual source mutant. Every child must run exactly its intended test in the requested interpreter mode and fail for that guard's reason. Full mutant streams are retained as base64 in LM006_CUSTODY_SOURCE_MUTATION log records. The declared threshold is3/3 source mutants in EACH Python mode; the paired focused commands above execute it. Fresh guard-fix results had not yet completed when this text was prepared; consult their exact native head and checkout identities. + +See [tool registry](GOVERNANCE.md) and [decision ledger](DECISIONS.md). Historical SCOPE records retain their original observations; their superseded author/family/approval requirements do not govern CBZ admission. diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index f192589e6..623b4eddc 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -152,7 +152,13 @@ def wait(self,timeout=None): self.assertEqual(row[side+'_sha256'],self.m.sha256(value)) + def check_custody_child_mode(self): + requested=os.environ.get('LM006_EXPECT_OPTIMIZE') + if requested is not None: + self.assertEqual(sys.flags.optimize,int(requested)) + def test_git_replacement_cannot_relabel_a_frozen_blob(self): + self.check_custody_child_mode() mod=self.synthetic_project() relative=self.m.PACKET+'/NOTE.md' expected=(self.root/relative).read_text().strip() @@ -165,6 +171,7 @@ def test_git_replacement_cannot_relabel_a_frozen_blob(self): self.assertEqual(mod.git(self.root,'show',original+':'+relative),expected) def test_ambient_git_environment_cannot_redirect_source_checks(self): + self.check_custody_child_mode() from unittest.mock import patch mod=self.synthetic_project() own=mod.git_head(self.root) @@ -177,6 +184,7 @@ def test_ambient_git_environment_cannot_redirect_source_checks(self): self.assertEqual(mod.git_head(self.root),own) def test_loaded_driver_cannot_claim_a_later_committed_source(self): + self.check_custody_child_mode() mod=self.synthetic_project() driver=self.root/self.m.EXECUTION_FILES[0] driver.write_bytes(driver.read_bytes()+b'\n# committed after this module was loaded\n') @@ -188,4 +196,52 @@ def test_loaded_driver_cannot_claim_a_later_committed_source(self): self.assertEqual(json.loads((out/'receipt.json').read_text())['status'],'FAIL') self.assertFalse((out/'tests.stdout').exists()) + + def test_custody_guards_reject_three_real_source_mutations(self): + import base64, shutil + source=DRIVER.read_text() + cases=[ + ('ambient',"env={key:value for key,value in os.environ.items() if not key.startswith('GIT_')} # MUTATION_GIT_ENV", + "env=dict(os.environ) # MUTATION_GIT_ENV", + 'test_ambient_git_environment_cannot_redirect_source_checks', + b'self.assertEqual(mod.git_head(self.root),own)'), + ('replacement',"GIT_NO_REPLACE_OBJECTS='1'","GIT_NO_REPLACE_OBJECTS='0'", + 'test_git_replacement_cannot_relabel_a_frozen_blob', + b"self.assertEqual(mod.git(self.root,'show',original+':'+relative),expected)"), + ('loaded',"require(raw==_LOADED_SOURCE,'loaded_driver_drift') # MUTATION_LOADED_DRIVER", + "require(True,'loaded_driver_drift') # MUTATION_LOADED_DRIVER", + 'test_loaded_driver_cannot_claim_a_later_committed_source', + b'AssertionError: ReplayError not raised'), + ] + for label,anchor,replacement,target,reason in cases: + with self.subTest(source_mutation=label): + self.assertEqual(source.count(anchor),1,'unique source mutation anchor') + with tempfile.TemporaryDirectory(prefix='lm006-custody-source-mutant-') as temporary: + scratch=Path(temporary) + for relative in self.m.EXECUTION_FILES: + destination=scratch/relative + destination.parent.mkdir(parents=True,exist_ok=True) + shutil.copyfile(DRIVER.parents[1]/relative,destination) + command=[sys.executable,'-B','-S']+(['-O'] if sys.flags.optimize else [])+['-m','unittest','discover','-s','tests','-p','test_lm006_oned_coefficient_replay.py','-k',target,'-v'] + environment=dict(os.environ,LM006_EXPECT_OPTIMIZE=str(sys.flags.optimize)) + baseline=subprocess.run(command,cwd=scratch,env=environment,capture_output=True,timeout=30) + self.assertEqual(baseline.returncode,0,baseline.stderr.decode()) + self.assertIn(b'Ran 1 test in',baseline.stderr) + self.assertTrue(baseline.stderr.endswith(b'\nOK\n')) + (scratch/self.m.EXECUTION_FILES[0]).write_text(source.replace(anchor,replacement,1)) + mutant=subprocess.run(command,cwd=scratch,env=environment,capture_output=True,timeout=30) + self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) + self.assertEqual(mutant.stdout,b'') + self.assertIn(b'Ran 1 test in',mutant.stderr) + self.assertIn(b'FAILED (failures=1)',mutant.stderr) + self.assertNotIn(b'ERROR:',mutant.stderr) + self.assertIn(reason,mutant.stderr) + self.assertNotIn(b'self.assertEqual(sys.flags.optimize',mutant.stderr) + record={'label':label,'optimize':sys.flags.optimize,'command':command, + 'baseline_exit':baseline.returncode,'mutant_exit':mutant.returncode, + 'driver_sha256':self.m.sha256(source.encode()), + 'stdout_base64':base64.b64encode(mutant.stdout).decode(), + 'stderr_base64':base64.b64encode(mutant.stderr).decode()} + print('LM006_CUSTODY_SOURCE_MUTATION '+json.dumps(record,sort_keys=True),file=sys.stderr) + if __name__=='__main__': unittest.main() diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py index 04bcf9344..dad24b273 100644 --- a/tools/lm006_oned_coefficient_replay.py +++ b/tools/lm006_oned_coefficient_replay.py @@ -6,6 +6,8 @@ import argparse, hashlib, json, os, re, signal, subprocess, sys, time from pathlib import Path, PurePosixPath +_LOADED_SOURCE=Path(__file__).read_bytes() + REPOSITORY='d6g8k5htny-coder/Math-' SOURCE_COMMIT='8fe14358a1ee5d7ef7d7e20520391f62f432fe04' PACKET='coefficients/lm006_wrong_sign_oned_20261006_a62c' @@ -86,15 +88,23 @@ def run_step(argv,cwd,logs,name,expected,kind,timeout=900): if failure is not None: raise ReplayError(failure) return record +def git_env(): + env={key:value for key,value in os.environ.items() if not key.startswith('GIT_')} # MUTATION_GIT_ENV + env.update(GIT_CONFIG_NOSYSTEM='1',GIT_CONFIG_GLOBAL=os.devnull,GIT_NO_REPLACE_OBJECTS='1',GIT_NO_LAZY_FETCH='1',GIT_OPTIONAL_LOCKS='0') # MUTATION_GIT_REPLACE + return env + def git(root,*args): - p=subprocess.run(['git',*args],cwd=root,capture_output=True,timeout=30);require(p.returncode==0,'git_command_failed');return p.stdout.decode('ascii').strip() + p=subprocess.run(['git',*args],cwd=root,capture_output=True,timeout=30,env=git_env());require(p.returncode==0,'git_command_failed');return p.stdout.decode('ascii').strip() def git_head(root): h=git(root,'rev-parse','HEAD');require(re.fullmatch('[0-9a-f]{40}',h) is not None,'invalid_git_head');return h def execution_sources(root,head): result={} for name in EXECUTION_FILES: - raw=source_file(root,name).read_bytes();committed=git(root,'rev-parse',head+':'+name);require(committed==git_blob(raw),'execution_source_drift');result[name]={'git_blob':committed,'sha256':sha256(raw),'bytes':len(raw)} + raw=source_file(root,name).read_bytes() + if name==EXECUTION_FILES[0]: + require(raw==_LOADED_SOURCE,'loaded_driver_drift') # MUTATION_LOADED_DRIVER + committed=git(root,'rev-parse',head+':'+name);require(committed==git_blob(raw),'execution_source_drift');result[name]={'git_blob':committed,'sha256':sha256(raw),'bytes':len(raw)} return result def host_identity(head,env): From ca38ec6b864e242f6b9c4c49172e440b6765479f Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:29:34 -0500 Subject: [PATCH 15/24] Make the LM006 replacement-object mutant actually remove the guard Git treats GIT_NO_REPLACE_OBJECTS as enabled whenever present, including when set to zero. Preserve the failed observations and all original controls. --- .../README.md | 5 +++++ .../normal-red.log | 18 ++++++++++++++++++ .../optimized-red.log | 18 ++++++++++++++++++ tests/test_lm006_oned_coefficient_replay.py | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 cbz/evidence/lm006-replacement-mutation-20261029/README.md create mode 100644 cbz/evidence/lm006-replacement-mutation-20261029/normal-red.log create mode 100644 cbz/evidence/lm006-replacement-mutation-20261029/optimized-red.log diff --git a/cbz/evidence/lm006-replacement-mutation-20261029/README.md b/cbz/evidence/lm006-replacement-mutation-20261029/README.md new file mode 100644 index 000000000..a8e9a4af3 --- /dev/null +++ b/cbz/evidence/lm006-replacement-mutation-20261029/README.md @@ -0,0 +1,5 @@ +# LM006 Git replacement mutation correction + +At head 68cf855bcc953cad6c4a7ac8f04d201d2ccf7949, run 40948228286 observed 20 passes and one failing mutation-control test in both modes. The replacement mutant set GIT_NO_REPLACE_OBJECTS to the string '0'. Git interprets the variable's presence as enabling the no-replacement behavior, so the supposed mutant remained protected. This successor removes the variable from the subprocess environment in the mutant. The original test and the production guard remain unchanged. This records a harness correction, not evidence that the corrected mutant has yet been killed. + +Decision 2026-10-29 20:29:31 UTC: retain both original failure excerpts and all three source mutations; run the corrected test in both modes on the new source. No numerical code or bounds change. diff --git a/cbz/evidence/lm006-replacement-mutation-20261029/normal-red.log b/cbz/evidence/lm006-replacement-mutation-20261029/normal-red.log new file mode 100644 index 000000000..72a5d3544 --- /dev/null +++ b/cbz/evidence/lm006-replacement-mutation-20261029/normal-red.log @@ -0,0 +1,18 @@ +FAIL: test_custody_guards_reject_three_real_source_mutations (test_lm006_oned_coefficient_replay.ReplayTests.test_custody_guards_reject_three_real_source_mutations) (source_mutation='replacement') +2026-10-29T20:24:14.1862014Z ---------------------------------------------------------------------- +2026-10-29T20:24:14.1862627Z Traceback (most recent call last): +2026-10-29T20:24:14.1870144Z File "/home/runner/work/Math-/Math-/tests/test_lm006_oned_coefficient_replay.py", line 233, in test_custody_guards_reject_three_real_source_mutations +2026-10-29T20:24:14.1872039Z self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) +2026-10-29T20:24:14.1873507Z AssertionError: 0 != 1 : test_git_replacement_cannot_relabel_a_frozen_blob (test_lm006_oned_coefficient_replay.ReplayTests.test_git_replacement_cannot_relabel_a_frozen_blob) ... ok +2026-10-29T20:24:14.1874469Z +2026-10-29T20:24:14.1874653Z ---------------------------------------------------------------------- +2026-10-29T20:24:14.1875064Z Ran 1 test in 0.044s +2026-10-29T20:24:14.1875225Z +2026-10-29T20:24:14.1875326Z OK +2026-10-29T20:24:14.1875443Z +2026-10-29T20:24:14.1875454Z +2026-10-29T20:24:14.1875628Z ---------------------------------------------------------------------- +2026-10-29T20:24:14.1876051Z Ran 21 tests in 2.512s +2026-10-29T20:24:14.1876219Z +2026-10-29T20:24:14.1876337Z FAILED (failures=1) +2026-10-29T20:24:14.2045861Z ##[error]Process completed with exit code 1. diff --git a/cbz/evidence/lm006-replacement-mutation-20261029/optimized-red.log b/cbz/evidence/lm006-replacement-mutation-20261029/optimized-red.log new file mode 100644 index 000000000..3b916ac52 --- /dev/null +++ b/cbz/evidence/lm006-replacement-mutation-20261029/optimized-red.log @@ -0,0 +1,18 @@ +FAIL: test_custody_guards_reject_three_real_source_mutations (test_lm006_oned_coefficient_replay.ReplayTests.test_custody_guards_reject_three_real_source_mutations) (source_mutation='replacement') +2026-10-29T20:27:02.6543829Z ---------------------------------------------------------------------- +2026-10-29T20:27:02.6544146Z Traceback (most recent call last): +2026-10-29T20:27:02.6549772Z File "/home/runner/work/Math-/Math-/tests/test_lm006_oned_coefficient_replay.py", line 233, in test_custody_guards_reject_three_real_source_mutations +2026-10-29T20:27:02.6550426Z self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) +2026-10-29T20:27:02.6551081Z AssertionError: 0 != 1 : test_git_replacement_cannot_relabel_a_frozen_blob (test_lm006_oned_coefficient_replay.ReplayTests.test_git_replacement_cannot_relabel_a_frozen_blob) ... ok +2026-10-29T20:27:02.6551568Z +2026-10-29T20:27:02.6551692Z ---------------------------------------------------------------------- +2026-10-29T20:27:02.6551961Z Ran 1 test in 0.035s +2026-10-29T20:27:02.6552266Z +2026-10-29T20:27:02.6552370Z OK +2026-10-29T20:27:02.6552491Z +2026-10-29T20:27:02.6552504Z +2026-10-29T20:27:02.6552645Z ---------------------------------------------------------------------- +2026-10-29T20:27:02.6552913Z Ran 21 tests in 3.085s +2026-10-29T20:27:02.6553023Z +2026-10-29T20:27:02.6553107Z FAILED (failures=1) +2026-10-29T20:27:02.6679713Z ##[error]Process completed with exit code 1. diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 623b4eddc..af0df2552 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -205,7 +205,7 @@ def test_custody_guards_reject_three_real_source_mutations(self): "env=dict(os.environ) # MUTATION_GIT_ENV", 'test_ambient_git_environment_cannot_redirect_source_checks', b'self.assertEqual(mod.git_head(self.root),own)'), - ('replacement',"GIT_NO_REPLACE_OBJECTS='1'","GIT_NO_REPLACE_OBJECTS='0'", + ('replacement',"GIT_NO_REPLACE_OBJECTS='1',","", 'test_git_replacement_cannot_relabel_a_frozen_blob', b"self.assertEqual(mod.git(self.root,'show',original+':'+relative),expected)"), ('loaded',"require(raw==_LOADED_SOURCE,'loaded_driver_drift') # MUTATION_LOADED_DRIVER", From ae3c35b41590ae8494c37602cdf87fc09c6ffb26 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:35:37 -0500 Subject: [PATCH 16/24] Expose timestamp-valid poisoned LM006 test-loader bytecode --- .github/workflows/cbz-lm006-bytecode.yml | 27 ++++++++++++++++ tests/test_lm006_oned_coefficient_replay.py | 34 +++++++++++++++++++-- 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/cbz-lm006-bytecode.yml diff --git a/.github/workflows/cbz-lm006-bytecode.yml b/.github/workflows/cbz-lm006-bytecode.yml new file mode 100644 index 000000000..afc0a492e --- /dev/null +++ b/.github/workflows/cbz-lm006-bytecode.yml @@ -0,0 +1,27 @@ +name: CBZ LM006 poisoned bytecode control +on: + push: + branches: [cbz/lm006-loaded-code-20261029] + workflow_dispatch: +permissions: + contents: read +jobs: + stale-bytecode: + strategy: + fail-fast: false + matrix: + mode: [normal, optimized] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 + with: + python-version: '3.11.16' + - name: Exercise timestamp-valid bytecode substitution + env: + CBZ_MODE: ${{ matrix.mode }} + run: | + set -euo pipefail + flags=() + if [ "$CBZ_MODE" = optimized ]; then flags=(-O); fi + python -B -S "${flags[@]}" -m unittest discover -s tests -p test_lm006_oned_coefficient_replay.py -k timestamp_valid_poisoned -v diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index af0df2552..535e87a98 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -4,11 +4,16 @@ DRIVER=Path(__file__).resolve().parents[1]/'tools/lm006_oned_coefficient_replay.py' +def load_driver(path): + spec=importlib.util.spec_from_file_location('trusted_driver',path) + module=importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + class ReplayTests(unittest.TestCase): def setUp(self): self.assertTrue(DRIVER.is_file(),'replay implementation missing') - spec=importlib.util.spec_from_file_location('oned_replay',DRIVER) - self.m=importlib.util.module_from_spec(spec);spec.loader.exec_module(self.m) + self.m=load_driver(DRIVER) self.tmp=tempfile.TemporaryDirectory();self.addCleanup(self.tmp.cleanup) self.root=Path(self.tmp.name)/'repo';self.root.mkdir();self.logs=Path(self.tmp.name)/'logs';self.logs.mkdir() @@ -22,6 +27,29 @@ def fixture(self): def child(self, code, expected=b'ok\n', timeout=3, name='child'): return self.m.run_step([sys.executable,'-B','-S','-c',code],self.root,self.logs,name,expected,'exact',timeout) + def test_timestamp_valid_poisoned_bytecode_cannot_replace_source(self): + import py_compile + source=DRIVER.read_bytes() + original=b"REPOSITORY='d6g8k5htny-coder/Math-'" + poisoned=b"REPOSITORY='x6g8k5htny-coder/Math-'" + self.assertEqual(source.count(original),1) + self.assertEqual(len(original),len(poisoned)) + path=self.root/'poisoned_driver.py' + path.write_bytes(source.replace(original,poisoned,1)) + timestamp=1700000000 + os.utime(path,(timestamp,timestamp)) + py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + path.write_bytes(source) + os.utime(path,(timestamp,timestamp)) + self.assertEqual(path.stat().st_size,len(source)) + spec=importlib.util.spec_from_file_location('unsafe_demonstration',path) + unsafe=importlib.util.module_from_spec(spec);spec.loader.exec_module(unsafe) + self.assertEqual(unsafe.REPOSITORY,'x6g8k5htny-coder/Math-','fixture must actually load poisoned bytecode') + self.assertEqual(unsafe._LOADED_SOURCE,source,'loaded-source read alone does not bind executed code') + verified=load_driver(path) + self.assertEqual(verified.REPOSITORY,'d6g8k5htny-coder/Math-') + self.assertEqual(verified._LOADED_SOURCE,source) + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) @@ -104,7 +132,7 @@ def synthetic_project(self, bad_test=False, output='synthetic', mutate=False): d=self.root/name;d.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(DRIVER.parents[1]/name,d) subprocess.run(['git','init','-q'],cwd=self.root,check=True);subprocess.run(['git','add','.'],cwd=self.root,check=True) subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','fixture'],cwd=self.root,check=True) - spec=importlib.util.spec_from_file_location('fixture_driver',self.root/self.m.EXECUTION_FILES[0]);mod=importlib.util.module_from_spec(spec);spec.loader.exec_module(mod) + mod=load_driver(self.root/self.m.EXECUTION_FILES[0]) mod.PINS={n:mod.git_blob((self.root/n).read_bytes()) for n in pins} return mod From 50c5aebbf3ee743cea83d868b8ff22bed5f2d099 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:39:08 -0500 Subject: [PATCH 17/24] Bind LM006 executed code to the actual source bytes Compile the test loader from a single read and reject ordinary stale code; retain actual poisoned-bytecode failures and the stronger bypass control. --- .github/workflows/cbz-lm006-bytecode.yml | 2 +- .../lm006-bytecode-20261029/normal-red.log | 20 +++++++ .../DECISIONS.md | 2 + .../GOVERNANCE.md | 6 ++ .../README.md | 6 ++ tests/test_lm006_oned_coefficient_replay.py | 55 ++++++++++++++++++- tools/lm006_oned_coefficient_replay.py | 1 + 7 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 cbz/evidence/lm006-bytecode-20261029/normal-red.log diff --git a/.github/workflows/cbz-lm006-bytecode.yml b/.github/workflows/cbz-lm006-bytecode.yml index afc0a492e..1b107ee10 100644 --- a/.github/workflows/cbz-lm006-bytecode.yml +++ b/.github/workflows/cbz-lm006-bytecode.yml @@ -24,4 +24,4 @@ jobs: set -euo pipefail flags=() if [ "$CBZ_MODE" = optimized ]; then flags=(-O); fi - python -B -S "${flags[@]}" -m unittest discover -s tests -p test_lm006_oned_coefficient_replay.py -k timestamp_valid_poisoned -v + python -B -S "${flags[@]}" -m unittest discover -s tests -p test_lm006_oned_coefficient_replay.py -v diff --git a/cbz/evidence/lm006-bytecode-20261029/normal-red.log b/cbz/evidence/lm006-bytecode-20261029/normal-red.log new file mode 100644 index 000000000..5e0ca2bd3 --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/normal-red.log @@ -0,0 +1,20 @@ +2026-10-29T20:36:34.7764685Z test_timestamp_valid_poisoned_bytecode_cannot_replace_source (test_lm006_oned_coefficient_replay.ReplayTests.test_timestamp_valid_poisoned_bytecode_cannot_replace_source) ... FAIL +2026-10-29T20:36:34.7768117Z +2026-10-29T20:36:34.7768617Z ====================================================================== +2026-10-29T20:36:34.7769777Z FAIL: test_timestamp_valid_poisoned_bytecode_cannot_replace_source (test_lm006_oned_coefficient_replay.ReplayTests.test_timestamp_valid_poisoned_bytecode_cannot_replace_source) +2026-10-29T20:36:34.7770890Z ---------------------------------------------------------------------- +2026-10-29T20:36:34.7771357Z Traceback (most recent call last): +2026-10-29T20:36:34.7779695Z File "/home/runner/work/Math-/Math-/tests/test_lm006_oned_coefficient_replay.py", line 50, in test_timestamp_valid_poisoned_bytecode_cannot_replace_source +2026-10-29T20:36:34.7780792Z self.assertEqual(verified.REPOSITORY,'d6g8k5htny-coder/Math-') +2026-10-29T20:36:34.7781405Z AssertionError: 'x6g8k5htny-coder/Math-' != 'd6g8k5htny-coder/Math-' +2026-10-29T20:36:34.7781927Z - x6g8k5htny-coder/Math- +2026-10-29T20:36:34.7782334Z ? ^ +2026-10-29T20:36:34.7782578Z + d6g8k5htny-coder/Math- +2026-10-29T20:36:34.7782805Z ? ^ +2026-10-29T20:36:34.7782909Z +2026-10-29T20:36:34.7782914Z +2026-10-29T20:36:34.7783087Z ---------------------------------------------------------------------- +2026-10-29T20:36:34.7783439Z Ran 1 test in 0.010s +2026-10-29T20:36:34.7783570Z +2026-10-29T20:36:34.7783656Z FAILED (failures=1) +2026-10-29T20:36:34.7882452Z ##[error]Process completed with exit code 1. diff --git a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md index 7ee1db744..1b7b4fdc8 100644 --- a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md +++ b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md @@ -7,3 +7,5 @@ [2026-10-29 20:20:44 UTC] [phase2] [layerA+B] [repair custody] Optimized20-method RED82c9004 has exactly3 intended failures: ambient Git, replacement refs, imported driver successor. Add sanitized Git and loaded-source guards, retain original tests, add actual3-source-mutant controls in both modes. Reversible. Evidence: run40946125351/job123701825783 and artifact12928953745. Normal original-driver RED remained queued and is not claimed. [2026-10-29 20:20:44 UTC] [phase2] [layerB] [register] Add local GOVERNANCE and exact commands/self-verification boundaries. Final federation canonical registry adoption remains part of integration. Reversible. Evidence: source-local registry and PR533 observations. + +[2026-10-29 20:39:07 UTC] [phase3] [layer B] Fix LM006 supported import path to compile one read of source bytes, record those exact bytes, and compare ordinary module code against its source. Preserve observed stale-bytecode RED; retain every existing control and add an actual bypass test plus reason-bound loader mutation. Arbitrary malicious bytecode can delete its own self-check; the trusted source loader is required. No numerical source or bound changed. Reversible:yes. Evidence:cbz/evidence/lm006-bytecode-20261029/normal-red.log. diff --git a/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md index 346d22bbd..841c3e7f0 100644 --- a/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md +++ b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md @@ -12,3 +12,9 @@ Source-local registry for federation criterion9. Main's canonical GOVERNANCE.md All tools: maintenance owner none — self-contained. These tools serve criteria5,7,9 and operational source custody; they do not admit new mathematical theorems. Layer B rule (2026-10-29 20:20:44 UTC): custody Git commands remove inherited GIT_* overrides, ignore global/system config, disable replacement refs and lazy fetching. Loaded driver bytes are checked before/after execution. Synthetic fixtures and source mutants are operational evidence; scientific packet/result bytes and all original test methods are preserved. + +## LM006 executed-code identity + +The supported test harness imports the exact single-read driver source with `compile` and `exec`, and binds its later source check to the very same bytes. The driver also compares its running module code object with the code compiled from its current source and refuses ordinary stale bytecode. The workflow's direct Python script execution compiles source. Arbitrary attacker-controlled bytecode can remove any self-check inside itself; callers requiring source identity must use the source-only loader or direct script execution. This is execution/custody evidence, not mathematical or formal verification, and changes no numerical bounds. + +The normal-mode intended RED was observed at source ae3c35b41590ae8494c37602cdf87fc09c6ffb26, run40950416828/job123716743203: one actual timestamp-valid, same-size poisoned bytecode executed although the recorded loaded-source bytes were legitimate. See the retained [failure excerpt](../../cbz/evidence/lm006-bytecode-20261029/normal-red.log). A repaired-source hosted run of all preserved tests and source mutations in both modes remains required; do not infer a pass from this commit. diff --git a/reviews/cbz_wrapper_composition_20261029/README.md b/reviews/cbz_wrapper_composition_20261029/README.md index 0fb45ffa0..2e3a056f8 100644 --- a/reviews/cbz_wrapper_composition_20261029/README.md +++ b/reviews/cbz_wrapper_composition_20261029/README.md @@ -42,3 +42,9 @@ Three real-Git/API controls produced an actual optimized RED at head82c9004c2a64 The driver now sanitizes its Git environment, disables replacement objects, and checks loaded driver bytes inside both execution-source snapshots. The focused suite has21 methods, preserving all original17. For each new guard, it also runs a clean target baseline and an actual source mutant. Every child must run exactly its intended test in the requested interpreter mode and fail for that guard's reason. Full mutant streams are retained as base64 in LM006_CUSTODY_SOURCE_MUTATION log records. The declared threshold is3/3 source mutants in EACH Python mode; the paired focused commands above execute it. Fresh guard-fix results had not yet completed when this text was prepared; consult their exact native head and checkout identities. See [tool registry](GOVERNANCE.md) and [decision ledger](DECISIONS.md). Historical SCOPE records retain their original observations; their superseded author/family/approval requirements do not govern CBZ admission. + +## LM006 executed-code identity + +The supported test harness imports the exact single-read driver source with `compile` and `exec`, and binds its later source check to the very same bytes. The driver also compares its running module code object with the code compiled from its current source and refuses ordinary stale bytecode. The workflow's direct Python script execution compiles source. Arbitrary attacker-controlled bytecode can remove any self-check inside itself; callers requiring source identity must use the source-only loader or direct script execution. This is execution/custody evidence, not mathematical or formal verification, and changes no numerical bounds. + +The normal-mode intended RED was observed at source ae3c35b41590ae8494c37602cdf87fc09c6ffb26, run40950416828/job123716743203: one actual timestamp-valid, same-size poisoned bytecode executed although the recorded loaded-source bytes were legitimate. See the retained [failure excerpt](../../cbz/evidence/lm006-bytecode-20261029/normal-red.log). A repaired-source hosted run of all preserved tests and source mutations in both modes remains required; do not infer a pass from this commit. diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 535e87a98..649041d19 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -7,7 +7,9 @@ def load_driver(path): spec=importlib.util.spec_from_file_location('trusted_driver',path) module=importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) + raw=Path(path).read_bytes() + exec(compile(raw,str(path),'exec',dont_inherit=True),module.__dict__) # SOURCE_ONLY_LOADER + module._LOADED_SOURCE=raw return module class ReplayTests(unittest.TestCase): @@ -35,7 +37,10 @@ def test_timestamp_valid_poisoned_bytecode_cannot_replace_source(self): self.assertEqual(source.count(original),1) self.assertEqual(len(original),len(poisoned)) path=self.root/'poisoned_driver.py' - path.write_bytes(source.replace(original,poisoned,1)) + guard=b"if sys._getframe().f_code != compile(_LOADED_SOURCE,sys._getframe().f_code.co_filename,'exec',dont_inherit=True): raise RuntimeError('loaded_driver_drift') # VERIFY_LOADED_CODE" + self.assertEqual(source.count(guard),1) + guardless=b"#"+b" "*(len(guard)-1) + path.write_bytes(source.replace(original,poisoned,1).replace(guard,guardless,1)) timestamp=1700000000 os.utime(path,(timestamp,timestamp)) py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) @@ -50,6 +55,52 @@ def test_timestamp_valid_poisoned_bytecode_cannot_replace_source(self): self.assertEqual(verified.REPOSITORY,'d6g8k5htny-coder/Math-') self.assertEqual(verified._LOADED_SOURCE,source) + def test_poisoned_bytecode_control_kills_loader_mutation(self): + import shutil + source=Path(__file__).read_text() + anchor="exec(compile(raw,str(path),'exec',dont_inherit=True),"+"module.__dict__) # SOURCE_ONLY_LOADER" + replacement="spec.loader.exec_module(module) # SOURCE_ONLY_LOADER" + self.assertEqual(source.count(anchor),1) + with tempfile.TemporaryDirectory(prefix='lm006-loader-mutation-') as directory: + root=Path(directory) + test_path=root/'tests/test_lm006_oned_coefficient_replay.py' + driver_path=root/'tools/lm006_oned_coefficient_replay.py' + test_path.parent.mkdir(parents=True) + driver_path.parent.mkdir(parents=True) + shutil.copyfile(DRIVER,driver_path) + command=[sys.executable,'-B','-S']+(['-O'] if sys.flags.optimize else [])+['-m','unittest','discover','-s','tests','-p','test_lm006_oned_coefficient_replay.py','-k','test_timestamp_valid_poisoned','-v'] + test_path.write_text(source) + good=subprocess.run(command,cwd=root,capture_output=True,timeout=30) + self.assertEqual(good.returncode,0,good.stderr.decode()) + self.assertIn(b'Ran 1 test in',good.stderr) + self.assertTrue(good.stderr.endswith(b'\nOK\n')) + test_path.write_text(source.replace(anchor,replacement,1)) + mutant=subprocess.run(command,cwd=root,capture_output=True,timeout=30) + self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) + self.assertEqual(mutant.stdout,b'') + self.assertIn(b'Ran 1 test in',mutant.stderr) + self.assertIn(b'FAILED (failures=1)',mutant.stderr) + self.assertIn(b"AssertionError: 'x6g8k5htny-coder/Math-'",mutant.stderr) + self.assertNotIn(b'ERROR:',mutant.stderr) + + def test_direct_import_detects_timestamp_valid_stale_code(self): + import py_compile + source=DRIVER.read_bytes() + old=b"REPOSITORY='d6g8k5htny-coder/Math-'" + new=b"REPOSITORY='x6g8k5htny-coder/Math-'" + self.assertEqual(source.count(old),1) + path=self.root/'drift_driver.py' + path.write_bytes(source.replace(old,new,1)) + os.utime(path,(1700000000,1700000000)) + py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + path.write_bytes(source) + os.utime(path,(1700000000,1700000000)) + spec=importlib.util.spec_from_file_location('drift_driver',path) + module=importlib.util.module_from_spec(spec) + with self.assertRaisesRegex(RuntimeError,'^loaded_driver_drift$'): + spec.loader.exec_module(module) + self.assertEqual(module._LOADED_SOURCE,source) + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py index dad24b273..55222ce7c 100644 --- a/tools/lm006_oned_coefficient_replay.py +++ b/tools/lm006_oned_coefficient_replay.py @@ -7,6 +7,7 @@ from pathlib import Path, PurePosixPath _LOADED_SOURCE=Path(__file__).read_bytes() +if sys._getframe().f_code != compile(_LOADED_SOURCE,sys._getframe().f_code.co_filename,'exec',dont_inherit=True): raise RuntimeError('loaded_driver_drift') # VERIFY_LOADED_CODE REPOSITORY='d6g8k5htny-coder/Math-' SOURCE_COMMIT='8fe14358a1ee5d7ef7d7e20520391f62f432fe04' From e4e8e30c4365b583d2b50033fe247cd085d6db88 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:39:42 -0500 Subject: [PATCH 18/24] Check the stale-import guard with an intended source mutation --- tests/test_lm006_oned_coefficient_replay.py | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 649041d19..602d16185 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -101,6 +101,33 @@ def test_direct_import_detects_timestamp_valid_stale_code(self): spec.loader.exec_module(module) self.assertEqual(module._LOADED_SOURCE,source) + def test_direct_import_guard_mutation_is_rejected(self): + import shutil + driver=DRIVER.read_text() + anchor="if sys._getframe().f_code != compile(_LOADED_SOURCE,sys._getframe().f_code.co_filename,'exec',dont_inherit=True): raise RuntimeError('loaded_driver_drift') # VERIFY_LOADED_CODE" + self.assertEqual(driver.count(anchor),1) + with tempfile.TemporaryDirectory(prefix='lm006-guard-mutation-') as directory: + root=Path(directory) + test_path=root/'tests/test_lm006_oned_coefficient_replay.py' + driver_path=root/'tools/lm006_oned_coefficient_replay.py' + test_path.parent.mkdir(parents=True) + driver_path.parent.mkdir(parents=True) + shutil.copyfile(Path(__file__),test_path) + driver_path.write_text(driver) + command=[sys.executable,'-B','-S']+(['-O'] if sys.flags.optimize else [])+['-m','unittest','discover','-s','tests','-p','test_lm006_oned_coefficient_replay.py','-k','test_direct_import_detects_timestamp_valid_stale_code','-v'] + good=subprocess.run(command,cwd=root,capture_output=True,timeout=30) + self.assertEqual(good.returncode,0,good.stderr.decode()) + self.assertIn(b'Ran 1 test in',good.stderr) + self.assertTrue(good.stderr.endswith(b'\nOK\n')) + driver_path.write_text(driver.replace(anchor,'# guard removed',1)) + mutant=subprocess.run(command,cwd=root,capture_output=True,timeout=30) + self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) + self.assertEqual(mutant.stdout,b'') + self.assertIn(b'Ran 1 test in',mutant.stderr) + self.assertIn(b'FAILED (failures=1)',mutant.stderr) + self.assertIn(b'AssertionError: RuntimeError not raised',mutant.stderr) + self.assertNotIn(b'ERROR:',mutant.stderr) + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) From b626da6201ea7ad20a0082127d17e9a9fae4f23b Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:41:58 -0500 Subject: [PATCH 19/24] Exercise poisoned packet test and implementation bytecode --- .../workflows/cbz-lm006-packet-bytecode.yml | 27 +++++++++++++ tests/test_lm006_oned_coefficient_replay.py | 39 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/cbz-lm006-packet-bytecode.yml diff --git a/.github/workflows/cbz-lm006-packet-bytecode.yml b/.github/workflows/cbz-lm006-packet-bytecode.yml new file mode 100644 index 000000000..ea047d67e --- /dev/null +++ b/.github/workflows/cbz-lm006-packet-bytecode.yml @@ -0,0 +1,27 @@ +name: CBZ LM006 packet bytecode controls +on: + push: + branches: [cbz/lm006-loaded-code-20261029] + workflow_dispatch: +permissions: + contents: read +jobs: + packet-bytecode: + strategy: + fail-fast: false + matrix: + mode: [normal, optimized] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 + with: + python-version: '3.11.16' + - name: Exercise source-bound packet imports + env: + CBZ_MODE: ${{ matrix.mode }} + run: | + set -euo pipefail + flags=() + if [ "$CBZ_MODE" = optimized ]; then flags=(-O); fi + python -B -S "${flags[@]}" -m unittest discover -s tests -p test_lm006_oned_coefficient_replay.py -k test_packet_pyc -v diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 602d16185..250c685a6 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -128,6 +128,45 @@ def test_direct_import_guard_mutation_is_rejected(self): self.assertIn(b'AssertionError: RuntimeError not raised',mutant.stderr) self.assertNotIn(b'ERROR:',mutant.stderr) + def _packet_pyc_fixture(self, target): + import py_compile + mod=self.synthetic_project() + packet=self.root/mod.PACKET + test_file=packet/'test_oned.py' + oned=packet/'oned.py' + body=test_file.read_text().replace('import unittest\n','import unittest, oned\n',1) + body=body.replace('self.assertTrue(True)','self.assertEqual(oned.VALUE,1)') + test_file.write_text(body) + oned.write_text("import sys\nVALUE=1\nif __name__ == '__main__':\n if sys.argv[1:] != ['--panels','1024']: raise SystemExit(2)\n print('synthetic')\n") + subprocess.run(['git','add',str(test_file.relative_to(self.root)),str(oned.relative_to(self.root))],cwd=self.root,check=True) + subprocess.run(['git','-c','user.name=Fixture','-c','user.email=f@example.invalid','-c','commit.gpgsign=false','commit','-qm','cache test fixture'],cwd=self.root,check=True) + mod.PINS={n:mod.git_blob((self.root/n).read_bytes()) for n in mod.PINS} + path=test_file if target=='test' else oned + original=path.read_bytes() + before=b'self.assertEqual(oned.VALUE,1)' if target=='test' else b'VALUE=1' + after=b'self.assertEqual(oned.VALUE,0)' if target=='test' else b'VALUE=0' + self.assertEqual(original.count(before),15 if target=='test' else 1) + self.assertEqual(len(before),len(after)) + path.write_bytes(original.replace(before,after,1)) + os.utime(path,(1700000000,1700000000)) + py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + path.write_bytes(original) + os.utime(path,(1700000000,1700000000)) + out=Path(self.tmp.name)/('packet-pyc-'+target) + try: + receipt=mod.execute(self.root,out,'optimized' if sys.flags.optimize else 'normal') + except mod.ReplayError as exc: + self.assertEqual(str(exc),'unexpected_exit') + self.assertIn(b'FAIL:',(out/'tests.stderr').read_bytes()) + self.fail('packet tests executed poisoned '+target+' bytecode') + self.assertEqual(receipt['status'],'PASS') + + def test_packet_pyc_test_module_is_not_executed(self): + self._packet_pyc_fixture('test') + + def test_packet_pyc_implementation_is_not_executed(self): + self._packet_pyc_fixture('implementation') + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) From 0bb61e56e7f0185e601428048e6f108960ee8d1f Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:43:21 -0500 Subject: [PATCH 20/24] Exercise external poisoned caches without violating packet membership --- tests/test_lm006_oned_coefficient_replay.py | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 250c685a6..b610b8a24 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -149,16 +149,26 @@ def _packet_pyc_fixture(self, target): self.assertEqual(len(before),len(after)) path.write_bytes(original.replace(before,after,1)) os.utime(path,(1700000000,1700000000)) - py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + cache=Path(self.tmp.name)/'external-cache' + cache.mkdir() + previous=sys.pycache_prefix + try: + sys.pycache_prefix=str(cache) + py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + finally: + sys.pycache_prefix=previous path.write_bytes(original) os.utime(path,(1700000000,1700000000)) + self.assertNotIn('__pycache__', [p.name for p in packet.iterdir()]) out=Path(self.tmp.name)/('packet-pyc-'+target) - try: - receipt=mod.execute(self.root,out,'optimized' if sys.flags.optimize else 'normal') - except mod.ReplayError as exc: - self.assertEqual(str(exc),'unexpected_exit') - self.assertIn(b'FAIL:',(out/'tests.stderr').read_bytes()) - self.fail('packet tests executed poisoned '+target+' bytecode') + from unittest.mock import patch + with patch.dict(os.environ,{'PYTHONPYCACHEPREFIX':str(cache)}): + try: + receipt=mod.execute(self.root,out,'optimized' if sys.flags.optimize else 'normal') + except mod.ReplayError as exc: + self.assertEqual(str(exc),'unexpected_exit') + self.assertIn(b'FAIL:',(out/'tests.stderr').read_bytes()) + self.fail('packet tests executed poisoned '+target+' bytecode') self.assertEqual(receipt['status'],'PASS') def test_packet_pyc_test_module_is_not_executed(self): From 2224dd97dd912c85dd0dcddecaa11b5f9eb692a1 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:44:10 -0500 Subject: [PATCH 21/24] Verify timestamp cache headers in poisoned-bytecode fixtures --- tests/test_lm006_oned_coefficient_replay.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index b610b8a24..fbb37fca9 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -4,6 +4,15 @@ DRIVER=Path(__file__).resolve().parents[1]/'tools/lm006_oned_coefficient_replay.py' +def compile_timestamp_cache(test,path): + import py_compile, struct + filename=py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize, + invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP) + header=Path(filename).read_bytes()[:16] + magic,flags,mtime,size=struct.unpack('<4sIII',header) + test.assertEqual(magic,importlib.util.MAGIC_NUMBER) + test.assertEqual((flags,mtime,size),(0,1700000000,path.stat().st_size)) + def load_driver(path): spec=importlib.util.spec_from_file_location('trusted_driver',path) module=importlib.util.module_from_spec(spec) @@ -43,7 +52,7 @@ def test_timestamp_valid_poisoned_bytecode_cannot_replace_source(self): path.write_bytes(source.replace(original,poisoned,1).replace(guard,guardless,1)) timestamp=1700000000 os.utime(path,(timestamp,timestamp)) - py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + compile_timestamp_cache(self,path) path.write_bytes(source) os.utime(path,(timestamp,timestamp)) self.assertEqual(path.stat().st_size,len(source)) @@ -92,7 +101,7 @@ def test_direct_import_detects_timestamp_valid_stale_code(self): path=self.root/'drift_driver.py' path.write_bytes(source.replace(old,new,1)) os.utime(path,(1700000000,1700000000)) - py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + compile_timestamp_cache(self,path) path.write_bytes(source) os.utime(path,(1700000000,1700000000)) spec=importlib.util.spec_from_file_location('drift_driver',path) @@ -154,7 +163,7 @@ def _packet_pyc_fixture(self, target): previous=sys.pycache_prefix try: sys.pycache_prefix=str(cache) - py_compile.compile(str(path),doraise=True,optimize=sys.flags.optimize) + compile_timestamp_cache(self,path) finally: sys.pycache_prefix=previous path.write_bytes(original) From dc1549ed32cc3b6c88c7e4975a177a49309c9692 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:45:09 -0500 Subject: [PATCH 22/24] Isolate LM006 child interpreter bytecode caches --- .../DECISIONS.md | 2 ++ .../GOVERNANCE.md | 2 ++ .../README.md | 2 ++ tests/test_lm006_oned_coefficient_replay.py | 27 +++++++++++++++++++ tools/lm006_oned_coefficient_replay.py | 27 ++++++++++--------- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md index 1b7b4fdc8..f923601c4 100644 --- a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md +++ b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md @@ -9,3 +9,5 @@ [2026-10-29 20:20:44 UTC] [phase2] [layerB] [register] Add local GOVERNANCE and exact commands/self-verification boundaries. Final federation canonical registry adoption remains part of integration. Reversible. Evidence: source-local registry and PR533 observations. [2026-10-29 20:39:07 UTC] [phase3] [layer B] Fix LM006 supported import path to compile one read of source bytes, record those exact bytes, and compare ordinary module code against its source. Preserve observed stale-bytecode RED; retain every existing control and add an actual bypass test plus reason-bound loader mutation. Arbitrary malicious bytecode can delete its own self-check; the trusted source loader is required. No numerical source or bound changed. Reversible:yes. Evidence:cbz/evidence/lm006-bytecode-20261029/normal-red.log. + +[2026-10-29 20:45:07 UTC] [phase3] [layer B] Isolate spawned LM006 interpreter bytecode caches in newly created private empty directories and remove inherited PYTHON variables. Preserve exact packet tests, execution outputs and bounds; retain tests that exercise external poisoned caches for test_oned and oned plus a reason-bound source mutation for each. The earlier imported-driver cache defect has observed RED; the packet-specific old-source jobs and repaired-source jobs remain pending. Reversible:yes. Evidence:tests/test_lm006_oned_coefficient_replay.py. diff --git a/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md index 841c3e7f0..09696a6f5 100644 --- a/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md +++ b/reviews/cbz_wrapper_composition_20261029/GOVERNANCE.md @@ -18,3 +18,5 @@ Layer B rule (2026-10-29 20:20:44 UTC): custody Git commands remove inherited GI The supported test harness imports the exact single-read driver source with `compile` and `exec`, and binds its later source check to the very same bytes. The driver also compares its running module code object with the code compiled from its current source and refuses ordinary stale bytecode. The workflow's direct Python script execution compiles source. Arbitrary attacker-controlled bytecode can remove any self-check inside itself; callers requiring source identity must use the source-only loader or direct script execution. This is execution/custody evidence, not mathematical or formal verification, and changes no numerical bounds. The normal-mode intended RED was observed at source ae3c35b41590ae8494c37602cdf87fc09c6ffb26, run40950416828/job123716743203: one actual timestamp-valid, same-size poisoned bytecode executed although the recorded loaded-source bytes were legitimate. See the retained [failure excerpt](../../cbz/evidence/lm006-bytecode-20261029/normal-red.log). A repaired-source hosted run of all preserved tests and source mutations in both modes remains required; do not infer a pass from this commit. + +The child-process runner now removes inherited PYTHON variables, creates a fresh private empty bytecode-cache prefix for each child, and continues to use -B for the packet test and coefficient process. This prevents externally supplied timestamp-valid caches from replacing packet or standard-library source during the supported child execution. The retained same-size/same-mtime packet controls cover both test_oned.py and its imported oned.py, and a named source mutation must be rejected for each. The packet-control pre-repair source is commit 2224dd97dd912c85dd0dcddecaa11b5f9eb692a1; its hosted runs are queued and no RED is inferred from that queue. The previously observed driver-import RED remains recorded separately. Repaired-source full-suite and mutation executions in both modes are pending. diff --git a/reviews/cbz_wrapper_composition_20261029/README.md b/reviews/cbz_wrapper_composition_20261029/README.md index 2e3a056f8..23ef8efa5 100644 --- a/reviews/cbz_wrapper_composition_20261029/README.md +++ b/reviews/cbz_wrapper_composition_20261029/README.md @@ -48,3 +48,5 @@ See [tool registry](GOVERNANCE.md) and [decision ledger](DECISIONS.md). Historic The supported test harness imports the exact single-read driver source with `compile` and `exec`, and binds its later source check to the very same bytes. The driver also compares its running module code object with the code compiled from its current source and refuses ordinary stale bytecode. The workflow's direct Python script execution compiles source. Arbitrary attacker-controlled bytecode can remove any self-check inside itself; callers requiring source identity must use the source-only loader or direct script execution. This is execution/custody evidence, not mathematical or formal verification, and changes no numerical bounds. The normal-mode intended RED was observed at source ae3c35b41590ae8494c37602cdf87fc09c6ffb26, run40950416828/job123716743203: one actual timestamp-valid, same-size poisoned bytecode executed although the recorded loaded-source bytes were legitimate. See the retained [failure excerpt](../../cbz/evidence/lm006-bytecode-20261029/normal-red.log). A repaired-source hosted run of all preserved tests and source mutations in both modes remains required; do not infer a pass from this commit. + +The child-process runner now removes inherited PYTHON variables, creates a fresh private empty bytecode-cache prefix for each child, and continues to use -B for the packet test and coefficient process. This prevents externally supplied timestamp-valid caches from replacing packet or standard-library source during the supported child execution. The retained same-size/same-mtime packet controls cover both test_oned.py and its imported oned.py, and a named source mutation must be rejected for each. The packet-control pre-repair source is commit 2224dd97dd912c85dd0dcddecaa11b5f9eb692a1; its hosted runs are queued and no RED is inferred from that queue. The previously observed driver-import RED remains recorded separately. Repaired-source full-suite and mutation executions in both modes are pending. diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index fbb37fca9..1d64cd83a 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -186,6 +186,33 @@ def test_packet_pyc_test_module_is_not_executed(self): def test_packet_pyc_implementation_is_not_executed(self): self._packet_pyc_fixture('implementation') + def test_isolated_cache_source_mutation_is_rejected(self): + import shutil + source=DRIVER.read_text() + anchor="env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPYCACHEPREFIX=cache) # MUTATION_ISOLATED_PYC" + replacement="env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPYCACHEPREFIX=os.environ.get('PYTHONPYCACHEPREFIX','')) # MUTATION_ISOLATED_PYC" + self.assertEqual(source.count(anchor),1) + for target in ('test','implementation'): + with self.subTest(packet_file=target), tempfile.TemporaryDirectory(prefix='lm006-cache-mutation-') as directory: + root=Path(directory) + for relative in self.m.EXECUTION_FILES: + destination=root/relative + destination.parent.mkdir(parents=True,exist_ok=True) + shutil.copyfile(DRIVER.parents[1]/relative,destination) + command=[sys.executable,'-B','-S']+(['-O'] if sys.flags.optimize else [])+['-m','unittest','discover','-s','tests','-p','test_lm006_oned_coefficient_replay.py','-k','test_packet_pyc_'+('test_module' if target=='test' else 'implementation'),'-v'] + good=subprocess.run(command,cwd=root,capture_output=True,timeout=60) + self.assertEqual(good.returncode,0,good.stderr.decode()) + self.assertIn(b'Ran 1 test in',good.stderr) + self.assertTrue(good.stderr.endswith(b'\nOK\n')) + (root/self.m.EXECUTION_FILES[0]).write_text(source.replace(anchor,replacement,1)) + mutant=subprocess.run(command,cwd=root,capture_output=True,timeout=60) + self.assertEqual(mutant.returncode,1,mutant.stderr.decode()) + self.assertEqual(mutant.stdout,b'') + self.assertIn(b'Ran 1 test in',mutant.stderr) + self.assertIn(b'FAILED (failures=1)',mutant.stderr) + self.assertIn(('packet tests executed poisoned '+target+' bytecode').encode(),mutant.stderr) + self.assertNotIn(b'ERROR:',mutant.stderr) + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py index 55222ce7c..cddddd535 100644 --- a/tools/lm006_oned_coefficient_replay.py +++ b/tools/lm006_oned_coefficient_replay.py @@ -3,7 +3,7 @@ Standard library / POSIX only. Execution/custody interlock, not theorem acceptance. """ -import argparse, hashlib, json, os, re, signal, subprocess, sys, time +import argparse, hashlib, json, os, re, signal, subprocess, sys, tempfile, time from pathlib import Path, PurePosixPath _LOADED_SOURCE=Path(__file__).read_bytes() @@ -65,17 +65,20 @@ def run_step(argv,cwd,logs,name,expected,kind,timeout=900): logs=Path(logs); out=logs/(name+'.stdout');err=logs/(name+'.stderr');proc=logs/(name+'.process.json') require(not any(p.exists() or p.is_symlink() for p in (out,err,proc)),'step_evidence_exists') start=time.monotonic_ns();record={'command':list(map(str,argv)),'returncode':None,'timed_out':False,'status':'FAIL','timeout_seconds':timeout};failure=None - with out.open('xb') as so,err.open('xb') as se: - try: - child=subprocess.Popen(argv,cwd=cwd,stdout=so,stderr=se,start_new_session=True,env={**os.environ,'PYTHONDONTWRITEBYTECODE':'1'}) - try: record['returncode']=child.wait(timeout=timeout) - except subprocess.TimeoutExpired: - record['timed_out']=True;failure='timeout' - try: os.killpg(child.pid,signal.SIGKILL) - except ProcessLookupError: pass - try: record['returncode']=child.wait(timeout=5) - except subprocess.TimeoutExpired: record['detail']='process-group termination did not finish in 5 seconds' - except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) + with tempfile.TemporaryDirectory(prefix='lm006-empty-pyc-') as cache: + env={key:value for key,value in os.environ.items() if not key.startswith('PYTHON')} + env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPYCACHEPREFIX=cache) # MUTATION_ISOLATED_PYC + with out.open('xb') as so,err.open('xb') as se: + try: + child=subprocess.Popen(argv,cwd=cwd,stdout=so,stderr=se,start_new_session=True,env=env) + try: record['returncode']=child.wait(timeout=timeout) + except subprocess.TimeoutExpired: + record['timed_out']=True;failure='timeout' + try: os.killpg(child.pid,signal.SIGKILL) + except ProcessLookupError: pass + try: record['returncode']=child.wait(timeout=5) + except subprocess.TimeoutExpired: record['detail']='process-group termination did not finish in 5 seconds' + except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) record['elapsed_ns']=time.monotonic_ns()-start;sizes=(out.stat().st_size,err.stat().st_size) if max(sizes)>MAX_STREAM_BYTES: failure=failure or 'output_too_large';record.update(stdout_bytes=sizes[0],stderr_bytes=sizes[1]) else: From 86cbfe0a221c59d5ad27f4318cdf9db2931d02b7 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:45:37 -0500 Subject: [PATCH 23/24] Retain failure records when isolated cache preparation fails --- .../cbz_wrapper_composition_20261029/DECISIONS.md | 2 ++ tests/test_lm006_oned_coefficient_replay.py | 11 +++++++++++ tools/lm006_oned_coefficient_replay.py | 12 ++++++------ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md index f923601c4..7473d7fff 100644 --- a/reviews/cbz_wrapper_composition_20261029/DECISIONS.md +++ b/reviews/cbz_wrapper_composition_20261029/DECISIONS.md @@ -11,3 +11,5 @@ [2026-10-29 20:39:07 UTC] [phase3] [layer B] Fix LM006 supported import path to compile one read of source bytes, record those exact bytes, and compare ordinary module code against its source. Preserve observed stale-bytecode RED; retain every existing control and add an actual bypass test plus reason-bound loader mutation. Arbitrary malicious bytecode can delete its own self-check; the trusted source loader is required. No numerical source or bound changed. Reversible:yes. Evidence:cbz/evidence/lm006-bytecode-20261029/normal-red.log. [2026-10-29 20:45:07 UTC] [phase3] [layer B] Isolate spawned LM006 interpreter bytecode caches in newly created private empty directories and remove inherited PYTHON variables. Preserve exact packet tests, execution outputs and bounds; retain tests that exercise external poisoned caches for test_oned and oned plus a reason-bound source mutation for each. The earlier imported-driver cache defect has observed RED; the packet-specific old-source jobs and repaired-source jobs remain pending. Reversible:yes. Evidence:tests/test_lm006_oned_coefficient_replay.py. + +[2026-10-29 20:45:35 UTC] [phase3] [layer B] Preserve stdout, stderr and a failed process record if the new cache directory cannot be created; add a direct failure-path control. Retain all prior tests. Reversible:yes. Evidence:tests/test_lm006_oned_coefficient_replay.py. Hosted verification pending. diff --git a/tests/test_lm006_oned_coefficient_replay.py b/tests/test_lm006_oned_coefficient_replay.py index 1d64cd83a..771193ad7 100644 --- a/tests/test_lm006_oned_coefficient_replay.py +++ b/tests/test_lm006_oned_coefficient_replay.py @@ -213,6 +213,17 @@ def test_isolated_cache_source_mutation_is_rejected(self): self.assertIn(('packet tests executed poisoned '+target+' bytecode').encode(),mutant.stderr) self.assertNotIn(b'ERROR:',mutant.stderr) + def test_cache_setup_failure_retains_process_record(self): + from unittest.mock import patch + with patch.object(self.m.tempfile,'TemporaryDirectory',side_effect=OSError('cache unavailable')): + with self.assertRaisesRegex(self.m.ReplayError,'^spawn_error$'): + self.m.run_step(['not-started'],self.root,self.logs,'cachefail',b'','exact') + record=json.loads((self.logs/'cachefail.process.json').read_text()) + self.assertEqual((record['status'],record['failure'],record['returncode']),('FAIL','spawn_error',None)) + self.assertIn('cache unavailable',record['detail']) + self.assertEqual((self.logs/'cachefail.stdout').read_bytes(),b'') + self.assertEqual((self.logs/'cachefail.stderr').read_bytes(),b'') + def test_snapshot_and_exact_packet_membership(self): pins=self.fixture();ids=self.m.validate_snapshot(self.root,pins) self.assertEqual(set(ids),set(pins)) diff --git a/tools/lm006_oned_coefficient_replay.py b/tools/lm006_oned_coefficient_replay.py index cddddd535..14332d8c4 100644 --- a/tools/lm006_oned_coefficient_replay.py +++ b/tools/lm006_oned_coefficient_replay.py @@ -65,11 +65,11 @@ def run_step(argv,cwd,logs,name,expected,kind,timeout=900): logs=Path(logs); out=logs/(name+'.stdout');err=logs/(name+'.stderr');proc=logs/(name+'.process.json') require(not any(p.exists() or p.is_symlink() for p in (out,err,proc)),'step_evidence_exists') start=time.monotonic_ns();record={'command':list(map(str,argv)),'returncode':None,'timed_out':False,'status':'FAIL','timeout_seconds':timeout};failure=None - with tempfile.TemporaryDirectory(prefix='lm006-empty-pyc-') as cache: - env={key:value for key,value in os.environ.items() if not key.startswith('PYTHON')} - env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPYCACHEPREFIX=cache) # MUTATION_ISOLATED_PYC - with out.open('xb') as so,err.open('xb') as se: - try: + with out.open('xb') as so,err.open('xb') as se: + try: + with tempfile.TemporaryDirectory(prefix='lm006-empty-pyc-') as cache: + env={key:value for key,value in os.environ.items() if not key.startswith('PYTHON')} + env.update(PYTHONDONTWRITEBYTECODE='1',PYTHONPYCACHEPREFIX=cache) # MUTATION_ISOLATED_PYC child=subprocess.Popen(argv,cwd=cwd,stdout=so,stderr=se,start_new_session=True,env=env) try: record['returncode']=child.wait(timeout=timeout) except subprocess.TimeoutExpired: @@ -78,7 +78,7 @@ def run_step(argv,cwd,logs,name,expected,kind,timeout=900): except ProcessLookupError: pass try: record['returncode']=child.wait(timeout=5) except subprocess.TimeoutExpired: record['detail']='process-group termination did not finish in 5 seconds' - except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) + except OSError as exc: failure='spawn_error';record['detail']=type(exc).__name__+': '+str(exc) record['elapsed_ns']=time.monotonic_ns()-start;sizes=(out.stat().st_size,err.stat().st_size) if max(sizes)>MAX_STREAM_BYTES: failure=failure or 'output_too_large';record.update(stdout_bytes=sizes[0],stderr_bytes=sizes[1]) else: From 5d2dfd44dc25ebe4d3186e08192d115eb107d0d5 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:25:37 -0500 Subject: [PATCH 24/24] Record hosted LM006 bytecode custody controls --- .../lm006-bytecode-20261029/OBSERVATIONS.md | 3 ++ .../packet-normal-green.log | 4 +++ .../packet-optimized-green.log | 4 +++ .../source-normal-green.log | 31 +++++++++++++++++++ .../source-optimized-green.log | 31 +++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 cbz/evidence/lm006-bytecode-20261029/OBSERVATIONS.md create mode 100644 cbz/evidence/lm006-bytecode-20261029/packet-normal-green.log create mode 100644 cbz/evidence/lm006-bytecode-20261029/packet-optimized-green.log create mode 100644 cbz/evidence/lm006-bytecode-20261029/source-normal-green.log create mode 100644 cbz/evidence/lm006-bytecode-20261029/source-optimized-green.log diff --git a/cbz/evidence/lm006-bytecode-20261029/OBSERVATIONS.md b/cbz/evidence/lm006-bytecode-20261029/OBSERVATIONS.md new file mode 100644 index 000000000..063a5cd06 --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/OBSERVATIONS.md @@ -0,0 +1,3 @@ +# LM006 bytecode source-custody observations + +Candidate commit `86cbfe0a221c59d5ad27f4318cdf9db2931d02b7`: hosted normal job 123721886641 and optimized job 123721887269 each passed all 29 tests, including timestamp-valid poisoned bytecode, packet implementation and test bytecode, and a source-loader mutation. Independent packet-specific jobs 123721883047 and 123721882544 each passed two tests. These results qualify the tested candidate's focused controls only; full workflow and current-head verification remain pending. `normal-red.log` preserves the observed pre-repair failure. The packet numerical code and bounds were unchanged. diff --git a/cbz/evidence/lm006-bytecode-20261029/packet-normal-green.log b/cbz/evidence/lm006-bytecode-20261029/packet-normal-green.log new file mode 100644 index 000000000..920f0e97d --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/packet-normal-green.log @@ -0,0 +1,4 @@ +2026-10-29T21:06:57.8901417Z test_packet_pyc_implementation_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_implementation_is_not_executed) ... ok +2026-10-29T21:06:58.1904344Z test_packet_pyc_test_module_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_test_module_is_not_executed) ... ok +2026-10-29T21:06:58.1905281Z Ran 2 tests in 0.624s +2026-10-29T21:06:58.1905465Z OK diff --git a/cbz/evidence/lm006-bytecode-20261029/packet-optimized-green.log b/cbz/evidence/lm006-bytecode-20261029/packet-optimized-green.log new file mode 100644 index 000000000..cdeb0a49e --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/packet-optimized-green.log @@ -0,0 +1,4 @@ +2026-10-29T21:06:56.4886093Z test_packet_pyc_implementation_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_implementation_is_not_executed) ... ok +2026-10-29T21:06:56.8325777Z test_packet_pyc_test_module_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_test_module_is_not_executed) ... ok +2026-10-29T21:06:56.8327831Z Ran 2 tests in 0.780s +2026-10-29T21:06:56.8328155Z OK diff --git a/cbz/evidence/lm006-bytecode-20261029/source-normal-green.log b/cbz/evidence/lm006-bytecode-20261029/source-normal-green.log new file mode 100644 index 000000000..9f32aa617 --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/source-normal-green.log @@ -0,0 +1,31 @@ +2026-10-29T21:15:51.2244714Z test_ambient_git_environment_cannot_redirect_source_checks (test_lm006_oned_coefficient_replay.ReplayTests.test_ambient_git_environment_cannot_redirect_source_checks) ... ok +2026-10-29T21:15:51.2298810Z test_cache_setup_failure_retains_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_cache_setup_failure_retains_process_record) ... ok +2026-10-29T21:15:51.2385631Z test_changed_missing_and_symlink_sources_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_changed_missing_and_symlink_sources_rejected) ... ok +2026-10-29T21:15:51.5165710Z test_complete_orchestration_real_subprocesses (test_lm006_oned_coefficient_replay.ReplayTests.test_complete_orchestration_real_subprocesses) ... ok +2026-10-29T21:15:51.9117243Z test_custody_guards_reject_three_real_source_mutations (test_lm006_oned_coefficient_replay.ReplayTests.test_custody_guards_reject_three_real_source_mutations) ... LM006_CUSTODY_SOURCE_MUTATION {"baseline_exit": 0, "command": ["/opt/hostedtoolcache/Python/3.11.16/x64/bin/python", "-B", "-S", "-m", "unittest", "discover", "-s", "tests", "-p", "test_lm006_oned_coefficient_replay.py", "-k", "test_ambient_git_environment_cannot_redirect_source_checks", "-v"], "driver_sha256": "7f347bfc5552bac8d9b52dfa27d2b1b0e40be6bd692086925ef84200e4d700a9", "label": "ambient", "mutant_exit": 1, "optimize": 0, "stderr_base64": "dGVzdF9hbWJpZW50X2dpdF9lbnZpcm9ubWVudF9jYW5ub3RfcmVkaXJlY3Rfc291cmNlX2NoZWNrcyAodGVzdF9sbTAwNl9vbmVkX2NvZWZmaWNpZW50X3JlcGxheS5SZXBsYXlUZXN0cy50ZXN0X2FtYmllbnRfZ2l0X2Vudmlyb25tZW50X2Nhbm5vdF9yZWRpcmVjdF9zb3VyY2VfY2hlY2tzKSAuLi4gRkFJTAoKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpGQUlMOiB0ZXN0X2FtYmllbnRfZ2l0X2Vudmlyb25tZW50X2Nhbm5vdF9yZWRpcmVjdF9zb3VyY2VfY2hlY2tzICh0ZXN0X2xtMDA2X29uZWRfY29lZmZpY2llbnRfcmVwbGF5LlJlcGxheVRlc3RzLnRlc3RfYW1iaWVudF9naXRfZW52aXJvbm1lbnRfY2Fubm90X3JlZGlyZWN0X3NvdXJjZV9jaGVja3MpCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KVHJhY2ViYWNrIChtb3N0IHJlY2VudCBjYWxsIGxhc3QpOgogIEZpbGUgIi90bXAvbG0wMDYtY3VzdG9keS1zb3VyY2UtbXV0YW50LWZtMmplMWkyL3Rlc3RzL3Rlc3RfbG0wMDZfb25lZF9jb2VmZmljaWVudF9yZXBsYXkucHkiLCBsaW5lIDM4NiwgaW4gdGVzdF9hbWJpZW50X2dpdF9lbnZpcm9ubWVudF9jYW5ub3RfcmVkaXJlY3Rfc291cmNlX2NoZWNrcwogICAgc2VsZi5hc3NlcnRFcXVhbChtb2QuZ2l0X2hlYWQoc2VsZi5yb290KSxvd24pCkFzc2VydGlvbkVycm9yOiAnYTk2MWMyZjY0ZDM5N2EzYmZhNTVhYzFiNDA1NTY3ZTc3NGMxZTIyNicgIT0gJ2UyZmNmODIxNWUwZmNlYjM4YzEzMGE4YTEyNTQyMzNlYjI1NDM1YTcnCi0gYTk2MWMyZjY0ZDM5N2EzYmZhNTVhYzFiNDA1NTY3ZTc3NGMxZTIyNgorIGUyZmNmODIxNWUwZmNlYjM4YzEzMGE4YTEyNTQyMzNlYjI1NDM1YTcKCgotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tClJhbiAxIHRlc3QgaW4gMC4xNDFzCgpGQUlMRUQgKGZhaWx1cmVzPTEpCg==", "stdout_base64": ""} +2026-10-29T21:15:52.8036670Z test_direct_import_detects_timestamp_valid_stale_code (test_lm006_oned_coefficient_replay.ReplayTests.test_direct_import_detects_timestamp_valid_stale_code) ... ok +2026-10-29T21:15:52.9937509Z test_direct_import_guard_mutation_is_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_direct_import_guard_mutation_is_rejected) ... ok +2026-10-29T21:15:52.9983580Z test_exact_output_contract_is_byte_exact (test_lm006_oned_coefficient_replay.ReplayTests.test_exact_output_contract_is_byte_exact) ... ok +2026-10-29T21:15:53.0191560Z test_existing_evidence_not_overwritten (test_lm006_oned_coefficient_replay.ReplayTests.test_existing_evidence_not_overwritten) ... ok +2026-10-29T21:15:53.2679790Z test_failed_tests_stop_before_coefficient (test_lm006_oned_coefficient_replay.ReplayTests.test_failed_tests_stop_before_coefficient) ... ok +2026-10-29T21:15:53.3312291Z test_git_replacement_cannot_relabel_a_frozen_blob (test_lm006_oned_coefficient_replay.ReplayTests.test_git_replacement_cannot_relabel_a_frozen_blob) ... ok +2026-10-29T21:15:53.3361501Z test_host_identity (test_lm006_oned_coefficient_replay.ReplayTests.test_host_identity) ... ok +2026-10-29T21:15:53.4504264Z test_invalid_cli (test_lm006_oned_coefficient_replay.ReplayTests.test_invalid_cli) ... ok +2026-10-29T21:15:55.2348846Z test_isolated_cache_source_mutation_is_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_isolated_cache_source_mutation_is_rejected) ... ok +2026-10-29T21:15:55.2694763Z test_loaded_driver_cannot_claim_a_later_committed_source (test_lm006_oned_coefficient_replay.ReplayTests.test_loaded_driver_cannot_claim_a_later_committed_source) ... ok +2026-10-29T21:15:55.5527286Z test_packet_pyc_implementation_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_implementation_is_not_executed) ... ok +2026-10-29T21:15:55.8363184Z test_packet_pyc_test_module_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_test_module_is_not_executed) ... ok +2026-10-29T21:15:55.8407420Z test_path_validation (test_lm006_oned_coefficient_replay.ReplayTests.test_path_validation) ... ok +2026-10-29T21:15:56.0153239Z test_poisoned_bytecode_control_kills_loader_mutation (test_lm006_oned_coefficient_replay.ReplayTests.test_poisoned_bytecode_control_kills_loader_mutation) ... ok +2026-10-29T21:15:56.3792060Z test_postflight_source_drift_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_postflight_source_drift_rejected) ... ok +2026-10-29T21:15:56.3847147Z test_secondary_timeout_still_writes_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_secondary_timeout_still_writes_process_record) ... ok +2026-10-29T21:15:56.3913867Z test_snapshot_and_exact_packet_membership (test_lm006_oned_coefficient_replay.ReplayTests.test_snapshot_and_exact_packet_membership) ... ok +2026-10-29T21:15:56.4143782Z test_success_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_success_process_record) ... ok +2026-10-29T21:15:56.4192774Z test_test_report_contract_requires_all_named_passes (test_lm006_oned_coefficient_replay.ReplayTests.test_test_report_contract_requires_all_named_passes) ... ok +2026-10-29T21:15:56.6261017Z test_timeout_retains_partial_evidence (test_lm006_oned_coefficient_replay.ReplayTests.test_timeout_retains_partial_evidence) ... ok +2026-10-29T21:15:56.6539852Z test_timestamp_valid_poisoned_bytecode_cannot_replace_source (test_lm006_oned_coefficient_replay.ReplayTests.test_timestamp_valid_poisoned_bytecode_cannot_replace_source) ... ok +2026-10-29T21:15:56.6590487Z test_workflow_contract (test_lm006_oned_coefficient_replay.ReplayTests.test_workflow_contract) ... ok +2026-10-29T21:15:56.7283318Z test_wrong_exit_output_and_stderr_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_wrong_exit_output_and_stderr_rejected) ... ok +2026-10-29T21:15:56.9961728Z test_wrong_output_cannot_pass (test_lm006_oned_coefficient_replay.ReplayTests.test_wrong_output_cannot_pass) ... ok +2026-10-29T21:15:56.9962973Z Ran 29 tests in 5.845s +2026-10-29T21:15:56.9964232Z OK diff --git a/cbz/evidence/lm006-bytecode-20261029/source-optimized-green.log b/cbz/evidence/lm006-bytecode-20261029/source-optimized-green.log new file mode 100644 index 000000000..be5774900 --- /dev/null +++ b/cbz/evidence/lm006-bytecode-20261029/source-optimized-green.log @@ -0,0 +1,31 @@ +2026-10-29T21:17:13.6593440Z test_ambient_git_environment_cannot_redirect_source_checks (test_lm006_oned_coefficient_replay.ReplayTests.test_ambient_git_environment_cannot_redirect_source_checks) ... ok +2026-10-29T21:17:13.6653496Z test_cache_setup_failure_retains_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_cache_setup_failure_retains_process_record) ... ok +2026-10-29T21:17:13.6726200Z test_changed_missing_and_symlink_sources_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_changed_missing_and_symlink_sources_rejected) ... ok +2026-10-29T21:17:14.0041303Z test_complete_orchestration_real_subprocesses (test_lm006_oned_coefficient_replay.ReplayTests.test_complete_orchestration_real_subprocesses) ... ok +2026-10-29T21:17:14.9099807Z test_custody_guards_reject_three_real_source_mutations (test_lm006_oned_coefficient_replay.ReplayTests.test_custody_guards_reject_three_real_source_mutations) ... LM006_CUSTODY_SOURCE_MUTATION {"baseline_exit": 0, "command": ["/opt/hostedtoolcache/Python/3.11.16/x64/bin/python", "-B", "-S", "-O", "-m", "unittest", "discover", "-s", "tests", "-p", "test_lm006_oned_coefficient_replay.py", "-k", "test_ambient_git_environment_cannot_redirect_source_checks", "-v"], "driver_sha256": "7f347bfc5552bac8d9b52dfa27d2b1b0e40be6bd692086925ef84200e4d700a9", "label": "ambient", "mutant_exit": 1, "optimize": 1, "stderr_base64": "dGVzdF9hbWJpZW50X2dpdF9lbnZpcm9ubWVudF9jYW5ub3RfcmVkaXJlY3Rfc291cmNlX2NoZWNrcyAodGVzdF9sbTAwNl9vbmVkX2NvZWZmaWNpZW50X3JlcGxheS5SZXBsYXlUZXN0cy50ZXN0X2FtYmllbnRfZ2l0X2Vudmlyb25tZW50X2Nhbm5vdF9yZWRpcmVjdF9zb3VyY2VfY2hlY2tzKSAuLi4gRkFJTAoKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpGQUlMOiB0ZXN0X2FtYmllbnRfZ2l0X2Vudmlyb25tZW50X2Nhbm5vdF9yZWRpcmVjdF9zb3VyY2VfY2hlY2tzICh0ZXN0X2xtMDA2X29uZWRfY29lZmZpY2llbnRfcmVwbGF5LlJlcGxheVRlc3RzLnRlc3RfYW1iaWVudF9naXRfZW52aXJvbm1lbnRfY2Fubm90X3JlZGlyZWN0X3NvdXJjZV9jaGVja3MpCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KVHJhY2ViYWNrIChtb3N0IHJlY2VudCBjYWxsIGxhc3QpOgogIEZpbGUgIi90bXAvbG0wMDYtY3VzdG9keS1zb3VyY2UtbXV0YW50LWduc2szMjJ1L3Rlc3RzL3Rlc3RfbG0wMDZfb25lZF9jb2VmZmljaWVudF9yZXBsYXkucHkiLCBsaW5lIDM4NiwgaW4gdGVzdF9hbWJpZW50X2dpdF9lbnZpcm9ubWVudF9jYW5ub3RfcmVkaXJlY3Rfc291cmNlX2NoZWNrcwogICAgc2VsZi5hc3NlcnRFcXVhbChtb2QuZ2l0X2hlYWQoc2VsZi5yb290KSxvd24pCkFzc2VydGlvbkVycm9yOiAnZTU2MTBmMTk1NzYwMTc0MzMwMjNhYzEyMzIyMGY5NTYwODY2NGQzNicgIT0gJzhlODM2NDhlMjM5YmYxOWMyYmY5OTY5OWE4OGZmMmZjNjAzMDA4OTEnCi0gZTU2MTBmMTk1NzYwMTc0MzMwMjNhYzEyMzIyMGY5NTYwODY2NGQzNgorIDhlODM2NDhlMjM5YmYxOWMyYmY5OTY5OWE4OGZmMmZjNjAzMDA4OTEKCgotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tClJhbiAxIHRlc3QgaW4gMC4xNzRzCgpGQUlMRUQgKGZhaWx1cmVzPTEpCg==", "stdout_base64": ""} +2026-10-29T21:17:16.4243193Z test_direct_import_detects_timestamp_valid_stale_code (test_lm006_oned_coefficient_replay.ReplayTests.test_direct_import_detects_timestamp_valid_stale_code) ... ok +2026-10-29T21:17:16.9904114Z test_direct_import_guard_mutation_is_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_direct_import_guard_mutation_is_rejected) ... ok +2026-10-29T21:17:16.9958551Z test_exact_output_contract_is_byte_exact (test_lm006_oned_coefficient_replay.ReplayTests.test_exact_output_contract_is_byte_exact) ... ok +2026-10-29T21:17:17.0177000Z test_existing_evidence_not_overwritten (test_lm006_oned_coefficient_replay.ReplayTests.test_existing_evidence_not_overwritten) ... ok +2026-10-29T21:17:17.2712105Z test_failed_tests_stop_before_coefficient (test_lm006_oned_coefficient_replay.ReplayTests.test_failed_tests_stop_before_coefficient) ... ok +2026-10-29T21:17:17.3146639Z test_git_replacement_cannot_relabel_a_frozen_blob (test_lm006_oned_coefficient_replay.ReplayTests.test_git_replacement_cannot_relabel_a_frozen_blob) ... ok +2026-10-29T21:17:17.3200121Z test_host_identity (test_lm006_oned_coefficient_replay.ReplayTests.test_host_identity) ... ok +2026-10-29T21:17:17.4546540Z test_invalid_cli (test_lm006_oned_coefficient_replay.ReplayTests.test_invalid_cli) ... ok +2026-10-29T21:17:20.2054960Z test_isolated_cache_source_mutation_is_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_isolated_cache_source_mutation_is_rejected) ... ok +2026-10-29T21:17:20.2457326Z test_loaded_driver_cannot_claim_a_later_committed_source (test_lm006_oned_coefficient_replay.ReplayTests.test_loaded_driver_cannot_claim_a_later_committed_source) ... ok +2026-10-29T21:17:20.5356576Z test_packet_pyc_implementation_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_implementation_is_not_executed) ... ok +2026-10-29T21:17:20.8261843Z test_packet_pyc_test_module_is_not_executed (test_lm006_oned_coefficient_replay.ReplayTests.test_packet_pyc_test_module_is_not_executed) ... ok +2026-10-29T21:17:20.8315896Z test_path_validation (test_lm006_oned_coefficient_replay.ReplayTests.test_path_validation) ... ok +2026-10-29T21:17:21.4168656Z test_poisoned_bytecode_control_kills_loader_mutation (test_lm006_oned_coefficient_replay.ReplayTests.test_poisoned_bytecode_control_kills_loader_mutation) ... ok +2026-10-29T21:17:21.8380591Z test_postflight_source_drift_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_postflight_source_drift_rejected) ... ok +2026-10-29T21:17:21.8451827Z test_secondary_timeout_still_writes_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_secondary_timeout_still_writes_process_record) ... ok +2026-10-29T21:17:21.8529895Z test_snapshot_and_exact_packet_membership (test_lm006_oned_coefficient_replay.ReplayTests.test_snapshot_and_exact_packet_membership) ... ok +2026-10-29T21:17:21.8748422Z test_success_process_record (test_lm006_oned_coefficient_replay.ReplayTests.test_success_process_record) ... ok +2026-10-29T21:17:21.8808239Z test_test_report_contract_requires_all_named_passes (test_lm006_oned_coefficient_replay.ReplayTests.test_test_report_contract_requires_all_named_passes) ... ok +2026-10-29T21:17:22.0887514Z test_timeout_retains_partial_evidence (test_lm006_oned_coefficient_replay.ReplayTests.test_timeout_retains_partial_evidence) ... ok +2026-10-29T21:17:22.1019090Z test_timestamp_valid_poisoned_bytecode_cannot_replace_source (test_lm006_oned_coefficient_replay.ReplayTests.test_timestamp_valid_poisoned_bytecode_cannot_replace_source) ... ok +2026-10-29T21:17:22.1072695Z test_workflow_contract (test_lm006_oned_coefficient_replay.ReplayTests.test_workflow_contract) ... ok +2026-10-29T21:17:22.1779406Z test_wrong_exit_output_and_stderr_rejected (test_lm006_oned_coefficient_replay.ReplayTests.test_wrong_exit_output_and_stderr_rejected) ... ok +2026-10-29T21:17:22.4501324Z test_wrong_output_cannot_pass (test_lm006_oned_coefficient_replay.ReplayTests.test_wrong_output_cannot_pass) ... ok +2026-10-29T21:17:22.4503267Z Ran 29 tests in 8.969s +2026-10-29T21:17:22.4503647Z OK