Develop a library on the private Cloud pilot
With a pilot invitation, push a checked Lema module to a hosted project, let a second account change it, publish the result and read it on the Hub.
When two people (or a person and an agent on another machine) work on the same Lema library, each needs the other’s checked revisions rather than a copy of their files. Lema Cloud holds a project’s references and history on a hosted store in the EU. You keep developing locally, where lema add runs Lean’s kernel on your machine, and you share revisions with lema push, lema clone and lema fetch. The service checks every pushed revision again before it moves a reference, and a clone checks everything it downloads, so neither side has to trust the other’s receipts.
The walkthrough uses a project called bytekit (namespace Bytekit) with two accounts: OWNER, who creates and publishes it, and WRITER, who contributes a change. REV stands for a revision ID.
Before you start
- An invitation file for each account.
- Writer access to the project for the second account. During the pilot, project roles are granted on request.
- A second machine or operating-system login for the writer. Cloud credentials are stored per OS user, under
~/.config/lema. - A supported development host (Set up a machine for Lema).
1. Select the pilot client
Use the pilot binaries that come with your invitation. Put their directory (here PILOT_BIN) first on PATH in this shell only, so your installed lema stays as it is:
export PATH="$PILOT_BIN:$PATH"
lema --version && lema build-info --check-worker && lema help fetch
lema setupThe version names a pilot build, the worker check passes, and lema help fetch lists --revision REV. If setup finds no library pack for this build, run lema setup --no-pack. A project server started by another build is refused: run lema stop, then lema start.
2. Create the project and push the first revision (owner)
Sign up with your invitation, make an empty local project and create the hosted project from inside it. Running lema cloud project create inside a local project of the same name binds the two, so your first push knows where to go:
lema cloud signup --id OWNER --invite-file ~/invite.token
lema new bytekit --empty && cd bytekit
lema cloud project create --name bytekitSignup consumes the invitation and writes your credential to ~/.config/lema/credentials.json (mode 0600). Your handle is permanent. Pass the invitation with --invite-stdin when a credential manager supplies it; the CLI refuses secrets given as command-line arguments.
Now add a module. This one pads a byte list on the left and proves the length of the result:
namespace Bytekit.Pad
/-- `n` zero bytes, then `b`. -/
def padLeft (n : Nat) (b : List UInt8) : List UInt8 := List.replicate n 0 ++ b
theorem padLeft_length (n : Nat) (b : List UInt8) : (padLeft n b).length = n + b.length := by
simp [padLeft]
end Bytekit.PadCheck it, commit it and push it:
lema add Pad.lean
lema commit --intent "Add Bytekit.Pad"
lema push | tee push.jsonlema add runs the Lean kernel here, and lema test and lema run still run roots on your own VM. The push uploads the revision with everything it depends on, and the service checks it again from source before it moves the project’s reference. Later pushes send only content the hosted store does not hold yet.
3. Change it from the second account (writer)
On the writer’s machine or login, sign up with the second invitation and clone the project:
lema cloud signup --id WRITER --invite-file ~/invite.token
lema clone https://api.cloud.lema-lang.org/bytekit && cd bytekitThe clone downloads the published revision and its history, checks every object locally, re-elaborates the authoring records and binds your workspace to that revision. Edit Pad.lean (for example, add a second theorem about padLeft), then:
lema add Pad.lean && lema commit --intent "Describe the change"
lema pushA new project’s policy lets only its owner publish, so this push answers 422 review_required. The service has admitted your revision and keeps it as a held candidate; send its ID to the owner.
If the push answers 409 ref_conflict instead, the owner published after your clone or your last fetch. Run lema fetch, then lema merge with no argument, then lema push again. That merge puts the fetched head first and your commit second, which is the order hosted publication requires. Fetch imports history without touching your files or workspace head.
4. Publish the held candidate (owner)
Back in the owner’s project, bring your tracking up to date, import the held candidate, look at it and publish it under your own authority:
lema fetch
lema fetch --revision REV
lema revision show REV --cloud
lema checkout REV
lema pushThe plain lema fetch moves your tracking to the current reference. lema fetch --revision REV imports exactly that revision and its history, checks its checkpoint digest and project, and changes no files, workspace or tracking. The push admits the revision again, and its first parent must be the reference’s current revision; if it is not, merge first. lema diff --cloud --before SNAPSHOT --after SNAPSHOT compares two snapshots inside the project. Where a reference’s policy requires reviews, a listed reviewer records an approval with lema review --cloud --revision REV --decision approve --nonce 32_HEX_DIGITS (reuse the same nonce to retry an interrupted request), and the next push cites the review’s ID with --reviews-file.
5. Check that a push is durable
A push reply answers two separate questions. Its outcome says whether the reference moved: published, 409 ref_conflict or 422 review_required (read the reply’s own http_status and code). Its durability says whether the change is already stored durably (remote_committed, HTTP 200) or still being stored (pending_remote, HTTP 202). A 202 can accompany any of the three outcomes.
A successful fetch tells you the current reference, never whether a change is durable. After a lost reply, a 504 or a bare 503, fetch before you push again: the push may have been queued and committed.
6. Read the project on the Hub
Hub pages are read-only. During the pilot, a project appears on the public Hub only after you ask for its publication to be turned on; its pages are then at https://hub.lema-lang.org/@bytekit/. A published project shows its modules’ authoring sources (Pad.lean), its references and the objects they select, never other files from your directory. The Hub also searches a project’s declarations by name.
Keep a local copy whenever you like with lema export ../bytekit.lemabundle; lema import checks it again (Export and import a project or library bundle).
What to build here first
Start with a small, self-contained library. The service checks a project’s history again on each push, so a large or long-lived project can eventually exceed the pilot’s per-push limits and be refused with 413. Keep code that is not Lema in Git.
Common refusals
| Reply | Cause and fix |
|---|---|
409 ref_conflict | The reference moved since your last fetch. The service keeps your admitted candidate. Run lema fetch, lema merge, then lema push. |
422 review_required | The reference’s policy does not let your account publish. The service keeps your admitted revision as a held candidate until the owner publishes it (step 4). |
422 admission_failed | The service could not check the revision: a module did not check, or the check could not finish. Nothing is held. Read the reply’s error. |
403 object_inputs_outside_project | The upload names an object the project may not use and its own sources do not produce. Nothing is installed. |
403 snapshot_project_mismatch | A revision in the history, or a snapshot it names, belongs to another project. A renamed project’s earlier history counts as another project’s. |
413 | The push exceeds one of the pilot’s per-push limits. Nothing was started. The client itself refuses an upload larger than 64 MiB before sending it. |
507 storage_full | The service is not accepting new writes for now. Nothing was started; try again later. |
504, a bare 503 or a lost reply | The push may still be queued and commit. Run lema fetch before pushing again. |
Lema v0.3.2 · Updated 29 October 2026 · Version and compatibility