Open Ontology DSL Guide

This guide walks through the complete Open Ontology DSL using an HR domain example. You'll learn how to define schemas, relationships, entities, rules, actions, workflows, and integrations.


Domain Overview

We'll model a simple HR system with:

  • Departments — organizational units
  • Employees — people who work in departments
  • Contracts — employment agreements
  • Leave Requests — time-off requests requiring approval

1. Object Types

Object types define the schema for your entities. Use Ontology.ObjectTypes() to declare them:

Attribute Types

TypeBuilderDescription
stringAttr.string()Text values
numberAttr.number()Numeric values (including timestamps)
booleanAttr.boolean()True/false
enumAttr.enum([...])Constrained set of values
refAttr.ref()Reference to another entity
jsonAttr.json()Arbitrary JSON data

Attribute Modifiers


2. Relationships

Relationships define how object types connect. Use Ontology.Relationships():

Cardinality

BuilderMeaning
r.one("Type")Single reference (many-to-one)
r.many("Type")Multiple references (many-to-many)

3. Objects (Seed Data)

Create entity instances with Ontology.Objects():

Note: Use o.ref("entity-id") to create references to other entities.


4. Link Types

Link types define typed relationships that can have properties. Unlike simple relationships, links are first-class entities:

Link Cardinality

ValueMeaning
one-to-oneEach source has at most one target
one-to-manyEach source can have multiple targets
many-to-oneMultiple sources point to one target
many-to-manyNo restrictions

5. Links (Instances)

Create link instances with Ontology.Links():


6. Rules (Compliance)

Rules define compliance requirements using Datalog queries. When a rule's query returns results, violations are created:

Rule Structure

FieldDescription
nameUnique identifier
displayNameHuman-readable name
severityerror, warning, or info
entityTypeType of entity being validated
queryDatalog query that finds violations
messageTemplate with {{?var}} placeholders

7. Actions

Actions define operations that users can perform. They support wizard (multi-step) and instant modes:

Wizard Action: Employee Onboarding

Instant Action: Approve Leave Request

Action Field Types

TypeDescription
textSingle-line text input
emailEmail with validation
numberNumeric input
dateDate picker
selectDropdown from options
booleanCheckbox
entity-refReference to another entity
textareaMulti-line text

8. Workflows

Workflows define multi-step processes as DAGs (directed acyclic graphs):

Step Types

TypeDescription
automationExecute code/API calls
human-taskCreate a task for a person
queryRun a Datalog query
decisionConditional branching
aiAI-powered operations

Workflow Triggers


9. Integrations

Connect external systems using Sources, Mappings, and Match Rules:

Define a Source

Field Mappings

Map external fields to your ontology:

Match Rules

Resolve incoming records to existing entities:

Run Sync

Provenance Tracking

Synced entities automatically include provenance attributes:


10. Queries

Query your ontology using Datalog:

Basic Query

Query with Aggregation

Query with Negation

Cross-Entity Query

Time Travel Query


Building the Ontology

Assemble all components with Ontology.build():

The compiled ontology contains:

  • Object type schemas (for validation)
  • Link type definitions
  • Triple inputs (entity data)
  • Link instances

Next Steps

  • Try the Demo — See these concepts in action at /databases [blocked]
  • Read the Docs — Full API reference at /docs [blocked]
  • Explore the Architecture — Deep dive at /architecture [blocked]