Action types
An action type is a named, governed change to the Ontology. It declares what a person or an agent must provide, what must be true before the change is allowed, which objects change and how, what is written back to systems of record, and who is told. Every apply commits all of its edits at once or none of them, and leaves one entry in the action log. Screens, the API, agents and automations all change the Ontology this way and no other
In the platform today
- Action types run in the platform service, defined under
actionTypesinontology.yamlwithname,objectType,allowedGroups,requiresApproval,accessLabel,parameters,conditions,rules,writebackandnotify - Parameters are strings with optional values, integers, doubles, booleans, dates and timestamps, value types, and objects:
objectorobjectswith anobjectType, or with aninterfaceto take an object of any implementing type, given as{ objectType, key },{ _type, _key }or"type:key", and an action'sobjectTypemay name an interface notify:entries work their recipients out from the action, as described in notifications, and each recipient is checked against the action's main object:check,:run(withoptions.dryRunandoptions.includeEdits),:runBatchand:proposework as shown below- An agent can only propose an action that requires approval, and a person approves it
- Each apply writes the action log and its writeback outbox rows, then delivers writeback with an idempotency key and retries
- An applied action can be undone from the action log
- A run checks its parameters and conditions again just before it commits, and gets
ACTION_VALIDATION_FAILED.CONDITION_FAILEDwhen an earlier run's edits made one false, or 409CONCURRENCY_CONFLICT.OBJECT_CHANGEDwhen objects its parameters read keep changing while it commits options.expectedVersions({"batch:B-0840": 1}, from a form that showed those objects) refuses the run with 409CONCURRENCY_CONFLICT.STALE_OBJECTwhen one has changed since- Two people approving a proposal at once run it once and the second gets
CONCURRENCY_CONFLICT.PROPOSAL_DECIDED - An edit cannot leave a property marked
required: trueempty (ACTION_VALIDATION_FAILED.REQUIRED_PROPERTY, naming each object and property) - A
writebackentry withwhen: beforecalls a real system inside the run, before any edit, and its outputs feed the rules, as described on writeback - Parameters of type
attachmentandattachmentstake uploaded files, as described on attachments
- Option sets, visibility rules, the
sideEffects:block, the revert window and versions, theIdempotency-Keyheader, and version checks on objects a condition reads only through a function
- Editor or Owner on the ontology to create or change an action type, on a branch merged through a proposal; Viewer is enough to apply one when the action's apply permission includes you
- Every access label on the object types the action reads and writes, both to build it and to apply it
- A connector with write access to the target system for any writeback rule, and an edge agent when that system is on the plant network
- A published function version for any function rule or computed default
Why changes go through actions
An operation has rules that live nowhere in its data. A delivered run cannot be rerouted. A batch on hold for a failed quality check cannot ship. Only dispatch moves a truck to the ferry. If every screen and script writes objects directly, each one has to remember those rules, and sooner or later one forgets. An action type states the rules once, in the Ontology, and every client inherits them
New object types are actions only by default: their properties can be changed by sync from the source and by actions, and by nothing else. That also means a person can be allowed to apply an action without holding write access to the backing dataset, because the action, not the person, is what is trusted to write
Anatomy of an action type
| Part | What it declares | Covered in |
|---|---|---|
| Metadata | ID, display name, description, status, version and the object types it edits | This page |
| Parameters | Typed inputs with constraints, defaults, dropdown options and conditional visibility | Parameters and rules |
| Rules | The edits: create, modify and delete objects, add and remove links, or one function that computes the edits | Parameters and rules, edits from functions |
| Action conditions | Conditions on parameters, objects and the user that must hold, each with its own message | Action conditions |
| Permissions | Who may apply it, and which access labels they need | This page, access model |
| Writeback | Which committed edits go to which system of record, which calls run before the edits and feed them, and how conflicts are handled | Writeback |
| Side effects | Notifications and webhooks after commit | Notifications and webhooks |
| Log and revert | The summary template, which parameters are captured, and whether and how long the action can be reverted | Action log |
| Agent and automation policy | Whether agents and automations may only propose this action, or may apply it | This page, tools and guardrails |
A complete definition
This is the definition of place-hold for the illustrative creamery, shortened, as written under actionTypes in ontology.yaml. A QA lead uses it when a batch fails a quality check and must not ship until QA releases it
place-hold:
name: Place QA hold
objectType: batch
description: Stop a batch from shipping until QA releases it
accessLabel: QUALITY
allowedGroups: [quality, operations]
parameters:
batch: { type: object, objectType: batch, required: true }
reason: { type: string, required: true }
conditions:
- name: notHeld
message: "{{batch.batchNo}} is already on hold"
all:
- { left: { parameter: batch, property: hold }, op: isNot, right: true }
- name: made
message: "{{batch.batchNo}} has not been made yet"
all:
- { left: { parameter: batch, property: status }, op: isNot, right: Scheduled }
rules:
- modify:
object: { parameter: batch }
set: { hold: true, qaStatus: On hold, holdReason: { parameter: reason } }
- function: { name: product_hold_edits, args: { batch: { parameter: batch }, hold: true } }
writeback:
- system: production-sheet
operation: qa-event
payload:
batchRefs: { parameter: batch }
event: HOLD
reason: { parameter: reason }
enteredBy: { currentUser: name }
enteredAt: { now: true }
notify:
- group: quality
message: "{{batch.batchNo}} on QA hold: {{reason}}"
category: holds
required: true
Two things in it are worth noticing. The product's count of held stock is not typed by the QA lead: a function, product_hold_edits, computes it from the batch, so the same rule holds for everyone. And the hold reaches the production sheet through writeback, so the plant sees it without anyone retyping it. On request, option sets, visibility rules, side effects, a revert window and versions
Lifecycle of an apply
Every apply moves through the same stages in the action service. The first five run inside one transaction at one snapshot. The last two run after the commit, from the outbox, and can never undo it
- Validate. The caller is authenticated and must hold permission to apply the action and read access to every object it names. Parameters are resolved: defaults filled, including conditional parameter defaults, types and constraints checked, and dropdown choices checked against their option sets at the snapshot
- Conditions. Every action condition is evaluated. All failures are collected and returned together, each with its message, so a person fixes everything at once
- Edits. Rules compile into one edit per object, or a function rule runs in the function runtime and returns an edit set. The result is checked against value types, required properties and the limit of 10,000 edits per action
- Commit. Just before the commit, parameters and conditions are checked again and the version of every object the parameters read is compared with the stored one. If one changed since the check, the run starts again from step 1, and fails with
CONCURRENCY_CONFLICT.OBJECT_CHANGEDafter automatic retries. The edits are then written with the action log entry - Log. In the same commit, the action log entry is appended with parameters, before and after values and the snapshot the action read, and one outbox row is written for each writeback target and side effect
- Writeback. The writeback service delivers committed edits to systems of record, in order per object, with idempotency keys and retries. Its status is recorded on the log entry
- Side effects. Notifications and webhooks are sent, rendered from the committed values, with their own retries
Applying an action
POST /api/v2/actions/place-hold:run
Authorization: Bearer eyJhbGciOi…
Idempotency-Key: 7d3f1c2a-0b5e-4f7e-9b51-hold-B-0840
Content-Type: application/json
{
"parameters": {
"batch": "B-0840",
"reason": "Same silo draw as B-0841"
},
"options": { "includeEdits": true, "expectedVersions": { "batch:B-0840": 1 } }
}
{
"logId": "alog_01M5Y37ABN7VGMJ0CCB48C1046",
"result": "APPLIED",
"action": "place-hold",
"objectKey": "B-0840",
"edits": 2,
"writeback": [
{ "system": "production-sheet", "status": "delivered" },
{ "system": "order-desk", "status": "delivered" }
],
"changes": [
{ "op": "modify", "objectType": "batch", "primaryKey": "B-0840",
"changes": { "hold": { "before": false, "after": true },
"qaStatus": { "before": "Released", "after": "On hold" },
"holdReason": { "before": "", "after": "Same silo draw as B-0841" } } },
{ "op": "modify", "objectType": "product", "primaryKey": "PRD-CHO-T",
"changes": { "onHold": { "before": 0, "after": 200 },
"batchesOnHold": { "before": 0, "after": 1 } } }
]
}
expectedVersions is what a form sends for the objects it displayed, each written "type:key" with the _version it showed. If someone else changed the batch while the QA lead was looking at it, the apply fails with 409 CONCURRENCY_CONFLICT.STALE_OBJECT, and each entry in errors names the objectType, objectKey, expectedVersion and current version, rather than acting on a picture that is no longer true. A reference not written "type:key" is INVALID_ARGUMENT.BAD_EXPECTED_VERSION
The Idempotency-Key header makes an apply safe to retry after a network failure: a second request from the same person with the same key within 24 hours returns the first result, marked replayed, instead of applying again, and the same key with other parameters is refused. On request, the response also carries the action type's version and a consistency token for read-your-writes
From the SDK, the same call is typed against the generated action
try {
const res = await mso.actions(placeHold).run(
{ batch: "B-0840", reason: "Same silo draw as B-0841" },
{ includeEdits: true },
);
console.log(res.logId, res.changes);
} catch (err) {
if (err instanceof ActionValidationError) {
// every failing condition, not only the first
for (const c of err.conditions) console.warn(c.message);
} else throw err;
}
POST …/actions/{action}:check returns the result of every parameter and condition without committing, and :run with options.dryRun, or dryRun: true in the SDK, also returns the edits. On request, a preview of writeback and side effects. POST …/actions/{action}:runBatch applies a list of parameter sets in one request, up to 1,000 on request, described in parameters and rules
Concurrency and isolation
An apply checks its parameters and conditions, then checks them again just before it commits. Two QA leads holding the same batch at once cannot both win: the second run's final check sees the batch already on hold and fails its notHeld condition with CONDITION_FAILED. The same holds for two dispatchers booking one technician
The run also compares the version of every object its parameters read with the stored one just before it commits. When one changed in between, the run starts again from the check, and after automatic retries fails with CONCURRENCY_CONFLICT.OBJECT_CHANGED and lists the objects that kept moving. Automatic reruns are safe because nothing outside the Ontology has happened before the commit; a writeback entry with when: before reuses the outputs of its first call rather than calling again
On request, objects that conditions read only through a function become part of the read set too, not only the objects the parameters name. That closes the classic write skew. If a condition says "at most two reefer runs per sailing" and two dispatchers each add a run to a sailing that has one, the second commit sees that the sailing's run count moved and re-evaluates the condition, which now fails
Who can apply
- Permission to apply. Set on the action type by group or role. It is separate from conditions: permission decides whether the action appears at all, conditions decide whether this particular apply is allowed
- Object access. The caller must be able to see every object passed as a parameter. Row and field access apply as on any read
- Access labels. The caller must hold every access label on the objects the action reads and writes. An action that writes to a
QUALITYtype, such asbatch, can only be applied by people cleared for it - Agents. An agent applies actions on behalf of a person and never beyond that person's access. With
mode: proposethe agent stages the action and a person approves it, and the log records both the agent run and the approver - Automations. Run as their owner, with the same three modes.
applyis meant for low-risk, reversible actions
Errors
Applies fail with the stable codes on error codes. These are the ones an apply usually meets; the reason narrows each one, written CODE.REASON
| Code and reason | HTTP | Meaning |
|---|---|---|
ACTION_VALIDATION_FAILED.PARAMETER_INVALID | 422 | A parameter is missing, out of range or not among its options, or names an object the caller cannot see. Each one is listed in errors with PARAMETER_MISSING or PARAMETER_INVALID |
ACTION_VALIDATION_FAILED.CONDITION_FAILED | 422 | One or more action conditions failed. Every failure is listed with its message |
FUNCTION_FAILED.USER_FACING_ERROR | 422 | A function threw a FunctionError with a message meant for the person |
PERMISSION_DENIED | 403 | No permission to apply, or a missing access label. The response does not say which hidden object caused it |
NOT_FOUND.ACTION_TYPE_NOT_FOUND | 404 | The action type does not exist or is not visible to the caller |
ACTION_VALIDATION_FAILED.REQUIRED_PROPERTY | 422 | An edit would leave a required property empty: a create that does not set it, or a modify that clears it |
CONCURRENCY_CONFLICT.STALE_OBJECT | 409 | An object changed since the version in expectedVersions |
CONCURRENCY_CONFLICT.OBJECT_CHANGED | 409 | An object the parameters read kept changing through the automatic reruns |
CONCURRENCY_CONFLICT.PROPOSAL_DECIDED | 409 | Someone else approved or rejected the proposal first |
CONCURRENCY_CONFLICT.PROPOSAL_STALE | 409 | An object the proposal read changed before the approval, and the action type sets refuseIfChanged |
PERMISSION_DENIED.SEPARATE_APPROVER_REQUIRED | 403 | The person who proposed it tried to approve it, and the action type sets separateApprover |
IDEMPOTENCY_KEY_REUSED.BODY_MISMATCH | 409 | The Idempotency-Key was already used for a different request |
PAYLOAD_TOO_LARGE.BODY_TOO_LARGE | 413 | The request body is over the service's limit (16 MB, or 1 GB on upload routes) |
WRITEBACK_FAILED | 422, 502, 503 | A system called before the edits refused or did not answer. Nothing was edited |
ACTION_VALIDATION_FAILED.EDIT_LIMIT_EXCEEDED | 422 | More than 10,000 edits in one apply |
FUNCTION_FAILED, FUNCTION_TIMEOUT | 500, 504 | A function rule failed or timed out. Nothing was committed |
RATE_LIMITED | 429 | On request: over 120 applies per minute for the client, with Retry-After |
Versions and change
On request, versioned action types that callers can pin while they update, with each action's applies and failures shown
Limitations
- An apply is atomic only inside the Ontology. Writeback and side effects run after the commit, so a system of record can lag, reject or dead-letter an edit that the Ontology already shows as applied. A writeback entry with
when: beforeis the exception: the system is called first, and a run that then fails undoes the call through its operation'sundo, or names it asNOT_UNDONEwhen there is none - Nothing after the commit can undo it. A failed writeback or webhook is retried and reported on the log entry, but the edits stand until someone reverts or corrects them
- An action cannot apply another action. Shared logic belongs in a function, and a follow-on change belongs in an automation or a second apply
- Automatic reruns on conflict stop after a few attempts, after which the apply fails with
CONCURRENCY_CONFLICT.OBJECT_CHANGEDand the caller has to retry - Revert is only available when the action type allows it and within its configured window, and it cannot recall a writeback that the target system has already accepted
- On a branch, writeback and side effects are off by default, so a branch test does not show how the target system responds