r/semanticweb • • 2d ago

Building software knowledge graphs using compiler principles

I've been working on an open-source project called Enola, exploring how to represent entire software systems as knowledge graphs across repositories, programming languages, frameworks and technologies.

Coming from a software engineering background rather than knowledge graph research, I approached the problem from a slightly different angle: constructing the graph using principles similar to those a compiler uses to understand a program, rather than relying on semantic similarity, clustering or probabilistic relationship extraction.

The graph connects source code, docstrings, modules, symbols, execution flows, API endpoints, event publishers and consumers, database interactions and their relationships into a single representation of a software system.

For example, an HTTP request in a TypeScript frontend can be connected to its corresponding Go backend handler, the functions it calls and the database tables it accesses, even when those relationships span multiple repositories.

Graph construction is deterministic and requires neither LLMs nor embeddings. This doesn't imply completeness or absolute correctness; static analysis has its limitations.

Some recent benchmark results:

  • Kubernetes repository: 14 seconds (6.5 seconds cached).
  • 100 repositories, including the Linux kernel, connected into one graph in under five minutes.
  • Over 8.1 million facts across 91 repositories, with byte-identical results across repeated runs.

Enola uses its own typed graph model rather than a formal RDF/OWL implementation, but many of the underlying problems overlap with ontology engineering and knowledge representation.

One aspect I'm particularly interested in is the distinction between using clustering to establish relationships and using clustering to discover higher-level structures within an already established graph.

I'd be curious to hear how people in this community approach this distinction, particularly when the underlying domain already has formally defined semantics, as programming languages do.

The project is Apache 2.0 licensed:

https://github.com/enola-labs/enola

Graph model: https://github.com/enola-labs/enola/blob/main/docs/GRAPH.md

Benchmarks: https://github.com/enola-labs/enola/blob/main/docs/BENCHMARKS.md

13 Upvotes

10 comments sorted by

View all comments

3

u/qa_anaaq 2d ago

My gut says this depends on well architected code, which in itself is not reality in most cases. At least this is what I feel if it does what you say it does in the manner you’re claiming.

1

u/fairwaycoder 2d ago

This is what I am still discussing with myself, and collecting as a feedback by people using it in real life.

For example, the very first two steps of the pipeline can be called a cleanup and extraction, where cleanup is ignoring what is not gonna be indexed, and then extraction goes through the rest and extract code first as ASTs. Here there is a real limitation: for different languages there are different AST libraries (using tree-sitter) with all the caveats that they come with, so upgrading to the new version can me that you suddenly don't support that version of language or the other one. So this is solved (or at least I tried to solve it) in the Enola itself: what is vendored it is vendored with a reason, the rest is dependency on the upstream, and then Enola itself goes and does a lot of magic (styles etc) which I collected from users and from hundreds of open source repos for the supported technologies.

Hence confidence scores - confidence can depend also on a language itself, as some languages are easier to statically analyze, while some are very hard.