Skip to content

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 .lema contracts and .lean implementations, 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) with lema diff, commit revisions with lema commit, approve display-bound reviews, and merge branches by identity with lema merge.
  • Replace an implementation: Swap an implementation behind a contract by discharging a new lema.contract/v1 selection via Store::check_witness, or record a stateful simulation witness (Replaces / Simulates) with the store’s replace operation.
  • Export and import a project or library bundle: Transfer a complete project closure (lema.checkpoint/v1) across machines with lema export and lema import (replaying every object through the receiving store’s Lean kernel), or group reusable library exports into lema.bundle/v1 records.
  • 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/v2 execution record, compile accepted declarations to LemaIR (<store>/vm-code-cache), register your local lema-vm-runner worker, and verify static guarantee profiles (ConstantTime and SecretFlow).
  • Build an application with capabilities: Write a Prog application over Lema v0.2’s six capability tags (tcp, udp, block, random, clock, secret) and opaque exchange / serve drivers, configure lema-cap.json, format a 4 KiB BlockStore volume, and package TLS-bound credentials with lema secret bundle.
  • Release an application: Bind a compiled VM artifact, accepted store closure, worker digest, and lema-cap.json deployment configuration into an immutable lema.release/v1 record with lema 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, and llms.txt pages 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 reverify to replay every accepted object in a store from raw canonical encodings without relying on the incremental .olean module cache.
  • Write a runtime configuration: Configure lema.runtime-linux/v2 JSON files for isolated checker output directories, call_budget caps, container supervision profiles, or VM-only deployment hosts.
  • Install the pinned Lean distribution: Install and verify the pinned Lean 4.34.1 toolchain automatically with lema toolchain install or step by step from a pre-staged archive with lema verify-distribution.
  • Recover from a HALTED latch: Diagnose a sandboxed native call supervision or distribution fault (OUT/HALTED or LOCK.HALTED), inspect ledger.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).

Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility