mineproductivity.ontology¶
Auto-generated API reference for the Ontology package, rendered from the package's own docstrings. For the narrative overview, dependency rules, and extension guide, see Packages -> Ontology.
ontology ¶
mineproductivity.ontology -- the typed, machine-readable model of
the mining world.
Implements the ten sub-ontology families (equipment, material, location,
organization, production, maintenance, cost, quality, safety,
environmental) plus the cross-cutting entity-type root, relationships,
reference data, and the Knowledge Graph projection contract, per
docs/architecture/02_Ontology_Framework_Design_Specification.md.
ontology depends only on core -- see README.md for the full
set of architectural rules this package must satisfy.
Everything documented here is part of the public API and can be imported
directly from mineproductivity.ontology, e.g.::
from mineproductivity.ontology import RigidHaulTruck, Pit, Bench, Shift
CostCategory ¶
Bases: Enum
The cost categories a :class:CostCenter can classify spend
under, each mapping to a corresponding COST.* KPI namespace.
CostCenter
dataclass
¶
Bases: BaseEntityType
A cost center scoped to a
:class:~mineproductivity.ontology.organization.business_unit.BusinessUnit.
Examples:
>>> cc = CostCenter(id="CC-FUEL-01", business_unit_id="bu-1", category=CostCategory.FUEL)
>>> cc.category
<CostCategory.FUEL: 'fuel'>
BaseEntityType
dataclass
¶
Bases: BaseEntity[str], ABC
Root of every ontology entity type.
A concrete leaf (RigidHaulTruck, Pit, Shift, ...) is a
frozen dataclass subclass declaring a unique code: ClassVar[str]
(the stable registry key), a meta: ClassVar[EntityTypeMetadata],
and whatever domain fields the type needs. Neither code nor
meta is given a default at this level: a leaf type that forgets
to declare one fails loudly (AttributeError) the first time
either is read (e.g. by :meth:to_schema or the entity type
registry), rather than silently inheriting a placeholder value.
Inherits :class:~mineproductivity.core.entity.BaseEntity's
identity-based equality (two instances with the same id are equal
regardless of other fields), consistent with the Cookbook's rule that
entities are identity-bearing, not value-bearing.
Unlike :class:~mineproductivity.core.value_object.BaseValueObject,
core.BaseEntity defines no __post_init__/validate() hook
of its own (entities were not previously built on top of it by any
implemented package). Since the design specification requires
structural validation to be "enforced at construction" (§19),
BaseEntityType adds that hook locally -- mirroring
BaseValueObject's _normalize()/validate() pattern exactly
-- without modifying the locked core package.
validate ¶
Override to enforce invariants on this entity type's fields.
The default implementation does nothing (no invariants).
Raises:
| Type | Description |
|---|---|
Exception
|
Any exception may be raised to reject invalid state;
:class: |
to_schema ¶
Export this type's shape as JSON Schema -- read by dashboards, validation, and AI agents without touching source code. Cached per concrete type after the first call, since the schema is static for a given type version.
EntityTypeMetadata
dataclass
¶
EntityTypeMetadata(name, *, description='', tags=frozenset(), attributes=dict(), supported_kpis=(), parent_code=None)
Bases: BaseMetadata
Every entity type's descriptive metadata, in addition to
:class:~mineproductivity.core.metadata.BaseMetadata's
name/description/tags/attributes.
Mandatory per the metadata-first principle: a blank field here is a specification gap (mirrors the KPI Standard Library's completeness discipline).
EmissionFactor
dataclass
¶
Bases: BaseEntityType
A governed emission factor for one resource type (e.g. diesel,
grid power), feeding CARBON.* KPIs.
Examples:
>>> factor = EmissionFactor(id="diesel-factor", resource_type="diesel", kg_co2e_per_unit=2.68)
>>> factor.kg_co2e_per_unit
2.68
MonitoringPoint
dataclass
¶
LHD
dataclass
¶
Bases: EquipmentType
A Load-Haul-Dump unit -- the underground counterpart to a surface loader/truck pairing, combining loading and short-haul tramming.
ArticulatedHaulTruck
dataclass
¶
Bases: EquipmentType
An articulated (frame-steered) haul truck, typically used underground or on poor-condition surface haul roads.
BlastholeDrill
dataclass
¶
Conveyor
dataclass
¶
Crusher
dataclass
¶
Dozer
dataclass
¶
EquipmentType
dataclass
¶
Bases: BaseEntityType, ABC
Abstract root for every machine in the mine.
Common behaviour (the operational state machine, availability-KPI applicability) lives here; specifics (rated capacity, cycle-level KPIs) live in leaves -- the inheritance split demonstrated in Cookbook Part I, Ch. 8.
Grader
dataclass
¶
HydraulicShovel
dataclass
¶
Mill
dataclass
¶
OperationalState ¶
Bases: Enum
The four-state machine every equipment leaf type inherits.
Declared here as descriptive metadata only -- tracking which state an
instance is currently in is a future digital_twin concern,
derived from the event stream, never mutable state on the entity
itself (design spec AD-ON-04).
RigidHaulTruck
dataclass
¶
WaterTruck
dataclass
¶
WheelLoader
dataclass
¶
Bases: EquipmentType
A wheeled front-end loader, used for loading, stockpile rehandling, or as a secondary loading unit.
OntologyValidationError ¶
Bases: ValidationError
A :class:~mineproductivity.ontology.entity_type.BaseEntityType
instance failed structural or contextual validation.
RelationshipError ¶
Bases: MineProductivityError
A :class:~mineproductivity.ontology.relationship.Relationship
references a source_id/target_id that cannot be resolved, or
declares a :class:~mineproductivity.ontology.relationship.RelationshipKind
invalid for the two entity types involved.
UnknownEntityTypeError ¶
GraphEdge
dataclass
¶
Bases: BaseValueObject
One edge in a Knowledge Graph projection -- either an ontology relationship or a KPI dependency.
GraphNode
dataclass
¶
Bases: BaseValueObject
One node in a Knowledge Graph projection -- either an ontology entity or a KPI.
KnowledgeGraphProjection ¶
Bases: ABC
The contract a future Knowledge Graph builder consumes to project this package's declared entities and relationships into nodes and edges, so "the graph can never drift from the ontology" (Cookbook Part I, Ch. 8, Architecture Insight).
Traversal (neighbors/path/search) is explicitly NOT part
of this contract (design spec §4) -- it belongs to a future
graph-adjacent capability that consumes this projection, not to
ontology itself.
Bench
dataclass
¶
Drive
dataclass
¶
Bases: BaseEntityType
An underground drive (horizontal access tunnel) connecting a level to a stope or another drive.
Level
dataclass
¶
Bases: BaseEntityType
Underground sibling of
:class:~mineproductivity.ontology.location.pit.Bench: a horizontal
working level within an underground mine.
Mine
dataclass
¶
Bases: BaseEntityType
The top-level mine site entity: a named operation producing one or more commodities under one mining method.
Examples:
>>> mine = Mine(id="bingham-west", commodity_codes=("copper",), method="open_pit")
>>> mine.method
'open_pit'
Pit
dataclass
¶
Bases: BaseEntityType
An open pit within a mine.
Examples:
>>> west = Pit(id="pit-west", mine_id="bingham-west", commodity="copper")
>>> west.mine_id
'bingham-west'
Route
dataclass
¶
Bases: BaseEntityType
A haul route: a source -> destination pair with a one-way distance.
Examples:
>>> route = Route(
... id="B7N_CR1", source_zone_id="B7N", destination_zone_id="CR1",
... one_way_km=3.2, effective_grade_pct=8.5,
... )
>>> route.one_way_km
3.2
Stope
dataclass
¶
Zone
dataclass
¶
Bases: BaseEntityType
A named area within a mine (a dump, a stockpile, a haul-road
segment, a geofenced hazard area, ...). The generic location unit
other entities (:class:Route, a future
:class:~mineproductivity.ontology.safety.hazard.HazardZone) attach
speed limits, distances, and other spatial attributes to.
FailureMode
dataclass
¶
Bases: BaseEntityType
A classified equipment failure mode (e.g. HYD-001 for a
hydraulic failure), the reference taxonomy
:class:~mineproductivity.events.canonical.maintenance_event.MaintenanceEvent
instances point at.
Examples:
>>> mode = FailureMode(id="HYD-001", failure_mode_code="HYD-001", system="hydraulic")
>>> mode.system
'hydraulic'
MaintenanceWorkOrder
dataclass
¶
Bases: BaseEntityType
A maintenance work order's structural shape -- identity, the equipment it targets, and whether it is planned. Scheduling logic (assignment, prioritisation, execution) is explicitly out of scope for this package (design spec §2); this entity exists purely so other packages have a stable structural reference to point at.
Commodity
dataclass
¶
MaterialType ¶
Bases: Enum
Whether a given tonne of material is ore, waste, or a processed product.
BusinessUnit
dataclass
¶
Bases: BaseEntityType
An enterprise business unit that one or more mines roll up to --
the scope :class:~mineproductivity.ontology.cost.cost_center.CostCenter
and cross-site benchmarking (Cookbook Part I, Ch. 6) are computed
against.
Contractor
dataclass
¶
Crew
dataclass
¶
Fleet
dataclass
¶
Bases: BaseEntityType
A named group of equipment of one :class:~mineproductivity.ontology.equipment.equipment_type.EquipmentType.
Examples:
>>> fleet = Fleet(id="FL-NORTH", mine_id="pilbara-ridge", equipment_type_code="RIGID_HAUL_TRUCK")
>>> fleet.equipment_type_code
'RIGID_HAUL_TRUCK'
Operator
dataclass
¶
Bases: BaseEntityType
An equipment operator, linked to cycle and delay events for operator-level KPI dimensions.
Examples:
>>> op = Operator(id="OP-001", crew_id="A", licence_class="Haul Truck")
>>> op.licence_class
'Haul Truck'
Shift
dataclass
¶
Bases: BaseEntityType
One scheduled production shift: a UTC time window plus its
scheduled-hours denominator (the authoritative basis for
UTIL.PA/UTIL.UA per the KPI Engine spec's canonical time model).
Examples:
>>> from datetime import timezone
>>> shift = Shift(
... id="A-2026-06-25", mine_id="bingham-west", pattern="2x12",
... start_utc=datetime(2026, 6, 25, 6, tzinfo=timezone.utc),
... end_utc=datetime(2026, 6, 25, 18, tzinfo=timezone.utc),
... scheduled_h=12.0,
... )
>>> shift.contains(datetime(2026, 6, 25, 7, tzinfo=timezone.utc))
True
contains ¶
Half-open interval test: start_utc <= t < end_utc (the
Learning & Benchmark Suite's shift-assignment rule).
ShiftCalendar
dataclass
¶
Bases: BaseEntityType
The master shift reference table for one mine (the Learning &
Benchmark Suite's shared/shift_calendar.csv): declares the
pattern and timezone convention every :class:Shift instance at
that mine must conform to.
ShiftPattern ¶
Bases: Enum
Common shift patterns mines operate under.
GradeAttribute
dataclass
¶
Bases: BaseEntityType
A measurable grade/quality attribute for one commodity (e.g. "% Cu", "g/t Au").
Examples:
>>> grade = GradeAttribute(id="head-grade-cu", commodity_code="copper", unit="% Cu")
>>> grade.unit
'% Cu'
QualitySpecification
dataclass
¶
DelayCategory ¶
Bases: Enum
The six mutually-exclusive, collectively-exhaustive delay
categories, ruled canonical in Developer & Cookbook Guide Part III,
"Canonical Semantics". Owned here as ontology reference data;
consumed by events.DelayEvent and every UTIL/DELAY KPI.
precedence
property
¶
Lower number wins when a delay could plausibly belong to more than one category (e.g. refuelling during a breakdown).
Relationship
dataclass
¶
Bases: BaseValueObject
A declared, typed edge between two entity ids.
Relationships are how "by pit" or "by fleet" slicing resolves: a
:class:~mineproductivity.ontology.location.pit.Bench and a
:class:~mineproductivity.ontology.location.pit.Pit are independent,
independently serializable entities; Relationship is the explicit
edge connecting them, deliberately not an object-graph pointer (see
the design specification's AD-ON-02).
Examples:
>>> edge = Relationship(source_id="bench-7", kind=RelationshipKind.BELONGS_TO, target_id="pit-west")
>>> edge.kind
<RelationshipKind.BELONGS_TO: 'belongs_to'>
RelationshipKind ¶
Bases: Enum
The five relationship kinds the ontology declares between entities.
HazardZone
dataclass
¶
Bases: BaseEntityType
A geofenced zone with a governed speed limit -- the reference a
SAFE.SpeedViolationRate-style KPI resolves "violation" against.
Examples:
>>> zone = HazardZone(id="B7N_CR1", zone_id="B7N_CR1", speed_limit_kmh=45.0)
>>> zone.speed_limit_kmh
45.0
SafetyEventType ¶
Bases: Enum
The leading safety-indicator kinds a safety event can record.
SpeedLimitMap
dataclass
¶
Bases: BaseEntityType
A mine-wide map of zone id -> governed speed limit, the single
source of truth SAFE.SpeedViolationRate and similar KPIs read to
decide whether a given speed reading was a violation.
OntologyValidator ¶
Bases: BaseValidator[BaseEntityType]
Contextual validation for a constructed
:class:~mineproductivity.ontology.entity_type.BaseEntityType
instance, separate from the structural field validation every leaf
type already enforces on construction.
Checks two kinds of cross-entity reference by field-naming convention:
- A field named
*_type_code(e.g.Fleet.equipment_type_code) is checked against this package's own entity type registry --ontologyowns that registry, so this resolution never needs external help. - A field named
*_id(e.g.Bench.pit_id) is checked against the optional, injectableentity_resolvercallback --ontologydoes not persist entity instances itself (design spec §4), so instance-level resolution can only happen once a caller (a future config/datasets loader) supplies one. Without a resolver, instance -level references are not checked (structural validation at construction is still always enforced regardless).
An unresolved reference is always a warning in the returned
:class:~mineproductivity.core.validator.ValidationResult, never a
raised exception -- Cookbook Part I, Ch. 8's rule that an orphaned
reference must never silently halt ingestion of everything else.
Examples:
>>> from mineproductivity.ontology import Fleet
>>> validator = OntologyValidator()
>>> fleet = Fleet(id="FL-NORTH", mine_id="pilbara-ridge", equipment_type_code="RIGID_HAUL_TRUCK")
>>> validator.validate(fleet).is_valid
True
>>> bad_fleet = Fleet(id="FL-BAD", mine_id="pilbara-ridge", equipment_type_code="NOT_A_REAL_TYPE")
>>> validator.validate(bad_fleet).is_valid
False
register_equipment ¶
Register cls into the internal entity type registry, keyed by
cls.code. Applied as a decorator to every concrete leaf type
across all ten sub-ontology families (register_equipment in
ontology.equipment is a documented alias of this same function,
for readability at equipment-specific call sites).
Raises:
| Type | Description |
|---|---|
DuplicateError
|
If |