A flat table can't answer "Supplier Acme is late, which customers are affected?" An ontology names the links from supplier to part to product to customer, so the agent answers Kestrel and Orbis and shows the path as proof.
python3 --version.git clone https://github.com/DayanEbrar0X/data-anatomy.ai.git cd data-anatomy.ai
python3 -m venv .venv source .venv/bin/activate
cd methodologies/04-ontology python3 src/ontology.py
from facts import FACTS
# the ontology: types, and how they connect
ONTOLOGY = [("Supplier", "supplies", "Part"),
("Part", "used_in", "Product"),
("Product", "ordered_by", "Customer")]
def follow(start, path):
found = {start}
for rel in path:
found = {o for s, r, o in FACTS
if s in found and r == rel}
print(rel, "->", sorted(found))
return sorted(found)
path = [rel for _, rel, _ in ONTOLOGY]
print("affected:", follow("Acme", path))One late supplier. Which customers get hurt? Your AI agent often can't tell you. The fix is an ontology: a map of what things are, and how they link.
Say supplier Acme is running late. Each link lives in a different system. Search the orders for Acme: nothing. An ontology gives every thing a type, and every link a name.
Like a family tree: named links let you find any cousin. In code, the facts are triples: thing, relation, thing. The ontology is triples too, about types. Suppliers supply parts.
Parts are used in products. Products are ordered by customers. The follow function starts from one thing. For each relation, it keeps everything linked to what it found.
It prints each hop and returns the result. The path isn't guessed. It's read from the ontology. Then it follows that path from Acme.
Let's run it. Hop one: a bolt and a hinge. Hop two: the drone and the locker. Hop three: Kestrel and Orbis.
Two customers. Vela only buys pumps, so it's safe. Real companies run on ERP, CRM, and more. One ontology gives every system the same supplier, part and customer.
So agents follow links instead of guessing. Fewer hallucinations, and every answer shows its path. Types, links, one path. Now your agent can tell you.
Read the lesson on GitHub →