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
67 changes: 67 additions & 0 deletions .github/tests/release-consumer.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Exercise the actual reusable workflow code; no proof tooling or network needed.
const {test} = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const crypto = require('node:crypto');
const {spawnSync} = require('node:child_process');
const workflow = fs.readFileSync(path.join(__dirname, '../workflows/download-check.yml'), 'utf8');
const shell = workflow.split(' run: |\n')[1].split('\n - name:')[0]
.split('\n').map(line => line.slice(10)).join('\n');
const binding = workflow.split('// BEGIN CANDIDATE BINDING\n')[1].split('// END CANDIDATE BINDING')[0];
const expected = {schema: 'rule30/release-candidate/1', accepted_commit: 'a'.repeat(40),
tree: 'b'.repeat(40), repository: 'afflom/rule30', run_id: '123', run_attempt: '2'};
function checkBinding(candidate, tree=expected.tree) {
new Function('require', 'context', 'process', binding)(
() => ({readFileSync: () => JSON.stringify(candidate)}),
{sha: expected.accepted_commit, repo: {owner: 'afflom', repo: 'rule30'}},
{env: {ACCEPTED_TREE: tree, GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '2'}});
}
test('candidate binding cannot silently skip when tree output is missing', () => {
assert.match(workflow, /if: inputs\.require-candidate-binding/);
assert.doesNotMatch(workflow, /if: inputs\.accepted-tree/);
const main = fs.readFileSync(path.join(__dirname, '../workflows/main-ci.yml'), 'utf8');
assert.match(main, /require-candidate-binding: true/);
});
test('exact accepted candidate identity' , () => checkBinding(expected));
for (const key of Object.keys(expected)) {
test('reject mismatched ' + key, () => assert.throws(() => checkBinding({...expected, [key]: 'wrong'})));
test('reject missing ' + key, () => {const candidate = {...expected}; delete candidate[key]; assert.throws(() => checkBinding(candidate));});
}
test('reject malformed expected tree', () => assert.throws(() => checkBinding(expected, '')));
function sums(dir) {
fs.writeFileSync(path.join(dir, 'SHA256SUMS'), fs.readdirSync(dir).filter(n => n !== 'SHA256SUMS').sort()
.map(n => crypto.createHash('sha256').update(fs.readFileSync(path.join(dir, n))).digest('hex') + ' ' + n + '\n').join(''));
}
function fixture(mutate) {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'r30-consumer-'));
const dir = path.join(root, 'dist'); fs.mkdirSync(dir);
try {
for (const name of ['Rule30-Paper.pdf','Paper.pdf','Rule30-Core.pdf','Core.pdf','Paper.lean','Paper.tex',
'Core.lean','Core.tex','Observations.pdf','Observations.lean','Observations.tex','paper-lexlean.lock',
'core-lexlean.lock','paper-attestation-a.json','core-attestation-b.json']) fs.writeFileSync(path.join(dir,name), 'fixture\n');
fs.writeFileSync(path.join(dir,'candidate.json'), JSON.stringify(expected));
for (const name of ['lexlean-paper-verified-a.tar.gz','lexlean-core-verified-b.tar.gz']) {
assert.equal(spawnSync('tar', ['-czf', path.join(dir,name), '-C',dir,'Paper.lean']).status, 0);
}
sums(dir); if (mutate) mutate(dir);
return spawnSync('bash', ['-c',shell], {cwd:dir,env:{...process.env,RUNNER_TEMP:root},encoding:'utf8'});
} finally {fs.rmSync(root,{recursive:true,force:true});}
}
test('complete downloaded fixture passes', () => {const r=fixture(); assert.equal(r.status,0,r.stderr);});
const bad = {
'changed bytes': d => fs.appendFileSync(path.join(d,'Paper.lean'),'bad'),
'missing required asset': d => {fs.unlinkSync(path.join(d,'Paper.tex')); sums(d);},
'unlisted extra': d => fs.writeFileSync(path.join(d,'extra'),'bad'),
'duplicate checksum': d => {const p=path.join(d,'SHA256SUMS'); fs.appendFileSync(p,fs.readFileSync(p,'utf8').split('\n')[0]+'\n');},
'traversal checksum': d => fs.appendFileSync(path.join(d,'SHA256SUMS'),'0'.repeat(64)+' ../outside\n'),
'absolute checksum': d => fs.appendFileSync(path.join(d,'SHA256SUMS'),'0'.repeat(64)+' /outside\n'),
'hidden extra': d => fs.writeFileSync(path.join(d,'.extra'),'bad'),
'symlink': d => fs.symlinkSync('Paper.pdf',path.join(d,'link')),
'directory': d => fs.mkdirSync(path.join(d,'extra')),
'unequal aliases': d => {fs.writeFileSync(path.join(d,'Paper.pdf'),'other'); sums(d);},
'invalid archive': d => {fs.writeFileSync(path.join(d,'lexlean-core-verified-b.tar.gz'),'bad'); sums(d);},
'ambiguous attestation': d => {fs.writeFileSync(path.join(d,'core-attestation-c.json'),'{}'); sums(d);},
};
for (const [name,mutate] of Object.entries(bad)) test('reject '+name, () => assert.notEqual(fixture(mutate).status,0));
92 changes: 92 additions & 0 deletions .github/workflows/download-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Check downloaded candidate

