Object types

An object type defines one kind of thing the operation tracks: a silo, a batch, a truck run, a shop. It names the thing, says how each instance is identified, says which datasets supply its values and decides what happens when people edit it. This page is the reference for every part of an object type definition

1 keyOne property identifies each object for its whole life
11Base types for properties, including attachments
1 or noneBacking datasets, or none for action-only types; several, joined on the key, on request
3 statusesDraft, live and retiring (on request)

In the platform today

Built
  • Object types are read from objectTypes in ontology.yaml, in the format shown below: name, plural, key, a title template, description, icon, color, one backing dataset or none, one accessLabel, conflictPolicy and rowPolicy, one { property, attribute } or a list of them, every one applied on every read path
  • Properties have type, name, source, values, unit, hiddenFrom, required and description, with eleven base types: string, integer, double, boolean, date, timestamp, geopoint, array, struct, and attachment and attachments for files
  • A property marked required can't be left empty by an action or a sync, and a property can use a value type or a shared property
  • implements lists the interfaces a type implements, with its property and link mappings
  • A type's ID is its key under objectTypes, and a property's ID its key under properties
  • The object type API is built
On request
  • Aliases, status, folders, owners, several backing datasets, editMode, serving tiers, limits and provenance

The built format

The demo airline's aircraft type, as it is written in its ontology.yaml, shortened

objectTypes:
  aircraft:
    name: Aircraft
    plural: Aircraft
    description: An aircraft in the fleet, keyed by fleet number
    key: fleetNumber                    # must be a property
    title: "{fleetNumber} · {registration}"
    icon: airplane
    color: "#4C90F0"
    backing: gold.aircraft              # one dataset; columns map to properties
    accessLabel: null                   # an access label the reader must hold, or null
    conflictPolicy: preferEdit
    properties:
      fleetNumber: { type: string, name: Fleet number }
      aircraftType: { type: string, name: Type, values: [DH8-400, E175] }
      status: { type: string, values: [In service, AOG, In check, Stored] }
      statusSince: { type: timestamp }
      position: { type: geopoint }      # struct {lat, lon}
      hours: { type: double, unit: h, name: Flight hours }

Links, actions and row policies are covered in Link types, Action types and Access model. The rest of this page describes the full definition, delivered on request, using the illustrative ice cream maker

What an object type is

Pick the grain at which the business makes decisions, and make that one object. A Production batch is one run of one flavour on one line, because that is the unit QA releases and holds. A Reefer delivery is one truck run, because that is the unit dispatch reroutes. Getting the grain right is the most important modelling decision you make; Designing an ontology covers how to choose it

Each object type in the illustrative ice cream maker's ontology is listed below with its key and its typical size. Notice that the keys are the identifiers people already use on paperwork and in the ERP, not numbers invented by a database

Object typeClient classPrimary keyExampleObjects
Dairy farmFarmfarmIdFRM-0612
Milk pickupPickuppickupIdPU-2226About 9,000 a year
Raw milk siloSilosiloIdSIL-24
Production batchBatchbatchNoB-0841About 3,000 a year
QA testQatesttestNoQA-7710About 40,000 a year
Reefer deliveryDeliverydeliveryIdDLV-5521About 500 a year
Scoop shopShopshopIdSHP-HFX14
Wholesale customerCustomercustomerIdCUS-MMC6

Small and large types are treated the same way. Fourteen shops and forty thousand tests a year both get an index, security, links and actions, and the platform chooses storage tiers by how often a type is read, not by how big it is

Identity and names

A type's ID is its key under objectTypes, such as shop. It is the path segment in the REST API, such as /api/v2/types/shop, and the client generators turn it into the class name Shop. That is why it never changes: renaming it would break every client built against it. On request, a type also carries display names and aliases that can change

A good description matters as much as a good name. The description is shown on hover throughout the product, indexed for search and read by the Assistant and agents when they decide which type answers a question. Write one or two sentences that say what one object represents and at what grain, for example "One run of one flavour on one production line, from fill to hardening"

Primary keys and title properties

Each object carries one identifying value for its whole life, its primary key. Links, edits, the action log and every client cache refer to objects by it. It must be unique across the type and it must be deterministic: the same real thing must produce the same key on every pipeline build. Row numbers, random UUIDs generated during a build and timestamps of when a row was loaded all fail that test, and a type keyed on them loses its edits and links whenever the backing dataset is rebuilt

Use a string or integer key that never changes. Source keys such as B-0841 are strings, which makes a string the usual choice. Avoid decimals, dates and numbers too large for JavaScript to hold exactly

When the source has no single key, build one in the pipeline from the columns that together identify the thing, and keep the parts as their own properties. A shop's stock of one flavour is identified by the shop and the product, so the pipeline writes stockId = store_code || '/' || product_code and keeps both as shopId and productId

Changing a primary key is a migration

Objects are matched across revisions by key. If you change which property is the key, or change how the pipeline computes it, every existing object is treated as deleted and a new one created. Edits, links stored in join tables and action log references to the old keys stop resolving. Plan it as a migration on a branch with a mapping table, and the preview index will report how many objects would lose their history

Every object also needs a display name for lists, links, search results and the Assistant's citations, set by its title property. It does not have to be unique. Use the name people say out loud: the shop's name rather than SHP-HFX for a shop, but the batch number itself for a batch, because that is what the plant calls it

