Skip to content

Lean4 FV property provider: EIP spec → 01e properties + Kurtosis tests #88

Description

@grandchildrice

M2 · track:2-D · lean — target 7/14 (step 1) · depends on the provider-seam issue (#87) · blocks the full-EIP generation (#90) and Kurtosis reproduction (#92) issues · part of #86

Important

ステータス 2026-07-22 時点(正本 / タスク管理はこの issue を基準とする)

ゴール(gohan 確定): spec ごとに「実装即応で汎用な 01e チェックリスト」を作ることが成果物。品質は judge harness で solodit 参照バーと比較し、vuln dataset を教材にした自己改善で仕上げる。各 spec の 01e は 02c→04 まで走らせて findings を確認して検証する。02以降の本番実行は gohan マシン。

アーキテクチャ: ① Lean4 = critical な safety/liveness spec のみ形式化 → ② その定理を背骨に judge/improve ループで 01e を作る(eval は recall でなく LLM-as-judge の品質評価vuln dataset は improve の教材)→ ③ 02c→04 を naive な speca で走らせて findings を見る。

手順(この順で回す):

  1. gasper spec の 01e を作る ← ✅ 第1ドラフト完了(下記)
  2. その 01e で 02c→04 まで走らせる(findings を見て 01e の実効性を検証)← ⬜ 次の P0
  3. 並行して他 spec の 01e を作る(fab、Full-EIP property generation + bug-DB cross-check #90 方向)← ⬜
  4. それらも 02c→04 で走らせる ← ⬜

今どこ: 手順1が第1ドラフト完了。手順2が未着手で、ここが次の critical path。

完了したもの:

  • プラグイン基盤: v0.1.0 / speca 配線(#115)/ pin 強制(#137)/ lean provenance 貫通(#136)/ CI smoke green
  • gasper 01e 第1ドラフト: plugin#21CHK-15(gasper-lean4 定理から派生、ethereum-vuln-dataset の実バグに紐付けた実装即応な15項目)。emit-01e --property-provider lean で 76 properties(機械 lowering 61 + CHK-15)を emit。手書き項目が proved を騙らない honesty 修正済み(descends-from-*
  • 判定ハーネス: plugin#22 の judge(5軸 blind)+ improve ループ + 収束判定。実 sonnet judge で CHK-15 = 4.04 / solodit 参照バー 2.50 → バー到達

未達 / 留保(「バー到達 = 完了」ではない):

  • 手順2(gasper 01e を 02c→04 で実走)が未着手 — この 01e で実際にクライアントの findings が出るか未検証
  • CHK-15 は手書きで作ったものを judge で測っただけで、improve ループが実 LLM で未完走(sonnet/opus とも cyber safeguard に refuse)。「自己改善で作る」機構は未実証
  • judge の自己選好(Claude 生成を Claude 採点)— 別系統モデルでの再確認が要る(留保3点
  • ① は gasper のみ(手順3)

優先順位: P0 = 手順2(gasper 01e = CHK-15 を 02c→04 で実走し findings 確認、gohan マシン)+ 別系統 judge で自己選好チェック / P1 = 手順3(他 spec の 01e、#90 方向)/ P2 = #92 Kurtosis 配管

プロセス: author による self-merge 禁止(approve 後にレビュア側でマージ)。チェックボックス更新には根拠 PR + 検証内容を併記。

Background

With the provider seam from #87 in place, implement the lean generation method. It takes the program graphs SPECA already extracts in 01b — the .mmd subgraphs carrying RFC-2119 invariant annotations (e.g. INV-001: Precompile MUST NOT revert) — for a given EIP, encodes the relevant invariants as Lean 4 propositions, attempts the proofs, and emits two artifacts: properties in the 01e schema, and a Kurtosis devnet test per property that checks the same invariant against a running client.

Where Lean runs — dedicated external plugin

Lean 4 execution does not live in speca. It ships as a dedicated plugin repository, NyxFoundation/speca-lean4-plugin (the heavy lean/lake toolchain stays out of the core speca dependency tree). speca references it as a version-pinned, officially-certified plugin through the plugin boundary defined in #87; the lean provider in speca invokes the plugin across that seam. Build the plugin repo, then wire speca's lean provider to it.

Tasks

  • 1. Create NyxFoundation/speca-lean4-plugin: a lake-built Lean 4 workspace reusing modeling patterns from NyxFoundation/gasper-lean4, exposing a stable invocation interface (subprocess / CLI contract) that speca's lean provider calls. Pin the lean / lake version in the plugin repo, and pin the plugin version from speca (resolution point from Pluggable property providers and reproduction backends #87). Make CI install/resolve it. — v0.1.0 リリース、speca 側 pin + CI 解決は PR #115。ただし pin の「強制」(checkout 照合)は未了 → Pluggable property providers and reproduction backends #87 の残項目
  • 2. Take one pilot end to end before generalizing. — ✅ パイロットは EIP-7951 から gasper に変更(方針コメント参照)。gasper-lean4 Core 定理群 → 01e で一気通貫
  • 3. Per invariant: generate the Lean proposition, run the proof attempt, and record the outcome — proved, counterexample, or unknown — next to the emitted property. — ✅ plugin の provenance パイプライン(collectAxioms で sorry-free 検証 → lean_status: proved | unknown)
  • 4. Emit 01e-schema properties from the provider. Carry the proof status in a provider field (lean_status), never by mutating a core field. — ✅ additive lean_* フィールドとして実装、コアフィールド無変更を PR #115 レビューで検証済み
  • 5. Emit a Kurtosis fixture per property under outputs/kurtosis/<eip>/<property_id>/ (devnet config + assertion), and reference the path from the property record. — ✅ speca 実行時の fixture 実出力を #135 で実装(scaffold まで。devnet 実行は Kurtosis reproduction of confirmed findings #92
  • 6. Wire provider: lean in speca (dispatching to speca-lean4-plugin) and add a CI job mirroring 01e-properties.yml. — PR #115(properties-lean smoke ジョブ含む)
  • 7. Write docs/lean-direction.md in speca — one paragraph stating the Spec→Lean4 rationale for the EF check-in (see [M2] Milestone 2 tracking #86). — #135 でマージ済み
  • 8. Tests on the pilot: at least one proved property with a runnable Kurtosis fixture; output validates against the 01e schema. — ⬜ proved property の emit とスキーマ検証は✅(CI smoke)だが、runnable Kurtosis fixture が未達(Task 5 待ち)

Interfaces & contracts

Done when

  • NyxFoundation/speca-lean4-plugin exists, is version-pinned, and is resolved by speca as an official plugin.(pin の強制照合のみ Pluggable property providers and reproduction backends #87 残項目)
  • uv run python3 scripts/run_phase.py --phase 01e with provider: lean on the pilot produces schema-valid properties + Kurtosis fixtures.(properties は✅ / fixtures が⬜)
  • At least one invariant is machine-proved in Lean and its property is emitted.(gasper Core: accountable safety k_safety'、slashable bound、plausible liveness ほか)
  • Re-running is deterministic (same inputs → same properties and paths).(未検証)
  • The pilot is documented well enough to add a second EIP without reading the PR.(統合パイプライン仕様は plugin PR #19 でレビュー中)

方針コメントのTODO対応状況(2026-07-02 コメント参照)

Review checklist

  • Lean execution lives in speca-lean4-plugin, not vendored into speca; the boundary matches Pluggable property providers and reproduction backends #87.
  • Lean toolchain pinned and reproducible from a clean checkout; CI installs/resolves it.
  • Core 01e fields unchanged; Lean / Kurtosis data is additive.
  • Proof outcomes are recorded honestly — an unknown or counterexample is never silently dropped or relabeled proved.
  • One pilot fully working beats partial coverage of many.

Out of scope

Full-set generation and bug-DB cross-check (#90). Running Kurtosis at scale (#92).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

M2Milestone 2 grant workleanLean 4 formal verificationtrack:2-DDeliverable 2-D: SPECA x Lean integration

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions