Skip to content

OLR: native Lean obligation gym with MeTTa curation and certified STOP repair #123

OLR: native Lean obligation gym with MeTTa curation and certified STOP repair

OLR: native Lean obligation gym with MeTTa curation and certified STOP repair #123

name: PPT G03 live Lean verification
on:
pull_request:
paths:
- "research/lean_cgrt_hrm400/ppt_gym/**"
- "research/lean_cgrt_hrm400/PPT_G03_RUNBOOK.md"
- "research/lean_cgrt_hrm400/PPT_G03B_BACKTRACKING.md"
- ".github/workflows/ppt-g03-live-lean.yml"
push:
branches:
- "research/ppt-g03-live-lean-20261122"
- "research/ppt-g03b-backtracking-20261122"
paths:
- "research/lean_cgrt_hrm400/ppt_gym/**"
- ".github/workflows/ppt-g03-live-lean.yml"
workflow_dispatch:
jobs:
protocol:
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install CPU-only PyTorch
run: python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cpu
- name: PPT A/B and G03 protocol tests
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: python -m unittest discover -s ppt_gym/tests -v
lean-native:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: leanprover/lean-action@v1
with:
lake-package-directory: "research/lean_cgrt_hrm400/lean"
auto-config: false
build: true
test: false
use-mathlib-cache: false
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install CPU-only PyTorch
run: python -m pip install "torch==2.5.1" --index-url https://download.pytorch.org/whl/cpu
- name: Native Lean protocol smoke
working-directory: research/lean_cgrt_hrm400
run: |
python - <<'PY'
from lcgrt.lean_repl import LeanRepl
from lcgrt import config
with LeanRepl(timeout=60) as lean:
assert str(lean.version).startswith("4.19.0"), lean.version
s = lean.init("∀ (P0 P1 : Prop) (h0 : P0) (r0 : P0 → P1), P1", pp=True)
r = lean.run(s["sid"], "apply r0")
assert r["ok"] and len(r["state"]["goals"]) == 1, r
r = lean.run(r["state"]["sid"], "apply h0")
assert r["ok"] and r["state"]["goals"] == [], r
cert = lean.kernel(r["state"]["sid"])
assert cert["ok"] and cert["axioms"] == [], cert
print("PPT-G03 real Lean version", lean.version, "kernel-certified proof", cert["ok"])
from lcgrt.fragment import generate
from lcgrt.extract import explore
from lcgrt.certify import certify, decl_name
thm = generate(17, 2, "chain-dead", conj_p=0, tid="ppt_g03_native_smoke")
with LeanRepl(timeout=60) as lean:
trace = explore(lean, thm)
cert = certify([(thm.tid, thm, trace["proof"]["script"])], timeout=90)
assert cert["status"][decl_name(thm.tid)] == "passed", cert
print("PPT-G03 standalone Lean certificate", cert["source_sha256"])
from ppt_gym.core import Config, PlasticProofTransformer
from ppt_gym.live_suite import LiveCase
from ppt_gym.live_lean import replay_episode, run_episode
from ppt_gym.data import digest
import torch
torch.manual_seed(11)
model = PlasticProofTransformer(Config(plan="a", width=16, heads=4, max_bytes=32)).eval()
statement = "∀ (P0 P1 : Prop) (h0 : P0) (r0 : P0 → P1), P1"
case = LiveCase(root=digest(["native-smoke", statement]), lineage="native-smoke",
split="train", family="smoke", seed=11, depth=1,
tid="ppt_g03_terminal_replay", statement=statement)
with LeanRepl(timeout=60) as lean:
ep=run_episode(lean, case, model, policy="auto8", checks=8, depth=1)
ep["max_checks"]=8
assert ep["live_kernel"] and ep["accepted_script"]==["apply r0","apply h0"], ep
assert replay_episode(lean, case, ep)
print("PPT-G03 live kernel terminal transcript replay verified")
from ppt_gym.live_search import search_episode, replay_search
statement = "∀ (P0 P1 P2 : Prop) (h0 : P0) (r0 : P2 → P1) (r1 : P0 → P1), P1"
case = LiveCase(root=digest(["native-backtracking",statement]),
lineage="native-backtracking", split="calibration",
family="native-smoke", seed=11, depth=1,
tid="ppt_g03b_native_smoke", statement=statement)
with LeanRepl(timeout=60) as lean:
ep = search_episode(lean, case, model, policy="auto8", depth=1,
check_budget=8, rollback_budget=3)
assert ep["live_kernel"] and ep["tactic_checks"] == 3 and ep["rollbacks"] == 1, ep
assert ep["accepted_script"] == ["apply r1", "apply h0"], ep
assert replay_search(lean, case, ep)["replay_passed"]
print("PPT-G03B native backtracking and full kernel replay verified")
PY
- name: OLR-01B paired native Lean preflight
working-directory: research/lean_cgrt_hrm400
run: |
python -m ppt_gym.olr_native --seed 20261123 --pairs 4 --out runs/olr-01b-native
python - <<'PY'
import json
m = json.load(open("runs/olr-01b-native/manifest.json", encoding="utf-8"))
assert m["pairs"] == 4 and m["worlds"] == 8, m
assert m["independent_compiled_scripts"] == 8, m
assert m["all_episodes_replayed"] == 40, m
assert m["scorecard"]["ledger"]["kernel_closures"] == 8, m
assert m["scorecard"]["mean_only"]["kernel_closures"] == 4, m
assert m["scorecard"]["edge_swap"]["kernel_closures"] == 0, m
assert m["architecture_promotion_eligible"] is False
print("OLR-01B real Lean paired proof and replay preflight", m["scorecard"])
PY
- name: OLR-01C arithmetic-guard native bank
working-directory: research/lean_cgrt_hrm400
run: |
python -m ppt_gym.olr_guards --seed 20261123 --train 3 --dev 2 --out runs/olr-01c-native
python - <<'PY'
import json
m=json.load(open("runs/olr-01c-native/manifest.json",encoding="utf-8"))
assert m["independent_certificates"]["compiled"]==10, m
assert m["independent_certificates"]["clean_axioms"]==10, m
assert m["splits"]["train"]["worlds"]==6 and m["splits"]["dev"]["worlds"]==4, m
print("OLR native arithmetic-guard source bank certified",m["independent_certificates"])
PY
- name: OLR-01C trainable guard comparison
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
python -m ppt_gym.olr_guards --seed 20261124 --train 32 --dev 12 --ood 8 --out runs/olr-01c-bank
python -m ppt_gym.olr_guard_fit --bank runs/olr-01c-bank --out runs/olr-01c-fit --steps 80 --depth 3 --width 32 --seeds 17 29 43 --max-seconds 600
python - <<'PY'
import json
r=json.load(open("runs/olr-01c-fit/manifest.json",encoding="utf-8"))
s=r["evaluation"]
assert r["schema"]=="ppt.olr-guard-fit.v1" and len(r["seed_roster"])==3, r
assert len(r["training"])==15 and len(s)==(3*7+2)*2, (len(s),s)
assert all(x["worlds"]==24 if key.startswith("dev:") else x["worlds"]==16
for key,x in s.items()), s
assert s["dev:0:exact_arithmetic"]["proofs"]==24, s
assert s["ood:0:exact_arithmetic"]["proofs"]==16, s
assert r["independent_query_certificates"]["clean_axioms"]==40, r
assert r["architecture_promotion_eligible"] is False
assert r["training"]["17:cross"]["same_worker_bit_exact_replay"]
assert r["training"]["17:direct"]["same_worker_bit_exact_replay"]
assert r["cpu_environment"]["deterministic_algorithms"] is True
assert all(f"dev:{seed}:cross_zero_message" in s and
f"ood:{seed}:cross_margin_sham" in s and
f"ood:{seed}:cross_onepass" in s
for seed in (17,29,43))
print("OLR-01C trainable paired guard pilot scorecard",json.dumps(s,sort_keys=True))
PY
- name: Upload OLR-01C verified experiment receipts
if: always()
uses: actions/upload-artifact@v4
with:
name: olr-01c-native-guard-pilot
path: |
research/lean_cgrt_hrm400/runs/olr-01c-bank
research/lean_cgrt_hrm400/runs/olr-01c-fit
if-no-files-found: ignore
- name: OLR-01D multi-goal native search
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
python -m ppt_gym.olr_delayed_campaign freeze --source-bank runs/olr-01c-bank --seed 20261127 --pairs 8 --out runs/olr-01d-bank
python -m ppt_gym.olr_delayed_campaign score --registry runs/olr-01d-bank --source-bank runs/olr-01c-bank --source-fit runs/olr-01c-fit --out runs/olr-01d-score --max-seconds 500
python - <<'PY'
import json
with open("runs/olr-01d-score/manifest.json",encoding="utf-8") as f:
m=json.load(f)
assert m["schema"]=="ppt.olr-delayed-score.v1", m
assert m["root_worlds"]==16 and m["root_pairs"]==8, m
assert m["native_unique_trajectories"]==128 and m["native_event_replays"]==128, m
assert m["standalone"]["axiom_clean"]==32, m
score=m["scorecard"]
assert score["4:probe_early:0:exact_arithmetic"]["certified_proofs"]==16
assert score["6:probe_early:0:exact_arithmetic"]["tactic_calls"]==64
assert score["6:probe_early:0:fixed_r0"]["certified_proofs"]==16
assert score["6:probe_late:0:fixed_r0"]["certified_proofs"]==8
assert score["6:probe_early:0:fixed_r0"]["rollbacks"]==8
assert score["6:probe_late:0:fixed_r0"]["rollbacks"]==8
assert not m["learned_feedback_update"] and not m["architecture_promotion_eligible"]
print("OLR-01D verified native search scorecard", json.dumps(score,sort_keys=True))
PY
- name: Upload OLR-01D native search and frozen decisions
if: always()
uses: actions/upload-artifact@v4
with:
name: olr-01d-native-delayed-guards
path: |
research/lean_cgrt_hrm400/runs/olr-01d-bank
research/lean_cgrt_hrm400/runs/olr-01d-score
if-no-files-found: ignore
- name: Native MeTTa source curation and Lean STOP exchange
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
python -m pip install "hyperon==0.2.10"
python -m ppt_gym.metta_olr_cli --out runs/olr-metta-native-01
python - <<'PY'
import json
with open("runs/olr-metta-native-01/manifest.json",encoding="utf-8") as f:
r=json.load(f)
assert r["scientific_eligible"] is False, r
assert r["metta_runtime"]=="hyperon==0.2.10", r
assert r["source_train_curator"]["offer_ids"]==["goodproof"], r
assert r["repairs"]["native_macro_committed"] is True, r
assert r["repairs"]["native_macro_checks"]==2, r
assert r["repairs"]["short_budget_checks"]==0, r
assert r["standalone"]["axiom_clean"]==1, r
assert r["action_set"]["source_optimal_actions"]==["apply r0"], r
print("Verified native Hyperon-to-Lean STOP repair and source curation",
r["repairs"]["native_macro_metta_sha256"])
PY
- name: Upload OLR native MeTTa/Lean bridge receipts
if: always()
uses: actions/upload-artifact@v4
with:
name: olr-metta-01-native-hyperon-lean
path: research/lean_cgrt_hrm400/runs/olr-metta-native-01
if-no-files-found: ignore
- name: OLR MeTTa native multi-witness action-set pilot
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
python -m ppt_gym.metta_actionset_native --out runs/olr-metta-02-ties --seed 20261128 --train 12 --development 8 --steps 40
python - <<'PY'
import json
with open("runs/olr-metta-02-ties/manifest.json",encoding="utf-8") as f:
r=json.load(f)
assert r["schema"]=="ppt.olr-metta-multi-witness.v1", r
assert r["train_roots"]==12 and r["development_roots"]==8, r
assert r["tied_train_roots"]==3 and r["tied_development_roots"]==2, r
assert r["native_source_certificates"]["axiom_free"]==25, r
assert r["native_metta_curation"]["native_offer_count"]==12, r
assert r["native_query_trials"]==72, r
assert r["checkpoint_promotion_eligible"] is False, r
assert set(r["evaluation"])=={"canonical","hashed","set"}
assert all(x["trials"]==24 for x in r["evaluation"].values()), r
print("OLR native MeTTa optimal-action-set pilot",r["evaluation"])
PY
- name: Upload OLR native MeTTa action-set pilot
if: always()
uses: actions/upload-artifact@v4
with:
name: olr-metta-02-native-action-sets
path: research/lean_cgrt_hrm400/runs/olr-metta-02-ties
if-no-files-found: ignore
- name: Fresh generated Lean suite and model smoke
working-directory: research/lean_cgrt_hrm400
env:
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
run: |
python -m ppt_gym.live_cli freeze --out runs/ppt-g03-suite --seed 20261122 --per-split 2
python -m ppt_gym fixture --out runs/ppt-fixture --per-family 3 --seed 71
python -m ppt_gym train --fixture runs/ppt-fixture --allow-synthetic --plan a --width 16 --heads 4 --max-bytes 32 --steps 2 --depths 1 2 --max-seconds 60 --out runs/ppt-smoke-model
python -m ppt_gym.live_cli run --suite runs/ppt-g03-suite --checkpoint runs/ppt-smoke-model/checkpoint.pt --support-roots 1 --query-roots 1 --checks 8 --depth 1 --max-seconds 240 --cert-timeout 180 --out runs/ppt-g03-live
python -m ppt_gym.live_cli replay --suite runs/ppt-g03-suite --session runs/ppt-g03-live --out runs/ppt-g03-replay
python -m ppt_gym.search_cli run --suite runs/ppt-g03-suite --checkpoint runs/ppt-smoke-model/checkpoint.pt --split calibration --cases 1 --checks 8 --rollbacks 4 --depth 1 --max-seconds 180 --out runs/ppt-g03b-search
python -m ppt_gym.search_cli replay --suite runs/ppt-g03-suite --session runs/ppt-g03b-search --out runs/ppt-g03b-replay
python -m ppt_gym.live_cli export --suite runs/ppt-g03-suite --session runs/ppt-g03-live --replay-receipt runs/ppt-g03-replay/replay.json --out runs/ppt-g03-export
python - <<'PY'
import json
m=json.load(open("runs/ppt-g03-live/manifest.json",encoding="utf-8"))
assert m["actual_lean_process"]
assert m["source"]["checkpoint_evidence"]=="synthetic_fixture"
assert m["architecture_promotion_eligible"] is False
r=json.load(open("runs/ppt-g03-replay/replay.json",encoding="utf-8"))
assert r["replay_passed"]
e=json.load(open("runs/ppt-g03-export/manifest.json",encoding="utf-8"))
assert e["query_labels_exported"]==0 and e["source_kind"]=="generated_horn_problems_independently_lean_certified"
print("PPT-G03 real Lean replay passed",r["episodes"],"episodes; train export rows",sum(x["rows"] for x in e["streams"].values()))
b=json.load(open("runs/ppt-g03b-search/manifest.json",encoding="utf-8"))
r2=json.load(open("runs/ppt-g03b-replay/replay.json",encoding="utf-8"))
assert b["fully_paired_roots"]==1 and r2["replay_passed"] and r2["episodes"]==4
assert set(b["scorecard"])=={"auto8_zero_rollback","auto8","frozen_zero_rollback","frozen"}
print("PPT-G03B real Lean paired branch-search replay",b["scorecard"])
PY