From 4cab4769bf4c7455a778b959b0cdf51f038b5d47 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:42:16 -0500 Subject: [PATCH 1/4] fix(ci): bind C6 micro-tail subprocess output predicates --- .../c6-microscopic-tail-numerics.yml | 95 +++++++++++++++++-- 1 file changed, 88 insertions(+), 7 deletions(-) diff --git a/.github/workflows/c6-microscopic-tail-numerics.yml b/.github/workflows/c6-microscopic-tail-numerics.yml index d7d8769c8..688eae6ac 100644 --- a/.github/workflows/c6-microscopic-tail-numerics.yml +++ b/.github/workflows/c6-microscopic-tail-numerics.yml @@ -55,15 +55,96 @@ jobs: blob = hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() if len(data) != entry['bytes'] or hashlib.sha256(data).hexdigest() != entry['sha256'] or blob != entry['git_blob']: raise ValueError('consumed source identity mismatch on this tree: ' + entry['path']) + validator_source = r''' +class Result: + def __init__(self, returncode, stdout=b"", stderr=b""): + self.returncode = returncode + self.stdout = stdout + self.stderr = stderr + +def validate_baseline(result): + expected = b'{"check": "ok", "mutant": null}\\n' + if result.returncode != 0 or result.stdout != expected or result.stderr != b"": + raise ValueError("baseline output contract mismatch") + +def validate_mutant(result, diagnostic): + expected = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + if result.returncode != 1 or result.stdout != expected or result.stderr != b"": + raise ValueError("mutant output contract mismatch: " + diagnostic) + +def reject(fn, result, *args): + try: + fn(result, *args) + except ValueError: + return + raise AssertionError("invalid child result was accepted") + +def synthetic_controls(): + baseline = b'{"check": "ok", "mutant": null}\\n' + validate_baseline(Result(0, baseline, b"")) + for bad in ( + Result(0, b"not-json\\n", b""), + Result(0, baseline, b"unexpected stderr\\n"), + Result(0, baseline + b"extra\\n", b""), + Result(1, baseline, b""), + ): + reject(validate_baseline, bad) + + expected = { + "shape-integral": "I = 246528/35", + "gamma-power": "cusp integral replay J_cusp k=0.5", + "cusp-shift": "cusp integral replay J_cusp k=0.5", + } + for mutant, diagnostic in expected.items(): + valid = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + validate_mutant(Result(1, valid, b""), diagnostic) + wrong_label = b'{"check": "ok", "mutant": "wrong-mutant"}\\n' + for bad in ( + Result(1, b"", b"Traceback (most recent call last): RuntimeError\\n"), + Result(1, b"", b""), + Result(1, b"FAIL: unrelated failure\\n", b""), + Result(1, valid, b"unexpected stderr\\n"), + Result(0, valid, b""), + Result(1, baseline, b""), + Result(1, wrong_label, b""), + ): + reject(validate_mutant, bad, diagnostic) +''' + + validator_namespace = {} + exec(validator_source, validator_namespace) + validate_baseline = validator_namespace['validate_baseline'] + validate_mutant = validator_namespace['validate_mutant'] + synthetic_code = validator_source + "\\nsynthetic_controls()\\nprint('synthetic process-predicate controls passed')\\n" + for flags in (['-B', '-S'], ['-B', '-O', '-S']): + probe = subprocess.run([sys.executable, *flags, '-c', synthetic_code], capture_output=True, timeout=30) + if probe.returncode != 0 or probe.stderr != b'' or probe.stdout != b'synthetic process-predicate controls passed\\n': + raise RuntimeError('synthetic process-predicate controls failed under ' + ' '.join(flags) + + ': stdout=' + repr(probe.stdout) + ' stderr=' + repr(probe.stderr)) + script = str(root / 'tail_constants.py') + expected_mutants = { + 'shape-integral': 'I = 246528/35', + 'gamma-power': 'cusp integral replay J_cusp k=0.5', + 'cusp-shift': 'cusp integral replay J_cusp k=0.5', + } for flags in (['-B', '-S'], ['-B', '-O', '-S']): - out = subprocess.run([sys.executable, *flags, script, '--check'], cwd=root, capture_output=True, timeout=900) - if out.returncode != 0: - raise RuntimeError('check failed under ' + ' '.join(flags) + ': ' + out.stdout.decode()[-400:]) - for m in ['shape-integral', 'gamma-power', 'cusp-shift']: - rc = subprocess.run([sys.executable, *flags, script, '--check', '--mutant', m], cwd=root, capture_output=True, timeout=900).returncode - if rc != 1: - raise RuntimeError('mutant ' + m + ' not rejected') + baseline = subprocess.run([sys.executable, *flags, script, '--check'], cwd=root, capture_output=True, timeout=900) + try: + validate_baseline(baseline) + except ValueError as exc: + raise RuntimeError('baseline contract failed under ' + ' '.join(flags) + + ': rc=' + str(baseline.returncode) + ' stdout=' + repr(baseline.stdout) + + ' stderr=' + repr(baseline.stderr)) from exc + for mutant, diagnostic in expected_mutants.items(): + result = subprocess.run([sys.executable, *flags, script, '--check', '--mutant', mutant], + cwd=root, capture_output=True, timeout=900) + try: + validate_mutant(result, diagnostic) + except ValueError as exc: + raise RuntimeError('mutant ' + mutant + ' contract failed under ' + ' '.join(flags) + + ': rc=' + str(result.returncode) + ' stdout=' + repr(result.stdout) + + ' stderr=' + repr(result.stderr)) from exc print(json.dumps({'scientific_effect': 'NONE', 'certified': False})) PY git diff --exit-code From be0da9157a9c6a905fc964c1aded0ce88ed563e9 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:43:29 -0500 Subject: [PATCH 2/4] fix(ci): keep C6 wrapper validator inside workflow run block --- .../c6-microscopic-tail-numerics.yml | 114 +++++++++--------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/.github/workflows/c6-microscopic-tail-numerics.yml b/.github/workflows/c6-microscopic-tail-numerics.yml index 688eae6ac..be04412ca 100644 --- a/.github/workflows/c6-microscopic-tail-numerics.yml +++ b/.github/workflows/c6-microscopic-tail-numerics.yml @@ -56,61 +56,61 @@ jobs: if len(data) != entry['bytes'] or hashlib.sha256(data).hexdigest() != entry['sha256'] or blob != entry['git_blob']: raise ValueError('consumed source identity mismatch on this tree: ' + entry['path']) validator_source = r''' -class Result: - def __init__(self, returncode, stdout=b"", stderr=b""): - self.returncode = returncode - self.stdout = stdout - self.stderr = stderr - -def validate_baseline(result): - expected = b'{"check": "ok", "mutant": null}\\n' - if result.returncode != 0 or result.stdout != expected or result.stderr != b"": - raise ValueError("baseline output contract mismatch") - -def validate_mutant(result, diagnostic): - expected = ("FAIL: " + diagnostic + "\\n").encode("utf-8") - if result.returncode != 1 or result.stdout != expected or result.stderr != b"": - raise ValueError("mutant output contract mismatch: " + diagnostic) - -def reject(fn, result, *args): - try: - fn(result, *args) - except ValueError: - return - raise AssertionError("invalid child result was accepted") - -def synthetic_controls(): - baseline = b'{"check": "ok", "mutant": null}\\n' - validate_baseline(Result(0, baseline, b"")) - for bad in ( - Result(0, b"not-json\\n", b""), - Result(0, baseline, b"unexpected stderr\\n"), - Result(0, baseline + b"extra\\n", b""), - Result(1, baseline, b""), - ): - reject(validate_baseline, bad) - - expected = { - "shape-integral": "I = 246528/35", - "gamma-power": "cusp integral replay J_cusp k=0.5", - "cusp-shift": "cusp integral replay J_cusp k=0.5", - } - for mutant, diagnostic in expected.items(): - valid = ("FAIL: " + diagnostic + "\\n").encode("utf-8") - validate_mutant(Result(1, valid, b""), diagnostic) - wrong_label = b'{"check": "ok", "mutant": "wrong-mutant"}\\n' - for bad in ( - Result(1, b"", b"Traceback (most recent call last): RuntimeError\\n"), - Result(1, b"", b""), - Result(1, b"FAIL: unrelated failure\\n", b""), - Result(1, valid, b"unexpected stderr\\n"), - Result(0, valid, b""), - Result(1, baseline, b""), - Result(1, wrong_label, b""), - ): - reject(validate_mutant, bad, diagnostic) -''' - + class Result: + def __init__(self, returncode, stdout=b"", stderr=b""): + self.returncode = returncode + self.stdout = stdout + self.stderr = stderr + + def validate_baseline(result): + expected = b'{"check": "ok", "mutant": null}\\n' + if result.returncode != 0 or result.stdout != expected or result.stderr != b"": + raise ValueError("baseline output contract mismatch") + + def validate_mutant(result, diagnostic): + expected = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + if result.returncode != 1 or result.stdout != expected or result.stderr != b"": + raise ValueError("mutant output contract mismatch: " + diagnostic) + + def reject(fn, result, *args): + try: + fn(result, *args) + except ValueError: + return + raise AssertionError("invalid child result was accepted") + + def synthetic_controls(): + baseline = b'{"check": "ok", "mutant": null}\\n' + validate_baseline(Result(0, baseline, b"")) + for bad in ( + Result(0, b"not-json\\n", b""), + Result(0, baseline, b"unexpected stderr\\n"), + Result(0, baseline + b"extra\\n", b""), + Result(1, baseline, b""), + ): + reject(validate_baseline, bad) + + expected = { + "shape-integral": "I = 246528/35", + "gamma-power": "cusp integral replay J_cusp k=0.5", + "cusp-shift": "cusp integral replay J_cusp k=0.5", + } + for mutant, diagnostic in expected.items(): + valid = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + validate_mutant(Result(1, valid, b""), diagnostic) + wrong_label = b'{"check": "ok", "mutant": "wrong-mutant"}\\n' + for bad in ( + Result(1, b"", b"Traceback (most recent call last): RuntimeError\\n"), + Result(1, b"", b""), + Result(1, b"FAIL: unrelated failure\\n", b""), + Result(1, valid, b"unexpected stderr\\n"), + Result(0, valid, b""), + Result(1, baseline, b""), + Result(1, wrong_label, b""), + ): + reject(validate_mutant, bad, diagnostic) + ''' + validator_namespace = {} exec(validator_source, validator_namespace) validate_baseline = validator_namespace['validate_baseline'] @@ -121,7 +121,7 @@ def synthetic_controls(): if probe.returncode != 0 or probe.stderr != b'' or probe.stdout != b'synthetic process-predicate controls passed\\n': raise RuntimeError('synthetic process-predicate controls failed under ' + ' '.join(flags) + ': stdout=' + repr(probe.stdout) + ' stderr=' + repr(probe.stderr)) - + script = str(root / 'tail_constants.py') expected_mutants = { 'shape-integral': 'I = 246528/35', @@ -145,6 +145,4 @@ def synthetic_controls(): raise RuntimeError('mutant ' + mutant + ' contract failed under ' + ' '.join(flags) + ': rc=' + str(result.returncode) + ' stdout=' + repr(result.stdout) + ' stderr=' + repr(result.stderr)) from exc - print(json.dumps({'scientific_effect': 'NONE', 'certified': False})) - PY git diff --exit-code From 1b179cedc0adf6323a33fa4441294a21cc762ee0 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:43:43 -0500 Subject: [PATCH 3/4] fix(ci): correct C6 predicate probe newline literals --- .../c6-microscopic-tail-numerics.yml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/c6-microscopic-tail-numerics.yml b/.github/workflows/c6-microscopic-tail-numerics.yml index be04412ca..d2bf03f5d 100644 --- a/.github/workflows/c6-microscopic-tail-numerics.yml +++ b/.github/workflows/c6-microscopic-tail-numerics.yml @@ -63,12 +63,12 @@ jobs: self.stderr = stderr def validate_baseline(result): - expected = b'{"check": "ok", "mutant": null}\\n' + expected = b'{"check": "ok", "mutant": null}\n' if result.returncode != 0 or result.stdout != expected or result.stderr != b"": raise ValueError("baseline output contract mismatch") def validate_mutant(result, diagnostic): - expected = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + expected = ("FAIL: " + diagnostic + "\n").encode("utf-8") if result.returncode != 1 or result.stdout != expected or result.stderr != b"": raise ValueError("mutant output contract mismatch: " + diagnostic) @@ -80,12 +80,12 @@ jobs: raise AssertionError("invalid child result was accepted") def synthetic_controls(): - baseline = b'{"check": "ok", "mutant": null}\\n' + baseline = b'{"check": "ok", "mutant": null}\n' validate_baseline(Result(0, baseline, b"")) for bad in ( - Result(0, b"not-json\\n", b""), - Result(0, baseline, b"unexpected stderr\\n"), - Result(0, baseline + b"extra\\n", b""), + Result(0, b"not-json\n", b""), + Result(0, baseline, b"unexpected stderr\n"), + Result(0, baseline + b"extra\n", b""), Result(1, baseline, b""), ): reject(validate_baseline, bad) @@ -96,14 +96,14 @@ jobs: "cusp-shift": "cusp integral replay J_cusp k=0.5", } for mutant, diagnostic in expected.items(): - valid = ("FAIL: " + diagnostic + "\\n").encode("utf-8") + valid = ("FAIL: " + diagnostic + "\n").encode("utf-8") validate_mutant(Result(1, valid, b""), diagnostic) - wrong_label = b'{"check": "ok", "mutant": "wrong-mutant"}\\n' + wrong_label = b'{"check": "ok", "mutant": "wrong-mutant"}\n' for bad in ( - Result(1, b"", b"Traceback (most recent call last): RuntimeError\\n"), + Result(1, b"", b"Traceback (most recent call last): RuntimeError\n"), Result(1, b"", b""), - Result(1, b"FAIL: unrelated failure\\n", b""), - Result(1, valid, b"unexpected stderr\\n"), + Result(1, b"FAIL: unrelated failure\n", b""), + Result(1, valid, b"unexpected stderr\n"), Result(0, valid, b""), Result(1, baseline, b""), Result(1, wrong_label, b""), @@ -115,10 +115,10 @@ jobs: exec(validator_source, validator_namespace) validate_baseline = validator_namespace['validate_baseline'] validate_mutant = validator_namespace['validate_mutant'] - synthetic_code = validator_source + "\\nsynthetic_controls()\\nprint('synthetic process-predicate controls passed')\\n" + synthetic_code = validator_source + "\nsynthetic_controls()\nprint('synthetic process-predicate controls passed')\n" for flags in (['-B', '-S'], ['-B', '-O', '-S']): probe = subprocess.run([sys.executable, *flags, '-c', synthetic_code], capture_output=True, timeout=30) - if probe.returncode != 0 or probe.stderr != b'' or probe.stdout != b'synthetic process-predicate controls passed\\n': + if probe.returncode != 0 or probe.stderr != b'' or probe.stdout != b'synthetic process-predicate controls passed\n': raise RuntimeError('synthetic process-predicate controls failed under ' + ' '.join(flags) + ': stdout=' + repr(probe.stdout) + ' stderr=' + repr(probe.stderr)) From 0655e1371422e3abd04f498554be61137d1c39a5 Mon Sep 17 00:00:00 2001 From: Dylan Roy <249851642+d6g8k5htny-coder@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:51:34 -0500 Subject: [PATCH 4/4] fix(ci): close C6 replay heredoc before shell diff check --- .github/workflows/c6-microscopic-tail-numerics.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/c6-microscopic-tail-numerics.yml b/.github/workflows/c6-microscopic-tail-numerics.yml index d2bf03f5d..63001ce95 100644 --- a/.github/workflows/c6-microscopic-tail-numerics.yml +++ b/.github/workflows/c6-microscopic-tail-numerics.yml @@ -145,4 +145,5 @@ jobs: raise RuntimeError('mutant ' + mutant + ' contract failed under ' + ' '.join(flags) + ': rc=' + str(result.returncode) + ' stdout=' + repr(result.stdout) + ' stderr=' + repr(result.stderr)) from exc + PY git diff --exit-code