Skip to content

Design decisions

Architectural walkthrough of Lema's numbered design decisions (0001 through 0062), grouped by identity and content addressing, kernel checking and packs, authoring views and selections, and capabilities and VM execution.

Major architectural and workflow choices in Lema are recorded as numbered decision records in docs/decisions/ inside the language repository. Each record captures the concrete engineering problem we hit, the trade-offs considered, what we chose, and how later decisions refine earlier ones.

The active public decisions below are grouped into five themes:

  1. Identity, DAG sharing & content addressing (0027, 0030, 0032, 0038, 0039, 0045, 0060)
  2. Kernel checking, axioms, packs & store operations (0025, 0028, 0033, 0034, 0036, 0037, 0041, 0044, 0046, 0048, 0055, 0056, 0062)
  3. Authoring scopes, views & contract selections (0049, 0050, 0051)
  4. Capabilities, concurrency & store-native VM execution (0029, 0031, 0035, 0040, 0043, 0052, 0054, 0059)
  5. Workflow & governance foundations (0001, 0002, 0003, 0022, 0023, 0026)

1. Identity, DAG sharing & content addressing

0027 What object identity covers

14 Oct 2026. Early object hashes included checker binary digests and the axiom ceiling, and cited dependencies concretely. Moving the checker to another Linux host re-hashed 1,655 objects, and editing a proof forced every caller to get a new hash.

Decision 0027 introduced a single namespace object (pinning the Lean version, Git commit, and Init base) and established three rules that still govern the store:

  1. Host pins and checker digests live in local receipts, never inside an object’s SHA-256 ID.
  2. Axiom ceilings are store-level policies enforced above the fixed floor rather than baked into object hashes.
  3. Indirect citations: Statements and templates cite definitions by template ID and theorems by statement ID, keeping proofs decoupled from callers (Code stored by identity).

0030 Shared expressions and one running encoding

16 Oct 2026. Serializing deeply shared proof terms as nested JSON trees caused exponential size blowups (one 2,423-node proof expanded into 556,691 tree nodes). Decision 0030 switched canonical expressions to flat arrays of deduplicated post-order nodes with maximal subterm sharing enforced on validation, retiring earlier encodings cleanly.

0032 Received structures now, regenerated family helpers after Stage 4

17 Oct 2026. Registered structure projection metadata during replay so dot-projection syntax (x.field) works on store-imported records immediately, and scheduled full regeneration of inductive helper constants as stored declarations (completed in Decision 0045).

0038 Retire the library .lean files behind a committed audit view

19 Oct 2026. Maintaining library source files in Git alongside the content-addressed store created a dual-authority trap. Decision 0038 retired the hand-maintained library source trees: standard library modules are authored through the store API as symbolic authoring records and rendered deterministically into a read-only audit/view/ directory verified offline in workspace tests.

0039 Indexed inductive families in the object model

19 Oct 2026. Extended canonical objects to admit single indexed inductive families (such as length-indexed Vec α n and graph reachability Reach u v) without changing the hashes of ordinary unindexed types, while continuing to refuse mutually recursive or nested inductive declarations (Types and invariants).

0045 Regenerated family helper units (option B)

19 Oct 2026. Turns every auxiliary constant generated for an inductive family (casesOn, recOn, noConfusion, sizeOf, constructor injectivity) into a kernel-checked generated declaration verified row-for-row in a quarantined environment during replay, so pattern matching and induction behave identically on local and imported types.

0060 Identity Genesis v1

8 Nov 2026. Consolidated canonical object hashing and replay onto the clean lema.core/v4 and lema.replay/v4 baseline (“Identity Genesis v1”), tightening canonical metadata rules and rebuilding the standard library cleanly on the unified identity format.


2. Kernel checking, axioms, packs & store operations

0025 Lean-first core development through the codebase

14 Oct 2026. Uses the pinned Lean 4.34.1 kernel (addDeclCore at --trust=0) as Lema’s single mechanical proof authority rather than maintaining an unproved custom proof kernel.

0028 Classical choice in proofs

15 Oct 2026. Allows Lean’s three standard mathematical axioms (propext, Quot.sound, Classical.choice) by default because standard array and string lemmas in Init use classical reasoning inside proofs even when the functions themselves are computable. Because all Prop proofs erase before compilation (Decision 0052), Classical.choice never introduces non-computable runtime code, and constructive stores can opt into lema init --axioms propext,Quot.sound.

0033 Change-triggered acceptance, records as evidence, rapid development

17 Oct 2026. Established three operating rules: retire superseded pre-1.0 code cleanly rather than carrying legacy shims; run fast workspace tests on every edit with path-triggered native suites; and label every claim explicitly as checked, tested, or assumed (Checked, tested and assumed).

0034 A container runtime profile for native acceptance

17 Oct 2026. Added a portable bubblewrap + cgroup/rlimit Linux sandbox profile alongside the systemd scope profile so containerized environments run the exact same source-free Lean 4.34.1 kernel replay and memory/CPU caps (How the store accepts code).

0036 A fast merge gate, batched slow suites, light reviews and the dual-form freeze

18 Oct 2026. Split native test suites into a fast pre-merge tier and a deeper post-merge tier, and removed volatile hashes and timing tables from prose documentation so parallel pull requests do not conflict.

0037 Refactoring and boundary operations now, typed draft goals deferred

19 Oct 2026. Kept the accepted store graph free of unproved statements or sorryAx, adding proof rebinding (rebind), theorem specialization (instantiate), and interface boundary checks (Decision 0046).

0041 Designated long-lived stores for native suites

