Graph Learning and a World Model for Code
The deterministic graph in software knowledge graph answers questions about facts: who calls X, which commit changed Y. Two research directions go further. Graph machine learning adds pattern recognition over the graph, and a world model adds dynamics, so that the system can predict and run counterfactuals.
Graph learning as a neuro-symbolic overlay
The compiler supplies the symbolic truth (structure); graph ML supplies probabilistic intuition (patterns, similarity, inference).
- Symbolic layer (the hard graph). The CPG, import graph and call graph are deterministic ground truth.
- Neural layer (the soft overlay). Graph neural networks and graph embeddings learn latent representations of nodes. They answer questions the deterministic graph cannot: “Which other service is architecturally similar to this one?”, “Is this new call pattern anomalous compared with history?”
The most interesting part is graph embeddings.
Techniques
- Graph embeddings for structural retrieval. Instead of embedding only a function’s text (as CodeBERT does), embed its structural role with Node2Vec, GraphSAGE or GAT. Two functions with different names but the same call-graph and data-flow shape end up close together. In incident debugging, the system can search for subgraphs with the same shape as the failing transaction (“past traces where a DB write was followed by an async callback timeout”), and find incidents with the same structural cause even when the error text differs.
- Link prediction for missing traceability. The SDLC graph is always incomplete; someone forgets to link a ticket to a PR. Link prediction (R-GCNs, knowledge-graph embeddings such as TransE or DistMult) estimates the probability of a missing edge: “this unlinked commit modifies
PaymentServiceand uses terms from Ticket-123; link probability 89%.” Suggested links can fill gaps in the graph, stored as inferred edges with their score (edge provenance), so the model does not have to guess them. The 89% is an illustration, not a measured result. - Node classification for root-cause scoring. Train a GNN on past incident subgraphs where the root-cause node is labeled. For a new incident, it propagates error signals through the dependency graph and scores each function or service as a likely culprit, so the LLM starts from the top three nodes instead of reading fifty files.
- Soft pruning and adaptive context. Precomputed slices can be redundant. A GNN scorer can drop nodes that are technically in the slice but structurally irrelevant (logging utilities, standard library). It can also learn which edge types (data flow, control flow) helped with similar past tickets and filter the graph accordingly for the current query.
If these techniques work, the graph becomes more than a lookup table: it can suggest likely links and likely causes. Each needs data this project does not have yet: labeled incidents for root-cause scoring, enough linked history for link prediction, and a way to measure structural similarity for embeddings. They are research bets, not planned features. The cheapest first test is the embedding one: compare structural and text embeddings for “find similar functions” on one repository.
World model and simulation engine
A knowledge graph is a static snapshot. A world model adds transition functions, so the system can answer “what if?” as well as “what is?”.
- Static graph:
Service AcallsService B. - World model:
Service AcallsService Bwith .
The graph provides the state; the modeling engine provides the dynamics. This is a move from descriptive answers (“here is the trace”) to predictive and counterfactual ones (“if I retry this request, will it fail again?”).
Causal simulation
The engine is a causal inference engine, not a physics engine. Its primitive is a structural causal model: each variable is a function of its parents, for example latency , with the functions learned from observability data (traces, metrics).
Simulation loop:
- Initialize with the current state (graph and configuration).
- Perturb with a mutation (“change
TIMEOUTfrom 5 s to 2 s”). - Propagate the effect through the causal functions downstream.
- Report: “predicted 500-error rate increases by 12%.”
Use cases
- Counterfactual debugging. Replay the crash state while toggling variables: original input crashes, input under 1 MB succeeds, so the failure is caused by input size. This is a causal explanation, not a correlation.
- Impact prediction. Clone the live graph into a sandbox, apply a config change, replay historical load profiles: “this change deadlocks
Service CwhenUserType=Premium.” - Architecture verification. Scale the load variable tenfold and see which services hit the capacity limits recorded in the environmental layer (implicit knowledge).
Staged build
- Static rules. The engine is a rule checker with constraints taken from IaC: if an edge’s timeout is shorter than the callee’s processing time, predict failure.
- Statistical replay. Sample real requests (for example a thousand from last week’s logs), route them through the changed graph logic, and estimate the effect (“latency +10 ms”).
- Learned causal models. Train a GNN or Bayesian network on traces to learn the latent transition functions (“when A’s CPU exceeds 80%, B’s latency spikes”), which allows simulation of non-linear failure modes.
Related open idea: a library of typical incident evolution schemes that the simulation or root-cause scorer could match against.
References
- Cited for GNN root-cause scoring: arXiv:2404.04496
- Cited for structural subgraph retrieval and pruning: arXiv:2405.16506
- CIRCA, causal inference for root-cause analysis (KDD 2022): https://netman.aiops.org/wp-content/uploads/2022/08/KDD22-CIRCA.pdf
- World models: https://worldmodels.github.io
- A gentle introduction to graph neural networks: https://distill.pub/2021/gnn-intro
Library sources
- Hogan et al. 2021, Knowledge Graphs (doi:10.1145/3447772) – on Link prediction for missing traceability
- Negro et al. 2026, Knowledge Graphs and LLMs in Action – on Node classification for root-cause scoring
- OREN et al. 2018, A Shift from Model-Based to Simulation-Based Paradigm (doi:10.15344/2456-4451/2018/126) – on World model and simulation engine
Further reading:
- Hu et al. 2025, GRAG: Graph Retrieval-Augmented Generation
- Law 2015, Simulation Modeling and Analysis
- OREN et al. 2023, Body of Knowledge for Modeling and Simulation (doi:10.1007/978-3-031-11085-6)
- Sargent 2017, A Perspective on Fifty-five Years of the Evolution of Scientific Respect for Simulation
- Smith and Sturrock 2024, Simio and Simulation: Modeling, Analysis, Applications
- Sokolowski and Banks 2009, Principles of Modeling and Simulation: A Multidisciplinary Approach
- Zeigler et al. 2019, Theory of Modeling and Simulation