# Drawing the Context Graph

> How we built Cortex's new relationship graph, and why it only works because we stopped computing ownership at read time.

_By Chelsea Hohmann · Published 2026-11-23 · Tags: relationship-graph, context-graph, ownership, postgres, data-modeling_
Source: https://builders.cortex.io/blog/drawing-the-context-graph/

---

I'm a visual person. When I'm trying to understand a system, I want to see how all the pieces fit together, not read about them. So it always bugged me that I couldn't see the answer to the question, "What is my team actually responsible for?"

In Cortex, there's a lot of flexibility in how you configure relationships between entities, on purpose, because every company draws those lines differently. A team can sit inside a larger team, own services directly or through a domain, depend on services that other teams run, and connect to anything else through custom relationship types you define. The capability to model all of this existed, but when it came time to answer "what is my team responsible for?", I had to put the picture together in my head from a bunch of different lists. That's fine when the answer is three services. It's not fine when the answer is three hundred.

And that question comes up at the worst times: during an incident, in a reorg, or on a new hire's first week. Every time someone has to rebuild the picture by hand, they spend time they don't have, and they usually miss something.

That's the problem the new relationship graph in Cortex is built to solve. Team hierarchy, domain hierarchy, ownership, dependencies, and your own custom relationship types now live in one interactive picture, each drawn in its own color. It's the visual side of the [Context Graph](https://www.cortex.io/products/context-graph): all the ways the things in your catalog connect to each other.

In this post, I'll walk through what the graph answers, how it stays fast on catalogs with millions of entities, and the two biggest challenges we hit along the way.

## Why It's Hard

The organizations we work with have structures that are just inherently complicated. It's not unusual for a customer to keep a giant whiteboard (or a Miro board, or a slide nobody wants to update) describing how their *entity types* fit together. Something like this:

That diagram is useful, but look at what's missing. It shows the shape, not the things. It can't tell you that the Payments product area has 14 APIs served by 230 services, that 40 of those services are owned by a team that got reorged last quarter, or that one of them quietly calls half the company. Even getting the type model right is hard. Showing the actual entities and how they connect is a whole step above that.

Work stalls when it hits this gap. Planning a migration, scoping an incident, or handing a system to a new team all depend on knowing what's actually connected to what, not what the whiteboard says should be.

We heard versions of this from a lot of customers. The asks fell into a few buckets:

| What customers asked for | What it meant |
|---|---|
| See teams and domains together | "Show me how services roll up into both teams and domains in the same view." |
| Start from a team | "Let me go from a team to everything it owns, and back up again." |
| Show my own model | "Our custom types and relationships don't show up, so there's no single view of how our catalog fits together." |
| Make big graphs usable | "We hit the node limit, and even when we don't, the view isn't readable." |
| Make direction readable | "We can't tell which way a dependency points." |

So we rebuilt the relationship graph page around a few questions people actually ask.

## What Is This Team Actually Responsible For?

This is the question we heard most, so it's where the graph starts. Pick a team (or start from the teams you're on), and the graph draws it with the teams it belongs to above and everything it owns below. Many companies also group their services by business area, which Cortex calls domains. Turn those on, and you see where each service fits in that structure too. And because no two companies organize the same way, Cortex lets you define your own building blocks, such as a product area that contains APIs, which are in turn served by services. You probably want to see those too, so they show up in the same picture.

This matters most when the team changes. After a reorg, a new manager inherits a pile of services they've never heard of. During planning, someone needs to know whether a team can realistically take on one more thing. Both start with the same question, and both used to start with a scavenger hunt.

Every type of relationship gets its own color, so a team's parents and everything it owns show up in one picture without turning into spaghetti. The two combinations people reach for most are **team plus ownership** ("what does this team own?") and **teams plus domains** ("how does our org chart line up with our architecture?").

## Where Do My Dependencies Go?

In Cortex, a dependency means one entity calls another: this service talks to that API, or reads from that database. Not package dependencies like the libraries in your package.json, which Cortex tracks separately. You can declare them in an entity's YAML, or let integrations like APM discover them from real traffic. Dependencies were in the old graph too, technically. But it was hard to read which way they pointed, and big graphs hit a node limit long before they told you anything useful.

Mapping dependencies across a whole organization is hard everywhere, not just at Cortex. Nobody holds the full call graph in their head, and the moment you try to draw all of it, you get a hairball.

