# lmi — the install-introspection language

Ask the running deployment what it is and what it can actually do. Safe mode, needs the host's install bridge — so POST /api/lmx/run or Studio's LMX Playground, not the CLI.


Ask the **running deployment** what it is and what it can actually do. **Safe** mode, needs the host's
`install` bridge — so `POST /api/lmx/run` or Studio's LMX Playground, not the CLI.

```lmi
INSTALL
KINDS

LIST apps LIMIT 5
FIND "invoice"

CAN ai.text.generate
PROVIDERS FOR email.send
```

---

## Why this exists

Leumas is a product other people run. **"Leumas can do X" and "you can do X" are different claims**,
and the second is the one that matters when answering someone about their own deployment.

A given install has a role, an edition, a set of published apps and tools, its own index sources, a
set of connected providers, and a per-user entitlement map. None of that is knowable from the source
tree — the repo says what Leumas *can* ship, not what this box *has*. `lmi` asks the instance.

Like `lma`, it holds no vocabulary. `LIST <kind>` accepts whatever kinds the install indexes, because
the bridge takes the **same `{ <kind>: async () => Array }` source map** `createIndexRouter` takes —
in `leumas-api` literally the same hoisted object. Add a source there and the language gains a kind.

---

## [critical] The rule: never answer "yes" by default

Every answer here is three-state:

| | Means |
|---|---|
| `yes` | this install said so |
| `no` | this install said so |
| `unknown` | nothing was wired to answer, so nothing was said |

An `unknown` reported as `yes` produces a confident, wrong claim about somebody else's deployment —
exactly the failure this language exists to stop. So:

- `CAN` with no entitlement engine wired prints **`unknown — no entitlement engine is wired here`**,
  and its `allowed` field is `null`, never `true`.
- `LIST` on a kind this install does not index **throws**, naming the kinds that do exist. Returning
  `[]` would read as "you have none of those", which is a different and misleading answer.
- A source that fails is reported as **broken** (`count: null` plus the error), not as empty.

## And: entitled ≠ fulfillable

`CAN` and `PROVIDERS FOR` answer different questions, and a thing only works here when both are
satisfied. A user can be perfectly entitled to `email.send` on an install where nothing is connected
to send it. `PROVIDERS FOR` says so in as many words:

```
--- providers for sms.send (0) ---
  nothing here fulfils it — CAN may still say yes, and it would still fail
```

---

## Statements

`#` starts a comment.

| Statement | Answers |
|---|---|
| `INSTALL` | role, edition, plane flags, which kinds are indexed, who you are |
| `KINDS` | every indexed kind with a live count |
| `LIST <kind> [WHERE …] [LIMIT n] [-> var]` | that kind's rows |
| `FIND "query"` | search every kind at once |
| `CAN <capability> [-> var]` | is THIS user entitled, and up to what limit |
| `PROVIDERS FOR <capability> [-> var]` | which connected provider would actually serve it |
| `ORPHANS` | capabilities nothing here fulfils — a worklist |
| `SET` · `PRINT` · `WHEN … THEN` · `RETURN` | the usual |

`WHERE` takes one comparison against a row field: `LIST tools WHERE category = "media" LIMIT 20`.

Every question and its answer is kept in `answers` on the result — a report about an install should be
quotable, and that is the quotable part.

---

## What it deliberately cannot do

- **Change anything.** No method on the bridge installs, enables, entitles or connects. It is a
  read-only surface by construction, not by check.
- **Default a missing fact.** A `describeInstall` that omits `edition` yields no `edition` field —
  "this install did not say" is not "community".
- **Run from the CLI.** No `install` bridge there, and answering from nothing is the one thing this
  language must never do.

---

## Running it

```bash
curl -s -X POST localhost:3000/api/lmx/run \
  -H 'content-type: application/json' \
  -d '{"mode":"lmi","source":"INSTALL\nKINDS"}'
```

Bundled examples: `shared/engines/lmx/src/scripts/demo.lmi`, `shared/engines/lmx/src/scripts/audit-install.lmi` — the latter is the report
to run **before** telling a user what they can do on their install.

Tests: `shared/engines/lmx/src/test/lmi.test.js`. Guard: `pnpm smoke:lmx`.


---
Source: .claude/skills/leumas-lmx/reference/lmi.md
Canonical: https://docs.leumas.tech/p/skills/leumas-lmx/lmi
