Skip to content
8 min read

Building a world model of a codebase: entities, edges and how we keep it current

The reasons behind your code are spread across pull requests, incidents and agent sessions. Entelligence links them in one graph. Here is what those links look like in our own workspace.

Aditya JhaAditya Jha DevRel ·
Illustration: a person stands in a vast chamber whose walls are packed with linked code windows, pull request cards, chat bubbles and people. From their raised hand one glowing thread climbs through a bug, a fix, a pull request and a discussion to a brilliant code window at the top.

In 1985 Peter Naur argued that a program lives in the heads of the people who built it. In his account, the program’s death “happens when the programmer team possessing its theory is dissolved.” The code can keep running after that. The loss shows up later, when someone needs a change and nobody left can say which changes are safe. Naur didn’t think reading the code and the documentation was enough to recover it.

Some of what those people knew does leave a trail: the pull request that changed a file, the failure that prompted it, the decision taken afterward, the agent session that wrote the patch. The pieces sit in different tools, and the links between them are usually only in someone’s memory. A world model writes those links down and keeps them up to date.

The short version
  • Entities: code is one kind of node. Issues, patterns, pull requests, fixes, decisions, sessions, tasks, people and product areas are the others.
  • Edges: a link is useful when it has a type and a direction. fixed_by answers a question that “related” can’t.
  • Evidence: a link should say what it rests on. When nothing was recorded, the model should show the gap.
  • Freshness: sources sync at different speeds, so a fact is only as current as the connector behind it. Check that before you act on it.

What is a world model of a codebase?

A world model of a codebase is a graph of the code and the work around it, kept current as both change. A code index can tell you what a function calls. A world model also holds which failure hit that code, which pull request was flagged for it, and what the team decided after the fix.

In Entelligence it is one graph of the code, the pull requests, the review threads, the incidents and the sessions your agents run, and the products read from that index. Ask Ellie answers from the same graph, so you can ask a question or browse the graph yourself. In the app it opens as a globe. Here is ours:

Screenshot: the World Model globe for our own workspace over all time, with 460 issues, 218 sessions, 151 decisions and 76 patterns drawn, and a side list of issue patterns, people, product areas and decisions.
The World Model over all time. Entelligence’s own workspace; people’s names replaced.

The footer counts are what the globe draws. It shows 151 decisions while the list on the left has 909, and by default it draws only the costliest few hundred agent sessions. Read it as a partial map, and use the lists when you need a total.

The entities: code is one node among ten

We opened nodes in our own workspace and wrote down what they connected to. Ten kinds of entity came up. Pull requests, sessions, tasks, people and product areas are what they sound like. The other five need a definition:

EntityWhat it stands for
Code locationA file that something happened in. An issue can also name the function it is attributed to.
IssueOne failure, with a severity and a detection count.
Issue patternA group of issues that fail in a similar way.
FixAn attempt to resolve an issue, including ones marked inconclusive.
DecisionA rule recorded from earlier work, and the files it applies to.

Someone has to choose what counts as an entity. If a decision were only a paragraph inside a pull request, you could find it by searching for the pull request. As a node of its own, it can be reached from any file it applies to, by someone who has never heard of that pull request.

In the nodes we opened, we saw 14 types of edge between those entities. The full list may be longer.

Diagram of the 14 edge types: person ran session; session contains_task task; task belongs_to_theme product area; task touched code location; session produced and session_provenance pull request; pull request authored_by person; issue flagged_in pull request, matches_pattern issue pattern, occurs_at code location, fixed_by fix; fix taught decision; decision applies_to code location and decided_by person.
Entities and the edges between them, as seen in our own workspace on Nov 24. Every path in the next section passes through a code location or a pull request.

Similarity search can tell you that a file and an issue are alike. A typed edge makes a claim you can check: this issue occurs_at that file, this fix taught that decision. If it is wrong, you know which edge is at fault.

Here is one issue from our backend, Null LLM Response String Access. A model call returned nothing and the code treated the result as a string. It has been detected 66 times and flagged on 7 pull requests.

Screenshot: the issue Null LLM Response String Access, P2, with 66 detections and 7 flagged PRs, connected to code locations such as metrics/handler.py and pr_reviewer/cross_repo_analyzer.py, to three pull requests and to the pattern Pre Execution Validation.
One issue in the center, with the eight code locations it occurs_at, three of its pull requests and its pattern. Entelligence’s own workspace; cropped, and one finding and one node label hidden.

The eight locations include the PR reviewer, the review pipeline, metrics and an infrastructure template. Someone fixing this from a single stack trace might only find one of them. The issue is also one of ten in a pattern called Pre Execution Validation, so the other nine can be reached through it. The pattern as a whole has been detected 16,180 times. Our last post covers how patterns reach code review.

Following edges to an answer

To answer a question, start at one entity and follow the edges that bear on it. Here are three examples:

Three paths. Where does this failure live and who touched that code: issue, code location, task, session, person. Why is this file written this way: code location, decision, fix, issue. Which work produced the flagged PR: issue, pull request, session, task, product area.
Three questions as paths. The arrows show how each edge is stored, and a path can follow an edge backward.

The second path gets closest to what Naur thought was lost. Take the file agent_insights/health.py. One of the decisions pointing at it is Retire Inline Cypher Paths: stop writing graph queries inline and use named ones. It was learned from a fix in PR #7540 and applies to five files.

Screenshot: the decision Retire Inline Cypher Paths, learned from PR 7540 merged 2026-11-15, decided by Not recorded, extraction method incident fix, with edges to five agent_insights files and a Fix marked inconclusive.
A decision, the pull request it was learned from and the files it applies to. Entelligence’s own workspace.

