How-to guides
Step-by-step recipes for project authoring, semantic version control, VM execution, capability configuration, and store administration in Lema.
Each guide walks through a concrete engineering, governance, or operational task from start to finish, showing both the ergonomic project CLI commands (lema new, lema add, lema diff, lema commit, lema merge, lema release, lema export, lema import) and the underlying store or server commands (--json, rebind, replace, bundle, reverify, secret bundle) when you need fine-grained control. Along the way, each page explains how to diagnose any refusals you meet.
If you are new to Lema, start with the Tutorials or read Explanation for the conceptual architecture. For exhaustive command flags, record schemas, and wire layouts, see the Reference.
Project workflow and semantic version control
Use these guides for day-to-day authoring, contract verification with AI coding agents such as Claude Code or Codex, and semantic history management:
- Work with a Lema project: Create a project (
lema.project/v1), author Pythonic.lemacontracts and.leanimplementations, manage the background server, and configure actors and protected reference policies (lema.policy/v1). - Review and merge semantic changes: Inspect the seven semantic change categories and contract selection statuses (
open,checked,waived) withlema diff, commit revisions withlema commit, approve display-bound reviews, and merge branches by identity withlema merge. - Replace an implementation: Swap an implementation behind a contract by discharging a new
lema.contract/v1selection viaStore::check_witness, or record a stateful simulation witness (Replaces/Simulates) with the store’sreplaceoperation. - Export and import a project or library bundle: Transfer a complete project closure (
lema.checkpoint/v1) across machines withlema exportandlema import(replaying every object through the receiving store’s Lean kernel), or group reusable library exports intolema.bundle/v1records. - Develop a library on the private Cloud pilot: With a pilot invitation, push a checked module to a hosted Lema Cloud project, let a second account clone and change it, publish its held candidate and read the project on the Hub.
Building, configuring, and releasing VM applications
Use these guides to compile accepted store closures to LemaIR, configure the six byte-level capability tags, and deploy released VM applications:
- Build a VM application: Import or infer a
lema.exec/v2execution record, compile accepted declarations toLemaIR(<store>/vm-code-cache), register your locallema-vm-runnerworker, and verify static guarantee profiles (ConstantTimeandSecretFlow). - Build an application with capabilities: Write a
Progapplication over Lema v0.2’s six capability tags (tcp,udp,block,random,clock,secret) and opaqueexchange/servedrivers, configurelema-cap.json, format a 4 KiBBlockStorevolume, and package TLS-bound credentials withlema secret bundle. - Release an application: Bind a compiled VM artifact, accepted store closure, worker digest, and
lema-cap.jsondeployment configuration into an immutablelema.release/v1record withlema release, run it through the release gate (lema run --release), or deploy to a VM-only host without Lean installed. - Build static inspection pages: Render deterministic, zero-JavaScript HTML, Markdown,
.lema, JSON, andllms.txtpages from a store (lema site build), including cryptographic approval views (lema.review-display/v1) for human code review.
Store and runtime operations
Use these guides for low-level store operations, axiom governance, toolchain setup, and supervision recovery:
- Update or uninstall Lema: Update the CLI and VM, restart active work explicitly, and preserve projects when removing an installation.
- Build the Lema tools from source: Contributor-only Rust and linker setup for an authorized language checkout.
- Move an alias safely: Perform compare-and-swap updates on individual store aliases (
lema call alias) using expected target IDs, generation counters, and idempotency keys. - Create a store with a narrower axiom policy: Initialize a store (
lema init --axioms) that restricts proofs to constructive axioms (propext,Quot.sound) or zero axioms (''), and inspect each declaration’s transitive axiom footprint. - Re-check a store from scratch: Run
lema reverifyto replay every accepted object in a store from raw canonical encodings without relying on the incremental.oleanmodule cache. - Write a runtime configuration: Configure
lema.runtime-linux/v2JSON files for isolated checker output directories,call_budgetcaps, container supervision profiles, or VM-only deployment hosts. - Install the pinned Lean distribution: Install and verify the pinned Lean
4.34.1toolchain automatically withlema toolchain installor step by step from a pre-staged archive withlema verify-distribution. - Recover from a HALTED latch: Diagnose a sandboxed native call supervision or distribution fault (
OUT/HALTEDorLOCK.HALTED), inspectledger.jsonl, confirm systemd scope cleanup, and restore execution safely. - Run the repository checks: Run the fast zero-Lean Rust workspace tests (
cargo test --workspace), OpenSpec checks, and path-selected native verification suites (cargo run -q -p lema-native -- list --changed origin/main).
- Work with a Lema project
- Review and merge semantic changes
- Replace an implementation
- Export and import a project or library bundle
- Develop a library on the private Cloud pilot
- Build a VM application
- Build an application with capabilities
- Release an application
- Build static inspection pages
- Move an alias safely
- Create a store with a narrower axiom policy
- Re-check a store from scratch
- Write a runtime configuration
- Install the pinned Lean distribution
- Recover from a HALTED latch
- Run the repository checks
- Update or uninstall Lema
- Build the Lema tools from source
Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility