Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/c293-morse-finite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: C293 Morse finite critical (hosted Lean, no scientific promotion)
'on':
pull_request:
paths:
- 'frontiers/morse_finite_critical_20261018/**'
- 'tools/c293_hosted_verify.py'
- 'tests/test_c293_hosted_verify.py'
- '.github/workflows/c293-morse-finite.yml'
- 'formal/lean-toolchain'
- 'formal/lakefile.toml'
- 'formal/lake-manifest.json'
- 'specifications/lean_statements_20261010/Specifications/Lifetime.lean'
- 'companions/torus_filtration_20261011/TorusTopology.lean'
push:
branches: [main]
paths:
- 'frontiers/morse_finite_critical_20261018/**'
- 'tools/c293_hosted_verify.py'
- 'tests/test_c293_hosted_verify.py'
- '.github/workflows/c293-morse-finite.yml'
- 'formal/lean-toolchain'
- 'formal/lakefile.toml'
- 'formal/lake-manifest.json'
- 'specifications/lean_statements_20261010/Specifications/Lifetime.lean'
- 'companions/torus_filtration_20261011/TorusTopology.lean'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: c293-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
c293-hosted-formal:
name: c293-hosted-formal
runs-on: ubuntu-24.04
timeout-minutes: 55
env:
LEAN_NUM_THREADS: '2'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
fetch-depth: 1
- name: Verify source identities and eight registration engineering tests
run: |
python3 -B -S tools/c293_hosted_verify.py source
python3 -B -S -m unittest discover -s tests -p test_c293_hosted_verify.py -v
python3 -B -O -S -m unittest discover -s tests -p test_c293_hosted_verify.py -v
- name: Install pinned Lean and retrieve dependency cache
uses: leanprover/lean-action@f061402b660e0c34644504b324e830f2991d4865
with:
lake-package-directory: formal
auto-config: 'false'
build: 'false'
test: 'false'
lint: 'false'
use-mathlib-cache: 'true'
use-github-cache: 'false'
- name: Build five C293 objects, kernel replay, audit and missing-premise rejection
run: |
cd formal
lake env python3 -B -S ../tools/c293_hosted_verify.py execute
- name: Retain exact tested-run C293 outputs including failures
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
with:
name: c293-hosted-${{ github.run_id }}-${{ github.run_attempt }}
path: .lake/c293-hosted-evidence/
include-hidden-files: true
if-no-files-found: warn
retention-days: 90
37 changes: 37 additions & 0 deletions docs/c293-hosted-formal-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# C293 hosted formal replay — engineering-only registration

**Scientific effect: NONE.** This is source-bound, hosted Lean verification of C293's conditional finite-critical-class declaration; it is not acceptance of C292, elder pairing, or the persistence-lifetime law.

## Ownership, source and current gates

Source PR: https://github.com/d6g8k5htny-coder/Math-/pull/482 at exact head 0ea97aff489f9420632b4cee81ad82dbec5fe88e. The stacked CI branch is based on that head; it does not change source modules, source reviews, historical receipts, negative controls, or original evidence.

The existing required math-downstream-gates invokes the original formal-lean.yml, which builds the independent formal/ target. Neither that required job nor the existing torus-filtration.yml companion executes this new C293 declaration. The latter's Claude companion ownership and the separate Sol/elder-registration work remain undisturbed.

The addition is a dedicated C293 workflow named c293-morse-finite.yml. Its c293-hosted-formal job is **not a branch-protection-required context** and is not inserted into formal/gate.py or the required aggregate. Enforcing it as required should follow separately with current gate owners after hosted execution, capacity evidence, source review and readback.

## Hosted invocation and pins

The job uses Lean 4.34.1 and exactly the existing formal Lake project and its nine package pins, including Mathlib d13f23b723b8a846827a245b89c10fc7d3f11612. Python source checks compare all five C293 Lean modules to their published byte counts/SHA-256 values and require exact identity with the canonical Lifetime and TorusTopology upstream files. A mutated control, pin, source or upstream copy fails closed; normal and optimized test modes exercise the guard.

To repeat after installing the formal Lake dependencies, execute from the repository root:

python3 -B -S tools/c293_hosted_verify.py source
python3 -B -S -m unittest discover -s tests -p test_c293_hosted_verify.py -v
python3 -B -O -S -m unittest discover -s tests -p test_c293_hosted_verify.py -v
cd formal
lake env python3 -B -S ../tools/c293_hosted_verify.py execute