But knowing that call graph is exactly what you need during an incident. When something breaks, the first question is "what else is affected?", and one customer told us they needed to see blast radius at the domain level, because that's how their operations teams actually work. The same question comes up before you deprecate or migrate anything: who still calls this, and who do I need to talk to first?

Both of those questions start from one service, not the whole map, so the graph never tries to draw all of it. You start from one entity, and every card shows a badge with how many parents and children it has for each relationship type. You expand only the directions you care about. Dependencies follow the same rules as every other relationship type, with arrows you can actually read.

That's also why hitting the node limit stopped being a dead end. Our old graph tried to solve this by loading everything up front, so in a bigger catalog, you'd hit the node limit before you could see anything interesting. The new graph starts from one entity and only grows as you expand it. It still stops at 300 entities on the canvas, but you get there by choosing what to open, and when you do, the graph says so: narrow the filters, or use "Start here" on another card to keep exploring from there. Wide families load one page at a time and wrap into rows of 12, instead of one row that's a mile wide.

This change to have users incrementally build the graph that matters to them instead of drawing the whole world at once is also what keeps the graph fast on big catalogs, because the database does less work too:

- Counts stop at 500. A badge doesn't need to know that a team owns 12,437 things. "500+" tells you everything you can act on, so the database stops counting at 501 instead of counting every row.
- Pages come straight off the index. To show the next page of a hub's children, the database reads them in the order they're already stored, instead of counting and sorting all of them first. On one of the biggest hubs in our production-sized data, that cut a page load from reading about 8 GB to about 34 MB (over 200 times less), and it now returns in 87 ms, with no new index.
- Counting children for every relationship type on a card stays under 5 ms per page.

## What Neighborhood Does This Service Live In?

Sometimes you don't start from a team. You start from the service that just paged you. When you're on call, context is the thing you're shortest on. You need to know what this service talks to, who owns the things around it, and who to pull in, ideally in the first five minutes, not the first hour. From any entity, you can expand in any direction, and "Start here" re-roots the graph on whatever card you're looking at. You can filter by entity type, group, or archived status, and search highlights matching cards instead of pruning the graph. So you keep the context of everything around the match.

Clicking a card opens a details panel with every relationship type that entity has, split by direction. It's the fastest way I know to answer "what else touches this thing?"

## Why Does This Service Have the Owner It Has?

