Skip to main content
The ontology/ folder turns your data into typed objects, and gives agents and people a small set of reads and actions over them. Every call is decided by Cedar policies in the same folder. See Ontology for the concepts. An ontology has four layers. You write one of each here:
  1. A source brings raw records in.
  2. A model shapes them into a table with SQL.
  3. An object maps that table to a typed noun, such as Customer.
  4. Reads and actions are the handlers agents and spaces call.

The package

ontology/package.json
Tilde provides @tilde/ontology when it builds the project, so don’t list it. List only the packages your own code imports.

Sources, models, and objects

This example ships two customers as reference data, so you need no connection yet. Later you replace the stream with a pipeline.
ontology/customers.ts
  • .map() properties come from the source. Only the source system changes them.
  • .owned() properties belong to the ontology. Only its actions change them, and every edit is audited.
  • A transactional view groups what changes together under one key, here one customer.

Reads and actions

Each handler has a name, a zod input and output, and declares what it reads and edits. Tilde turns each one into an agent tool and a typed call for spaces.
ontology/handlers.ts
Write each description for the agent that will call it.

Policies

Access is deny by default. These policies let signed-in people and agents use the customer handlers, and let people open the customers space you add next.
ontology/policies.ts
An agent acting for a person needs both to be allowed, so it never does more than that person. See Policies to narrow these.

The entry point

ontology.ts default-exports the whole ontology.
ontology/ontology.ts
Split the other files however you like. Only ontology.ts is fixed.

Next

Add a space that shows these customers to people.