Skip to main content

LaC - LLM as Code

Release PyPI License

LaC is a protocol for building LLM applications the way IaC builds infrastructure: behavior is declared in versioned artifacts, not improvised in prompts. An application is a folder of plain files - a compose declaration, law files with explicit authority levels, and a commands module. The engine is generic and knows nothing about any particular application.

This repository holds the LaC specification (SPEC.md) and the reference engine. The engine is intentionally small: a compose loader with a strict parser, a context assembler that loads law in trust order (L1 then L2 then L3), a REPL, and an agentic loop where free-form language and canonical !commands are two roads into the same code.

Status: pre-release. The spec (SPEC.md, methodology v0.2) is the canon; this engine tracks it through milestones M0-M3 (loader, retrieval commands, write perimeter, drift metrics). APIs and the compose schema will change.

Core ideas

  • Levels are roles. L1 (admin) and L2 (dev) files carry behavior and load always; L3 (user data) is content, never instructions.
  • Two roads, one code. Canonical !commands bypass the model entirely (zero tokens); free-form requests reach the same functions through tool calling. The model interprets and narrates; code executes.
  • Perimeter in code, not in prose. Effects on disk are the engine's job. A wrong action must be survivable.

Quick start

pipx install lac-engine
cd your-app
lac

An application folder looks like:

your-app/
  .lac/
    llm_compose.yaml    # the anchor: all paths resolve relative to the app root
    law/                # L1/L2 law files
    souls/              # personas (L2)
  commands_<app>.py     # the app's command module (TOOLS + COMMANDS registry)
  <memory folders>      # L3 content

The engine finds .lac/llm_compose.yaml in the current directory (or in the directory passed as the first argument) and resolves every path in the compose against that root. No absolute paths anywhere.

Providers: Anthropic (raw HTTP, prompt + conversation caching, ANTHROPIC_API_KEY from env only), Mistral (MISTRAL_API_KEY), and Ollama for local models. The vendor surface lives in one dispatch table, adapter.PROVIDERS, behind adapter.send(); any OpenAI-shaped API is one new entry.

Trust model: the commands module is application code (L2) and the engine executes it deliberately - running an app means trusting its dev layer, the same way installing any package means trusting its authors. The levels protect L1/L2 from the model and from L3 content, not the machine from the app you chose to run.

First application

Grimoire - a personal memory system and the first LaC application. Its earlier implementation runs the same protocol on Claude Code, with the perimeter enforced by harness permissions instead of engine code: one law, two hosts.

License

Apache-2.0. The protocol is free; applications built on it license themselves independently.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lac_engine-0.1.3.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lac_engine-0.1.3-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file lac_engine-0.1.3.tar.gz.

File metadata

  • Download URL: lac_engine-0.1.3.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for lac_engine-0.1.3.tar.gz
Algorithm Hash digest
SHA256 27883616ec3c93b63bdd39dcc7ea4b05ff3480c6db04d2190f27aaf6b9e96dbb
MD5 498a0399aa5746da347adec126227225
BLAKE2b-256 c23ab0b4b8f2ae3de01740ee973d72bce3884be93cc31af037b8c75fab1c9d68

See more details on using hashes here.

File details

Details for the file lac_engine-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: lac_engine-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for lac_engine-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 39445ced653acfa471a63209d4d5dfe3dd801c1959b320a48fcb93721b0e923d
MD5 89508d51f62d5460bc28dc801eb19e04
BLAKE2b-256 a1ffa4cddd8bf4cf03cb5bf067ce5260d8fed906a1dfba448589634222b5a99c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page