The runner verifies tested GitHub commit, repository, run ID and attempt; Lean version; exact installed revisions and clean source; then compiles from new isolated outputs in the order Lifetime, TorusTopology, MorseFiniteCritical, MorseFiniteControls, MorseFiniteAxiomAudit. The three new modules use warnings-as-errors; all builds and the negative control use -j2 -M14000.

**Memory deviation:** The original author receipts use -M4096. Anthropic/Claude's provider-distinct Linux replay, recorded in https://github.com/d6g8k5htny-coder/Math-/pull/482#issuecomment-6246988654 , needed -M14000 for six build/negative invocations. This workflow records the new limit without altering the original receipts.

All five new .olean files must match the published object SHA-256 values. Three named-module leanchecker -v passes, the full 169-declaration (103/38/20/8) standard-only transitive axiom audit, and the exact intended missing-IsMorseDistinct rejection are mandatory. A nonzero result for an unrelated reason is not a pass.

The 90-day workflow artifact contains phase stdout/stderr, digests and exact-run RESULT.json. Hosted standard named-module replay is **not** a hosted leanchecker --fresh of the entire import closure. External --fresh is a separate evidence record; neither implies institutional mathematical acceptance.

## Source review and protected integration

This change should receive review of its *CI verifier*, not substitute for the source author's C293 mathematical review. Inspect the new hosted c293-hosted-formal job and its real logs on the exact tested PR merge; do not reclassify old green checks. Keep this implementation stacked until C293 source PR #482 receives its own legitimate integration disposition. Do not automatically merge into the source author's draft branch, alter rulesets, waive reviewer independence or set a scientific status. Before any later merge, re-check ownership, base/head, source hashes, reviews, gates and the protected merge process.

C293 does not close critical-level local path connectivity or path attainment, the full C292 adapter, almost-sure Morse, elder pairing, exhaustive once-counting, all-small-bars converse, regional collisions or stochastic lifetime transfer.
239 changes: 239 additions & 0 deletions tests/test_c293_hosted_verify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
"""Fail-closed C293 hosted-registration tests; no Lean execution or theorem acceptance."""
import importlib.util
from pathlib import Path
import shutil
import tempfile
import unittest

REPO = Path(__file__).resolve().parents[1]
MODULE_PATH = REPO / "tools/c293_hosted_verify.py"
spec = importlib.util.spec_from_file_location("c293_hosted_verify", MODULE_PATH)
c293 = importlib.util.module_from_spec(spec)
spec.loader.exec_module(c293)


class C293HostedRegistrationTests(unittest.TestCase):
def test_actual_published_source_and_pin_crosswalk(self):
result = c293.verify_sources()
self.assertEqual(result["source_commit"], c293.SOURCE_COMMIT)
self.assertEqual(len(result["module_sha256"]), 5)
self.assertEqual(result["dependency_pins"]["mathlib"], c293.MATHLIB_PIN)

def make_source_fixture(self):
temp = tempfile.TemporaryDirectory()
root = Path(temp.name)
src = Path("frontiers/morse_finite_critical_20261018")
for name in c293.SOURCES:
p = src / "final-project" / f"{name}.lean"
(root / p).parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(REPO / p, root / p)
for p in [src / "negative-project/WithoutMorse.lean",
Path("formal/lakefile.toml"), Path("formal/lean-toolchain"),
Path("formal/lake-manifest.json")]:
(root / p).parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(REPO / p, root / p)
for p in c293.UPSTREAM.values():
(root / p).parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(REPO / p, root / p)
return temp, root

def test_modified_theorem_source_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / "frontiers/morse_finite_critical_20261018/final-project/MorseFiniteCritical.lean"
p.write_bytes(p.read_bytes() + b"\n-- mutation\n")
with self.assertRaisesRegex(RuntimeError, "source identity mismatch"):
c293.verify_sources(root)

def test_modified_upstream_copy_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / c293.UPSTREAM["TorusTopology"]
p.write_bytes(p.read_bytes() + b"\n-- changed upstream\n")
with self.assertRaisesRegex(RuntimeError, "upstream C293 input differs"):
c293.verify_sources(root)