on:
workflow_call:
inputs:
artifact-name:
type: string
required: true
require-candidate-binding:
type: boolean
default: false
accepted-tree:
type: string
default: ''

permissions:
contents: read

jobs:
download-smoke:
name: Check downloaded mathematical assets
runs-on: ubuntu-latest
steps:
- name: Download the candidate assets without a source checkout
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: dist

- name: Check required assets and downloaded bytes
working-directory: dist
shell: bash
run: |
set -euo pipefail
# Validate paths before checksum-controlled file access. Assets must
# be flat regular files, with no symlinks or hidden extras.
shopt -s dotglob nullglob
for asset in *; do
[[ "$asset" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]
test -f "$asset" && test ! -L "$asset"
done
test -s SHA256SUMS
while IFS= read -r record || [[ -n "$record" ]]; do
[[ "$record" =~ ^[0-9a-f]{64}\ \ [A-Za-z0-9][A-Za-z0-9._-]*$ ]]
done < SHA256SUMS
for asset in Rule30-Paper.pdf Paper.pdf Rule30-Core.pdf Core.pdf \
Paper.lean Paper.tex Core.lean Core.tex \
Observations.pdf Observations.lean Observations.tex \
paper-lexlean.lock core-lexlean.lock SHA256SUMS; do
test -s "$asset"
done
for pattern in 'paper-attestation-*.json' 'core-attestation-*.json' \
'lexlean-paper-verified-*.tar.gz' 'lexlean-core-verified-*.tar.gz'; do
mapfile -t matches < <(compgen -G "$pattern")
test "${#matches[@]}" -eq 1
test -s "${matches[0]}"
done
sha256sum --check --strict SHA256SUMS
# Check coverage too: an unlisted extra file must not be published.
sha256sum -- * | sed '/ SHA256SUMS$/d' > "$RUNNER_TEMP/downloaded-checksums"
sort SHA256SUMS > "$RUNNER_TEMP/expected-checksums"
sort "$RUNNER_TEMP/downloaded-checksums" > "$RUNNER_TEMP/actual-checksums"
cmp "$RUNNER_TEMP/expected-checksums" "$RUNNER_TEMP/actual-checksums"
cmp Rule30-Paper.pdf Paper.pdf
cmp Rule30-Core.pdf Core.pdf
for bundle in lexlean-*-verified-*.tar.gz; do
tar -tzf "$bundle" > /dev/null
done

- name: Check candidate identity against the accepted run
if: inputs.require-candidate-binding
uses: actions/github-script@v7
env:
ACCEPTED_TREE: ${{ inputs.accepted-tree }}
with:
script: |
// BEGIN CANDIDATE BINDING
const fs = require('node:fs');
const candidate = JSON.parse(fs.readFileSync('dist/candidate.json', 'utf8'));
const expected = {
schema: 'rule30/release-candidate/1',
accepted_commit: context.sha,
tree: process.env.ACCEPTED_TREE,
repository: context.repo.owner + '/' + context.repo.repo,
run_id: process.env.GITHUB_RUN_ID,
run_attempt: process.env.GITHUB_RUN_ATTEMPT,
};
if (!/^[0-9a-f]{40}$/.test(expected.tree)) throw new Error('Invalid accepted tree');
for (const [key, value] of Object.entries(expected)) {
if (candidate[key] !== value) throw new Error('Candidate identity mismatch: ' + key);
}
// END CANDIDATE BINDING
68 changes: 68 additions & 0 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ jobs:
runs-on: ubuntu-latest
env:
LEXLEAN_CI_TELEMETRY: ${{ github.workspace }}/.r30/verification-telemetry
outputs:
accepted-tree: ${{ steps.candidate.outputs.tree }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test download validation regressions
run: node --test .github/tests/release-consumer.test.cjs

- name: Set up proof toolchain
uses: ./.github/actions/setup-proof-tools

Expand All @@ -42,6 +47,60 @@ jobs:
RULE30_REFRESH_PDFS: "0"
run: python3 scripts/validate_git_tree.py "$GITHUB_SHA"

- name: Package the exact accepted mathematical candidate
id: candidate
shell: bash
run: |
python3 - <<'PYTHON'
import hashlib, json, os, re, shutil, subprocess, sys
from pathlib import Path
sys.path.insert(0, 'scripts')
from validate_git_tree import lexlean_input_digest
from tools.r30.engine import gate_tools_key
root = Path.cwd()
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
if commit != os.environ['GITHUB_SHA']:
raise SystemExit('Checkout differs from accepted commit')
tree = subprocess.check_output(['git', 'rev-parse', 'HEAD^{tree}'], text=True).strip()
tools = gate_tools_key(root)
if not tools:
raise SystemExit('Cannot identify accepted proof tools')
cache = root / '.git/rule30-validation/lexlean' / tools
for project in ('rule30-lexlean', 'rule30-paper'):
slot = cache / project / lexlean_input_digest(root, tree, project)
result = json.loads((slot / 'latest-verified.json').read_text())
identity = result.get('attestation_id', '')
if result.get('success') is not True or not re.fullmatch('[0-9a-f]{64}', identity):
raise SystemExit('Missing exact accepted evidence: ' + project)
source = slot / 'verified' / identity
if not (source / 'attestation.json').is_file():
raise SystemExit('Missing accepted bundle: ' + project)
# A fresh destination prevents overlaying unrelated historical evidence.
target = root / project / '.lexlean'
target.mkdir()
shutil.copytree(source, target / 'verified' / identity)
shutil.copyfile(slot / 'latest-verified.json', target / 'latest-verified.json')
# Existing packager validates attestations/locks and renders copies only.
subprocess.run(['./scripts/build_release.sh', '--package-only'], check=True)
manifest = dict(schema='rule30/release-candidate/1', accepted_commit=commit,
tree=tree, repository=os.environ['GITHUB_REPOSITORY'],
run_id=os.environ['GITHUB_RUN_ID'], run_attempt=os.environ['GITHUB_RUN_ATTEMPT'])
dist = root / 'dist'
(dist / 'candidate.json').write_text(json.dumps(manifest, sort_keys=True) + '\n')
records = [hashlib.sha256(p.read_bytes()).hexdigest() + ' ' + p.name + '\n'
for p in sorted(dist.iterdir()) if p.name != 'SHA256SUMS']
(dist / 'SHA256SUMS').write_text(''.join(records))
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write('tree=' + tree + '\n')
PYTHON

- name: Upload complete accepted candidate
uses: actions/upload-artifact@v4
with:
name: rule30-release-candidate-${{ github.run_attempt }}
path: dist/*
if-no-files-found: error

- name: Prune the factory's retained evidence
run: bin/r30 engine prune --apply

Expand Down Expand Up @@ -73,3 +132,12 @@ jobs:
include-hidden-files: true
if-no-files-found: ignore
path: .r30/verification-telemetry

download-candidate:
name: Check accepted candidate download
needs: validate
uses: ./.github/workflows/download-check.yml
with:
artifact-name: rule30-release-candidate-${{ github.run_attempt }}
require-candidate-binding: true
accepted-tree: ${{ needs.validate.outputs.accepted-tree }}
34 changes: 33 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ on:
workflow_dispatch:

permissions:
contents: write
contents: read

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
build-and-release:
Expand All @@ -30,11 +34,39 @@ jobs:
with:
name: rule30-lexlean-artifacts
path: dist/*
if-no-files-found: error

download-smoke:
needs: build-and-release
uses: ./.github/workflows/download-check.yml
with:
artifact-name: rule30-lexlean-artifacts

publish:
name: Publish qualified release assets
needs: download-smoke
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Require v0.2 native release qualification
if: github.ref_name == 'v0.2' || startsWith(github.ref_name, 'v0.2.') || startsWith(github.ref_name, 'v0.2-')
run: |
echo '::error::v0.2 native packaging and consumer qualification are pending. See docs/releases/v0.2.md; mathematical asset checks alone do not qualify this release.'
exit 1

- name: Download the checked candidate assets
uses: actions/download-artifact@v4
with:
name: rule30-lexlean-artifacts
path: dist

- name: Publish GitHub Release assets
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
files: |
dist/Rule30-Paper.pdf
dist/Paper.pdf
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Kernel-checked [LexLean](https://github.com/afflom) and Lean 4 formalization of

The authored statements in [Paper](Rule30-Paper.pdf), [Core](Rule30-Core.pdf), and
[Observations](Rule30-Observations.pdf) are verified by the Lean 4 kernel
(`leanprover/lean4:v4.32.1`) and `leanchecker` under only the axioms `{propext, Quot.sound}`,
using the toolchain pinned in `rule30-core-lean/lean-toolchain` and `leanchecker` under only the axioms `{propext, Quot.sound}`,
with zero `sorry`s and zero custom axioms. **`Classical.choice` is not used anywhere in the
authored proof surfaces.** The kernel audits of the research library and of the bridge reject
any theorem that depends on it, every LexLean statement declares `\allowaxioms{Quot.sound;propext}`,
Expand Down Expand Up @@ -299,6 +299,21 @@ writes to `dist/`; the pre-commit gate publishes those outputs to all tracked PD
### Automated Releases
Pushing any version tag `v*` (e.g. `v0.1`) triggers [`.github/workflows/release.yml`](.github/workflows/release.yml), which builds `rule30-core-lean`, `Rule30PrizeKit/lean`, and `rule30-bridge`, compiles `Rule30-Paper.pdf` and `Rule30-Core.pdf`, packages the verified LexLean bundles, and attaches all PDFs and LexLean artifacts to the GitHub Release.

Publication requires the unchanged acceptance gate and a separate job that downloads
the candidate mathematical assets without a source checkout, checks their inventory
and checksums, and reads the verified archives. These download checks do not replay
proofs or qualify native executables. Manual dispatch builds and checks candidates
without publishing a release. Main CI also packages its exact accepted mathematical
candidate from the gate evidence and runs the shared download checks in a separate
job, without repeating proofs. Its checksum-covered manifest binds the accepted
checkout (the merge commit on PRs), tree and run attempt. This hosted path remains
pending until its updated workflow succeeds; it does not qualify native commands.

**v0.2 is not yet qualified for publication.** Its native artifact contract and
consumer tests remain pending; the workflow blocks publication of v0.2 series tags
until that integration is complete. See the [v0.2 release contract](docs/releases/v0.2.md).
The existing v0.1 release remains historical evidence, and Problem 1 remains unproved.

The compiler development pin follows LexLean `release/v0.5` through
[the Host interface contribution](https://github.com/UOR-Foundation/LexLean/pull/396)
and [native command execution](https://github.com/UOR-Foundation/LexLean/pull/439).
Expand Down
Binary file modified Rule30-Core.pdf
Binary file not shown.
Binary file modified Rule30-Observations.pdf
Binary file not shown.
Binary file modified Rule30-Paper.pdf
Binary file not shown.
Loading
Loading