An engineer or an agent about to add an inline query to that file can find the rule without knowing PR #7540 exists. The reasoning that never reached a pull request is still missing, and no graph will recover it.

You don’t have to walk every path by hand. Ask Ellie is inside the World Model: ask about the node you have open, and the globe lights up each node Ellie visits while it searches. It works from the full-page Ask Ellie chat too, where answers from the World Model show the nodes they cited and an Open in World Model link. Starter questions are answered from fixed graph queries and skip the planning step.

How the graph shows what it doesn’t know

Two details of that decision matter as much as the rule. Decided by reads “Not recorded”, and the fix it is connected to is marked “inconclusive”. A graph that filled in the most likely engineer would look more complete and would sometimes be wrong. You can’t spot that kind of error by reading the answer.

The same goes for edges. “This session produced that pull request” might be something the session declared, or a guess based on timing. In the edges we looked at, session_provenance carried both the basis for the link and a commit:

Diagram of one edge record: source session, target pull_request, type session_provenance, head_sha a commit SHA, attribution_basis declared_cloud_session, with the question each field answers.
Fields on one edge and the question each one answers. The last two let you check the link.

Work that can’t be attributed still has to appear somewhere. Our globe has a product area called Not yet assigned. Agent Insights shows its attribution rate, 80.2% for us this month, and keeps a Non repo work row for sessions with no repository: 678 of them. Without that row, those sessions would either vanish from the totals or get credited to a repository that had nothing to do with them.

How we keep it current

A graph of code goes out of date as the code changes. We didn’t find a single “last updated” time for ours, and sources sync on different schedules. A few things help you judge how fresh it is:

  • With Auto Review on Every Commit turned on, a new commit on an open pull request gets a new review.
  • Sync timing differs per connector, and a recent event may not appear until its refresh finishes.
  • The World Model shows a badge such as “Syncing 51%” while sessions are being analyzed, or when the sync has stalled. Agent Insights prints its age, and ours said “Last indexed 8h ago”.
  • Each pattern has a last-seen time, so “P1, 4h ago” and “P1, 4 months ago” don’t look alike.
  • Ask Ellie reads only connected systems. Switch one off and its records leave the answers.

You can also filter the globe by time. Set to the last week, ours drops from 460 issues to 46:

Screenshot: the World Model globe filtered to the last week, with 102 sessions, 46 issues, 31 patterns and 19 pull requests drawn.
The same globe, changes from the last week. Entelligence’s own workspace; people’s names replaced.

The filter applies to the overview only. Opening a node shows its full history whatever window you picked, so an old cause isn’t hidden by a recent filter.

None of this will tell you that a decision has stopped being true. In the decisions we opened, the state was “active”, and we saw no marker for one that a later decision had replaced. Someone still has to notice that and say so.

Flowchart: before acting on a fact from the graph, ask whether the source is connected, whether the sync has caught up, and whether the link says what it rests on. Any no leads to opening the record. Three yeses lead to using the fact and keeping the link.
A check to run before you, or an agent, act on a fact from the graph. It won’t catch a decision that has been replaced.

How to test whether your graph is current

You can test any graph of your code, ours included, with changes whose answers you already know:

  1. Pick a file with some history. Write down its last three pull requests, its last failure and one decision about it, using only the source tools.
  2. Ask the graph for the same facts and compare.
  3. Merge a small pull request. Note when it appears, and when it is linked to its author and session.
  4. Rename a file that a decision applies to, then check whether the decision follows it.
  5. Ask something the graph can’t know. It should say so.
MeasureWhat it tells you
Correct edgesOf the links you checked, how many the source confirms.
Missing edgesLinks you knew about that the graph doesn’t have.
Time to appearHow long after a merge the change shows up, per connector.
Survives a renameWhether an edge follows the code or stays on a path that is gone.
Invented answersGaps filled with something plausible. Aim for zero.

Report missing edges and invented answers separately. A missing edge costs someone a search, while an invented answer can send a change to the wrong place.

How this differs from a code index or a wiki

World modelCode indexWiki
HoldsCode and its historyDefinitions, typesWhat people wrote
LinkTyped, across toolsTyped, in codeA hyperlink
Good atWhy, who, what nextWhat calls thisIntent
Goes staleSync lags, rules replacedNo rebuildNo edits

For exact references, use a code index. Kythe, for example, builds its graph from compilers and the build system, so it knows definitions and types precisely. A wiki is still the right place for intent that never passed through a pull request.

Questions people ask

Is the World Model just a visualization?

The globe is one way to look at it. Other Entelligence products read the same index, and you can query it through Ask Ellie without opening the globe.

Does it connect every repository automatically?

No. Cross-repository context requires explicit approval, and our docs advise linking codebases only for real dependencies, such as a service and its SDK or an API and its frontend. Data from a connector isn’t automatically shared with every product either.

Why is something I merged today missing?

Check the sync badge and the connector first. Recent events may not appear until a refresh completes. Then check the time window, which your browser remembers.

Is our code used to train models?

No. Customer code is not used to train models.

Want to run the freshness test on your own repo? Book a demo and we will go through it with you.

Sources: Peter Naur, Programming as Theory Building (1985); Kythe overview; Ask Ellie on the World Model; World Model connected globe; Ask Ellie; Ask Ellie permissions; Repositories; Code Review settings; Architecture; Designing an incident-aware review loop.

The memory starts the day you connect a repo.

From that day on, every session, review and incident lands in the same index.

  • No credit card required
  • No training on customer code
  • Deploy in your cloud, your own keys