[Keith Zeto](https://www.linkedin.com/in/keith-zeto-50b068166) wrote a great post on [why ownership matters and how it flows through teams and domains](../whose-service-is-it-anyway/), so I won't repeat it here. The new part is that the graph shows you *how* an owner got there.

Inherited ownership is powerful, but it's invisible by default. When a service shows an owner nobody expected, or a page goes to the wrong team, the fix usually lives somewhere up the hierarchy, and finding it meant reading configuration on every parent until you found the right one.

Cortex supports two ways for owners to be inherited from a parent, like a domain ([docs](https://docs.cortex.io/ingesting-data-into-cortex/entities-overview/entities/ownership/ownership-inheritance#inheritance-modes)):

- **APPEND:** the child keeps its own owners *and* adds the parent's.
- **FALLBACK:** the child only takes the parent's owners if it doesn't have any of its own.

In the graph, an edge an owner was inherited across is styled **thick for APPEND** and **dashed for FALLBACK**.

The part I like most is where that styling comes from. We don't read it from configuration. Every inherited ownership row we store records the path the owner actually travelled, farthest ancestor first. So the last hop on that path tells us exactly which edge the owner crossed. The graph shows what really happened, not what the configuration says should happen. Those are usually the same thing. When they aren't, that's exactly the case you want to see.

In the graph above, which starts from our CI/CD product area, each thick line is an edge an owner crossed with APPEND. Here's how each owner got where it is:

- CI/CD is owned by Core Services directly. Its parent, Integrations, is owned by Data, so CI/CD keeps Core Services and adds Data.
- ArgoCD and BuildKite have no owners of their own, so both teams come down to them through CI/CD.
- Bitbucket, in the middle of the bottom row, has two parents: CI/CD and Version Control.

Bitbucket is where the graph beats the configuration. The configuration only says "a sub-category adds the owners of its parent product area." Both of Bitbucket's parents have Data, so the configuration can't tell you which one it came from. The stored path can: Data came from Version Control. So if Data stopped owning Integrations, ArgoCD and BuildKite would lose Data, but Bitbucket would keep it.

Working that out without a picture is hard: you'd open every parent of every entity, check its owners and how it passes them down, and hold all the paths in your head at once. The relationship graph draws those paths for you, so where each owner came from is something you can see, not something you have to reconstruct.

## Can I Share Exactly What I'm Looking At?

Yes. The whole graph state lives in the URL: the start entity, what's expanded, what's hidden, the selected card, the search, and the filters. Paste the link into an incident channel, a design review, or an onboarding doc, and whoever opens it sees exactly what you saw.

A screenshot goes stale the moment the data changes, and a written description of "the graph, but expanded two levels from the checkout service" never quite lands. Shared context is the whole point of an incident channel or a design review, so the link should carry the context with it.

Everything lives in the link itself. Nothing is saved on our side. But the URL doesn't hold a snapshot of the canvas. It holds a short, versioned list of the steps you took to build it: which cards you expanded, in which direction, how far, and what you hid. Each step is one entry, so paging the same card further updates its entry instead of adding a new one. When someone opens the link, the graph replays those steps against today's data. That keeps links short, and it means a link still works after the data changes: you see the same view, with today's data.

## Challenges and What I Learned

### You can't draw what you have to compute

This graph would not have been possible a year ago. The reason is boring but important: we used to calculate ownership at read time.

Every ownership question walked team hierarchies, domain hierarchies, entity relationships, and identity mappings on the spot. For a big team hierarchy, that could take around 30 seconds. That's painful for one page. For a graph, it's impossible. Every card on the canvas needs its own parent and child counts for every relationship type, and every expand needs a page of neighbors. If each of those triggered a live hierarchy walk, the graph would spend most of its life loading.

And speed isn't a nice-to-have here. People open the graph when they're trying to understand something quickly, often mid-incident. A graph that takes 30 seconds per card just teaches people to go back to asking around in Slack.

What made it possible was the Entity Property Value (EPV) project our team shipped earlier this year. EPV flipped ownership and hierarchy lookups from "compute on read" to "compute on write":

Here's how it works:

1. **Providers compute values when inputs change.** Small, standalone providers each know how to calculate one piece of a property, like direct owners, team owners, or hierarchy parents, for a batch of entities.
2. **Results land in one table.** `entity_property_values` holds one row per entity per value. The value is a URI like `team://CORTEX_TEAMS/platform` or `entity://service/checkout#hosted-on`.
3. **Each row remembers how it got there.** `source_list` is the path walked to get the value (null when it's direct), plus the inheritance mode (APPEND or FALLBACK).
4. **Each row remembers what it came from.** `cleanup_keys` lists the database rows it was derived from, so a change knows exactly which entities to recompute.
5. **Change data capture keeps it fresh.** When a team, owner, or parent changes in Postgres, the consumer recomputes just the affected entities, usually within seconds. A scheduled refresh runs as a safety net.

Today that table holds about 173 million rows. And it's what lets the graph be mostly index lookups. "Who are this entity's children?" is "which rows name this entity as their value?". "Who are its parents?" is "this entity's own direct rows". Counts for every card on the canvas come back in one query, not one query per card. Even the APPEND and FALLBACK edges from earlier come straight out of `source_list`.

The lesson I took from this is that a lot of "UI performance" problems are really data model problems. We could have spent months optimizing the graph's front end and it still wouldn't have mattered if every card had to wait on a live hierarchy walk.

### Not every relationship belongs in that table

Our first plan was to put dependencies in EPV too, so we built it and measured it on a copy of production. Storing every indirect caller for every entity would have doubled the whole table, and one tenant alone would have added about 80 million rows. Dependencies are cyclic, dense, and rediscovered by integrations on every sync, so there's no cheap way to keep all of that current. So dependencies stayed in their own table, and the graph reads them one hop at a time as you expand. The lesson: precompute what's shaped like a tree. Leave graphs as graphs. (The full story of that investigation deserves its own post.)

## Try It Out

The relationship graph is live for Cortex customers. Next time you're scoping an incident, onboarding to a new team, or planning a migration, start there instead of piecing together a bunch of different lists. Pick a team you're on, turn on ownership and team hierarchy, and see what your team is actually responsible for. Then expand a dependency or two and see what you find. ([Docs](https://docs.cortex.io/ingesting-data-into-cortex/entities-overview/entities/relationship-graph).)

If you're not a Cortex customer yet and you'd rather see how it all fits together than read about it, [book a demo](https://www.cortex.io/demo) and we'll show you your own catalog in one picture.
