
lean-directory
io.github.kaylum54/lean-directory
Lean 4 verification registry and live Solana mint, program and transaction checks.
Documentation
Lean Directory
The permissionless API for Lean on Solana. Lean Directory lists Lean 4 formal-verification tools for Solana and serves them as JSON at lean.directory. Seven core libraries live in this repository and are built and kernel-checked on every commit. Other Lean projects for Solana are indexed from GitHub. The same API runs live checks on mints, deployed programs and unsigned transactions, and an MCP server exposes all of it to agents.
No API key, no sign-up. Anyone can add a tool with a pull request: see Add a tool.
Lean Directory is independent and not affiliated with the Lean FRO or the Solana Foundation.
Quick start
# Find a library
curl "https://lean.directory/v1/tools?q=vault"
# Read its kernel check: build result, theorem count, axioms, sorry count, source hashes
curl https://lean.directory/v1/tools/vault-specs/verify
# Scaffold a Lean 4 project pinned to the checked libraries, then build it
npx lean-solana init full
cd leansvm-full && lake build
lake build needs Lean 4 through elan. The project pins its own toolchain.
Tools
| Tool | Where | What it checks | What it does not check |
|---|---|---|---|
prove | lean-solana prove <crate> --spec <slug> | That your plain-Rust logic functions refine a Lean Directory spec (six VaultSpecs, two ShareMath and three AmmMath constant-product obligations). Charon and Aeneas translate the crate and the Lean kernel checks one refinement theorem per obligation | Anchor glue, Borsh decoding, CPI, the sBPF compiler. Charon, Aeneas and the Lean kernel are trusted. The Aeneas Lean library needs Mathlib; the core libraries do not |
| Program badge | GET /v1/programs/:programId and /badge.svg | OtterSec verified-build status, the live ProgramData hash and upgrade authority, and whether a CI-reproduced attestation matches the deployed bytecode | The link from source to proof is checked by CI, not proven. A self-attested or unbound record never shows green |
| Transaction firewall | lean-solana firewall, POST /v1/firewall/check, MCP check_transaction | Decodes a legacy or v0 transaction and checks its top-level instructions against a policy. The policy evaluator's rules are proven in AgentGuard.Firewall | CPI inner instructions. Signer balance, debitBounds and lookup-table contents are trusted as the caller gives them |
| Live mint check | lean-solana mint, GET /v1/mint/:address, MCP check_mint | SPL Token and Token-2022 mint facts, extension and fee-config flags, computed by a JS mirror of MintProof from the RPC node's answer | The live answer is not kernel-checked unless you compile the includeLean=1 certificate. The RPC node is trusted |
| Share and AMM maths | @leansvm/share-math, @leansvm/amm-math | Vault share rounding and the first-depositor bound; constant-product and CLMM rounding pinned to Raydium sources at recorded commits | That a deployed program uses these formulas |
| MCP server | POST /mcp (Streamable HTTP), lean-solana mcp (stdio) | Eight tools over the registry and the three live checks above, each description ending with its trust limit | Same limits as the tools it calls |
There are 0 attested programs today. registry/programs.index.json lists every submitted program: an entry with a CI record has ciReproduced: true, and a submission CI has not reproduced (record: null) is listed with ciReproduced: false and never raises a status. Only ciReproduced: true entries count toward stats.attestedPrograms. To submit one, see registry/CONTRIBUTING-PROGRAM.md.
API (CORS-open)
Base URL https://lean.directory. Defined in apps/workbench/src/worker.mjs.
| Endpoint | Returns |
|---|---|
GET /v1 | Registry discovery: apiVersion, toolchain, registrySha256, stats (tool, Lean file, theorem and attested-program counts), endpoints, templates |
GET /v1/tools | All tools. Filter with ?tier=core|ecosystem|community, ?category=, ?q= (matches slug, package name, summary) |
GET /v1/tools/:slug | One tool: manifest, install.lakeRequire snippet, per-file SHA-256s and theorem names under verification.files |
GET /v1/tools/:slug/verify | The tool's verification block: axiom list, sorry and custom-axiom counts, sourceSha256, reproduceCmd |
GET /v1/init?template=<name>&name=<project> | Starter repo as a files array. Templates come from VALID_TEMPLATES in registry/templates.mjs (full is the default). Unknown template returns 400 |
GET /v1/diff/:slug?from=&to= | Release changes between two versions, a breaking flag and migration notes |
GET /v1/schema | Submission schema plus the acceptance rules (sorryCount, allowedAxioms, licenses) |
GET /v1/mint/:address | Live mint facts, extensionScanStatus, feeConfigStatus and flags. No overall pass or fail. ?includeLean=1 adds a certificate to compile with lean |
GET /v1/programs | Submitted program attestations, each with ciReproduced true or false |
GET /v1/programs/:programId | Program status, verified-build evidence, upgrade authority and attestation binding |
GET /v1/programs/:programId/badge.svg | Status badge naming the proven scope and whether the program is upgradeable |
GET /v1/status | Whether each live dependency passed the external monitor's last check, and when. A check that has not run recently is stale, never up |
POST /v1/firewall/check | Firewall verdict no_top_level_violation or block, per-instruction flags and violations. No RPC |
POST /mcp | MCP Streamable HTTP (stateless). OPTIONS /mcp answers the browser preflight |
The site also serves GET /api/health, GET /api/packages, the legacy GET /api/inspect?mint= (same handler as /v1/mint) and four POST /api/* demo routes. Request bodies are capped as they stream: 64 KB for API routes and 128 KB for /mcp. See docs/CONTRACTS.md.
Counts (tools, theorems, Lean files, attested programs) are computed by scripts/build-registry.mjs. Read them from GET /v1 (stats) or registry/index.json.
CLI
The CLI is lean-solana (packages/cli). It carries a copy of the registry, so the registry commands work offline.
npx lean-solana init svm-model --dir ./my-svm-proof # scaffold a starter (template defaults to full)
npx lean-solana list # every tool (flags: --tier, --category, --json)
npx lean-solana verify borsh-lean # a tool's kernel check
npx lean-solana diff vault-specs --from 0.1.0 --to 0.2.0
npx lean-solana mint <mint-address> # live mint facts over RPC (--rpc <url> overrides the public endpoint)
npx lean-solana program <programId> # program status (SOLANA_RPC_URL overrides the public endpoint)
npx lean-solana firewall <base64-tx> # top-level instruction check, no network
npx lean-solana prove ./crate --spec share-math # refinement check (needs the prove toolchain: prove doctor, prove setup)
npx -y lean-solana mcp # MCP over stdio
init also takes --name, --force, --json and --api https://lean.directory (fetch the starter from the live API instead of the bundled registry).
From a checkout, run the same commands with node packages/cli/bin/leansvm.mjs. node packages/cli/pack.mjs builds the npm package into packages/cli/npm/; a test packs it, extracts it outside the repo and runs each subcommand from there.
Core packages (tier: "core")
Each library has a lean-toolchain pinned to leanprover/lean4:v4.36.0, no Mathlib dependency, and passes the repo's sorry and custom axiom scan. npm run build:registry runs lake build and #print axioms on every public theorem and records the result in registry/index.json. The build fails if any theorem uses an axiom other than Classical.choice, Quot.sound and propext, so native_decide is not accepted.
| Package | Lean files | Theorems | Tests | Purpose |
|---|---|---|---|---|
@leansvm/svm-model | 3 | 19 | 17 | Account model, rent formula (0B = 890,880, 82B = 1,461,600), owner/signer/writable/executable guards, CPI privilege non-escalation, multi-instruction lamport conservation |
@leansvm/borsh-lean | 3 | 25 | 16 | Borsh little-endian u8/u16/u32/u64/Bool roundtrips, 36-byte SPL COption<Pubkey>, Anchor 8-byte discriminators, bounded BorshVec |
@leansvm/mint-proof | 6 | 37 | 59 | SPL Mint (82 bytes), Token-2022 TLV extensions and transfer-fee schedules, pump.fun bonding curve and FeeSharingConfig decoders, live mint check |
@leansvm/vault-specs | 6 | 28 | 20 | TokenVault, FeeSplitter, Escrow, TimeLockVault, multi-step traces, Anchor // @lean-theorem audit, reference rust-core, 6 exploit mutations |
@leansvm/agent-guard | 8 | 46 | 64 | MoneyMath, Slippage, Lease, Transaction, Reconciliation, WireFormat and Firewall proofs, static JS/TS money-bug scanner, transaction firewall |
@leansvm/share-math | 5 | 17 | 26 | Virtual-offset vault share maths, reference rust-core and Anchor program, 5 mutations |
@leansvm/amm-math | 5 | 25 | 25 | Constant-product and CLMM maths pinned to Raydium CP-Swap and CLMM |
@leansvm/prove | none | none | 43 | lean-solana prove and audit-annotations |
@leansvm/mcp | none | none | 44 | MCP tool table, HTTP and stdio transports |
lean-solana | none | none | 9 | The CLI and its npm pack |
apps/workbench | none | none | 122 | Cloudflare Worker (API, /mcp and site), configured by wrangler.jsonc |
Lean file and theorem totals for the seven libraries: 36 files, 197 theorems. Lean counts come from scripts/build-registry.mjs; test counts come from node --test in each package during npm test. The mint-proof total includes 1 live mainnet test and the prove total includes 15 live pipeline tests; they are skipped unless MINT_PROOF_LIVE=1 or LEANSVM_PROVE_LIVE=1 is set. scripts/test/registry.test.mjs adds 11 registry tests.
Ecosystem index (tier: "ecosystem")
External GitHub projects listed in registry/ecosystem.json with verification.status: "indexed-external". They are not built or audited here. Details in docs/ECOSYSTEM-TOOLS.md, live list at /v1/tools?tier=ecosystem.
- Solana runtime and clients:
solana-foundation/leanprover-solanalib,QEDGen/qedsvm,MidTermDev/lean-Solana-client,dennj/solana-lean - Rust-to-Lean pipelines:
AeneasVerif/aeneas,AeneasVerif/charon,Certora/lusterna,QEDGen/solana-skills - Cryptography and ZK:
Beneficial-AI-Foundation/curve25519-dalek-lean-verify,Verified-zkEVM/VCVio,reilabs/proven-zk
Add a tool
Lean Directory is permissionless: tools are added by pull request, and CI checks every one.
- Ecosystem listing: your Lean project stays in your own repository. Add one entry to
registry/ecosystem.json. About 10 minutes. - Core library: the library lives in
packages/<slug>and every public theorem is kernel-checked on every build. - Program attestation: submit inputs in
registry/programs/<programId>.json; CI builds the program, rerunsproveand writes the result. Seeregistry/CONTRIBUTING-PROGRAM.md.
The full guide, with a template entry, the acceptance rules and the review steps, is in registry/CONTRIBUTING-TOOL.md. To suggest a tool without writing the entry, open an issue.
Run locally
Requires Node 20.11+ (CI uses Node 24) and Lean 4 through elan; each package pins its toolchain.
npm test # sorry/axiom scan, lake build per library, vault mutation check, node --test per package
npm run build:registry # rebuilds registry/index.* and programs.index.*; runs lake build
npm run check:registry # fails if the committed registry differs from a fresh build (CI runs this)
node apps/workbench/scripts/dev-server.mjs # http://127.0.0.1:4321 (PORT env overrides)
Documentation
- Tool catalog, Prove guide
- Submitting a tool and JSON Schema, Submitting a program
- Architecture, Contracts, Security policy, Contributing
License
MIT, see LICENSE.
lean-solananpm install lean-solana