--- layout: home title: Forma for Ontology description: Pure-IR domain modeling with preludes/ontology.lisp. Declare entities, relations, seeds, links, and typed queries with content-addressed payload contracts and zero TypeScript codegen required. sidebar: false aside: false pageClass: forma-index forma-ontology ---

Forma for Ontology · shipped prelude · pre-alpha

Pure-IR domain modeling, with zero codegen required.

Not every Forma program compiles to TypeScript. preludes/ontology.lisp is a shipped prelude for modeling entities, relations, seed records, links, and typed queries directly into canonical, content-addressed IR validated against payload contracts. Define a Salesforce or CRM-style domain once and hand verified IR straight to any host.

(entity   Account     {…})
(relation ForAccount  Opportunity Account {})
(seed     Account     "account:acme" {…})
(link     ForAccount  "opp:renewal" "account:acme" {})
(query    open-deals  :from Opportunity :where …)
   │
   │  read → project → check → validate
   ▼
Content-Addressed Domain IR
(zero TypeScript codegen required)

Shipped in preludes/ontology.lisp · generated reference

00 The problem

Domain models shouldn't be trapped inside one language's ORM.

In a typical CRM or operational app, your domain graph is split across database migrations, ORM classes, seed fixtures, and ad-hoc query strings. Nothing checks that a seed record matches its schema, that a link connects the right entity types, or that a query filters on a real field. preludes/ontology.lisp checks the whole graph together and emits portable IR instead of tying you to a single target runtime.

  1. accounts.sqlCREATE TABLE account (name TEXT, …)← schemaentity
  2. relations.sqlFOREIGN KEY (account_id) REFERENCES …← typed edgerelation
  3. fixtures.json{ "id": "account:acme", … }← checked dataseed / link
  4. pipeline.sqlSELECT title FROM opportunity WHERE …← scoped readquery

Live-checked CRM model

(entity / relation / seed / link / query)

Shipped · Ontology prelude

Schemas, instances, and queries checked in one file.

This CRM example is checked live against the bundled preludes/ontology.lisp prelude. entity declares Account, Contact, and Opportunity schemas. relation declares typed edges between them.

seed validates every record field against its entity schema (including defaults and required attributes). query brings the entity's fields into scope so :where and :select reject unknown columns or type mismatches. In full ontology elaboration, link also validates relation instances against the declared source and target entity types.

crm.lispchecked against preludes/ontology.lisp
```lisp fragment (entity Account {:name String :tier String :arr Int}) (entity Contact {:name String :email String}) (entity Opportunity {:title String :stage String :amount Int}) (relation WorksAt Contact Account {:role String}) (relation ForAccount Opportunity Account {}) (seed Account "account:acme" {:name "Acme Corp" :tier "enterprise" :arr 120000}) (seed Contact "contact:ada" {:name "Ada Lovelace" :email "ada@acme.example"}) (seed Opportunity "opp:renewal" {:title "Annual Renewal" :stage "proposal" :amount 120000}) (query enterprise-deals :from Opportunity :where (>= amount 50000) :select [title stage amount]) ```

Pure IR & payload contracts

Zero TypeScript codegen required.

Shipped · Conformance corpus

The IR is the deliverable.

Unlike Forma for Effect, an ontology program does not need a TypeScript backend to be useful. Every form in preludes/ontology.lisp declares its exact IR shape—EntityIR, RelationIR, RecordIR, LinkIR, QueryIR—and validates its output against domain-payload artifact contracts.

Artifacts are canonical and content-addressed, so a host application, database loader, or structural workbench can verify, diff, cache, and interpret the domain graph directly without running a code generator or embedding a Lisp evaluator at runtime.

03 Beyond entities

Everything else in preludes/ontology.lisp.

The ontology prelude is tested across the repository's conformance fixtures and example corpus, and includes higher-level domain vocabulary alongside schemas and queries.

Typed relations & links

relation names source and target entities plus edge attributes. link validates endpoint IDs and edge fields against the relation declaration.

Scoped queries

query injects entity attributes into :where scope as typed bindings and computes the query's result row type from :select.

Identity & permissions

identity and permission declare roles, groups, and allow/deny policies over actions and entity schemas in the same checked IR.

Process graphs

process, node, and edge declare entity-triggered DAGs with compile-time checks for duplicate nodes, unknown endpoints, and dependency cycles.

04 Limits

What you give up, and what is outside Forma.

Forma checks and projects the domain model; storing and executing it belongs to your host.

Trade-offs

  • No bundled database or query engine. Forma validates query expressions and emits QueryIR; executing queries against Postgres, SQLite, or an in-memory store is the host's job.
  • No automatic ORM or TypeScript codegen. Pure-IR workflows intentionally avoid code generation; if you want generated Effect TypeScript services, use Forma for Effect.
  • Pre-alpha IR evolution. preludes/ontology.lisp and its payload contracts are actively refined as the conformance corpus grows.

Missing today

  • Schema migrations. Content-addressed artifacts make schema diffs inspectable, but Forma does not generate SQL migrations or backfill scripts.
  • Multi-entity joins in query. The query form reads over one :from entity; richer relational or Datalog query execution depends on host support.
  • Live runtime preview. The ontology sandbox checks and inspects your domain model and prelude, without a built-in database browser or Preview Portal runtime.

05 Fit

When to try it.

Worth trying

  • Platforms and hosts that want a single checked, content-addressed domain IR for schemas, links, permissions, and queries.
  • Modeling CRM, operations, or knowledge-graph domains where seed data and links must be validated at compile time.
  • Teams building custom domain preludes on top of Forma's descriptor and artifact pipeline.

Not yet

  • Teams looking for an out-of-the-box database, migration runner, or GraphQL/REST server.
  • Projects that want generated TypeScript ORM models from an ontology file today.
  • Production schemas that require long-term binary IR stability guarantees.

Model the domain, then inspect the prelude.

Open the Ontology sandbox to edit a CRM model against preludes/ontology.lisp, or browse the generated prelude reference for every form and IR contract.