---
title: "Discussion on \"Ontology-Based Context Engineering: When RAG Is Not Enough\" | Hashnode"
description: "Discussion on \"Ontology-Based Context Engineering: When RAG Is Not Enough\". Leveraging Large Language Models in Large Legacy Systems"
url: "https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Ontology-Based Context Engineering: When RAG Is Not Enough](https://elie29.hashnode.dev/ontology-based-context-engineering-when-rag-is-not-enough?utm_source=hashnode&utm_medium=feed)

Leveraging Large Language Models in Large Legacy Systems

Sep 11 · 36 min read · elie29.hashnode.dev  
Updated Sep 25  
Read the article

-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#context-engineering](https://hashnode.com/tag/context-engineering)
-   [#ontology](https://hashnode.com/tag/ontology)
-   [#llm](https://hashnode.com/tag/llm)
-   [#rag](https://hashnode.com/tag/rag)

## Written by

[Elie Nehmé](https://hashnode.com/@elie29)

@elie29 · France

  
[View profile](https://hashnode.com/@elie29)

Directeur Software & Solutions - Sopra Steria

Stratégie · Transformation · Ingénierie · Architecture

## Responses 6

Markdown supported · ⌘↵ to post

[Adam Lewis](https://hashnode.com/@nark3d)

[Sep 21](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6ab19b74c676071a6bc94a96)

Once the relationships between concepts are stated rather than inferred from embedding distance, the answer stops depending on the luck of the chunk. What I had been underestimating was how much the phrasing around the question steers the answer. Looking forward to the rest of it.

[Elie Nehmé](https://hashnode.com/@elie29)

[Sep 25](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6ab19b74c676071a6bc94a96#reply-6ab64fb82c44a281c0c99b5f)

Thank you for your feedback.

Exactly — that was one of the things that surprised me too. The question itself can steer retrieval more than we realize. Explicit relationships give the model a much more stable path. And I just realized I hadn't updated the article with the link to the second part — fixing that now. You can find more on my website: [https://elienehme.fr/en](https://elienehme.fr/en)

Thanks for reading!

[Salman Parvez | ML Systems](https://hashnode.com/@ml-systems)

[Sep 11](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6aa449bb7df0f7f5400a7c05)

"The meaning is never in one place" and "the documents contradict each other across versions" is the exact problem we hit with a house instead of a codebase. ML Systems builds an ontology for residential deconstruction, and the same building is described by a town assessor record, a homeowner's memory, satellite and street imagery, and seven AI agents that each write their own claims. They disagree constantly, and the disagreements are usually about the same node.

Two choices we made that might transfer back to your legacy-system case:

1.  The ontology types claims, not facts. Your "PKG\_INVOICE is described by specification v3" is true for one release and false for another; our "roof re-shingled in 2016" is STATED by the homeowner, absent from the assessor's RECORD, and MODELED by vision. Instead of resolving that at ingestion, every edge carries its source and an evidence grade (MEASURED > STATED > RECORD > MODELED), authority is scoped to a domain (the assessor is authoritative on legal and valuation facts, vision on the visible envelope, the homeowner on intent and recent work), and where two credible sources still collide the node resolves to a conflict state and stays there. The LLM is allowed to see the conflict. For a 20-year document trail I suspect the contradictions are the most valuable edges in the graph, not noise to clean out.
    
2.  Your "the model never describes what an artifact does internally" rule matches ours exactly. The Collective Ontology stores what a member is and what it touches (a rafter sits on the plate, ties to the ridge, is fastened through by the sheathing) and nothing about how; the disassembly sequence is derived from the edges as a DAG, not stored. The ontology grows by extending codes, not storage, which is your PR-on-Turtle-files loop with the reasoner swapped for a scheduler.
    

The territory article is the one I'd like to read. Extracting a reliable graph from contradictory sources is where our work sits too.

github.com/MLSystemsRI/ml-systems-public

[Elie Nehmé](https://hashnode.com/@elie29)

[Sep 11](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6aa449bb7df0f7f5400a7c05#reply-6aa44f691e6cb0aaf1b2a0d6)

Thank you so much, Salman, for your thoughtful and detailed feedback! I really appreciate that you read the article so closely and drew these parallels with your own work. I know how challenging and complex this kind of work can be.

My approach was shaped by the specific problems I encountered, and I don’t see it as a universal solution to every context-engineering problem. I haven’t faced the exact challenge you’re describing, so your perspective is particularly interesting to me.

Your approach of distinguishing claims from facts sounds particularly insightful. I also really like the idea of treating the ontology not as a cleaned-up representation of reality, but as what we currently have evidence to believe about reality. I’ll definitely take a closer look at your work!

Best regards,

Elie

[Elie Nehmé](https://hashnode.com/@elie29)

[Sep 11](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6aa449bb7df0f7f5400a7c05#reply-6aa456f598feddbb2c58936f)

I would like to add that one important difference I see between our cases is that, for a given version, the code ultimately has deterministic behavior, which is not necessarily the case when describing a house from different sources. A function cannot really do “yes and no” at the same time.

The rule may change from one version to another, and understanding why it changed is extremely valuable context. But at the end of the day, what matters most is being able to determine what the function actually does in that specific version.

So I think contradictions between documentation, specifications, historical sources, etc. are important to preserve as context and evidence, but they don't necessarily need to remain unresolved when it comes to the actual behavior of the code.

[Salman Parvez | ML Systems](https://hashnode.com/@ml-systems)

[Sep 13](https://hashnode.com/posts/ontology-based-context-engineering-when-rag-is-not-enough/6aa3b54650f99ce700ab144b/comment/6aa449bb7df0f7f5400a7c05#reply-6aa6a13db43117747e0416ef)

That is the right distinction, and it is where the two cases meet rather than split. The ledger keeps the contradiction in the row as claims, but the record still has to behave deterministically for a purpose: a takeoff needs one roof height. So a seat stamps a value. The Custodian's stamp, two keys bound to a content hash, is the equivalent of your "what the function does in this version." Change the underlying content and the stamp lapses, which is a new version. Until a seat stamps, a conflict row is quarantined and nothing downstream may consume it. Evidence preserved, behavior resolved, and the resolution is signed by someone who can be asked why.