Backing data

Most object types get their property values from one backing dataset: an open table, built by a pipeline, with one row per object and one column per property. The sync service reads the table's change feed and keeps the objects current, when a sync runs. On request, a streaming sync keeps them within 2 s at p50 and 15 s at p99 of a commit to the table

creamery.gold.shopsfrom the POS store listshopId, name, province, status creamery.gold.shop_freezersfrom the sensor gateway, 1 min rollupshopId, freezerTemp, freezerSetpoint Actionsaction-only properties Scoop shop shopId (key) name (title), province, status freezerTemp, freezerSetpoint openingParTubs (action-only) joined on shopId Rules each property has one owner every dataset has shopId the first dataset is primary rows only in a secondary dataset are rejected
Multiple backing datasets let teams that own different facts about a shop publish them on their own schedules. The store list changes weekly; the freezer rollup changes every minute

Multiple backing datasets

Delivered on request. An object type can have several backing datasets, joined on the primary key. The first is the primary dataset: it decides which objects exist. Each additional dataset contributes properties for objects that already exist; a row whose key is not in the primary dataset is rejected and reported. Every property is owned by exactly one dataset, so two datasets can never disagree about a value

Use this when facts about the same thing arrive from different systems at different rates, as with the store list and the freezer sensors above, rather than joining them in one pipeline that must rebuild whenever either side changes

Action-only object types

An object type with no backing dataset is action-only. Its objects are created, modified and deleted only by actions, and the edits are its only record. Incident reports, approval records, shop visit notes and the transfer slips that shop leads create are all modelled this way. Action-only types get the same storage, index, security and action log as any other; their edits are compacted into an open table, <tenant>.ontology.edits_<type>, so they remain readable without the platform. That compacted table is delivered on request

Column mapping

Each property maps to a column by name, or by source when they differ. Struct properties map one column per field, and geopoints map a latitude and longitude column or a single WKT column. The base type of the column must match the property's base type, or be safely castable: an integer column can back a long property, but a string column cannot back a timestamp. In the platform service a row that cannot be read is rejected at sync. On request, mismatches are reported when you push the definition, before anything is indexed

Edits and conflict policy

Actions can edit any property that is not derived, including properties backed by a dataset. Every property value records its provenance: whether its current value came from the source or from an action, and if from an action, which action log entry. In the platform service each object lists its edited properties in _edited. On request, the object page shows edited values with a marker, and the API returns provenance when you ask for $provenance

When the source later changes a property that an action has edited, the type's conflict policy decides which value stands

PolicyResultUse when
preferEdit (default)The edited value stays and a review task is raised for the type's ownersEdits are decisions the source does not know about yet, such as a rerouted run before the ERP confirms
preferSourceThe source value replaces the edit, and the action log entry is marked supersededThe source is authoritative and edits are provisional, such as a manual stock count before the next POS sync
latestWinsWhichever is newer stands, comparing the source commit time to the edit commit timeBoth sides make legitimate changes and the latest is right, such as a shop's opening hours

In the platform service an edit clears when the source reports the same value. preferEdit keeps the edit without raising a review task, preferSource clears it, and latestWins keeps whichever changed last: a property counts as changed by the source at the commit where its source column changed, and a full rebuild keeps the edit

When writeback delivers an edit and the source reflects the same value on its next sync, the source and edit agree and the edit marker clears without a conflict. Most conflicts are expected to be writebacks that failed or were changed by the source system, which is why preferEdit raises a task rather than silently choosing

Make actions the only way in

Delivered on request. Set editMode: actionsOnly on types whose changes must always be validated, such as Production batch. Inline edits in tables then go through a matching action, and no API path can write the type except through an action type's rules

Status and folders

On request, a type has a status of draft, live or retiring that tells builders and clients how much to rely on it, and belongs to folders, such as "Production" and "Cold chain", that organize navigation and search

Storage, limits and the full definition

On request, a fuller definition adds owners, aliases, status, several backing datasets, an actions-only edit mode and serving tiers, with limits set per implementation. The format in the platform today is above

Width costs more than height. A type with 400 properties and 100,000 objects takes more index space and hydration time than one with 40 properties and a million objects, and every reader pays to load properties they never look at. Split rarely used groups of properties into their own linked type, or leave them in the dataset unmapped until someone needs them

API

GET /api/v2/types
GET /api/v2/types/{type}
GET /api/v2/types/{type}/objects?pageSize=100&pageToken=…
GET /api/v2/types/{type}/objects/{key}

These run in the platform service. The first two return definitions at the current revision of main, or of a branch when you pass ?branch= or the X-MSO-Branch header. The last two return objects. Object pages default to 100 objects and allow up to 1,000, ordered by primary key unless you pass orderBy, as property or property:desc

Limitations

  • A type has one backing dataset, one access label and eleven base types, with attachment and attachments
  • The primary key cannot be changed in place. Changing the key property, or how a pipeline computes it, deletes every object and creates new ones, so edits, join-table links and action log references to the old keys stop resolving
  • Only the primary backing dataset can create objects. A row in an additional backing dataset whose key is missing from the primary one is rejected, not turned into a new object
  • Each property is owned by exactly one backing dataset. Two datasets cannot both supply the same property, even if one would only fill gaps in the other
  • The conflict policy is set per object type, not per property. A type cannot keep edits on one property and let the source win on another

Related