Designing an ontology
A good ontology reads like the operation it describes. A planner can find what they are looking for by the name they already use, every fact lives in one place, and every decision the business makes has an action with the data it needs. This page sets out the principles we design by, names the mistakes we design against, and shows how to test a design with the people who will use it
In the platform today
- Model changes are change sets on a branch of the model, under
/api/v2/model-changes: each edit toontology.yamlis checked for validity, for what it breaks (an action, function, agent, metric or pipeline still using a removed or renamed type, property or link) and for its impact, previewed on a data branch, reviewed by the owners and merged - A change set also says what happens to the edits people made on a property it changes:
moveEdits,castEdits,dropEditsorresetEdits, and a type change that would strand edits is blocked withEDITS_NOT_CONVERTEDuntil it does; see branches and proposals - Proven definitions can be exported as solution packages and installed in another ontology
- The linter and its eleven design rules run on the demo app's proposals
- The lint rules in the platform service, the linter's command line and drills
How to use this page
The principles on this page apply as written to any implementation. Read them before you model your first type, and the anti-patterns before you open your first proposal. Most of the anti-patterns are not wrong at first; they are reasonable shortcuts that become expensive once apps, functions and agents depend on them. The cost of fixing a model rises with every consumer, so the cheapest time to get it right is before a type becomes active
The examples use the illustrative ice cream maker: a creamery with raw milk silos, two production lines, a QA lab, a fleet of reefer trucks that cross by bridge or ferry, fourteen scoop shops and a list of wholesale customers. Each anti-pattern below is something a reasonable team could build for it in a first week
Principles
1. Model the operation, not the systems
Object types describe things in the world: a silo, a batch, a run, a shop. They do not describe tables. The ERP has a LOCATIONS table with shops, depots and the creamery in it; the point of sale has STORES; the scheduling tool has SITES. None of those is the right object type. A Scoop shop takes its name and address from the ERP, its sales from the point of sale and its staffing from the scheduler, joined in a pipeline or as multiple backing datasets. If a source system is replaced, the object type should not change, only its backing
2. Choose the grain decisions are made at
An object should be the unit someone acts on. QA holds and releases a batch, so Production batch is one run of one flavour on one line, not one pallet and not one day of production. Dispatch reroutes a run, so Reefer delivery is one truck run, not one stop. When two teams act on different grains of the same thing, model both and link them: a run has many stops, and if shops sign for each stop, Delivery stop becomes its own type
3. Store a fact in one place
Every fact has one home. A shop's province lives on the shop; a delivery reaches it through the link. The number of open deliveries for a shop is not a stored column, it is a derived property over the link, and so it is never wrong. Duplicated facts drift: a stored count that a pipeline forgot to rebuild, or a province copied onto deliveries that was not updated when a shop moved. Derive at read time where it is cheap and store in a pipeline only where filtering on the value is constant and costly
4. Name things the way the floor names them
Use the words people say out loud. Plant staff say "batch" and "lot", dispatch says "run", shop managers say "tubs". Put those words in display names and aliases, write a description for every type, property and action, and keep source system codes out of names. A name should be understood without context by a new hire on their first day, and should read correctly from both ends when it names a link side
5. Model decisions as actions, with the data they need
An ontology that only describes the operation is a catalogue. For every recurring decision, ask what the person looks at, what they change and who needs to know, and make that an action type with parameters, criteria and side effects. "Hold a batch", place-hold, takes a batch and a reason; it sets the hold, notifies quality and writes back to the production sheet and the order desk. One action per decision, not one per field and not one for everything
6. Share shapes through interfaces, not type trees
When types share a shape, express it with an interface that each implements, not by merging them into one type or by building a hierarchy of types. Small interfaces that describe one capability (temperature-controlled, cold-storage-asset, geolocated) compose cleanly. A type implements as many as apply, and tools written against each one work everywhere
7. Express access in business terms
Security rules should read like policy: "wholesale account managers see customers in their region", "only QA sees failed quality results". Write them as row access policies, field access and access labels on one type, not by making a copy of the type for each audience. A Wholesale customer (Maritimes) type next to a Wholesale customer (Ontario) type is a security policy that has been implemented as a schema
8. Grow the model without breaking it
Once a type is active, consumers depend on its IDs, its keys and its meaning. Prefer additive changes: a new property, a new link, a new action, a new interface that extends an old one. When something must change, deprecate it with a date and a replacement, migrate consumers, then remove it. Protect names, keys and security first; they are the hardest things to change later. When a property must move or change type, say in the same change set what becomes of the edits on it, so decisions people made are carried over rather than lost
9. Write down why
Every proposal carries a description. Use it to record why a grain was chosen, why a link is object-backed, why a property is action-only. The next person to change the model will read the proposal history before they read anything else, and so will agents that explain the model to users
When principles conflict
The principles are listed in priority order. When two pull against each other, the earlier one usually wins. A few conflicts come up often enough to settle here
| Tension | Usually resolve toward | Example |
|---|---|---|
| Real-world model versus source convenience | The real world | Split the ERP's LOCATIONS table into shops, depots and the creamery, even though one type would be one pipeline |
| One fact once versus query cost | One fact, until measured cost says otherwise | Keep openDeliveries derived; store weekToDateTubs in a pipeline because shops filter on it all day |
| Floor names versus consistency across teams | The floor's name, with aliases for the rest | Display name "Production batch", aliases "lot", "run", "batch" |
| Compose versus fewer types | Compose | Four cold types and one interface, not one type with a kind column |
| Add versus clean | Add now, clean through deprecation | New crossingMode property; deprecate viaFerry with a 90-day deadline |
Anti-patterns
Each anti-pattern has a name so reviewers can point to it in a proposal comment. The table summarizes them; the sections that follow cover the ones that cost the most
| Name | Symptom | Fix |
|---|---|---|
| Stored echoes | Counts and copied values stored on objects | Derived properties and traversal |
| Insider names | One word meaning different things, or codes as names | Precise names, aliases and descriptions |
| The long way round | Common questions need four or more hops | Add the missing link type |
| Copies by team | The same thing modelled once per department | One type, with views and security per team |
| Copies by year | Types or properties with a year or version in the name | One type with time as data |
| Tables as types | One object type per source table, named after the table | Model the real thing; join sources behind it |
| Overloaded types | A type with hundreds of properties, many empty or technical | Keep what people use; split detail into linked types |
| One type for everything | One generic type with a kind column and mostly empty properties | Separate types, joined by an interface |
| Actions shaped like forms | Many actions that each set one property | One action per decision |
| One action for everything | One action that can set every property, with no criteria | Specific actions with parameters and criteria |
Stored echoes
The pipeline writes openDeliveries onto each shop and copies province onto each delivery. Both are right on the day they are built and wrong after the first change the pipeline misses. Replace the count with a derived property over the link and remove the copied value; traverse to the shop when you need its province. Lint flags a stored number that matches a link count for over 90% of objects
Insider names and the long way round
"Order" means a wholesale customer's purchase order to sales, a production order to the plant and a transfer order to dispatch. Name them Wholesale order, Production order and Reefer delivery, and put "order" in the aliases of each. Separately, if the most common question, "which shops got lot LOT-0840-2", needs four hops through types nobody thinks about, a link is missing; add it, or derive it, so the common path is one or two hops
Copies by team or by year
Production models Plant batch, QA models Lab batch and retail models Lot, each from its own system, each with a different status. When a quality check fails, the hold in Lab batch does not reach Lot, and a shop sells from it. One Production batch type, with QA properties from the LIMS as a second backing dataset, lets each team see its own view with field access and saved object sets, and makes the hold a single action that everyone sees
Shop targets 2025 and Shop targets 2026, or freezerTempOld next to freezerTemp. Every year a new type appears, apps are cloned and queries across years need unions. Model Shop target once with a season property and a link to the shop. Object versions and the action log already hold history; the open tables give point-in-time reads of anything else
Tables as types
The team connects the ERP and creates ERP Location, ERP Transfer Order and ERP Transfer Line; then the point of sale and creates POS Store. A planner who wants Saturday's stock for one shop now has to know that it is POS Store 0007 and ERP Location LOC01, and the Assistant has two half-answers for "which shops are short". The fix is to model Scoop shop with the key people use, its shopId, map the system keys in the pipeline, and keep the source tables as datasets, not object types
Overloaded types and one type for everything
Production batch has 340 properties because the pipeline mapped every column of the MES export: etl_load_ts, src_row_hash, 60 sensor columns that are filled for one line only, and three different fill-weight fields. Every reader pays to load them, nobody knows which fill weight is right, and the Assistant cites src_row_hash as evidence. Keep the properties someone uses in a screen, a filter, an action or a function; move per-line sensor data to time series; leave the rest in the dataset, unmapped until it is needed
To avoid "too many types", the team creates Asset with assetKind in Silo, Truck, Freezer, Pasteurizer, Filler, and properties for every kind: fatPercent, licencePlate, doorOpenCount, holdTubeSeconds. For any object most properties are empty, every action needs criteria on assetKind, and security cannot differ between trucks and fillers. Make each kind its own object type and add a Maintainable asset interface for what they share. Ten well-shaped types are easier to use than one that is wrong for everyone
Actions shaped like forms, or one action for everything
These are opposite mistakes with the same root: actions modelled around fields instead of decisions. Set crossing, Set sailing and Set ETA as three actions means a reroute is three transactions, three log entries and a window in which a run is on the ferry with the bridge ETA. One Update delivery action that can set any field, with no criteria, means nothing stops a run that has already left from being edited, and the action log says "updated" for every kind of change. The fix for both is one action per decision: reroute-delivery, drop-stop, top-up-delivery, each with the parameters, criteria and side effects that decision needs
A worked redesign
The figure shows the first week's model on the left, built by mirroring sources, and the reviewed model on the right. The reviewed model has fewer types that people need to know and more links between them
Validating a design
A model can pass every structural review and still fail the people who use it. The only proof is to watch someone answer real questions with it. We call this a drill
- Write the questions. Six to ten questions from a real recent event, in the order someone would ask them: what is happening, why, and what it affects. "Which batches are on hold?", "Why is B-0841 on hold?", "Which shops have received that lot?", "Which runs are carrying it now?"
- Pick the people. Two or three people who will use the model and did not build it. A shift supervisor and a dispatcher are better than the data team
- Use a general tool. Run the drill in object exploration, not a purpose-built app, so the model is tested and not the app's shortcuts
- Record what happens. Correct or not, time taken, terms they searched for, types they opened and abandoned, and any time they exported data to finish the answer by hand
- Run it with an agent. Ask the same questions through the Assistant. Questions only the agent answers point at names people do not use; questions only people answer point at logic that lives in heads, not in the model
- Fix and repeat. Keep the questions as an evaluation suite and re-run them on every large proposal
| What you observe | Likely cause | Fix |
|---|---|---|
| Search finds no type for the word they use | Missing alias or wrong display name | Add aliases; rename while still a draft |
| They open two types before picking one | Copies by team or unclear names | Merge, or sharpen descriptions |
| They export to a spreadsheet to join two lists | A missing link type | Add the link |
| They scroll past dozens of empty properties | Overloaded types | Hide or remove unused properties |
| The answer is right but takes minutes of clicking | The long way round | Add a direct link or a derived property |
| They know the answer but cannot change it | A missing action | Model the decision as an action type |
Lint rules
Every proposal runs the ontology linter, and new findings appear as checks. Errors block the merge by default; warnings and information do not. The linter and its eleven design rules run in the demo app on its proposals; running it from a CLI before pushing, as below, is delivered on request
mso ontology lint --branch shops-redesign --new-only
# ERROR status link-type lot-delivery is live, endpoint lot is draft
# WARN junk-drawer batch has 212 properties; 141 are under 20% filled
# WARN stored-echo shop.openDeliveries equals the count of delivery-stop-shop
# for 97% of objects
# WARN dated-copy object type shop-targets-2026 has a year in its name
# WARN field-actions delivery has 3 actions that each modify one property
# INFO naming link side delivery-stop.shop reads the same from both ends
# INFO docs 4 properties on qatest have no description
# 1 error, 4 warnings, 2 info
Review checklist
Reviewers of a proposal that adds or reshapes object types should be able to answer yes to each of these
- Each new type is a real thing or event, at the grain someone acts on
- The primary key is the identifier people already use, and is deterministic across pipeline rebuilds
- Display names, aliases and descriptions use the floor's words, and every property someone will see has a description
- No fact is stored in two places; counts and copied values are derived
- Every link side reads correctly from its own end, and relationships with data are join objects
- Shared shapes are interfaces; no type has a
kindcolumn that decides which properties are filled - Each recurring decision has one action type with criteria and the right side effects
- Access rules are policies and access labels on one type, not copies of the type
- Breaking changes go through deprecation with a date and a replacement
- The drill questions for this area pass, for people and for the Assistant