Skip to content

Build static inspection pages

Render a store's Pythonic .lema contracts, revisions, releases, and cryptographic approval views (lema.review-display/v1) into static HTML, Markdown, JSON, and llms.txt pages.

When you review work produced by an AI coding agent or audit a release before deployment, you want to read the contracts, semantic change reports, and evidence status without wading through raw JSON files or tactic scripts.

lema site build (crates/lema-site/, lema.site/v1) reads a store and generates a deterministic static site of zero-JavaScript HTML, Markdown, .lema, and JSON files, plus an optional llms.txt index for coding agents. Every declaration page renders its Pythonic .lema contract view first, shows lema.contract/v1 selection statuses (open, checked, waived) alongside their concrete target.realizations, and computes exact cryptographic approval digests (lema.review-display/v1) for pending human reviews.

Before you start

  • A Lema project or store containing at least one reference (main), release, or pending review (Work with a Lema project).

1. Build the static inspection site (lema site build)

You can run lema site build either against a live server socket (--socket, or automatically inside a project with a running background server) or directly against a stopped store directory (--store):

Shell
# Inside a project (or using --socket):
lema site build --out inspection --ref main --llms

# Or directly against a stopped store directory:
lema site build --store .lema/store --out inspection --ref main --llms

Select any combination of references, releases, and pending review subjects:

FlagWhat it includes in the generated site
--ref NAMEA project reference (main), its exported declarations rendered in Pythonic .lema syntax, contract selections, revision history, and active policy (repeatable).
--release IDA lema.release/v1 record, its LemaIR and worker digests, ConstantTime / SecretFlow guarantees, and closure receipts (repeatable).
--review REF=revision:IDA cryptographic approval view (lema.review-display/v1) for a pending revision publication on REF.
--review REF=policy:IDA cryptographic approval view for a pending policy upgrade on REF.
--llmsWrites an llms.txt index at the root of --out linking every exported contract statement and .md page so AI coding agents can browse the project’s specifications directly.
--history NMaximum ancestor revisions per reference (default 1,000).
--max-bytes N / --max-files N / --max-objects NDeterministic resource caps (256 MiB, 200,000 files, 50,000 objects by default); if exceeded, the build fails cleanly without writing a partial site.

2. Inspect the generated pages and .lema views

For every logical page X, lema site build writes X.html, X.md, and X.json side by side, and indexes every file’s SHA-256 digest in inspection/site.json:

Generated pathContents
index.{html,md,json}Overview of all selected references, releases, contract selection summaries, and pending reviews.
ref/<name>.{html,md,json}The reference’s head revision, generation, active lema.policy/v1, exported declarations in Pythonic .lema syntax, and contract selection table (open, checked, waived).
revision/<id>.{html,md,json}The revision’s intent, parent revisions, lema.change-report/v1 seven-category diff, lema.contract/v1 targets and law progress (laws[i].by vs. whole-selection by), and attached receipts.
object/<id>.{html,md,json} & object/<id>.lemaA single content-addressed object with its statement shown first, plus a standalone object/<id>.lema file whenever its Pythonic .lema view round-trips faithfully via view::rederive.
release/<id>.{html,md,json}The release record, target (vm), artifact and worker SHA-256 digests, ConstantTime / SecretFlow verdicts, and closure receipts.
authoring/<id>/Original .lema and .lean source files from lema.authoring/v2 bundles.
approval/<ref>/<subject>.{html,md,json}The exact display-bound approval view for human code review (Step 3).

Visual separation of evidence tiers

Every page in the generated site keeps three kinds of evidence visually and structurally separate:

  1. Mathematical proof acceptance (checked): Accepted by source-free replay in the pinned Lean 4.34.1 kernel under the store’s axiom policy, or discharged as a lema.contract/v1 selection via Store::check_witness.
  2. Human specification review (reviewed): Display-bound human review records (lema.review/v1).
  3. VM execution and static analysis (tested / assumed): ConstantTime and SecretFlow guarantees, VM test verdicts, and lema.release/v1 bindings.

3. Approve a protected contract change from an approval view (lema review)

When a reference’s lema.policy/v1 protects critical contracts (protect in crates/lema-store/src/protect.rs), advancing the reference to a revision $REV that modifies a protected export requires a human reviewer to sign the approval view digest (lema.review-display/v1, domain LEMA-REVIEW-DISPLAY-v1\0).

Build the approval page for the pending revision:

Shell
lema site build --out inspection --ref main --review main=revision:$REV

Open inspection/approval/main/revision-$REV.html (or .md). For every protected declaration, the page displays:

  • the rendered Pythonic .lema declaration (def, law, contract, requires, ensures, forall);
  • the Rederived::hidden occurrence table listing every implicit or typeclass instance argument in left-to-right textual occurrence order ((occurrence, kind, text)), plus the explicit @f(...) view (Rederived::explicit) so swapped instances can never hide behind surface notation; and
  • the renderer_sha256() digest (LEMA-CONTRACT-VIEW-v1\0, hashing view.rs production source and view/external-binders.json).

When every protected declaration’s Pythonic view passes view::rederive (Outcome::Faithful, Display::approvable() == true), the page prints the exact lema review command pre-filled with --display:

Shell
lema review --ref main --revision $REV --decision approve \
  --display $DISPLAY_SHA256 --actor steward --token-file steward.token

Why does lema review bind both the rendered .lema text and renderer_sha256()? Because under protect.rs, a display-bound approval counts at ref.publish or ref.adopt only while the subject still renders to that exact digest under the current renderer_sha256(). If main moved or the rendered contract changed after the reviewer inspected the page, the store refuses the stale digest (is not what its subject displays now) so a reviewer never approves something different from what they read.

Common refusals

Refusal message containsCause and fix
is not empty and holds no site.json--out points to an existing non-empty directory that was not created by lema site build. Pass a new directory path or an existing inspection directory containing site.json.
is not what its subject displays nowThe target reference moved, its policy version changed, or the rendered view changed since the approval page was built. Re-run lema site build --review ... and inspect the updated page.
display is not approvable (Mismatch)A protected declaration uses a construct whose view did not round-trip (Outcome::Mismatch); the approval view permits only --decision reject until refactored into a faithful contract declaration.

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