Domain Model Reference¶
Machina's domain model is the backbone of the framework. Every connector normalizes external data into these entities, and every agent reasons in these terms. The model is aligned with ISO 14224 — the international standard for reliability and maintenance data collection — so teams already using ISO-aligned CMMS tooling can interoperate without custom field mapping.
The entities are pydantic v2 models with
validators. Fields carrying ISO 14224 codes (iso_14224_code,
equipment_class_code, failure_impact) are optional and live alongside
Machina's own catalog identifiers — you can adopt the ISO alignment
incrementally, one field at a time.
Core Entities¶
Asset¶
Asset ¶
Bases: BaseModel
A physical piece of equipment in the maintenance hierarchy.
Assets represent any maintainable item — from an entire plant down to an individual bearing. They carry metadata for identification, location, and maintenance strategy.
AssetType ¶
Bases: StrEnum
Pragmatic equipment classification inspired by ISO 14224 and common industry usage.
This enum uses Machina-specific buckets that blend ISO 14224 equipment
categories (rotating, electrical, safety) with common industry terms
(static, instrument, piping, structural, HVAC). For strict ISO 14224
alignment, use Asset.equipment_class_code to carry the Annex A
Table A.4 code (e.g. 'PU', 'CO', 'HE', 'EM').
Criticality ¶
Bases: StrEnum
Asset criticality classification for maintenance prioritisation.
A = Critical (production-stopping), B = Important, C = Standard.
WorkOrder¶
WorkOrder ¶
Bases: BaseModel
A maintenance work order with lifecycle tracking.
Supports status transitions, SLA tracking, and links to the asset, failure mode, and required spare parts.
transition_to ¶
Transition the work order to a new status.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the transition is not allowed. |
WorkOrderType ¶
Bases: StrEnum
Classification of the maintenance activity.
WorkOrderStatus ¶
Bases: StrEnum
Lifecycle state of a work order.
Priority ¶
Bases: StrEnum
Work order urgency level.
FailureImpact ¶
Bases: StrEnum
Failure impact on equipment function (ISO 14224 Table 6).
- CRITICAL: loss of equipment function (production-stopping)
- DEGRADED: equipment still functioning but below specification
- INCIPIENT: imminent failure detected before functional loss
SparePartRequirement ¶
Bases: BaseModel
A spare part needed for a work order.
FailureMode¶
FailureMode ¶
Bases: BaseModel
A known failure mode for a class of equipment.
Encodes domain knowledge about how equipment fails, how to detect the failure, and what to do about it.
SparePart¶
SparePart ¶
Bases: BaseModel
A spare part with inventory and reorder tracking.
Links to compatible assets for automatic part lookup during work order creation.
needs_reorder
property
¶
Whether current stock is at or below the reorder point.
Alarm¶
Alarm ¶
Bases: BaseModel
A sensor alarm or event from an industrial data source.
Represents a threshold exceedance or anomalous condition detected by the IoT / SCADA layer.
Example
is_above_threshold
property
¶
Whether the measured value exceeds the threshold.
Severity ¶
Bases: StrEnum
Alarm severity level.
MaintenancePlan¶
MaintenancePlan ¶
Bases: BaseModel
A preventive maintenance plan defining recurring tasks for an asset.
Links an asset to a set of inspection or service tasks performed at a fixed calendar or operating-hours interval.
Example
Interval ¶
Bases: BaseModel
A maintenance interval specification.
At least one of the duration fields should be set.
Plant¶
Plant ¶
Bases: BaseModel
Top-level container representing a physical plant or site.
Acts as the root of the asset hierarchy and provides lookup methods for navigating the equipment tree.
get_asset ¶
Look up an asset by ID.
Raises:
| Type | Description |
|---|---|
AssetNotFoundError
|
If no asset with the given ID exists. |
load_assets_from
async
¶
Load assets into the plant from a connector or a file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
Either a connector exposing an async |
required |
Returns:
| Type | Description |
|---|---|
int
|
The number of assets loaded. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
FileNotFoundError
|
If the file path does not exist. |
ValueError
|
If the file extension is unsupported or the file does not contain a list of asset dicts. |
Domain Services¶
FailureAnalyzer¶
FailureAnalyzer ¶
Service that matches symptoms to known failure modes.
This is a rule-based baseline; future versions will integrate LLM-assisted reasoning and historical failure data.
register_failure_mode ¶
Add a failure mode to the knowledge base.
diagnose ¶
Return failure modes whose indicators match the alarm parameters.
Can be called two ways:
- Programmatic:
diagnose(alarms=[alarm1, alarm2])— returns a plainlist[FailureMode]for Python callers. - From workflow engine:
diagnose(parameter="vibration_velocity_mm_s", value="7.8", asset_id="P-201", severity="warning")— returns a :class:DiagnosisResultso downstream workflow steps can extract aprimary_code(str) forWorkOrder.failure_modevia the template{analyze_alarm.primary_code}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alarms
|
list[Alarm] | None
|
Active alarms to match against failure modes. |
None
|
**kwargs
|
Any
|
Workflow trigger fields (parameter, value, asset_id, severity). |
{}
|
Returns:
| Type | Description |
|---|---|
list[FailureMode] | DiagnosisResult
|
Either a list of matching :class: |
list[FailureMode] | DiagnosisResult
|
(programmatic path) or a :class: |
list[FailureMode] | DiagnosisResult
|
path) — the workflow wrapper exposes the same ranked dicts |
list[FailureMode] | DiagnosisResult
|
via iteration plus convenience attributes for templating. |
WorkOrderFactory¶
WorkOrderFactory ¶
Factory for creating pre-filled work orders from alarms or plans.
Future versions will use the failure analyzer and spare-part inventory to auto-populate fields.
create ¶
create(*, id: str = '', asset_id: str = '', type: WorkOrderType = WorkOrderType.CORRECTIVE, priority: Priority = Priority.MEDIUM, description: str = '', failure_mode: str | None = None, **kwargs: Any) -> WorkOrder
Create a work order with sensible defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Work order identifier. Auto-generated as
|
''
|
asset_id
|
str
|
Target asset. |
''
|
type
|
WorkOrderType
|
Maintenance type. |
CORRECTIVE
|
priority
|
Priority
|
Urgency level. |
MEDIUM
|
description
|
str
|
Free-text summary. |
''
|
failure_mode
|
str | None
|
Optional failure mode code. |
None
|
Returns:
| Type | Description |
|---|---|
WorkOrder
|
A new |
create_batch ¶
Create multiple work orders in one call.
Each item in work_orders is a dict of keyword arguments
forwarded to :meth:create.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
work_orders
|
list[dict[str, Any]] | None
|
List of per-WO keyword-argument dicts. |
None
|
Returns:
| Type | Description |
|---|---|
list[WorkOrder]
|
List of created |
MaintenanceScheduler¶
MaintenanceScheduler ¶
MaintenanceScheduler(*, plans: list[MaintenancePlan] | None = None, last_executed: dict[str, date] | None = None)
Service for computing maintenance due dates.
This is a calendar-based baseline; future versions will account for operating hours and condition-based triggers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plans
|
list[MaintenancePlan] | None
|
Optional list of maintenance plans to manage. |
None
|
last_executed
|
dict[str, date] | None
|
Optional mapping of plan ID to last execution date. |
None
|
next_due_date ¶
Calculate the next due date for a maintenance plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
MaintenancePlan
|
The maintenance plan. |
required |
last_executed
|
date
|
Date the plan was last executed. |
required |
Returns:
| Type | Description |
|---|---|
date
|
The next calendar date the maintenance is due. |
is_overdue ¶
Check whether a maintenance plan is overdue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
MaintenancePlan
|
The maintenance plan. |
required |
last_executed
|
date
|
Date the plan was last executed. |
required |
today
|
date | None
|
Reference date (defaults to today). |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the plan is past its due date. |
find_window ¶
Find the next available maintenance window for an asset.
Returns a suggested window based on the asset's maintenance plans and last execution dates. In future versions this will integrate with calendar connectors to check production schedules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
str
|
Target asset identifier. |
''
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dict with |
scan_due_plans ¶
Return maintenance plans due within the given horizon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
horizon_days
|
int | str
|
Number of days to look ahead (accepts str for workflow template compatibility). |
14
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A list of dicts with plan details and due dates. |