03 — Integration

Scheduled Maintenance is a member of the Work & Supply network (message protocol v1) with the network domain schedule. Its contract is schema/maintenance_schedule.integration.dsl (authoring spec v1.5), generated with python -m codegen.cli integration maintenance_schedule --network work_supply; the handlers are in integration/handlers.py. The whole network is in networks/work_supply/NETWORK_MAP.md.

What it owns

Network entity Model Business reference
schedule.item ScheduleItem item_number (SI-{sequence:05})

Messages

Kind Message What
publishes schedule.item_due / schedule.item_overdue an item reached its due point / passed its tolerance
publishes schedule.item_deferred an item was deferred beyond the plan's tolerance (Assurance decides whether it is material)
consumes work.work_order_created the order Work raised for an item (its cause is the item's command)
consumes work.work_closed matched by the stored order: last done, reset the lesser services, next cycle
consumes asset.group_assignment_changed, asset.status_changed generate or close a unit's items
consumes lifecycle.life_due, lifecycle.life_forecast_changed life items
consumes *_reference_changed of templates, groups, assets, SMCS codes, usage metric types readable references stay current
accepts schedule.defer_item, schedule.recalculate
answers schedule.upcoming, schedule.item_status read-only
sends work.create_work_order the command that raises an item's order (accepted by Work from this application)
reads lifecycle.current_usage, usage_at, life_status, asset.group_membership, group_units, current_configuration, profile, work.work_order_status, work.search_maintenance_templates synchronous, read-only lookups

How an item reaches Work

The handler queues work.create_work_order in the outbox, in the same transaction, with the unit, a title, the plan's template (work_template_cid / work_template_ref; no work type) and source_entity_type = schedule.item / source_entity_cid. The command's message id is SCHED-<item cid>:<due date>:<n>: the same item and due point is the same command (a retry cannot raise a second order), and the work.work_order_created event Work raises while handling it names it as its cause, which is how the item learns its order. n rises when an earlier order was cancelled or the item was reopened.

References

asset.asset, asset.asset_group (pickers), classification.smcs (picker), work.maintenance_template (picked with work.search_maintenance_templates), lifecycle.usage_metric_type (picked with lifecycle.search_usage_metric_types) and work.work_order. The Work template fields are maintenance_template_cid / _ref (a reference to a Work template must end in the entity's name).