19 Oct 2026. Allowed native test suites to reuse warm stores bound to cryptographic digests of the checker, compiler, and host profile, automatically rebuilding from scratch whenever any trusted component changes.

0044 Jobs in lema serve, with reads against a pinned snapshot

19 Oct 2026. Made lema serve concurrent: read queries answer immediately against a pinned snapshot while long-running elaboration, replay, and VM jobs run on background workers and re-verify expectations atomically on commit.

0046 The interface boundary is a field of a protect gate

20 Oct 2026. Added boundary checks to protected branch policies (Semantic version control), walking citation graphs to ensure client theorems depend only on declared interfaces and never unfold private implementation templates.

0048 Scoped elaboration metadata is a pinned elaboration input

21 Oct 2026. Replaced name-based heuristics for imported typeclasses and reducibility hints with explicit, hash-pinned scope metadata kept outside object identity.

0055 Release-checked standard library packs

28 Oct 2026. Enabled lema setup and lema new to adopt release-checked standard library packs (verified for archive integrity, toolchain match, and store axiom policy) so new projects start in seconds without re-elaborating the entire cryptography and HTTPS stack locally, recording provenance transparently as checked (Lema release).

0056 Native Apple Silicon macOS Seatbelt runtime

28 Oct 2026. Added native Apple Silicon macOS support (aarch64-apple-darwin) for sandboxed Lean checking and VM execution using the pinned Darwin Lean distribution and macOS Seatbelt profiles, requiring no Linux virtual machine or container daemon.

0062 Local decoder build and audited pack modules

8 Nov 2026. Tightened library pack adoption so the local replay decoder is built against the pinned toolchain and audits imported pack module environments before local elaboration caches use them, keeping onboarding within a tight setup budget while strengthening local verification.


3. Authoring scopes, views & contract selections

0049 Received alternatives take the source’s names

21 Oct 2026. Mapped human-readable constructor names onto positional content-addressed kernel constructors during elaboration so match, cases, and induction read naturally without changing canonical object hashes.

0050 Namespace scopes and source-name views are pinned elaboration inputs

21 Oct 2026. Replaced manual import preludes with declarative, hash-pinned scope mappings that resolve cross-module names deterministically and reject ambiguous shadowing.

0051 Proof-optional, interface-first development and contract selections

22 Oct 2026. Separated operational interfaces from proposition-valued contracts and introduced explicit select Contract(Impl) records (open, checked, waived). Code compiles and runs on the VM while selections are open, partial per-law progress is tracked cleanly, and witness verification ensures a theorem binds the exact selected implementation IDs (Contracts, selections and proofs).


4. Capabilities, concurrency & store-native VM execution

0029 The Rust backend on hold

16 Oct 2026. Retired an early prototype that transpiled Lean IR into generated Rust files, later superseded cleanly by Decision 0052.

0031 Standalone leanc applications under the Flat-Byte FFI rule

16 Oct 2026. Established the Flat-Byte capability rule retained across the platform: host capability calls exchange only flat byte frames or fixed-width scalars with explicit status codes rather than heap pointers or exceptions (Capabilities and the host boundary).

0035 The runner’s channel vocabulary

18 Oct 2026. Admitted bounded mailbox and rendezvous channel primitives inside the supervised runner to back actor and session-type models while preventing raw unverified channel calls in user code.

0040 Stable command families for capability applications

19 Oct 2026. Split external interaction into independent, composable command families (tcp, udp, block, random, clock, secret, exchange, serve, stream, tasks, actors, sessions) so applications link only the families they declare and adding new families never alters existing hashes.

0043 A store-local memo for the run gate’s store bindings

19 Oct 2026. Added store-local verification and compile memos so repeated lema run --release startups avoid redundant closure recompilation while explicit release.verify checks always re-derive from scratch.

0052 Accepted objects → LemaIR → the Rust VM is the application execution path

23 Oct 2026. Made store-native lowering (LemaIR), the Rust register VM, and the supervised capability runner the sole execution path for Lema applications (The compiler and VM), removing leanc and C glue code so builds and deployments need zero Lean or C compiler calls.

0054 Anonymous TLS accept in the stream family

27 Oct 2026. Added an anonymous TLS 1.3 listener capability (stream) alongside SigV4-authenticated serve, allowing browsers and public HTTPS clients to connect to Lema web servers and echo starters while keeping server TLS private keys isolated inside the runner’s driver sub-run.

0059 Keeping the core repository focused on the VM target

7 Nov 2026. Extracted experimental bare-metal x86_64 KVM unikernel work (explored in Decision 0053) into its own standalone repository so the core platform stays focused on the store, checker, libraries, and cross-platform register VM.


5. Workflow & governance foundations

0001 Delivery tracking and OpenSpec

10 Oct 2026. Tracks roadmap priorities and architectural decisions transparently; prose specs inform engineering work and never substitute for a Lema contract or a kernel proof.

0002 Solo development with AI ownership and review

10 Oct 2026. Records AI agent reviews transparently as technical agent reviews rather than independent human assurance.

0003 Standing delegated working model

10 Oct 2026. Separates owner-approved architectural and trust-boundary decisions from delegated day-to-day engineering mechanics so either can be audited and revisited cleanly.

0022 Develop first, qualify evidence at meaningful boundaries

12 Oct 2026. Keeps routine iteration fast while requiring full verification gates whenever changes touch kernel checking, store admission, or public capability claims.

0023 Sole-human development and agent-reviewed route selection

12 Oct 2026. Uses an independent non-author review agent as a second technical check on architectural routes and pull requests.

0026 Linux continuation host and non-author agent review

14 Oct 2026. Standardized primary CI kernel replay and sandbox qualification on x86_64 Linux alongside non-author pull-request review.

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