src.dackar.RCA.cmms_integration.cmms_adapter¶
cmms_adapter — CMMSContextAdapter Protocol, NoOpCMMSAdapter, MockCMMSAdapter.
Concrete live adapters (MaximoCMMSAdapter, SAPPMCMMSAdapter) live in separate files and implement the same Protocol. See CMMS_INTEGRATION_GUIDE.md for the implementation skeleton.
Attributes¶
Classes¶
Protocol for live CMMS data adapters. |
|
Silently returns empty CR and WO lists. |
|
Returns configurable fixture CR and WO records. |
Functions¶
|
Map a raw CMMS status code to the cmms_context schema enum. |
Module Contents¶
- src.dackar.RCA.cmms_integration.cmms_adapter.normalize_cmms_status(raw_status)[source]¶
Map a raw CMMS status code to the cmms_context schema enum.
Recognizes every documented Maximo and SAP PM code plus the already- normalized values; any unrecognized or empty value maps to
"unknown"so the artifact never carries a status outsideschemas/cmms_context.json(statusenum:open/closed/cancelled/unknown).- Parameters:
raw_status (Any)
- Return type:
str
- class src.dackar.RCA.cmms_integration.cmms_adapter.CMMSContextAdapter[source]¶
Bases:
ProtocolProtocol for live CMMS data adapters.
Implementations must be read-only with respect to the CMMS — no writes. Results should be idempotent for the same (asset_id, lookback window) inputs: calling fetch() twice with the same arguments must return the same records (within CMMS data consistency guarantees).
- fetch(primary_asset_id, sister_component_ids, lookback_from, lookback_to, event)[source]¶
Fetch CR and WO records from the CMMS.
- Parameters:
primary_asset_id (str) – Asset ID of the event asset. Used as the primary query scope.
sister_component_ids (List[str]) – KG component IDs of sister equipment (same_train / adjacent). These are opaque KG identifiers; a live adapter must resolve them to CMMS FLOCs / equipment IDs (via the
maximo_floc/sap_equipment_idKG properties, the same lookupCAPExportSerializeruses) before querying. This Protocol passes only the IDs, so an adapter that needs the mapping must be constructed with its own KG/FLOC resolver (or a site config table). Threading a schema-shaped query scope (component ID + FLOC + equipment ID) or a KG resolver throughfetch()itself is a planned contract enhancement, deferred to the live-adapter / injection MR — see CMMS_INTEGRATION_GUIDE.md §4.lookback_from (str) – ISO-8601 UTC timestamp — start of the query window (inclusive). Derived from the last PM date on the primary asset, or the event_time minus the configured fallback window.
lookback_to (str) – ISO-8601 UTC timestamp — end of the query window (inclusive). Typically the event timestamp.
event (JsonDict) – The raw event dict, passed for adapter-specific context (e.g., failure mode keywords for full-text search).
- Returns:
Must contain at minimum:
{"cr_records": [...], "wo_records": [...]}Each record should include at least: an ID field,status,short_description,created_date, andis_sister_equipment.- Return type:
dict
- class src.dackar.RCA.cmms_integration.cmms_adapter.NoOpCMMSAdapter[source]¶
Silently returns empty CR and WO lists.
Used in unit tests, CI, and deployments where no CMMS connection is available. Makes no network calls and has no external dependencies.
- class src.dackar.RCA.cmms_integration.cmms_adapter.MockCMMSAdapter(cr_records=None, wo_records=None, filter_by_asset=False)[source]¶
Returns configurable fixture CR and WO records.
Designed for unit testing
CMMSContextBuilderand the synthesizer prompt without a live CMMS connection.- Parameters:
cr_records (Optional[List[JsonDict]]) – List of CR record dicts to return from
fetch(). Each dict should follow thecmms_context.jsonschemacr_recordsitem structure (minus derived fields thatCMMSContextBuildercomputes:days_before_event,component_id).wo_records (Optional[List[JsonDict]]) – List of WO record dicts to return from
fetch().filter_by_asset (bool) – If
True, only records whosefunctional_locationorequipment_idcontainsprimary_asset_id(case-insensitive substring) are returned for the primary scope; all others are treated as sister records. Defaults toFalse(all records returned regardless of asset).