From 54f3af3e083850ec512eeef3fbc1c12248621f7a Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:03:55 -0700 Subject: [PATCH 1/7] C6 residual: record native mutant output contracts before enforcing diagnostics --- .github/workflows/c6-residual-closure.yml | 29 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c6-residual-closure.yml b/.github/workflows/c6-residual-closure.yml index c99afc4f1..b5b801880 100644 --- a/.github/workflows/c6-residual-closure.yml +++ b/.github/workflows/c6-residual-closure.yml @@ -66,9 +66,32 @@ jobs: if out != (root / pinned).read_bytes(): raise RuntimeError('output differs from ' + pinned + ' under ' + ' '.join(flags)) for m in mutants: - rc = subprocess.run([sys.executable, *flags, script, '--mutant', m], - capture_output=True, timeout=300).returncode - if rc != 1: + proc = subprocess.run([sys.executable, *flags, script, '--mutant', m], + capture_output=True, timeout=300) + # Diagnostic-only first stage: do not treat this as a repaired gate. + # Record actual child identity without exposing full proof packets. + try: + payload = json.loads(proc.stdout) + except (ValueError, UnicodeError): + payload = None + obj = payload if isinstance(payload, dict) else {} + checks = obj.get('checks') + failed = (sorted(k for k, v in checks.items() if v is False) + if isinstance(checks, dict) else None) + print('C6_RESIDUAL_MUTANT_OBSERVATION ' + json.dumps({ + 'mutant': m, + 'mode': 'optimized' if '-O' in flags else 'normal', + 'returncode': proc.returncode, + 'stdout_bytes': len(proc.stdout), + 'stdout_sha256': hashlib.sha256(proc.stdout).hexdigest(), + 'stderr_bytes': len(proc.stderr), + 'stderr_sha256': hashlib.sha256(proc.stderr).hexdigest(), + 'object': obj.get('object'), + 'passed': obj.get('passed'), + 'register_state': obj.get('register_state'), + 'failed_checks': failed, + }, sort_keys=True), flush=True) + if proc.returncode != 1: raise RuntimeError('mutant ' + m + ' not rejected') print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY From f0d0ed6cc97af17a0556e139c9df87f62dc19722 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:09:34 -0700 Subject: [PATCH 2/7] C6 residual: add focused strict child-output contract tools/c6_residual_child_contract.py --- tools/c6_residual_child_contract.py | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 tools/c6_residual_child_contract.py diff --git a/tools/c6_residual_child_contract.py b/tools/c6_residual_child_contract.py new file mode 100644 index 000000000..fc9d0a188 --- /dev/null +++ b/tools/c6_residual_child_contract.py @@ -0,0 +1,109 @@ +"""Strict child-result contracts for the C6 residual closure workflow. + +Engineering guard only. The eight named checks and expected mutant failure +sets are derived from the pinned residual_check.py branches and the original +Python 3.11.16 hosted observations; no mathematical proof is rerun here. +""" + +import json + +CHECK_NAMES = frozenset(( + "IDENTITIES", "VERDICTS", "LIVE", "REVIEWED", "DEDUCTION", + "TRANSITIONS", "GATE", "NEGATIVES", +)) +EXPECTED_FAILURES = { + "partial-install": frozenset(("TRANSITIONS",)), + "allow-symlink": frozenset(("NEGATIVES",)), + "no-hash": frozenset(("NEGATIVES",)), + "stale-fingerprint": frozenset(("TRANSITIONS", "GATE")), + "drop-required-edge": frozenset(("TRANSITIONS", "GATE")), + "executed-flag": frozenset(("TRANSITIONS", "GATE")), + "controlling-true": frozenset(("TRANSITIONS", "GATE")), + "tail-reversed": frozenset(("DEDUCTION",)), + "pair-identity-broken": frozenset(("DEDUCTION",)), + "route-c-broken": frozenset(("DEDUCTION",)), + "drop-review-needle": frozenset(("VERDICTS",)), + "installed-drift": frozenset(("TRANSITIONS", "GATE")), + "snapshot-omitted": frozenset(("GATE",)), + "record-unreviewed": frozenset(("REVIEWED", "TRANSITIONS", "GATE")), + "reviewed-text-drift": frozenset(("REVIEWED",)), +} +REPORT_KEYS = frozenset(( + "checks", "component_nodes", "gate", "inventory_files", "live_state", + "object", "passed", "register_state", "scope", +)) + + +def _require(predicate, message): + if not predicate: + raise ValueError("C6 residual child contract: " + message) + + +def _loads(raw): + _require(type(raw) is bytes, "stdout must be bytes") + + def unique(pairs): + obj = {} + for key, value in pairs: + _require(key not in obj, "duplicate JSON key: " + key) + obj[key] = value + return obj + + def reject_constant(value): + raise ValueError("nonfinite JSON constant: " + value) + + try: + return json.loads(raw, object_pairs_hook=unique, parse_constant=reject_constant) + except (UnicodeDecodeError, json.JSONDecodeError) as exc: + raise ValueError("C6 residual child contract: invalid JSON stdout") from exc + + +def _check_common(report, baseline): + _require(type(report) is dict and set(report) == REPORT_KEYS, + "missing or extra report fields") + _require(report["object"] == baseline["object"] == "C6-RESIDUAL-CLOSURE-20260930-v1", + "incorrect object") + _require(type(report["inventory_files"]) is int and report["inventory_files"] == baseline["inventory_files"], + "inventory identity changed") + _require(type(report["component_nodes"]) is int and report["component_nodes"] == baseline["component_nodes"], + "component identity changed") + _require(type(report["scope"]) is str and report["scope"] == baseline["scope"], + "source scope changed") + _require(report["register_state"] == baseline["register_state"] and + report["register_state"] in ("baseline", "installed"), + "register state changed") + _require(type(report["live_state"]) is dict and + report["live_state"].get("state") == report["register_state"], + "live state does not match register state") + _require(type(report["gate"]) is dict, "gate report must be an object") + checks = report["checks"] + _require(type(checks) is dict and set(checks) == CHECK_NAMES and + all(type(v) is bool for v in checks.values()), + "invalid or incomplete eight-check result") + _require(type(report["passed"]) is bool, "passed must be a Boolean") + return checks + + +def validate_baseline(process, pinned_bytes): + """Bind the genuine zero-mutant result to its already-pinned source bytes.""" + _require(process.returncode == 0, "baseline exit must be zero") + _require(process.stderr == b"", "baseline wrote unexpected stderr") + _require(process.stdout == pinned_bytes, "baseline stdout differs from pinned result") + report = _loads(process.stdout) + _check_common(report, report) + _require(report["passed"] is True and all(report["checks"].values()), + "baseline must pass all eight checks") + return report + + +def validate_mutant(mutant, process, baseline): + """Reject crashes, silence, malformed output and failures for the wrong reason.""" + _require(mutant in EXPECTED_FAILURES, "unregistered mutant label") + _require(process.returncode == 1, "mutant exit must be one") + _require(process.stderr == b"", "mutant wrote unexpected stderr") + report = _loads(process.stdout) + checks = _check_common(report, baseline) + failed = frozenset(name for name, value in checks.items() if value is False) + _require(report["passed"] is False and failed == EXPECTED_FAILURES[mutant], + "mutant failed a different check set: " + mutant) + return report From 34fbe8ef57dbf3257d597cbfe828bfb758f66e62 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:09:37 -0700 Subject: [PATCH 3/7] C6 residual: add focused strict child-output contract tests/test_c6_residual_child_contract.py --- tests/test_c6_residual_child_contract.py | 110 +++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/test_c6_residual_child_contract.py diff --git a/tests/test_c6_residual_child_contract.py b/tests/test_c6_residual_child_contract.py new file mode 100644 index 000000000..80f4e42f8 --- /dev/null +++ b/tests/test_c6_residual_child_contract.py @@ -0,0 +1,110 @@ +"""External controls for C6 residual child output admissibility (no proof edits).""" +import copy +import json +import pathlib +import sys +import unittest +from subprocess import CompletedProcess + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / 'tools')) +from c6_residual_child_contract import (CHECK_NAMES, EXPECTED_FAILURES, + validate_baseline, validate_mutant) + + +def packet(state='baseline'): + return dict(object='C6-RESIDUAL-CLOSURE-20260930-v1', + checks={name: True for name in CHECK_NAMES}, passed=True, + inventory_files=13, component_nodes=10, scope='pinned mathematical scope', + register_state=state, live_state={'state': state}, gate={}) + + +def output(payload, *, returncode=1, stderr=b''): + return CompletedProcess(['residual_check.py'], returncode, + stdout=json.dumps(payload, sort_keys=True).encode(), stderr=stderr) + + +class ChildContracts(unittest.TestCase): + def test_baseline_in_both_register_states(self): + for state in ('baseline', 'installed'): + original = packet(state) + out = output(original, returncode=0) + with self.subTest(state=state): + self.assertEqual(validate_baseline(out, out.stdout), original) + with self.assertRaises(ValueError): + validate_baseline(output(original, returncode=0, stderr=b'warning'), out.stdout) + with self.assertRaises(ValueError): + validate_baseline(output(original, returncode=0), b'changed') + + def test_all_fifteen_frozen_mutant_failure_sets_in_both_states(self): + for state in ('baseline', 'installed'): + baseline = packet(state) + for mutant, expected_failed in EXPECTED_FAILURES.items(): + result = copy.deepcopy(baseline) + result['passed'] = False + for name in expected_failed: + result['checks'][name] = False + with self.subTest(state=state, mutant=mutant): + self.assertEqual(validate_mutant(mutant, output(result), baseline), result) + bad = copy.deepcopy(result) + bad['checks'] = dict.fromkeys(CHECK_NAMES, True) + bad['checks']['IDENTITIES'] = False + if expected_failed != frozenset(('IDENTITIES',)): + with self.assertRaises(ValueError): + validate_mutant(mutant, output(bad), baseline) + + def test_crash_silence_wrong_exit_and_extra_stderr_are_refused(self): + baseline = packet() + example = copy.deepcopy(baseline) + example['passed'] = False + example['checks']['DEDUCTION'] = False + for child in [CompletedProcess([], 1, b'', b''), + CompletedProcess([], 1, b'', b'Traceback: unrelated crash'), + output(example, returncode=0), + output(example, stderr=b'warning'), + CompletedProcess([], 1, b'not-json', b'')]: + with self.subTest(child=child): + with self.assertRaises(ValueError): + validate_mutant('tail-reversed', child, baseline) + + def test_structural_invalidity_and_type_confusion(self): + baseline = packet() + good = copy.deepcopy(baseline) + good['passed'] = False + good['checks']['DEDUCTION'] = False + mutations = [] + for key, value in [('object','DIFFERENT'), ('passed',0), ('register_state','fake'), + ('scope','changed'), ('inventory_files',True), + ('component_nodes','10'), ('gate',None)]: + changed = copy.deepcopy(good) + changed[key] = value + mutations.append(changed) + changed = copy.deepcopy(good) + changed['checks']['DEDUCTION'] = 0 + mutations.append(changed) + changed = copy.deepcopy(good) + del changed['checks']['DEDUCTION'] + mutations.append(changed) + changed = copy.deepcopy(good) + changed['checks']['OTHER'] = False + mutations.append(changed) + changed = copy.deepcopy(good) + changed['extra'] = 'field' + mutations.append(changed) + changed = copy.deepcopy(good) + changed['live_state']['state'] = 'installed' + mutations.append(changed) + for changed in mutations: + with self.subTest(changed=changed): + with self.assertRaises(ValueError): + validate_mutant('tail-reversed', output(changed), baseline) + + def test_duplicate_fields_nonfinite_and_extra_json(self): + baseline = packet() + for data in (b'{"passed":false,"passed":false}', b'{"x":NaN}', + b'{"x":Infinity}', b'{}{}'): + with self.subTest(data=data): + with self.assertRaises(ValueError): + validate_mutant('tail-reversed', CompletedProcess([],1,data,b''), baseline) + +if __name__ == '__main__': + unittest.main() From 4412f6156016d7708a5f6169101ca369432e1fff Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:09:59 -0700 Subject: [PATCH 4/7] C6 residual: add tests-first negative for missing workflow child-output guard --- tests/test_c6_residual_child_contract.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_c6_residual_child_contract.py b/tests/test_c6_residual_child_contract.py index 80f4e42f8..9ef43aebe 100644 --- a/tests/test_c6_residual_child_contract.py +++ b/tests/test_c6_residual_child_contract.py @@ -98,6 +98,13 @@ def test_structural_invalidity_and_type_confusion(self): with self.assertRaises(ValueError): validate_mutant('tail-reversed', output(changed), baseline) + def test_workflow_wires_strict_child_validation(self): + workflow = (pathlib.Path(__file__).resolve().parents[1] / + '.github/workflows/c6-residual-closure.yml').read_text() + self.assertIn('from c6_residual_child_contract import validate_baseline, validate_mutant', workflow) + self.assertIn('validate_baseline(base_proc, expected)', workflow) + self.assertIn('validate_mutant(m, proc, baseline)', workflow) + def test_duplicate_fields_nonfinite_and_extra_json(self): baseline = packet() for data in (b'{"passed":false,"passed":false}', b'{"x":NaN}', From ad6667124c71483796ce2176f72475199c8890b1 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:10:40 -0700 Subject: [PATCH 5/7] C6 residual: require authentic eight-check reasons for each mutant --- .github/workflows/c6-residual-closure.yml | 44 +++++++++-------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/.github/workflows/c6-residual-closure.yml b/.github/workflows/c6-residual-closure.yml index b5b801880..c8577515b 100644 --- a/.github/workflows/c6-residual-closure.yml +++ b/.github/workflows/c6-residual-closure.yml @@ -5,6 +5,9 @@ name: C6 residual closure checks paths: - 'reviews/c6_residual_closure_20260930/**' - '.github/workflows/c6-residual-closure.yml' + - 'tools/c6_residual_child_contract.py' + - 'tools/c6_residual_child_contract/**' + - 'tests/test_c6_residual_child_contract.py' - 'frontiers/spectral_cluster_closure_20260929/PROOF.md' - 'frontiers/spectral_cluster_closure_20260929/REVIEW_RECORD.md' - 'frontiers/spectral_cluster_closure_20260929/README.md' @@ -34,6 +37,10 @@ jobs: - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 with: python-version: '3.11.16' + - name: Refuse unrelated C6 residual child failures in both Python modes + run: | + python -B -S -m unittest discover -s tests -p test_c6_residual_child_contract.py -v + python -B -O -S -m unittest discover -s tests -p test_c6_residual_child_contract.py -v - name: Verify sources, replay both modes (baseline or installed register), reject mutants env: PYTHONDONTWRITEBYTECODE: '1' @@ -41,6 +48,8 @@ jobs: set -euo pipefail python -B -S - <<'PY' import hashlib, json, pathlib, subprocess, sys + sys.path.insert(0, str(pathlib.Path('tools').resolve())) + from c6_residual_child_contract import validate_baseline, validate_mutant root = pathlib.Path('reviews/c6_residual_closure_20260930').resolve() manifest = json.loads((root / 'SOURCE_FILES.json').read_text())['files'] present = sorted(p.name for p in root.iterdir()) @@ -57,42 +66,21 @@ jobs: script = str(root / 'residual_check.py') mutants = ['partial-install', 'allow-symlink', 'no-hash', 'stale-fingerprint', 'drop-required-edge', 'executed-flag', 'controlling-true', 'tail-reversed', 'pair-identity-broken', 'route-c-broken', 'drop-review-needle', 'installed-drift', 'snapshot-omitted', 'record-unreviewed', 'reviewed-text-drift'] for flags in (['-B', '-S'], ['-B', '-O', '-S']): - out = subprocess.run([sys.executable, *flags, script], - check=True, capture_output=True, timeout=300).stdout + base_proc = subprocess.run([sys.executable, *flags, script], + capture_output=True, timeout=300) + out = base_proc.stdout state = json.loads(out).get('register_state') if state not in ('baseline', 'installed'): raise RuntimeError('checker reports register_state ' + repr(state)) pinned = 'RESULTS.json' if state == 'baseline' else 'RESULTS_INSTALLED.json' - if out != (root / pinned).read_bytes(): + expected = (root / pinned).read_bytes() + if out != expected: raise RuntimeError('output differs from ' + pinned + ' under ' + ' '.join(flags)) + baseline = validate_baseline(base_proc, expected) for m in mutants: proc = subprocess.run([sys.executable, *flags, script, '--mutant', m], capture_output=True, timeout=300) - # Diagnostic-only first stage: do not treat this as a repaired gate. - # Record actual child identity without exposing full proof packets. - try: - payload = json.loads(proc.stdout) - except (ValueError, UnicodeError): - payload = None - obj = payload if isinstance(payload, dict) else {} - checks = obj.get('checks') - failed = (sorted(k for k, v in checks.items() if v is False) - if isinstance(checks, dict) else None) - print('C6_RESIDUAL_MUTANT_OBSERVATION ' + json.dumps({ - 'mutant': m, - 'mode': 'optimized' if '-O' in flags else 'normal', - 'returncode': proc.returncode, - 'stdout_bytes': len(proc.stdout), - 'stdout_sha256': hashlib.sha256(proc.stdout).hexdigest(), - 'stderr_bytes': len(proc.stderr), - 'stderr_sha256': hashlib.sha256(proc.stderr).hexdigest(), - 'object': obj.get('object'), - 'passed': obj.get('passed'), - 'register_state': obj.get('register_state'), - 'failed_checks': failed, - }, sort_keys=True), flush=True) - if proc.returncode != 1: - raise RuntimeError('mutant ' + m + ' not rejected') + validate_mutant(m, proc, baseline) print(json.dumps({'scientific_effect': 'NONE', 'mathematical_acceptance': False})) PY git diff --exit-code From fe1e56e78a853b31818b013f97843305acdf1847 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 13 Oct 2026 06:39:11 -0700 Subject: [PATCH 6/7] C6 residual: accept authentic installed-state mutant contracts --- tests/test_c6_residual_child_contract.py | 57 +++++++++++++++++++++++- tools/c6_residual_child_contract.py | 27 ++++++++--- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/tests/test_c6_residual_child_contract.py b/tests/test_c6_residual_child_contract.py index 9ef43aebe..ab3f2152c 100644 --- a/tests/test_c6_residual_child_contract.py +++ b/tests/test_c6_residual_child_contract.py @@ -1,13 +1,17 @@ """External controls for C6 residual child output admissibility (no proof edits).""" import copy +import importlib.util import json import pathlib +import shutil +import subprocess import sys +import tempfile import unittest from subprocess import CompletedProcess sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / 'tools')) -from c6_residual_child_contract import (CHECK_NAMES, EXPECTED_FAILURES, +from c6_residual_child_contract import (CHECK_NAMES, EXPECTED_FAILURES_BY_STATE, validate_baseline, validate_mutant) @@ -38,11 +42,14 @@ def test_baseline_in_both_register_states(self): def test_all_fifteen_frozen_mutant_failure_sets_in_both_states(self): for state in ('baseline', 'installed'): baseline = packet(state) - for mutant, expected_failed in EXPECTED_FAILURES.items(): + for mutant, expected_failed in EXPECTED_FAILURES_BY_STATE[state].items(): result = copy.deepcopy(baseline) result['passed'] = False for name in expected_failed: result['checks'][name] = False + if 'LIVE' in expected_failed: + result['register_state'] = 'partial' + result['live_state']['state'] = 'partial' with self.subTest(state=state, mutant=mutant): self.assertEqual(validate_mutant(mutant, output(result), baseline), result) bad = copy.deepcopy(result) @@ -51,6 +58,52 @@ def test_all_fifteen_frozen_mutant_failure_sets_in_both_states(self): if expected_failed != frozenset(('IDENTITIES',)): with self.assertRaises(ValueError): validate_mutant(mutant, output(bad), baseline) + if 'LIVE' not in expected_failed: + bad_state = copy.deepcopy(result) + bad_state['register_state'] = 'partial' + bad_state['live_state']['state'] = 'partial' + with self.assertRaises(ValueError): + validate_mutant(mutant, output(bad_state), baseline) + + def test_three_state_dependent_mutants_against_checker_installed_graph(self): + repo = pathlib.Path(__file__).resolve().parents[1] + checker_path = (repo / 'reviews/c6_residual_closure_20260930' / + 'residual_check.py') + module_spec = importlib.util.spec_from_file_location('c6_residual_checker', + checker_path) + checker = importlib.util.module_from_spec(module_spec) + module_spec.loader.exec_module(checker) + + source_graph = json.loads( + (repo / 'frontiers/downstream_gate_20260925/GRAPH.json').read_text()) + proposal = json.loads( + (repo / 'reviews/c6_residual_closure_20260930' / + 'PROPOSED_TRANSITIONS.json').read_text()) + installed = checker.build(proposal, source_graph, 'final')[1] + + with tempfile.TemporaryDirectory() as tmp: + root = pathlib.Path(tmp) + shutil.copytree(repo / 'frontiers', root / 'frontiers') + shutil.copytree(repo / 'reviews', root / 'reviews') + graph_path = root / 'frontiers/downstream_gate_20260925/GRAPH.json' + graph_path.write_text(json.dumps(installed, indent=2, sort_keys=True) + '\n') + script = root / 'reviews/c6_residual_closure_20260930/residual_check.py' + pinned = (root / 'reviews/c6_residual_closure_20260930' / + 'RESULTS_INSTALLED.json').read_bytes() + + for flags in (('-B', '-S'), ('-B', '-O', '-S')): + base_proc = subprocess.run( + [sys.executable, *flags, str(script)], + cwd=root, capture_output=True, timeout=300) + baseline = validate_baseline(base_proc, pinned) + self.assertEqual(baseline['register_state'], 'installed') + for mutant in ('stale-fingerprint', 'record-unreviewed', + 'installed-drift'): + proc = subprocess.run( + [sys.executable, *flags, str(script), '--mutant', mutant], + cwd=root, capture_output=True, timeout=300) + with self.subTest(flags=flags, mutant=mutant): + validate_mutant(mutant, proc, baseline) def test_crash_silence_wrong_exit_and_extra_stderr_are_refused(self): baseline = packet() diff --git a/tools/c6_residual_child_contract.py b/tools/c6_residual_child_contract.py index fc9d0a188..83e117013 100644 --- a/tools/c6_residual_child_contract.py +++ b/tools/c6_residual_child_contract.py @@ -28,6 +28,15 @@ "record-unreviewed": frozenset(("REVIEWED", "TRANSITIONS", "GATE")), "reviewed-text-drift": frozenset(("REVIEWED",)), } +EXPECTED_FAILURES_BY_STATE = { + "baseline": EXPECTED_FAILURES, + "installed": dict(EXPECTED_FAILURES, **{ + "stale-fingerprint": frozenset(("GATE", "LIVE", "TRANSITIONS")), + "installed-drift": frozenset(("TRANSITIONS",)), + "record-unreviewed": frozenset(("GATE", "LIVE", "REVIEWED", + "TRANSITIONS")), + }), +} REPORT_KEYS = frozenset(( "checks", "component_nodes", "gate", "inventory_files", "live_state", "object", "passed", "register_state", "scope", @@ -58,7 +67,7 @@ def reject_constant(value): raise ValueError("C6 residual child contract: invalid JSON stdout") from exc -def _check_common(report, baseline): +def _check_common(report, baseline, expected_failures=frozenset()): _require(type(report) is dict and set(report) == REPORT_KEYS, "missing or extra report fields") _require(report["object"] == baseline["object"] == "C6-RESIDUAL-CLOSURE-20260930-v1", @@ -69,8 +78,10 @@ def _check_common(report, baseline): "component identity changed") _require(type(report["scope"]) is str and report["scope"] == baseline["scope"], "source scope changed") - _require(report["register_state"] == baseline["register_state"] and - report["register_state"] in ("baseline", "installed"), + expected_state = ("partial" if "LIVE" in expected_failures + else baseline["register_state"]) + _require(baseline["register_state"] in ("baseline", "installed") and + report["register_state"] == expected_state, "register state changed") _require(type(report["live_state"]) is dict and report["live_state"].get("state") == report["register_state"], @@ -98,12 +109,16 @@ def validate_baseline(process, pinned_bytes): def validate_mutant(mutant, process, baseline): """Reject crashes, silence, malformed output and failures for the wrong reason.""" - _require(mutant in EXPECTED_FAILURES, "unregistered mutant label") + register_state = baseline.get("register_state") + _require(register_state in EXPECTED_FAILURES_BY_STATE, + "unregistered baseline state") + expected = EXPECTED_FAILURES_BY_STATE[register_state] + _require(mutant in expected, "unregistered mutant label") _require(process.returncode == 1, "mutant exit must be one") _require(process.stderr == b"", "mutant wrote unexpected stderr") report = _loads(process.stdout) - checks = _check_common(report, baseline) + checks = _check_common(report, baseline, expected[mutant]) failed = frozenset(name for name, value in checks.items() if value is False) - _require(report["passed"] is False and failed == EXPECTED_FAILURES[mutant], + _require(report["passed"] is False and failed == expected[mutant], "mutant failed a different check set: " + mutant) return report From df6f2eef0f0d73f7eef9e6991baa9d09b2adc0a1 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Tue, 13 Oct 2026 06:42:23 -0700 Subject: [PATCH 7/7] C6 residual: distinguish hosted and installed-state evidence --- tools/c6_residual_child_contract.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/c6_residual_child_contract.py b/tools/c6_residual_child_contract.py index 83e117013..31b1407f8 100644 --- a/tools/c6_residual_child_contract.py +++ b/tools/c6_residual_child_contract.py @@ -1,8 +1,10 @@ """Strict child-result contracts for the C6 residual closure workflow. Engineering guard only. The eight named checks and expected mutant failure -sets are derived from the pinned residual_check.py branches and the original -Python 3.11.16 hosted observations; no mathematical proof is rerun here. +sets are derived from the pinned residual_check.py branches. Baseline-state +sets use the original Python 3.11.16 hosted observations; installed-state +overrides use checker-constructed installed-graph replays. No mathematical +proof is rerun here. """ import json