Version: 1.1.0Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Last Updated: 2026-03-06
Owner: FM (Facilities Management)
Overview
This document defines the integration contracts for the Facilities Management (FM) core module. All FM events follow the standard event contract pattern defined inEVENT_CONTRACTS.md.
Event Categories
1. Work Order Events (FM-01)
work_order_created
Published when: A work order is created (request, scheduled, PM-generated, or inspection-generated).
- PF-10 (Notifications): Notify facilities manager of new work orders
- FA (Finance): Track pending maintenance costs
work_order_completed
Published when: A work order status changes to completed.
- FA (Finance): Create cost allocation journal entries
- FM-04 (Preventive Maintenance): Update PM schedule next due date
- FM-05 (Asset Management): Update asset maintenance history
- FM-06 (Compliance): Update inspection compliance status
- FM-03 (Vendor Management): Update vendor performance metrics
work_order_overdue
Published when: A work order passes its due date without completion.
- PF-10 (Notifications): Alert facilities manager and assigned technician/vendor
2. Inventory Events (FM-02)
inventory_low_stock
Published when: Inventory quantity falls below reorder point.
- PF-10 (Notifications): Alert procurement manager
- FA-04 (Purchase Orders): Auto-create purchase order (if enabled)
inventory_item_used
Published when: Inventory is used on a work order (usage transaction created).
- FM-01 (Work Orders): Update work order material cost
- FA (Finance): Track inventory cost allocation
3. Vendor Events (FM-03)
vendor_certification_expiring
Published when: Vendor certification is within 90/60/30 days of expiration.
- PF-10 (Notifications): Alert compliance officer and facilities manager
- GR (Governance): Track compliance status
vendor_work_order_assigned
Published when: A work order is assigned to an external vendor.
- PF-10 (Notifications): Notify vendor of assignment
- FA-03 (Accounts Payable): Prepare for vendor invoice matching
4. Preventive Maintenance Events (FM-04)
pm_due
Published when: A PM schedule is due (work order auto-generated).
- PF-10 (Notifications): Alert facilities manager and assigned technician
- FM-05 (Asset Management): Track upcoming maintenance
pm_overdue
Published when: A PM schedule passes its due date without completion.
- PF-10 (Notifications): Alert facilities manager and compliance officer
- GR (Governance): Track compliance violations
pm_completed
Published when: A PM work order is completed.
- FM-05 (Asset Management): Update asset maintenance history
- FA (Finance): Track maintenance costs
5. Asset Events (FM-05)
asset_purchased
Published when: A new asset is created/registered.
- FA (Finance): Create capitalization journal entry
asset_disposed
Published when: An asset status changes to disposed.
- FA (Finance): Create disposal journal entry
- FM-04 (Preventive Maintenance): Deactivate PM schedules for asset
asset_warranty_expiring
Published when: Asset warranty is within 90/60/30 days of expiration.
- PF-10 (Notifications): Alert compliance officer and asset manager
6. Inspection & Compliance Events (FM-06)
inspection_due
Published when: An inspection schedule is due (work order auto-generated).
- PF-10 (Notifications): Alert inspector and compliance officer
- GR (Governance): Track upcoming compliance inspections
inspection_failed
Published when: An inspection is completed with failed checklist items.
- PF-10 (Notifications): Alert facilities manager and compliance officer
- GR (Governance): Track compliance violations
- FM-01 (Work Orders): Create corrective action work order
inspection_compliant
Published when: An inspection is completed with all checklist items passed.
- GR (Governance): Update compliance status
- FM-05 (Asset Management): Update asset inspection history (if asset-based)
Cross-Module Dependencies
FM-04 ↔ FM-05 Circular Dependency Resolution
Issue: FM-04 (Preventive Maintenance) and FM-05 (Asset Management) have mutual dependencies:- FM-04 PM schedules reference assets (FM-05)
- FM-05 asset maintenance history references PM completions (FM-04)
- Database Level: Use foreign key references with
ON DELETE SET NULLwhere appropriate to allow independent table creation - Event-Based Updates: Use events (
pm_completed,asset_disposed) for cross-module state updates rather than direct queries - Implementation Order:
- Phase 1: Implement FM-05 base tables (fm_assets)
- Phase 2: Implement FM-04 with asset references
- Phase 3: Add FM-05 maintenance history integration via events
- RLS Policies: Both use
fm_has_org_access()SECURITY DEFINER function to avoid RLS recursion
RLS Security Pattern
All FM tables use thefm_has_org_access() SECURITY DEFINER function for RLS policies to avoid infinite recursion:
FA Integration Dependencies
The following FA specs are referenced by FM but not yet implemented:- FA-03 (Accounts Payable): Vendor invoice matching, payment tracking
- FA-04 (Purchase Orders): Auto-create POs from low stock alerts
- FM publishes events; FA will consume when implemented
- FM stores
purchase_order_idandvendor_invoice_idas nullable foreign keys - No blocking dependencies; FM can operate independently
Event Publishing Pattern
7. Fleet Management Events (FM-13)
vehicle_registered
Published when: A new vehicle is registered in the fleet.
- PF-10 (Notifications): Notify fleet manager of new vehicle
- FM-05 (Asset Management): Link to asset record if created
vehicle_status_changed
Published when: Vehicle status changes (active → maintenance → retired → disposed).
- PF-10 (Notifications): Alert fleet manager of status change
- FM-05 (Asset Management): Update asset status
license_expiring
Published when: Driver license is within 90/60/30 days of expiration.
- PF-10 (Notifications): Alert driver and fleet manager
- GR (Governance): Track compliance status
registration_expiring
Published when: Vehicle registration is within 90/60/30 days of expiration.
- PF-10 (Notifications): Alert fleet manager
- GR (Governance): Track compliance status
fleet_maintenance_due
Published when: A fleet vehicle maintenance schedule is due.
- PF-10 (Notifications): Alert fleet manager and assigned technician
- FM-01 (Work Orders): Track associated work order
fleet_maintenance_overdue
Published when: A fleet vehicle maintenance schedule is overdue.
- PF-10 (Notifications): Alert fleet manager with urgency
- GR (Governance): Track maintenance compliance violations
8. Budgeting & Planning Events (FM-09)
budget_variance_alert
Published when: A facilities budget line item exceeds its threshold variance (default: >10% over budget for approved budgets).
- PF-10 (Notifications): Alert facilities manager and finance manager
- FA-08 (Budgeting & Forecasting): Sync variance to FA budget module (📝 Planned — FA-08 not yet implemented; event replays when available)
9. Capital Planning Events (FM-12)
capital_project_approved
Published when: A capital project status changes to approved.
- FA-09 (Capital Projects): Create capital project record in FA (📝 Planned — FA-09 not yet implemented; event replays when available)
- PF-10 (Notifications): Notify requesting user and finance manager of approval
10. Energy Management Events (FM-10)
energy_anomaly_detected
Published when: Automated anomaly detection identifies abnormal energy usage (spike, off-hours usage, baseline deviation). Requires FM-10-DEFERRED-EXPANSION Phase 2 (smart meter integration) to be implemented.
- PF-10 (Notifications): Alert energy manager of anomaly
- GR (Governance): Track compliance if anomaly indicates equipment regulatory issue
11. Space Management Events (FM-11)
space_occupancy_threshold
Published when: A space’s recorded occupancy exceeds its configured capacity threshold.
- PF-10 (Notifications): Alert facilities manager
- HR (Human Resources): Space occupancy data for headcount planning (📝 Planned)
12. Analytics Events (FM-07)
facilities_report_generated
Published when: A scheduled or on-demand facilities analytics report is generated and available for export.
- PF-10 (Notifications): Notify requestor when report is ready
Consumer Verification Matrix
See: FM-CONSUMER-VERIFICATION.md (to be created as part of FM-14 implementation) for implementation status of each consumer.
| Event | Owner Spec | Status | FA Consumer | GR Consumer | PF-10 Consumer | HR Consumer |
|---|---|---|---|---|---|---|
work_order_created | FM-01 | ✅ Defined | 📝 Planned | — | 📝 Planned | — |
work_order_completed | FM-01 | ✅ Defined | 📝 Planned | — | 📝 Planned | — |
work_order_overdue | FM-01 | ✅ Defined | — | — | 📝 Planned | — |
inventory_low_stock | FM-02 | ✅ Defined | 📝 Planned (FA-04) | — | 📝 Planned | — |
inventory_item_used | FM-02 | ✅ Defined | 📝 Planned | — | — | — |
vendor_certification_expiring | FM-03 | ✅ Defined | — | 📝 Planned | ✅ Verified | — |
vendor_work_order_assigned | FM-03 | ✅ Defined | 📝 Planned (FA-03) | — | 📝 Planned | — |
pm_due | FM-04 | ✅ Defined | — | — | 📝 Planned | — |
pm_overdue | FM-04 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
pm_completed | FM-04 | ✅ Defined | 📝 Planned | — | — | — |
asset_purchased | FM-05 | ✅ Defined | 📝 Planned | — | — | — |
asset_disposed | FM-05 | ✅ Defined | 📝 Planned | — | — | — |
asset_warranty_expiring | FM-05 | ✅ Defined | — | — | 📝 Planned | — |
inspection_due | FM-06 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
inspection_failed | FM-06 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
inspection_compliant | FM-06 | ✅ Defined | — | 📝 Planned | — | — |
vehicle_registered | FM-13 | ✅ Defined | — | — | 📝 Planned | — |
vehicle_status_changed | FM-13 | ✅ Defined | — | — | 📝 Planned | — |
license_expiring | FM-13 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
registration_expiring | FM-13 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
fleet_maintenance_due | FM-13 | ✅ Defined | — | — | 📝 Planned | — |
fleet_maintenance_overdue | FM-13 | ✅ Defined | — | 📝 Planned | 📝 Planned | — |
budget_variance_alert | FM-09 | 📝 Planned | 📝 Planned (FA-08) | — | 📝 Planned | — |
capital_project_approved | FM-12 | 📝 Planned | 📝 Planned (FA-09) | — | 📝 Planned | — |
energy_anomaly_detected | FM-10 | 📝 Planned | — | 📝 Planned | 📝 Planned | — |
space_occupancy_threshold | FM-11 | 📝 Planned | — | — | 📝 Planned | 📝 Planned |
facilities_report_generated | FM-07 | 📝 Planned | — | — | 📝 Planned | — |
FM↔FA Finance Interface Summary
See: FM-16: FM↔FA Finance Interface for full interface contract.All FM→FA flows are non-blocking:
- FM publishes events to
pf_domain_events; FA subscribes when implemented - FM stores nullable FKs (
purchase_order_id,vendor_invoice_id) for future FA reconciliation - FM-09 and FM-12 use FM-local cost data; FA integration is an enhancement layer
Related Documentation
- EVENT_CONTRACTS.md - Standard event contract patterns
- API_CONTRACTS.md - API contract patterns
- PLATFORM_INTEGRATION_LAYERS.md - Platform integration patterns
- FM-14: Integration Contract Alignment
- FM-15: Backlog Delivery Orchestration
- FM-16: FM↔FA Finance Interface
- FM-01 Work Order Management
- FM-02 Inventory Management
- FM-03 Vendor Management
- FM-04 Preventive Maintenance
- FM-05 Asset Management
- FM-06 Compliance & Inspections
- FM-07 Facilities Analytics & Reporting
- FM-08 Mobile Field Operations
- FM-09 Facilities Budgeting & Planning
- FM-10 Energy Management
- FM-11 Space Management
- FM-12 Capital Planning
- FM-13 Fleet Management