6. Using LemmaBase

LemmaBase is a registry and hosting platform for Lemma specs. You can publish your own specs, import specs published by others, and query any published spec over HTTP.

Publishing a spec

Create a repository on LemmaBase, write your spec in the editor, and click Publish. Each publication creates a versioned snapshot. Older versions remain queryable.

From the CLI, target your LemmaBase repository directly:

lemma publish --repo @yourhandle/repo-name weather_advice.lemma

Querying over HTTP

Every published spec has a stable HTTP endpoint. Send a POST request with your data as JSON:

curl -X POST https://lemmabase.com/api/@yourhandle/weather-advice/consult \
-H "Content-Type: application/json" \
-d '{"forecast": "rain", "temperature": 8}'

The response includes the result of every rule in the spec:

{
  "needs_umbrella": true,
  "dress_warmly": true,
  "veto_outdoor_activity": "veto"
}

Importing a spec from LemmaBase

Any published spec can be imported into your own spec with its registry path:

spec my_pricing

uses @lemma/vat-rates as vat

data country: text
data subtotal: number

rule total_with_vat:
  subtotal * (1 + vat.rate)

Lemma resolves the dependency at consult time. The referenced spec is always evaluated against the same effective date as the parent.

Time travel

Pass an as_of parameter to query the version of a spec that was effective on a given date:

curl -X POST https://lemmabase.com/api/@yourhandle/weather-advice/consult?as_of=2024-01-01 \
-H "Content-Type: application/json" \
-d '{"forecast": "rain", "temperature": 8}'

This is useful for auditing decisions made in the past or testing upcoming rule changes before they go live.

Access control

Repositories are private by default. You can make a repository public, or invite specific users. API access uses your LemmaBase API key, passed as a bearer token.