Enterprise Ontologies & Messy Legacy Integration
Unify fragmented ERP, mainframe, and SFTP feeds into an operational Ontology with entity resolution, schema-drift quarantine, and safe idempotent writeback.
In this lesson (4 bite-sized sections)
The operational Ontology: Objects, Links, Actions, and ACLs
Large enterprises rarely store business truth in one database. Customer, order, and facility state lives scattered across SAP ERP tables, COBOL mainframe nightly drops, partner SFTP folders, and SaaS webhooks. Querying raw tables directly forces every downstream app and AI agent to re-implement fragile joins and permission checks.
An operational Ontology replaces ad-hoc table joins with a unified domain layer built from four primitives: typed Objects (Facility, Shipment, PurchaseOrder), typed Links (Facility holds InventoryLot), governed Actions (ApproveTransfer, HoldShipment), and row-level ACLs enforced uniformly across dashboards, APIs, and agents. Unlike a read-only BI semantic layer that only computes metrics, an operational Ontology governs state transitions with validation rules, role checks, and immutable audit logs.
Operational Ontology and safe legacy writeback: an architecture diagram of 8 components and 8 connections. Full description follows.
- SAP ERP & Mainframe Drops: external system, in Legacy Source Systems.
- SFTP Feeds & Webhooks: external system, in Legacy Source Systems.
- Entity Resolution & Lineage: service, in Unified Ontology Plane.
- Schema-Drift Quarantine: queue or log, in Unified Ontology Plane.
- Operational Ontology (Objects, Links, ACLs): database, in Unified Ontology Plane.
- Action Service & HITL Approval: service, in Governed Writeback Path.
- Idempotent Writeback Outbox: queue or log, in Governed Writeback Path.
- Legacy Writeback Connector: service, in Governed Writeback Path.
- SAP ERP & Mainframe Drops sends asynchronously to Entity Resolution & Lineage (batch / CDC).
- SFTP Feeds & Webhooks sends asynchronously to Entity Resolution & Lineage (file drop).
- Entity Resolution & Lineage sends asynchronously to Schema-Drift Quarantine (contract breach).
- Entity Resolution & Lineage calls synchronously Operational Ontology (Objects, Links, ACLs) (golden objects).
- Operational Ontology (Objects, Links, ACLs) calls synchronously Action Service & HITL Approval (ACL-checked read).
- Action Service & HITL Approval calls synchronously Idempotent Writeback Outbox (idempotency token).
- Idempotent Writeback Outbox sends asynchronously to Legacy Writeback Connector (retryable dispatch).
- Legacy Writeback Connector feeds back into SAP ERP & Mainframe Drops (governed writeback).
Deterministic and probabilistic entity resolution with provenance
Legacy systems almost never share primary keys. SAP records a clinic as CUST-00419, while a regional warehouse drop lists St. Jude N. Wing with an abbreviated street address. Entity resolution bridges those silos in two stages: deterministic matching first (tax ID, DUNS, verified crosswalk tables), followed by probabilistic matching (blocking by ZIP code or region, then scoring weighted name, address, and phone similarity).
Route probabilistic scores into three bands: auto-merge above a high confidence threshold, send borderline pairs to a human data-steward queue, and keep low scores separate. Crucially, every golden Object must retain immutable source records plus field-level provenance (source system, batch timestamp, and survivorship priority). Without provenance, operators cannot trust why an address changed and engineers cannot unmerge false-positive matches cleanly.
Schema-drift quarantine and contract boundaries
Upstream ERP admins and third-party vendors regularly rename CSV headers, inject currency symbols into numeric fields, or shift fixed-width mainframe columns with zero warning. Enforce versioned schema contracts right at the ingestion edge. Additive nullable fields can log a warning and pass; breaking changes (missing join keys, type failures, or sudden 90% row-count drops) must route to a schema-drift quarantine queue while the Ontology continues serving its last known good snapshot with a visible staleness badge.
Assign each responsibility to either the Read & Resolution Layer or the Governed Writeback Layer.
Sort 4 more items to check
Safe bidirectional writeback to legacy systems
Reading legacy data carries modest blast radius; writing back to SAP, Oracle, or a decades-old mainframe is where enterprise rollouts fail hard. Legacy endpoints routinely lack native idempotency, lock tables during overnight batch windows, or drop connections after committing internally.
Hardened FDE writeback rests on four controls: idempotency tokens persisted in a durable outbox so retries never duplicate orders; dry-run diffs displaying exact before/after changes to operators before submission; human-in-the-loop (HITL) approval queues for mutations above risk or dollar limits; and compensating actions (explicit credit or cancellation entries) when a cross-system workflow fails mid-flight, since distributed two-phase commit rarely exists across legacy ERP boundaries.
Recap: model fragmented legacy feeds as governed Ontology Objects, Links, Actions, and ACLs; preserve source provenance for reversible entity resolution; quarantine schema drift at ingest; and guard every legacy writeback with idempotency tokens, dry-run diffs, HITL approvals, and compensating actions.
Sources: Palantir Foundry Ontology Overview · Microservices.io, Saga Pattern · Stripe Engineering, Designing Robust Idempotency
import hashlib
import re
SOURCES = [
{"src": "SAP", "ext_id": "CUST-419", "name": "St. Jude N. Wing", "zip": "60611"},
{"src": "WMS", "ext_id": "W-882", "name": "St Jude N Wing!", "zip": "60611"},
]
ontology, writeback_log = {}, {}
for rec in SOURCES:
clean = re.sub(r"[^a-z0-9]+", "", rec["name"].lower())
gid = "FAC-" + hashlib.sha256(f"{clean}:{rec['zip']}".encode()).hexdigest()[:6]
obj = ontology.setdefault(gid, {"id": gid, "sources": [], "name": None, "provenance": {}})
obj["sources"].append(f"{rec['src']}:{rec['ext_id']}")
if obj["provenance"].get("name") != "SAP": # SAP wins canonical name
obj["name"], obj["provenance"]["name"] = rec["name"], rec["src"]
def dispatch_writeback(action_id: str, facility_id: str, payload: dict) -> str:
if action_id in writeback_log:
return f"DEDUPED ({action_id} -> {writeback_log[action_id]})"
writeback_log[action_id] = {"facility": facility_id, **payload}
return f"COMMITTED ({action_id})"
gid = next(iter(ontology))
print("Golden objects:", list(ontology.values()))
print("Attempt 1:", dispatch_writeback("act-9001", gid, {"hold": True}))
print("Attempt 2:", dispatch_writeback("act-9001", gid, {"hold": True}))Apply
Your turn
The task this lesson builds to.
Specify an operational Ontology and bidirectional writeback layer for a medical-device distributor reconciling inventory across an on-prem SAP ERP, three regional warehouse SFTP drops, and a cloud CRM.
Think about
- What core Objects, Links, Actions, and row-level ACL boundaries belong in the Ontology?
- How do you resolve mismatched facility and SKU identifiers while keeping merges reversible?
- How do you stop an unexpected warehouse CSV header change from zeroing out live stock counts?
- What controls make order-release and lot-hold writebacks into SAP safe under timeouts and retries?
Draft your design answer here Save your draft, compare against the model answer, and track progress.
Practice
Make it stick
A second problem on the same idea, so it survives past today.
Walk through an incident postmortem where an overnight vendor CSV changed 'qty_on_hand' to 'quantity_available', causing the ingestion script to coerce missing counts to zero and trigger 400 automated restock orders in SAP, 35 of which duplicated after gateway timeouts. Diagnose every control failure and propose the hardened architecture.
Think about
- Where should the renamed CSV header have been caught before reaching inventory state?
- Why were 400 automated restock orders able to fire without a human or anomaly circuit breaker?
- How did gateway timeouts turn 35 orders into duplicates inside SAP, and how do you reconcile them now?
Draft your design answer here Save your draft, compare against the model answer, and track progress.