From c72d32aab6465e277bad71d5dad9fbdc79f630b0 Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:00:45 +1300 Subject: [PATCH 1/6] Stack independently qualified closure context and universe substitution guards --- src/conv.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/conv.rs b/src/conv.rs index 77338081..d8f9546b 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -62,7 +62,15 @@ impl<'x, 't, 'p> TypeChecker<'x, 't, 'p> { return true; } match (a, b) { - (Env::Nil { .. }, Env::Nil { .. }) => return true, + (Env::Nil { .. }, Env::Nil { .. }) => { + // A closure with zero bound variables can still carry a + // nontrivial universe substitution. Hash equality is not proof. + return match (a.lsub(), b.lsub()) { + (None, None) => true, + (Some(x), Some(y)) => x.ks == y.ks && x.vs == y.vs, + _ => false, + }; + }, ( Env::Cons { v: va, parent: pa, hash: ha, .. }, Env::Cons { v: vb, parent: pb, hash: hb, .. }, @@ -202,6 +210,11 @@ impl<'x, 't, 'p> TypeChecker<'x, 't, 'p> { if bx.body == by.body && std::ptr::eq(*dx, *dy) && Self::envs_ptr_equal(bx.env, by.env) + && match (bx.ctx, by.ctx) { + (None, None) => true, + (Some(x), Some(y)) => std::ptr::eq(x, y), + _ => false, + } { return true; } @@ -221,6 +234,11 @@ impl<'x, 't, 'p> TypeChecker<'x, 't, 'p> { if bx.body == by.body && std::ptr::eq(dx, dy) && Self::envs_ptr_equal(bx.env, by.env) + && match (bx.ctx, by.ctx) { + (None, None) => true, + (Some(x), Some(y)) => std::ptr::eq(x, y), + _ => false, + } { return true; } From ac28f13f4c2c595d9c9916821d5b08eb0fd17eae Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:02:43 +1300 Subject: [PATCH 2/6] Compose six individually qualified Flash soundness guards in one candidate --- src/inductive.rs | 110 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 5 deletions(-) diff --git a/src/inductive.rs b/src/inductive.rs index 41d44fb2..bb98c8f2 100644 --- a/src/inductive.rs +++ b/src/inductive.rs @@ -20,6 +20,7 @@ impl<'t, 'p: 't> ExportFile<'p> { let mut physical_ind_names = Vec::new(); let mut physical_ctor_types = Vec::new(); let mut physical_inductive_types_and_ctors = Vec::new(); + let mut physical_type_uparams = Vec::new(); for idx in start..start + size { let (_, declar) = self.declars.get_index(idx).expect("inductive block boundary exceeds environment"); @@ -27,15 +28,22 @@ impl<'t, 'p: 't> ExportFile<'p> { Declar::Inductive(inductive) => { physical_ind_names.push(inductive.info.name); physical_inductive_types_and_ctors.push(inductive.info.ty); + physical_type_uparams.push((inductive.info.ty, inductive.info.uparams)); } Declar::Constructor(constructor) => { physical_ctor_types.push(constructor.info.ty); physical_inductive_types_and_ctors.push(constructor.info.ty); + physical_type_uparams.push((constructor.info.ty, constructor.info.uparams)); } _ => {} } } assert!(!physical_ind_names.is_empty(), "inductive block contains no inductive types"); + // Require source-inductive/constructor universe scope independent of later declarations. + for (ty, uparams) in physical_type_uparams.iter().copied() { + ctx.assert_inductive_type_uparams_defined(ty, uparams); + } + for ty in physical_ctor_types.iter().copied() { ctx.check_uniform_inductive_occurrences( @@ -138,6 +146,48 @@ impl<'t, 'p: 't> ExportFile<'p> { } impl<'t, 'p: 't> TcCtx<'t, 'p> { + /// Validate the source-level universe scope of an inductive or constructor + /// before checking it in an environment without an active DeclarInfo. + /// This is an iterative DAG walk: no trusted memoized ACCEPT or name special case. + fn assert_inductive_type_uparams_defined(&self, ty: ExprPtr<'t>, allowed: LevelsPtr<'t>) { + let mut pending = vec![ty]; + let mut seen = crate::util::new_fx_hash_set(); + while let Some(e) = pending.pop() { + if !seen.insert(e) { + continue; + } + match self.read_expr(e) { + Var { .. } | NatLit { .. } | StringLit { .. } => {} + Sort { level, .. } => assert!( + self.all_uparams_defined(level, allowed), + "inductive block type uses an undeclared universe parameter" + ), + Const { levels, .. } => { + for level in self.read_levels(levels).iter().copied() { + assert!( + self.all_uparams_defined(level, allowed), + "inductive block constant uses an undeclared universe parameter" + ); + } + } + App { fun, arg, .. } => { + pending.push(fun); + pending.push(arg); + } + Pi { binder_type, body, .. } | Lambda { binder_type, body, .. } => { + pending.push(binder_type); + pending.push(body); + } + Let { data, .. } => { + pending.push(data.binder_type); + pending.push(data.val); + pending.push(data.body); + } + Proj { structure, .. } => pending.push(structure), + } + } + } + pub(crate) fn check_uniform_inductive_occurrences( &self, e: ExprPtr<'t>, @@ -714,13 +764,34 @@ impl<'x, 't: 'x, 'p: 't> TypeChecker<'x, 't, 'p> { all_inductives } - fn mk_unique_name(&mut self, n: NamePtr<'t>, st: &mut InductiveCheckState<'t>) -> NamePtr<'t> { + fn mk_unique_name( + &mut self, + n: NamePtr<'t>, + st: &mut InductiveCheckState<'t>, + container_name: NamePtr<'t>, + container_ctors: &[NamePtr<'t>], + ) -> NamePtr<'t> { + // Temporary specialized types, their recursors, and their constructors + // must not collide with *any* declaration in the full imported export. + // The old environment cutoff alone excludes later declarations and + // permits a later definition to capture a previously checked recursor. + let rec_suffix = self.ctx.alloc_string(std::borrow::Cow::Borrowed("rec")); for idx in st.next_ngen_idx..u64::MAX { let tester = self.ctx.append_index_after(n, idx); - if !self.env.get_old_declar(&tester).is_some() { - st.next_ngen_idx = idx + 1; - return tester; + let rec_name = self.ctx.str(tester, rec_suffix); + let declarations = &self.ctx.export_file.declars; + if declarations.contains_key(&tester) || declarations.contains_key(&rec_name) { + continue; + } + let ctor_conflict = container_ctors.iter().copied().any(|original_ctor| { + let temp_ctor = self.ctx.replace_pfx(original_ctor, container_name, tester); + self.ctx.export_file.declars.contains_key(&temp_ctor) + }); + if ctor_conflict { + continue; } + st.next_ngen_idx = idx + 1; + return tester; } panic!("Unable to generate unique name, u64 exhausted") } @@ -774,7 +845,8 @@ impl<'x, 't: 'x, 'p: 't> TypeChecker<'x, 't, 'p> { let aux_nested_container_name = { let nested_pfx = self.ctx.str1("_nested"); let base = self.ctx.concat_name(nested_pfx, nested_container_name); - self.mk_unique_name(base, st) + let ctor_names = all_nested_container_ctor_names.clone(); + self.mk_unique_name(base, st, nested_container_name, ctor_names.as_ref()) }; // Replace the telescope on the auxiliary declaration to match the declaration // we're currently checking. Can also add parameters as needed. @@ -1613,6 +1685,26 @@ impl<'x, 't: 'x, 'p: 't> TypeChecker<'x, 't, 'p> { assert_eq!(imported_rr.ctor_name, constructed_rr.ctor_name); assert_eq!(imported_rr.ctor_telescope_size_wo_params, constructed_rr.ctor_telescope_size_wo_params); let rr_made_val = self.ctx.subst_expr_levels(constructed_rr.val, st.rec_uparams.unwrap(), old); + if constructed_rr.ctor_telescope_size_wo_params == 0 { + // A nullary constructor's rule must select its minor premise. + // Preserve that binder-variable identity separately from the + // conversion check, which can otherwise admit a different RHS. + let mut imported_body = imported_rr.val; + let mut reconstructed_body = rr_made_val; + while let (Lambda { body: a, .. }, Lambda { body: b, .. }) = + (self.ctx.read_expr(imported_body), self.ctx.read_expr(reconstructed_body)) + { + imported_body = a; + reconstructed_body = b; + } + assert!( + matches!( + (self.ctx.read_expr(imported_body), self.ctx.read_expr(reconstructed_body)), + (Var { dbj_idx: a, .. }, Var { dbj_idx: b, .. }) if a == b + ), + "imported nullary recursor rule does not select the reconstructed minor", + ); + } self.assert_imported_expr_matches(imported_rr.val, rr_made_val); } @@ -2048,6 +2140,14 @@ impl<'x, 't: 'x, 'p: 't> TypeChecker<'x, 't, 'p> { let old = original.rec_rules[i]; let new = restored.rec_rules[i]; assert_eq!(old.ctor_name, new.ctor_name); + // Reconstructed nested recursors own their field counts; the export + // must not control iota argument splitting. Adapted from upstream + // nanoda_lib PR #63 (ammkrn, 2026-10-23). + assert_eq!( + old.ctor_telescope_size_wo_params, + new.ctor_telescope_size_wo_params, + "restored nested recursor field count mismatch", + ); self.assert_imported_expr_matches(old.val, new.val); } } From 04ad1f6223357ffb35c2fe911444aef76f3e2ef1 Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:03:23 +1300 Subject: [PATCH 3/6] Add source-pinned six-forgery paired official Arena qualification --- .../flash-soundness-stack-20261104/qualify.py | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 experiments/flash-soundness-stack-20261104/qualify.py diff --git a/experiments/flash-soundness-stack-20261104/qualify.py b/experiments/flash-soundness-stack-20261104/qualify.py new file mode 100644 index 00000000..d67c30c1 --- /dev/null +++ b/experiments/flash-soundness-stack-20261104/qualify.py @@ -0,0 +1,128 @@ +"""Paired source-pinned Flash / Arena regression for the six published soundness forgeries. + +The candidate must reject six official Arena forgery exports previously accepted +by the published checker. Every other case must keep its exact exit code. + +This is a bounded correctness regression, not a Mathlib performance result. +""" + +import argparse +import hashlib +import json +from pathlib import Path +import subprocess + + +TARGETS = ( + 'pi-closure-context', + 'closure-level-subst', + 'nested-rec-rule-nfields', + 'nested-name-capture', + 'unit-rec-rule', + 'inductive-undeclared-universe', +) + + +def digest(path): + h = hashlib.sha256() + with path.open('rb') as source: + for block in iter(lambda: source.read(1024 * 1024), b''): + h.update(block) + return h.hexdigest() + + +def check(binary, config, fixture, timeout): + try: + with fixture.open('rb') as stream: + result = subprocess.run( + [str(binary), str(config)], stdin=stream, + capture_output=True, timeout=timeout, check=False) + return {'rc': result.returncode, + 'stderr_sha256': hashlib.sha256(result.stderr).hexdigest(), + 'stderr_tail': result.stderr[-300:].decode(errors='replace')} + except subprocess.TimeoutExpired: + return {'rc': 'TIMEOUT'} + + +def main(): + arg = argparse.ArgumentParser() + arg.add_argument('--before', type=Path, required=True) + arg.add_argument('--after', type=Path, required=True) + arg.add_argument('--config', type=Path, required=True) + arg.add_argument('--fixtures', type=Path, required=True) + arg.add_argument('--fixture-archive', type=Path, required=True) + arg.add_argument('--report', type=Path, required=True) + a = arg.parse_args() + + # Every examined test is provided by the official Arena tarball. + cases = [] + skipped = [] + for fixture in sorted(a.fixtures.rglob('*.ndjson')): + parts = fixture.relative_to(a.fixtures).parts + if not parts or parts[0] not in ('good', 'bad'): + skipped.append({'case': str(fixture.relative_to(a.fixtures)), + 'reason': 'not in good/bad directory'}) + continue + if 'perf' in parts: + skipped.append({'case': str(fixture.relative_to(a.fixtures)), + 'reason': 'performance workload excluded from bounded regression'}) + continue + cases.append((fixture, parts[0])) + assert cases and all(any(target in fixture.name for fixture, _ in cases) for target in TARGETS) + assert len({str(fixture) for fixture, _ in cases}) == len(cases) + + results = [] + for index, (fixture, expected) in enumerate(cases): + original = check(a.before, a.config, fixture, timeout=60) + candidate = check(a.after, a.config, fixture, timeout=60) + identity = str(fixture.relative_to(a.fixtures)) + is_target = any(target in fixture.name for target in TARGETS) + is_same = original['rc'] == candidate['rc'] + passes = ((original['rc'] == 0 and candidate['rc'] == 1 and expected == 'bad') + if is_target else is_same) + result = {'case': identity, 'expected': expected, + 'input_sha256': digest(fixture), + 'before': original, 'after': candidate, + 'target': is_target, 'protected': passes} + results.append(result) + print('FLASH_PAIR', json.dumps({ + 'case': identity, 'before': original['rc'], 'after': candidate['rc'], + 'expected': expected, 'protected': passes}), flush=True) + # Preserve a partial evidence report even when a case falsifies the + # expected delta. We never erase negative or UNKNOWN observations. + a.report.parent.mkdir(parents=True, exist_ok=True) + a.report.write_text(json.dumps({ + 'suite_sha256': digest(a.fixture_archive), + 'before_binary_sha256': digest(a.before), + 'after_binary_sha256': digest(a.after), + 'cases': results, 'skipped': skipped, + 'status': 'INCOMPLETE' if index + 1 < len(cases) else 'EVALUATING', + }, indent=2) + '\n') + if not passes: + break + + all_pass = len(results) == len(cases) and all(r['protected'] for r in results) + target_rows = [r for r in results if r['target']] + all_pass = all_pass and len(target_rows) == len(TARGETS) + report = { + 'status': 'WARRANTED_BOUNDED_SMALL_ARENA_NONREGRESSION' if all_pass else 'REJECTED_OR_INCOMPLETE', + 'qualified': all_pass, + 'suite_sha256': digest(a.fixture_archive), + 'before_binary_sha256': digest(a.before), + 'after_binary_sha256': digest(a.after), + 'test_count': len(cases), 'tested_count': len(results), + 'targets': list(TARGETS), + 'target_positive': all(r['protected'] for r in target_rows) and len(target_rows) == len(TARGETS), + 'cases': results, 'skipped': skipped, + 'full_mathlib': 'NOT_TESTED', 'performance': 'NOT_TESTED', + 'attribution': 'Upstream-motivated soundness fixes for nanoda_lib #63/#74/#79 and sokonanoda #7/#8/#9; individually qualified before stacking', + } + a.report.write_text(json.dumps(report, indent=2) + '\n') + print('FLASH_PROTECTED_SUMMARY', json.dumps({k: v for k, v in report.items() + if k not in ('cases', 'skipped')}), flush=True) + if not all_pass: + raise SystemExit(1) + + +if __name__ == '__main__': + main() From 736ddd2d119103358b24bba9d301042ed3f2e6b2 Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:03:49 +1300 Subject: [PATCH 4/6] Add exact-input matched A/B/B/A full Mathlib acceptance and resource profile --- .../profile_mathlib.py | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 experiments/flash-soundness-stack-20261104/profile_mathlib.py diff --git a/experiments/flash-soundness-stack-20261104/profile_mathlib.py b/experiments/flash-soundness-stack-20261104/profile_mathlib.py new file mode 100644 index 00000000..488fbdef --- /dev/null +++ b/experiments/flash-soundness-stack-20261104/profile_mathlib.py @@ -0,0 +1,111 @@ +"""Matched full-Mathlib replay of published Flash and six-guard candidate. + +This is not an Arena submission or a proof of complete soundness. It records +exact input/binary hashes, kernel verdict, wall time and peak RSS, including +failures, timeouts and disagreement. A/B/B/A reduces order confounding. +""" +import argparse +import hashlib +import json +from pathlib import Path +import statistics +import subprocess +import time + + +def digest(path): + h = hashlib.sha256() + with path.open('rb') as f: + for buf in iter(lambda: f.read(8 * 1024 * 1024), b''): + h.update(buf) + return h.hexdigest() + + +def run(binary, config, inp, outdir, arm, index, seconds): + stem = outdir / f"{index:02d}-{arm}" + stdout = stem.with_suffix(".stdout") + stderr = stem.with_suffix(".stderr") + metrics = stem.with_suffix(".time") + command = ['/usr/bin/time', '-f', + 'wall_seconds=%e\\nuser_seconds=%U\\nsys_seconds=%S\\npeak_rss_kb=%M', + '-o', str(metrics), str(binary), str(config)] + result = {'arm': arm, 'ordinal': index, 'binary_sha256': digest(binary)} + start = time.monotonic() + try: + with inp.open('rb') as source, stdout.open('wb') as so, stderr.open('wb') as se: + proc = subprocess.run(command, stdin=source, stdout=so, + stderr=se, timeout=seconds, check=False) + result['returncode'] = proc.returncode + except subprocess.TimeoutExpired: + result['returncode'] = 'TIMEOUT' + result['elapsed_monotonic_seconds'] = round(time.monotonic() - start, 3) + result['stdout_sha256'] = digest(stdout) if stdout.exists() else None + result['stderr_sha256'] = digest(stderr) if stderr.exists() else None + result['stderr_tail'] = stderr.read_bytes()[-500:].decode(errors='replace') if stderr.exists() else None + if metrics.exists(): + for line in metrics.read_text(errors='replace').splitlines(): + if '=' in line: + key, val = line.split('=', 1) + try: + result[key] = float(val) + except ValueError: + result[key] = val + return result + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('--before', required=True, type=Path) + ap.add_argument('--after', required=True, type=Path) + ap.add_argument('--config', required=True, type=Path) + ap.add_argument('--input', required=True, type=Path) + ap.add_argument('--outdir', required=True, type=Path) + ap.add_argument('--seconds', type=int, default=900) + ap.add_argument('--expected-input-sha256', required=True) + a = ap.parse_args() + a.outdir.mkdir(parents=True, exist_ok=True) + input_sha = digest(a.input) + if input_sha != a.expected_input_sha256: + raise SystemExit(f'input SHA mismatch: {input_sha}') + report = {'status': 'INCOMPLETE', 'input_sha256': input_sha, + 'input_bytes': a.input.stat().st_size, + 'config_sha256': digest(a.config), + 'published_binary_sha256': digest(a.before), + 'candidate_binary_sha256': digest(a.after), + 'order': ['before', 'after', 'after', 'before'], + 'method': 'sequential A/B/B/A same runner, exact input and config; wall/RSS not arena-calibrated', + 'runs': []} + path = a.outdir / 'mathlib-report.json' + path.write_text(json.dumps(report, indent=2) + '\\n') + for index, arm in enumerate(report['order']): + binary = a.before if arm == 'before' else a.after + print('MATHLIB_BEGIN', json.dumps({'index': index, 'arm': arm}), flush=True) + result = run(binary, a.config, a.input, a.outdir, arm, index, a.seconds) + report['runs'].append(result) + path.write_text(json.dumps(report, indent=2) + '\\n') + print('MATHLIB_RUN', json.dumps(result), flush=True) + if result['returncode'] != 0: + print('MATHLIB_STOP', json.dumps({'cause': 'non-ACCEPT, timeout or resource failure', + 'index': index, 'arm': arm}), flush=True) + break + both_arms = {arm: [r for r in report['runs'] if r['arm'] == arm] + for arm in ('before', 'after')} + valid = len(report['runs']) == 4 and all(r['returncode'] == 0 for r in report['runs']) + if valid: + for arm, rs in both_arms.items(): + report[f'{arm}_median_wall_seconds'] = statistics.median(r['wall_seconds'] for r in rs) + report[f'{arm}_max_peak_rss_kb'] = max(r['peak_rss_kb'] for r in rs) + report['candidate_vs_published_wall_ratio'] = ( + report['after_median_wall_seconds'] / report['before_median_wall_seconds']) + report['status'] = 'BOUNDED_MATCHED_MATHLIB_ACCEPTANCE' + else: + report['status'] = 'UNKNOWN_OR_REJECTED_MATCHED_MATHLIB' + path.write_text(json.dumps(report, indent=2) + '\\n') + print('MATHLIB_STACK_SUMMARY', json.dumps({ + k: v for k, v in report.items() if k != 'runs'}), flush=True) + if not valid: + raise SystemExit(1) + + +if __name__ == '__main__': + main() From a389edbbd776a5733cdf003e963531d931e9b5da Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:04:05 +1300 Subject: [PATCH 5/6] Fix metrics newlines and preserve parseable full Mathlib run report --- .../flash-soundness-stack-20261104/profile_mathlib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/experiments/flash-soundness-stack-20261104/profile_mathlib.py b/experiments/flash-soundness-stack-20261104/profile_mathlib.py index 488fbdef..1d36d068 100644 --- a/experiments/flash-soundness-stack-20261104/profile_mathlib.py +++ b/experiments/flash-soundness-stack-20261104/profile_mathlib.py @@ -27,7 +27,7 @@ def run(binary, config, inp, outdir, arm, index, seconds): stderr = stem.with_suffix(".stderr") metrics = stem.with_suffix(".time") command = ['/usr/bin/time', '-f', - 'wall_seconds=%e\\nuser_seconds=%U\\nsys_seconds=%S\\npeak_rss_kb=%M', + 'wall_seconds=%e\nuser_seconds=%U\nsys_seconds=%S\npeak_rss_kb=%M', '-o', str(metrics), str(binary), str(config)] result = {'arm': arm, 'ordinal': index, 'binary_sha256': digest(binary)} start = time.monotonic() @@ -76,13 +76,13 @@ def main(): 'method': 'sequential A/B/B/A same runner, exact input and config; wall/RSS not arena-calibrated', 'runs': []} path = a.outdir / 'mathlib-report.json' - path.write_text(json.dumps(report, indent=2) + '\\n') + path.write_text(json.dumps(report, indent=2) + '\n') for index, arm in enumerate(report['order']): binary = a.before if arm == 'before' else a.after print('MATHLIB_BEGIN', json.dumps({'index': index, 'arm': arm}), flush=True) result = run(binary, a.config, a.input, a.outdir, arm, index, a.seconds) report['runs'].append(result) - path.write_text(json.dumps(report, indent=2) + '\\n') + path.write_text(json.dumps(report, indent=2) + '\n') print('MATHLIB_RUN', json.dumps(result), flush=True) if result['returncode'] != 0: print('MATHLIB_STOP', json.dumps({'cause': 'non-ACCEPT, timeout or resource failure', @@ -100,7 +100,7 @@ def main(): report['status'] = 'BOUNDED_MATCHED_MATHLIB_ACCEPTANCE' else: report['status'] = 'UNKNOWN_OR_REJECTED_MATCHED_MATHLIB' - path.write_text(json.dumps(report, indent=2) + '\\n') + path.write_text(json.dumps(report, indent=2) + '\n') print('MATHLIB_STACK_SUMMARY', json.dumps({ k: v for k, v in report.items() if k != 'runs'}), flush=True) if not valid: From 6c2889330be236b3bc063b3415de6e9af65ecfe1 Mon Sep 17 00:00:00 2001 From: Heath Sanchez Date: Wed, 4 Nov 2026 13:05:28 +1300 Subject: [PATCH 6/6] Add matched official Arena and full Mathlib qualification for six-guard Flash stack --- .../flash-soundness-stack-20261104.yml | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/flash-soundness-stack-20261104.yml diff --git a/.github/workflows/flash-soundness-stack-20261104.yml b/.github/workflows/flash-soundness-stack-20261104.yml new file mode 100644 index 00000000..4e6ce4db --- /dev/null +++ b/.github/workflows/flash-soundness-stack-20261104.yml @@ -0,0 +1,104 @@ +name: Flash six-guard soundness stack — official Arena and exact Mathlib + +on: + pull_request: + branches: + - flash + workflow_dispatch: + +permissions: + contents: read + +jobs: + six-guard-regression-and-mathlib: + runs-on: ubuntu-24.04 + timeout-minutes: 95 + env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + RUSTFLAGS: -C target-cpu=native + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Record exact source, compiler, and published Flash baseline + run: | + set -euo pipefail + git rev-parse HEAD + git cat-file -e 78c7502bac8a5ba000057b3f083bc0595ac65750^{commit} + rustc --version + cargo --version + mkdir -p /tmp/flash-qualification + + - name: Build published Flash and stacked candidate identically + run: | + set -euo pipefail + git worktree add --detach /tmp/flash-published 78c7502bac8a5ba000057b3f083bc0595ac65750 + cargo build --manifest-path /tmp/flash-published/Cargo.toml --release --locked + cargo build --manifest-path Cargo.toml --release --locked + sha256sum /tmp/flash-published/target/release/sokonanoda target/release/sokonanoda | tee /tmp/flash-qualification/binaries.sha256 + + - name: Fetch official Arena small corpus and hash it + run: | + set -euo pipefail + curl --fail --location --silent --show-error --retry 3 --max-time 120 \ + https://arena.lean-lang.org/lean-arena-tests.tar.gz \ + --output /tmp/flash-qualification/lean-arena-tests.tar.gz + printf '%s %s\n' 8223cb53aa5fa65f471054fbdf8cdcf50206556cfc7888f75e910f7816f4c8bb /tmp/flash-qualification/lean-arena-tests.tar.gz | sha256sum -c - + mkdir -p /tmp/flash-qualification/tests + tar -xzf /tmp/flash-qualification/lean-arena-tests.tar.gz -C /tmp/flash-qualification/tests + + - name: Require all six false ACCEPTs fixed and all other small verdicts unchanged + run: | + set -euo pipefail + printf '{"use_stdin":true,"nat_extension":true,"string_extension":true,"unpermitted_axiom_hard_error":false,"unsafe_permit_all_axioms":true,"num_threads":2}\n' > /tmp/flash-qualification/config.json + python3 experiments/flash-soundness-stack-20261104/qualify.py \ + --before /tmp/flash-published/target/release/sokonanoda \ + --after "$PWD/target/release/sokonanoda" \ + --config /tmp/flash-qualification/config.json \ + --fixtures /tmp/flash-qualification/tests \ + --fixture-archive /tmp/flash-qualification/lean-arena-tests.tar.gz \ + --report /tmp/flash-qualification/report.json + + - name: Restore exact independently pinned full Mathlib export + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + mkdir -p /tmp/flash-qualification/mathlib-source /tmp/flash-qualification/mathlib + gh api repos/heathsanchez/test/actions/artifacts/13231986845/zip > /tmp/flash-qualification/mathlib.zip + printf '%s %s\n' 3dd3fbb522816bdaa9d9cd2808196e075bfa27e3d6c82648731140594f87ce2b /tmp/flash-qualification/mathlib.zip | sha256sum -c - + unzip -q /tmp/flash-qualification/mathlib.zip -d /tmp/flash-qualification/mathlib-source + zstd -d /tmp/flash-qualification/mathlib-source/mathlib.ndjson.zst -o /tmp/flash-qualification/mathlib.ndjson + printf '%s %s\n' 22c5de83469408950005589a3bc5ef5157c65549b5a802f85d567c29151306a6 /tmp/flash-qualification/mathlib.ndjson | sha256sum -c - + rm /tmp/flash-qualification/mathlib.zip /tmp/flash-qualification/mathlib-source/mathlib.ndjson.zst + ls -lh /tmp/flash-qualification/mathlib.ndjson + + - name: Matched published-versus-stacked full Mathlib A/B/B/A + run: | + set -euo pipefail + python3 experiments/flash-soundness-stack-20261104/profile_mathlib.py \ + --before /tmp/flash-published/target/release/sokonanoda \ + --after "$PWD/target/release/sokonanoda" \ + --config /tmp/flash-qualification/config.json \ + --input /tmp/flash-qualification/mathlib.ndjson \ + --outdir /tmp/flash-qualification/mathlib \ + --seconds 900 \ + --expected-input-sha256 22c5de83469408950005589a3bc5ef5157c65549b5a802f85d567c29151306a6 + + - name: Preserve results and negative evidence even if a gate fails + if: always() + uses: actions/upload-artifact@v4 + with: + name: flash-six-guard-stack-${{ github.sha }} + if-no-files-found: warn + path: | + /tmp/flash-qualification/report.json + /tmp/flash-qualification/binaries.sha256 + /tmp/flash-qualification/config.json + /tmp/flash-qualification/lean-arena-tests.tar.gz + /tmp/flash-qualification/mathlib/mathlib-report.json + /tmp/flash-qualification/mathlib/*.time + /tmp/flash-qualification/mathlib/*.stderr + /tmp/flash-qualification/mathlib/*.stdout