From Legacy Artifacts to Served Context: My Six-Stage Method
Building a Knowledge Graph and Keeping It True, Release After Release

Note: Originally published on Medium
In my previous article, I explained why RAG alone was not enough for my legacy system, which standards exist (RDF, SKOS, SHACL, R2RML...), how to govern them, and I closed with the six stages of my method as a one-page overview. This part is the method itself: each stage in the detail that overview could not give, from raw legacy artifacts to context served to the LLM. And it covers both runs of the pipeline: the initialization*, the first full pass that builds the baseline from an empty store, and the* update*, the delta that keeps the graph true at every release after it.*
An ontology with no data is a diagram on a wall. The value comes from the pipeline that extracts facts from real sources (code, database, documents), keeps them versioned release after release, and serves them to the model at question time. My method has six stages as follows:
The first four build and maintain the graph. The last two use it. The split is also a split of when things run:
Stage 1 is a decision, taken once and revisited at every release
Stages 2 to 4 are the CI job (collect, validate, rebuild the store, one graph per release), with one human checkpoint inside Stage 3 for the facts an LLM proposed
Stages 5 and 6 run at question time, against the store that job produced
The CI job has three triggers, the same three as the governance loop that takes an ontology change from proposal to deployed graph:
A pull request on the ontology repository. Validation only: the shapes, the reasoner and the regression queries run on sample data, and no collector runs until the change is merged.
The merge of a change proposal. The job repopulates the store with the new terms.
Every release of the sources (a commit, a tag or the nightly run). No proposal and no review, because the ontology already covers what changed.
One run stands apart from those three: the initialization, a full pass over every source from an empty store. Every run after it is a delta. And one principle runs through all six stages, because everything else follows from it:
Facts extracted by deterministic tools are trusted. Facts proposed by an LLM are suspected until validated
Static analysis does not hallucinate. An LLM does. Both are useful, but they do not enter the graph through the same door.
A note on confidentiality: which LLMs?
One question always comes first when the sources are the code and the specifications of a legacy system: is any of it sent to a public cloud? No. Every LLM task in this method (document classification, version detection, link proposals, the sorting of quarantine reports, and the final answer generation) ran on local models served by Ollama, on my own machines, with nothing leaving the network. Which models is a detail I leave out on purpose: they changed during the project.
Note that the method does not depend on any specific model, which is one more benefit of keeping the LLM at the border: you can swap the model tomorrow without touching the graph, the collectors or the queries.
Stage 1 — Analyzing: match each artifact to its standard
Before writing any collector, walk through your artifact families and decide, for each one, which standard will represent it. This stage is cheap (a few workshops with the ontology draft on the table) and it prevents the classic failure: modeling everything with the wrong tool.
This is how the analysis looked on my project:
A question I get every time I show this table: my system is Java and PostgreSQL, not C and Oracle. Does any of this still apply? It does, and the table is its own proof: not one of its rows is really about a technology. The left column is a family of artifacts; the technologies I name are simply the ones that happened to be in my system.
Only the collectors are technology-specific, and they are the cheapest and most replaceable part of the whole thing. The ontology, the SHACL shapes, the queries and the six stages do not change when you swap PHP for Java. That is the real reason to model the domain instead of the code: a call graph is about your language, :calls is about your system.
Two outputs close this stage. The first is the core ontology, which in my case stayed around a dozen classes (CModule, CppModule, SmartyTemplate, PlsqlPackage, DbTable, SpecificationDocument, Release, BusinessRule...). The second is the decision table above, which becomes the contract for every collector you write next.
There is a second decision in this stage, and it is the one I got wrong first: granularity. My instinct was to push the model down: every function a node, every SQL statement an edge, and why not every line an assertion. It is a trap. The graph becomes a bad copy of source files that are already the best representation of themselves; the number of facts to re-collect at every release explodes; and nobody has ever asked me a relationship question about a line. The rule I settled on: model a thing when it is either the endpoint of a relation someone will traverse, or an anchor an answer needs to cite. That puts the floor at the procedure, the table, the template, the document section: the level at which a senior developer can point and say "yes, that is the thing". Below that floor the node carries a pointer (file, line, section) and the content stays where it is. The graph stops where the text begins. That sentence is what keeps an ontology from becoming a slow re-implementation of the file system.
One warning from experience: resist the temptation to design the perfect ontology. Analyze one subsystem, model what it needs, and let the ontology grow release after release, through the change proposals that unanswered questions generate. A small ontology that is populated beats a complete ontology that is empty.
Stage 2 — Collecting: one collector per source family
Each source family gets its own collector. The good news: for code and database, extraction is deterministic and reliable. The bad news comes with the documents.
C and C++: the call graph is already there
You do not need an LLM to know that function A calls function B. Decades-old tooling does it better:
Doxygen (XML output) or libclang can provide functions, references/call relationships, and file structure. Even cscope/ctags databases can be exploited for a quick start.
tree-sitter is my favorite middle ground: fast, tolerant of code that no longer compiles (yes, legacy repos contain files that no current toolchain accepts), and scriptable.
Embedded SQL (Pro*C) deserves a dedicated pass: a simple parser over
EXEC SQLblocks can extract valuablereadsTable/writesTablerelationships that connect the C world to the Oracle world.
Traps to expect: macros that hide calls, function pointers, generated code. My rule: extract what is certain, mark the rest as unresolved instead of guessing. An incomplete graph that is true beats a complete graph that lies.
PL/SQL: the database already knows everything
As you know, Oracle already maintains, for free, most of the graph you need:
ALL_DEPENDENCIES: which package depends on which package, view, table. This single view is half of your PL/SQL subgraph.PL/Scope (
ALL_IDENTIFIERS,ALL_STATEMENTS): once enabled at compilation, it tells you which procedure references which column, at line level. Gold.ALL_SOURCE,ALL_TAB_COLUMNS, constraints, triggers: the code text and the structural skeleton.
The collector is mostly SQL queries against these views, and it emits Turtle like the other collectors: the dependency edges are collected facts, loaded into the graph of their release. Only the table contents stay in Oracle, served virtually through the R2RML mappings decided in Stage 1. The blind spot is dynamic SQL (EXECUTE IMMEDIATE, DBMS_SQL): the dictionary cannot see through it. I handle it with a text pass that flags dynamic statements and, when the table name is a literal, extracts it with a low-tech regex, marked with lower confidence, never silently mixed with dictionary facts.
PHP: follow the routes
For the PHP MVC layer, nikic/php-parser extracts includes, calls and database access points; the Smarty templates connect the user-facing screens to the controllers behind them. The chain template → controller → SQL → table is what links user behavior to the rest of the graph. Legacy PHP loves string-concatenated SQL, so the same rule applies: literal table names are extracted, dynamic ones are flagged.
Documents: the real battlefield
Code extraction is a solved problem. Twenty years of documents is not. Specifications in .doc and .docx, PDFs, exports of old wikis, two languages in the same corpus, and the same specification existing in five versions for five releases, none of them labeled clearly.
My document pipeline, in order: convert everything to text (keep the section structure, headings are the anchors the graph will point to); detect identity and version, which means asking "which document is this, and for which release?" before asking "what does this document?"; and this is where the LLM earns its place: classifying a document, guessing its release range, detecting that document A is probably a newer version of document B, proposing that section 4.2 describes PKG_INVOICE. Every proposal carries a confidence score and goes to the review queue of the next stage.
Stage 3 — Transforming: from raw facts to validated graph
Nothing enters the graph directly. The transformation stage has three jobs.
Entity resolution. Legacy systems are champions of synonyms: the same concept is CONTRACT in the database, ctr in the C code, "souscription" in the French documents and "subscription" in the English ones. Deterministic keys solve it where possible (database objects have exact names; code entities have file + symbol; stable business keys prevent duplicates by construction). SKOS solves everything human: one node per business concept, one skos:prefLabel, as many skos:altLabel as history has produced, in both languages. Every synonym discovered in review becomes one more altLabel, and the glossary grows as a side effect of the pipeline.
Human validation of LLM proposals. Every identity, version or link proposed by the LLM goes into a review queue. A domain expert confirms or corrects in seconds. That is much cheaper than discovering, three months later, that the graph mixed spec v2 and v3, which is exactly the failure vector RAG gave me before the ontology.
The SHACL gate. Collectors write candidate facts into a staging graph: a dedicated repository for the current run, holding candidates that nothing has validated yet. SHACL shapes decide what passes on structure: every document has at least one appliesToRelease, every calls connects two known entities, no orphan nodes. The gate adds one quality rule on top of the shapes: a fact below the confidence threshold is not refused, it is held for a human decision. What fails goes into a quarantine graph, another dedicated repository, with the violation report attached. The quarantine is your to-do list: every entry is a collector bug, a modeling gap, or a real data problem in the sources. All three are worth knowing.
The gate runs the same way on both runs of the pipeline, and it is what shapes the initialization. The first pass walks every source from an empty store, and nothing that comes out of it is trusted on arrival: it crosses the gate like every later delta, the quarantine fills, and each entry is fixed at its origin (the collector, the shape or the ontology) or stays out when the fact is simply not in the sources. The collectors run again, and the baseline is what survives once the quarantine stops growing, which takes more than one pass. The update then walks only what changed since the last run, through the same collectors and the same gate, and Stage 4 says where its facts land.
Every fact that passes keeps its provenance. With RDF-star this is pleasantly compact:
<< :BillingEngine :calls :PKG_INVOICE >>
:extractedBy :CollectorC_v2 ;
:extractedFrom "src/billing/engine.c" ;
:extractedOn "2026-05-12"^^xsd:date ;
:confidence 0.98 .
The provenance travels with the fact into the fact store and comes back out as these RDF-star triples when the triple store is rebuilt. When a senior developer challenges an answer, you can show not only the path in the graph, but where each edge of the path comes from.
Where the validated facts land. What passes the gate is merged into the fact store, and the triple store is built from it plus the repository. That makes four places a fact can sit, and they are easy to confuse: the staging graph while the run is on and nothing is decided, the quarantine graph if the gate refused it, the fact store once it was accepted or judged, and the triple store, rebuilt from the fact store, where the queries of Stage 5 read it.
It is worth being precise about what that triple store contains, because it is less than people assume. Four things: the ontology and the SKOS vocabulary, loaded straight from the repository; the facts the collectors extracted and the gate accepted; the provenance triples above; and the triples the reasoner derives from reasoning/rl/, computed once per release graph and loaded back into it. Three things it does not contain: the Oracle data, which stays in the database behind the R2RML mappings and is never copied; the text of the documents, which stays in the files while the graph keeps only pointers to the sections; and the history, which stays in the fact store. The triple store is rebuilt by CI from the repository plus the fact store, never edited in place, which is the rule of the whole approach seen from the pipeline side: the repository is the source of truth, the store is a build artifact.
The fact store is the other half of that rule, and the half a rebuild cannot regenerate. It holds every fact the gate accepted, with its provenance, and every decision a human made along the way: the verdicts of the review queue and the analysis of the quarantine entries. The facts could be collected again from the tagged sources. The decisions could not, which is why the fact store is the one component to back up, while the triple store is disposable: it holds only the resolved facts, after validation, and it comes back identical from the repository and the fact store at any release. On the first run the two look alike, and it is tempting to ask why there are two. The difference is the history of the decisions: the fact store keeps every verdict, every closure and every candidate that was ever judged, while the triple store holds only what those decisions let through. A fact the expert refused is nowhere in the triple store, so nothing there can stop a stateless collector from proposing it again; only the fact store remembers that it was refused, and Stage 4 shows what happens when the merge forgets to ask.
Stage 4 — Versioning: updating without lying
A graph that was true at release N and never updated is worse than no graph: people trust it, and it lies. Versioning is not an afterthought. It is a stage of the method, triggered every time the sources change.
One honest line before the rules. My graph covered several releases that already existed, side by side, so the named graphs and the two time axes below were built and tested on real multi-release data. The ongoing update, a new release arriving after the baseline and the delta run that follows it, is the part of the method I designed for that day and have not yet run in production. I describe it anyway, because a versioning stage that stops at the baseline answers nothing.
Delta runs per release. The collectors run in CI at every release (nightly for the cheap ones). The document pipeline runs only on new or changed files.
Append-only, close-don't-delete. New facts land in the named graph of the new release; disappeared facts are not deleted: they stay in the graphs of the releases where they were true, and the fact store closes them with
:validUntilthe new release. Combined with the release graphs andappliesToRelease, you get two time axes almost for free: the release a fact talks about, and the moment you learned it. Warehouse people will know this as a bitemporal model, obtained here without the ceremony.A closed edge is not a deprecation.
:deprecatedInReleaseis a lifecycle fact, and it comes from two sources: a release note that announces it, or the comparison of two collector runs, and the fact store records which one. The distinction matters because a package that disappears from the code is not always deprecated; sometimes it was just renamed.The store is rebuilt, never patched. A delta run does not edit the store in place: it produces a new set of facts, those facts are merged into the fact store one artifact at a time (new ones inserted, survivors kept with their provenance and their review verdicts, vanished ones closed), and CI reloads the store from the repository plus the fact store. A rejection is a decision too, and I learned it the hard way: two facts I had refused because they did not match the code came back in the review queue at the next pass of the baseline, since the collector that produced them is stateless and the merge only asked whether a fact was already accepted, not whether it had already been judged. The rule that follows: a candidate that matches a rejected fact from the same source is dropped and counted, and only a candidate whose source changed since the verdict comes back to the queue, marked as previously rejected. The append-only rule above is about the facts (a closed edge stays in the graphs of the releases where it was true, and the fact store keeps its
:validUntil), not about the store file, which remains what Stage 3 called it: a build artifact, reproducible from an empty database at any release.The ontology itself is versioned too, but that is a schema change, and it follows the git + CI + review process of the ontology repository (
owl:versionInfo, deprecate never delete). Stage 4 is about the data; the governance loop is about the model. Keep the two changes separate and both stay safe.Drift metrics on a dashboard. Percentage of unresolved calls, quarantine size, documents with no confirmed release, coverage per subsystem: all four fall out of the gate and the fact store, so put them on a dashboard from the first run. The alert rule I would set is simple: quarantine growing two releases in a row means stop and fix.
The two axes, concretely. The distinction is worth one paragraph, because collapsing the two is the classic mistake. The release graph and :appliesToRelease say which release a fact talks about: :BillingEngine :calls :PKG_INVOICE sits in the graph of 2022.2, SPEC_INV_V3 applies to 2021.1 and 2022.2, and that is exactly what the release filter in Stage 5 reads. :validUntil, in the fact store, says how long we believed a fact: the collectors saw a :calls edge up to release N, stopped seeing it at N+1, and the edge was closed instead of removed. The first axis answers "what is true for the version this developer works on", the second answers "what did we know, and when did we stop knowing it". Both are needed. Without the second one you cannot separate a fact that was never true from a fact you no longer believe, and "when did this behavior change?", the question senior developers ask most, becomes unanswerable the moment you delete instead of close.
Stage 5 — Retrieving: the graph selects, before the LLM reads
At question time the direction reverses: we stop writing the graph and start asking it.
One thing to settle before the steps, because it is the whole design in one sentence: the retrieval channels are not peers. The tempting architecture is to put graph traversal, lexical search and vector search side by side, run the three of them on every question and merge the results with a ranking formula. What comes out is a ranked pile: better than a random pile, still a pile, and still not something a developer can verify. Here the ontology and the graph decide what is on the table: which artifacts, which documents, which release. The text channels never widen that selection; they only find the right lines inside it. A gate, then a funnel, then the model.
Concretely, three steps:
Entity linking. The question, "what happens to an invoice when the client changes his contract in the middle of the month?", is mapped to graph nodes through the SKOS labels, French and English synonyms included. That glossary lookup is what ran on my graph, and it carried the load on its own. Around it, the order I would recommend depends on the case, and it is boring on purpose: exact match first, because a large share of what a developer types contains a symbol (
PKG_INVOICE,T_CONTRACT, anORA-code), and an exact lookup on the labels resolves those without any model at all; then the glossary built in Stage 3, which handles most of what is left; then, if the labels still miss phrasings, a small embedding fallback, with every catch becoming a newaltLabelso that the fallback shrinks over time. The first and the last are options; the glossary in the middle is the part that must exist.SPARQL traversal, filtered by release. Starting from the linked entities, queries collect the relevant subgraph (callers, called packages, touched tables, implementing rules), restricted to the release the user works on, which means the named graph of that release plus the shared graph, whose documents are filtered on
appliesToReleasewhile the rules and lifecycle facts come as they are. This filter is the single biggest accuracy win. Be honest about its weakness, though: for the documents in the shared graph, the filter is query discipline, not physics. One query that forgets theappliesToReleaseclause and versions mix again. This is exactly why the queries live in the repo and are reviewed like code, and why the SPARQL regression tests include a "wrong release must return nothing" case.Context assembly. The subgraph is serialized compactly, and the exact document sections it points to are fetched. Vector search did not disappear from my stack. It simply moved below the gate: it still finds the right paragraphs inside a long document. And if you build this today, put a plain lexical index under the gate next to it: when the question carries a symbol, exact search inside those same sections beats the embedding every time, because
CALC_PRORATAis a string, not a meaning. But the graph decides which documents and which code artifacts are on the table, and the text channels only rank and read within what it allowed.
The result is a small, dense, versioned context, not a pile of look-alike chunks.
A word on how the lexical channel and the glossary relate, because it is tempting to read the two as rivals: if exact match works, why keep SKOS? They operate at different levels. In step 1 the exact lookup runs against the graph's labels, and those labels already carry the synonyms: CONTRACT, ctr and "souscription" all hang off the same node, so the lookup succeeds whichever of the three the user typed. In step 3 the lexical search runs against raw text, where it gets no such help. A search for CONTRACT finds the database objects and misses every C file that says ctr, silently, which is the dangerous kind of miss. So the glossary does not compete with the lexical channel, it feeds it: SKOS expands the term into its altLabels and the index searches all of them at once. Without it, a lexical index on a bilingual corpus retrieves one name in three, and tells you nothing about the two it missed.
What the graph does not answer
Being precise about this is what keeps the method honest, and it is the question that always comes right after a demo: is everything supposed to become an ontology assertion? No. The graph answers four kinds of question, and only four: identity (which thing is this; is ctr the same concept as "souscription"?), classification (is this a package, a spec, a release note?), relationship (what calls it, what does it write, which rule does it implement?), and validity (for which release is this true, and what superseded it?).
It does not answer content questions ("what does §4.2 actually say?", "what does this four-hundred-line C function do?"), and it does not answer similarity questions ("is there another place that computes this differently?"). Those are text questions, and text questions are answered by reading text; the graph's job was to decide which text. That is the whole reason the stack keeps three channels instead of one, and the reason the ontology stays small: it is a map, not a replica.
Stage 6 — Serving: expose the graph as tools, not as a dump
The last stage is the interface between the graph and the model. Two serving modes proved useful:
Assembled context, for question answering. The context service runs the stage-5 funnel and hands the LLM the finished package: subgraph plus document sections plus the provenance. The model's job is only to write the answer, and every answer ships with its traceable path: this template → this module → this package → this table → this document, this release. Senior developers can verify a path but never a pile of similar chunks.
Graph tools, for agents. Instead of one big context, the agent gets a small set of callable tools backed by SPARQL (exposed through MCP): resolve this term to an entity, give me the subgraph around X, what is the impact of changing Y?, which documents apply to release R?. This is what makes the coding and correction loop safe: before proposing a fix, the agent queries the impact (who calls this procedure, which business rules does it implement, which screens touch this table), and the generated change respects what the graph knows. After the merge, the cycle restarts at Stage 1: most of the time the decision table already covers what changed and that pass costs nothing; when the change brings in something the ontology does not describe yet, this is where it gets added, and the collectors run again.
And when the model still gives a wrong or incomplete answer? That is not a failure of the method. It is its input: the missing fact or wrong link becomes a change proposal, and the correction loop of the ontology repository takes over.
Two walkthroughs, end to end
Theory is nice; let me show the machine running. Two real-style scenarios, one technical and one business, both around the same rule, because that is the point: the same graph serves both audiences.
Walkthrough 1 — a developer hunts a bug
The question. A developer on release 2022.2 types: "The pro-rata amount is wrong when a contract changes in the middle of the month. Which code implements this rule, and which spec defines it?"
Step 1: entity linking. "pro-rata" matches skos:altLabel "prorata" (and the French "au prorata") on the node :ProRataRule. "Contract changes" resolves to the business term :ContractChange, linked to :T_CONTRACT. The release comes from the user's session: :R2022_2.
Step 2: SPARQL traversal, release-filtered. One reusable query from queries/ does the walk, over the named graph of the developer's release plus the shared one:
SELECT ?artifact ?proc ?doc ?section
FROM g:R2022_2
FROM g:shared
WHERE {
?artifact :implementsRule :ProRataRule ;
:hasProcedure ?proc ;
:describedBy ?doc .
?doc :appliesToRelease :R2022_2 ;
:hasSection ?section .
FILTER NOT EXISTS { ?artifact :deprecatedBefore :R2022_2 }
}
It returns PKG_INVOICE / CALC_PRORATA, described by Spec v3 §4.2, and only v3: Spec v2 is excluded because it does not apply to 2022.2, and Spec v4 does not exist yet for this release. The traversal also collects the callers (BillingEngine, contract_change.tpl) and the touched tables.
Step 3: context assembly. The subgraph, the text of §4.2 (found by vector search inside the sections the graph selected), and, thanks to provenance, the exact source file of CALC_PRORATA.
Step 4: what the developer sees.
Rule: pro-rata invoicing (Spec v3 §4.2), valid for releases 2021.1 → 2022.2. The spec says the pro-rata is computed per day. The code in
PKG_INVOICE.CALC_PRORATA(src line shown) still rounds per month, which is the v2 behavior. The divergence is your bug, and since v3 applies from 2021.1, the bug is two releases older than you think. Path:contract_change.tpl→BillingEngine→PKG_INVOICE.CALC_PRORATA→T_INVOICE(spec v3 §4.2, release 2022.2). Before you fix:impact-of-change(CALC_PRORATA)→ 2 C modules, 1 batch job, 1 screen. Note: this package is deprecated in 2024.1 and replaced byPKG_INVOICE_V2. If the bug exists there too, two fixes are needed.
Every claim carries a link the developer can open. Without the release filter, the assistant would have blended v2, v3 and v4 into one confident, wrong explanation: the exact failure that pushed me toward the ontology in the first place.
Walkthrough 2 — a business question across releases
The question. A product owner asks, in French: "Comment est facturé un client qui change de contrat en milieu de mois ? Nos clients sont sur la 2021.1 et la 2023.1. Est-ce que la réponse est différente ?"
Step 1: entity linking. "facturé... changement de contrat en milieu de mois" resolves through the French altLabels to the same :ProRataRule. No translation step, no embedding gymnastics: the bilingual glossary from Stage 3 pays for itself here. Two releases are named, so the traversal will run once per release.
Step 2: traversal, twice. The same query as above, once with :R2021_1, once with :R2023_1. For 2021.1 it returns Spec v3 §4.2; for 2023.1, Spec v4 §5.1, because v4 applies to 2023.1 and :supersedes v3.
Step 3: assembly. Both sections, each tagged with its release range, plus the rule node they share.
Step 4: what the product owner sees.
Same rule, two behaviors:Releases 2021.1 → 2022.2 (Spec v3 §4.2): the invoice is split per day; the old price applies until the change date, the new price after. Releases 2023.1 → (Spec v4 §5.1): same daily split, but the new price applies immediately and a one-time adjustment line is added on the next invoice. A client on 2021.1 and a client on 2023.1 asking the same question get different, both correct answers. Each statement above links to its spec section and release range.
The LLM's only job was to turn two versioned facts into client-friendly French. It could not mix the versions, because it never saw the wrong one.
One honest detail connects the two walkthroughs: this business answer describes what the spec says, and it is trustworthy because the rounding bug from the first walkthrough had been fixed in the meantime. If it had not been, the answer could still have carried a warning: code and spec meet on the same implementsRule edge, so the context handed to the model holds both the section and the procedure, and the divergence is there to be read, as it was for the developer in the first walkthrough. An assistant that answers from documents alone never sees the code.
Two audiences, one graph, zero mixed versions. That is the demonstration I use to convince a room in fifteen minutes. One caveat belongs in that room too: the answer ships its path, and the path is what makes it checkable, but a checkable path is not a correct rule. The graph reports the system as it is, bugs included; its purpose is not to correct what exists. If CALC_PRORATA is wrong, the answer will faithfully describe a wrong computation, with the pointer that lets anyone see it and report it.
Objections I expect, and how I answer them
A method is only credible if it survives its own critics. Here are the four strongest objections I know against this method, and my honest answers.
Your release filter is discipline, not a guarantee
Partly true. For the structural facts I chose named graphs, one per release, so the isolation is physical: a query that runs over g:R2022_2 cannot see a :calls edge collected in 2024.1, whatever its author forgot. What stays discipline is the shared graph, where the documents carry appliesToRelease and one forgotten clause silently mixes v2 and v3 again. The alternative is validity predicates on every fact (appliesToRelease and validUntil on the edges themselves): one graph, no duplication, and nothing but discipline between a query and a mixed answer. Named graphs have their price too: storage duplication, and painful cross-release questions, since "when did this behavior change?", exactly the question senior developers ask the most, now needs two graphs or the fact store's validUntil instead of one triple pattern. The guardrails are the same either way: shared queries in the repo, reviewed like code, and a regression test where the wrong release must return nothing. If your releases are many and your cross-release questions frequent, predicates are the lighter choice. Both are defensible; the important thing is to know which trade you are making.
Your review queue will die under its own weight
This is the classic death of metadata projects, and the objection I take most seriously. Twenty years of documents generate tens of thousands of LLM proposals; "a domain expert confirms in seconds" is true per item and false in total. The answer I designed for it is calibrated auto-acceptance: validate a random sample per proposal type, measure the precision, auto-accept the types that score above a threshold, and queue only the uncertain middle. And track the queue size as a drift metric: it must shrink release after release. If it grows, the pipeline is broken, not the reviewers.
Deterministic does not mean correct
Also true. Static analysis does not hallucinate, but it lies in its own way: function pointers, same-named symbols in different modules, dead code that still produces edges, files that no longer compile. Deterministic means reproducible: a false calls edge born from a name collision enters the graph with confidence 1.0 and full trust. Two defenses: keep the "unresolved" marking aggressive (extract only what is certain), and let the correction loop do its job. When a senior developer sees a wrong path in an answer, the provenance tells you exactly which collector produced the bad edge. Trust is earned by being correctable, not by being perfect.
Stage 1 is waterfall thinking
It would be, if the decision table were signed once and framed on a wall. You cannot know upfront that you will never need OWL inference, or that documents will not need richer modeling: some needs only appear when queries fail in Stage 5. So the decision table is a living contract: revisited at every release, with stage-5 failures as its main input. Stage 1 does not mean "design everything first"; it means "never write a collector without deciding, consciously, which standard it feeds". Those are two different disciplines.
What I would tell you before you start
Do the analysis stage for real. A few workshops mapping artifacts to standards save months of remodeling. The decision table is your contract.
Start with the database collector. For a PL/SQL-heavy system it is the highest value for the lowest effort: the dictionary gives you thousands of reliable edges in a day.
Do code before documents. The code graph gives the skeleton; documents then attach to entities that already exist. Doing documents first means linking prose to nothing.
Keep the LLM at the border, not in the core. Classification, version detection, link proposals: yes. Direct writes to the graph: never. The review queue is not bureaucracy; it is what makes the graph a source of truth.
Measure coverage honestly. A statement like "the graph knows 60% of the C modules" is useful and honest, and it is a roadmap. Silent gaps are how trust dies.
One subsystem first. A complete six-stage pipeline on one subsystem teaches you more than six half-collectors on everything.
Conclusion
Six stages, one method: analyze each artifact family and give it the right standard; collect with deterministic tools wherever possible; transform with entity resolution, human validation and a SHACL gate; version with append-only facts so the graph never lies about a release; retrieve by letting the graph select a small, dense, release-filtered context; serve it as assembled context for answers and as callable tools for agents.
None of it is glamorous: parsers, SQL against the data dictionary, review queues, dashboards. But this is the part that decides everything: the ontology gives the graph its shape, the pipeline gives it its truth, and the serving layer is what finally turns twenty years of scattered meaning into answers a senior developer can verify.
Let's keep in touch
As always, I would love to hear from you. Which stage looks the hardest in your context: the collecting, the versioning, or the serving? Have you found better tools for the extraction? Share your experience in the comments. I answer all of them.
If you enjoyed this article, follow me on X and connect with me on LinkedIn so you do not miss the next part, and feel free to share it with a colleague who is fighting with a legacy monster of their own. Everything I write also lands on my site, elienehme.fr, in English and in French: each article gets a short summary and the reason I wrote it, next to shorter notes and ideas.
Sources and further reading:
Doxygen, libclang, cscope, Universal Ctags, tree-sitter, nikic/php-parser
Oracle documentation: PL/Scope,
ALL_DEPENDENCIES
About the author
- Stratégie · Transformation · Ingénierie · Architecture
Comments
Join the discussionNo comments yet. Be the first to comment.