def test_missing_premise_control_mutation_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / "frontiers/morse_finite_critical_20261018/negative-project/WithoutMorse.lean"
p.write_bytes(p.read_bytes() + b"\n-- mutation\n")
with self.assertRaisesRegex(RuntimeError, "control modified"):
c293.verify_sources(root)

def test_changed_dependency_pin_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / "formal/lean-toolchain"
p.write_text("leanprover/lean4:v4.35.0\n")
with self.assertRaisesRegex(RuntimeError, "toolchain pin changed"):
c293.verify_sources(root)

def test_audit_requires_169_exact_reports(self):
preamble = "\n".join(
f"MORSE_AUDIT_MODULE {module} COUNT {count}"
for module, count in c293.MODULE_COUNTS.items()
)
preamble += ("\nMORSE_AUDIT_STANDARD_ONLY_PASS COUNT 169\n"
"'TorusMorseFinite.quotientCriticalSet_finite' depends on axioms:"
" [propext, Classical.choice, Quot.sound]\n")
good = preamble + "MORSE_AUDIT_DECL name AXIOMS []\n" * 169
c293.validate_audit(good)
with self.assertRaisesRegex(RuntimeError, "169 declaration reports"):
c293.validate_audit(preamble + "MORSE_AUDIT_DECL name AXIOMS []\n" * 168)
with self.assertRaisesRegex(RuntimeError, "standard-only"):
c293.validate_audit(good.replace("MORSE_AUDIT_STANDARD_ONLY_PASS", "INCOMPLETE"))

def test_negative_requires_intended_failure_not_just_nonzero(self):
diagnostic = ("file:10:2: error: Type mismatch\n"
"quotientCriticalSet_finite d L hL g hs hp\n"
"has type IsMorseDistinct d L g → ...\n"
"but is expected to have type ...")
c293.validate_negative(1, diagnostic)
for code, output in ((0, diagnostic), (2, diagnostic),
(1, "error: unknown module MorseFiniteCritical"),
(1, diagnostic + "\nerror: unrelated")):
with self.subTest(code=code, output=output[:30]):
with self.assertRaises(RuntimeError):
c293.validate_negative(code, output)

def test_symlink_source_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / "frontiers/morse_finite_critical_20261018/final-project/Lifetime.lean"
elsewhere = root / "lifetime-copy"
shutil.copyfile(p, elsewhere)
p.unlink()
p.symlink_to(elsewhere)
with self.assertRaisesRegex(RuntimeError, "symlink"):
c293.verify_sources(root)

def test_same_size_source_mutation_rejected(self):
temp, root = self.make_source_fixture()
with temp:
p = root / "frontiers/morse_finite_critical_20261018/final-project/MorseFiniteControls.lean"
data = bytearray(p.read_bytes())
data[-2] ^= 0x01
p.write_bytes(bytes(data))
with self.assertRaisesRegex(RuntimeError, "source identity mismatch"):
c293.verify_sources(root)

def test_changed_lakefile_or_lock_pin_rejected(self):
for rel, old, new, message in (
("formal/lakefile.toml", c293.MATHLIB_PIN, "0" * 40, "Lake mathlib pin changed"),
("formal/lake-manifest.json", c293.PACKAGE_PINS["batteries"], "0" * 40,
"dependency pins differ")):
temp, root = self.make_source_fixture()
with temp, self.subTest(path=rel):
p = root / rel
self.assertIn(old, p.read_text())
p.write_text(p.read_text().replace(old, new))
with self.assertRaisesRegex(RuntimeError, message):
c293.verify_sources(root)

def test_out_of_tree_source_rejected(self):
temp, root = self.make_source_fixture()
with temp, tempfile.TemporaryDirectory() as other:
outside = Path(other) / "Lifetime.lean"
outside.write_text("-- outside\n")
with self.assertRaisesRegex(RuntimeError, "outside repository"):
c293.safe_source(outside, root)

def audit_text(self, decls=169, counts=None, main=True):
counts = counts or c293.MODULE_COUNTS
text = "\n".join(f"MORSE_AUDIT_MODULE {m} COUNT {n}" for m, n in counts.items())
text += "\nMORSE_AUDIT_STANDARD_ONLY_PASS COUNT 169\n"
if main:
text += ("'TorusMorseFinite.quotientCriticalSet_finite' depends on axioms:"
" [propext, Classical.choice, Quot.sound]\n")
return text + "MORSE_AUDIT_DECL name AXIOMS []\n" * decls

def test_audit_rejects_wrong_census_extra_reports_and_missing_main_report(self):
c293.validate_audit(self.audit_text())
wrong = dict(c293.MODULE_COUNTS, Lifetime=102)
for text, message in ((self.audit_text(counts=wrong), "audit missing Lifetime census"),
(self.audit_text(decls=170), "169 declaration reports"),
(self.audit_text(main=False), "main theorem axiom report absent")):
with self.subTest(message=message):
with self.assertRaisesRegex(RuntimeError, message):
c293.validate_audit(text)

def test_negative_rejects_wrong_mismatch_and_unrelated_failure(self):
diagnostic = ("file:10:2: error: Type mismatch\n"
"quotientCriticalSet_finite d L hL g hs hp\n"
"has type IsMorseDistinct d L g → ...\n"
"but is expected to have type ...")
for output in ("file:10:2: error: Type mismatch\nsomething else entirely\n",
diagnostic + "\nINTERNAL PANIC: lean::memory_exception"):
with self.subTest(output=output[-40:]):
with self.assertRaisesRegex(RuntimeError, "negative control"):
c293.validate_negative(1, output)

def test_hosted_context_requires_actual_run_identity(self):
names = ("GITHUB_SHA", "GITHUB_RUN_ID", "GITHUB_RUN_ATTEMPT", "GITHUB_REPOSITORY")
saved = {k: c293.os.environ.get(k) for k in names}
try:
try:
head = c293.git("rev-parse", "HEAD")
except (OSError, c293.subprocess.CalledProcessError):
self.skipTest("not a git checkout")
good = {"GITHUB_SHA": head, "GITHUB_RUN_ID": "1", "GITHUB_RUN_ATTEMPT": "1",
"GITHUB_REPOSITORY": "d6g8k5htny-coder/Math-"}
c293.os.environ.update(good)
self.assertEqual(c293.verify_context()["github_sha"], head)
for key, value, message in (("GITHUB_REPOSITORY", "someone/Math-", "wrong execution repository"),
("GITHUB_SHA", "0" * 40, "tested checkout mismatch"),
("GITHUB_RUN_ID", "", "actual GitHub run identity")):
with self.subTest(key=key):
c293.os.environ.update(good)
c293.os.environ[key] = value
with self.assertRaisesRegex(RuntimeError, message):
c293.verify_context()
finally:
for k, v in saved.items():
if v is None:
c293.os.environ.pop(k, None)
else:
c293.os.environ[k] = v

def test_unexpected_success_of_negative_phase_rejected(self):
saved = c293.EVIDENCE
with tempfile.TemporaryDirectory() as t:
c293.EVIDENCE = Path(t)
try:
with self.assertRaisesRegex(RuntimeError, "unexpected exit: 0"):
c293.run_phase("negative-probe", [c293.sys.executable, "-c", "pass"], t,
dict(c293.os.environ), expected_success=False)
finally:
c293.EVIDENCE = saved

def test_installed_dependency_commit_and_cleanliness_checked(self):
saved = (c293.FORMAL, c293.PACKAGE_PINS)
with tempfile.TemporaryDirectory() as t:
pkg = Path(t) / ".lake/packages/demo"
pkg.mkdir(parents=True)
run = lambda *a: c293.subprocess.run(["git", "-C", str(pkg), *a], check=True,
capture_output=True, text=True)
run("init", "-q")
(pkg / "f.txt").write_text("1\n")
run("add", "f.txt")
run("-c", "user.name=t", "-c", "user.email=t@example.invalid", "-c", "commit.gpgsign=false",
"commit", "-q", "-m", "x")
head = c293.git("-C", str(pkg), "rev-parse", "HEAD")
c293.FORMAL = Path(t)
try:
c293.PACKAGE_PINS = {"demo": head}
self.assertEqual(c293.verify_packages(), {"demo": head})
c293.PACKAGE_PINS = {"demo": "0" * 40}
with self.assertRaisesRegex(RuntimeError, "wrong installed dependency commit"):
c293.verify_packages()
c293.PACKAGE_PINS = {"demo": head}
(pkg / "f.txt").write_text("2\n")
with self.assertRaisesRegex(RuntimeError, "dirty installed dependency checkout"):
c293.verify_packages()
finally:
c293.FORMAL, c293.PACKAGE_PINS = saved


if __name__ == "__main__":
unittest.main()
Loading
Loading