# Lineage and blast radius

Lineage answers two questions before anyone acts: what feeds this object, and what breaks if it
changes. One graph covers sources, datasets, saved queries, dashboard widgets, alert rules,
destinations, exports, joins, rollups and pipeline rules. It is read three ways, and all three give
the same answer:

| Where | What it is |
| --- | --- |
| `egress_map_get` with `include: ["lineage"]` | an agent's read (adds about 1,200 tokens) |
| `GET /orgs/{orgSlug}/lineage` | the dashboard's panel on the egress map card |
| the approval cards of destinations, pipelines, sources and saved queries | the dependents, listed before the act |

## The graph

An edge runs from the upstream object to the downstream one, the way data flows: `from` feeds `to`.
`dataset:spans -> saved_query:Q` with relation `reads` says Q reads spans.

| Relation | Means | Declared by (the `to` end unless noted) |
| --- | --- | --- |
| `reads` | reads a dataset, a join or a saved query | saved queries, widgets, exports |
| `alerts_on` | watches a dataset | alert rules (telemetry conditions) |
| `joins` | a typed join's two sides | joins |
| `exports_to` | what a destination sends | destinations |
| `feeds` | feeds something (declaring object is the `from` end) | sources, pipeline rules |
| `writes` | writes into something (declaring object is the `from` end) | exports, into their destination |

`fieldPath` names the field an edge is about (`http.user_agent`) and is empty for an edge between
whole objects. Field paths are normalised the same way everywhere, so the same field written
two ways in two specs is one field here.

**Every edge is declared by one object, from that object's own spec.** Nothing is inferred by a
model, and nothing is guessed from a log. The declaring object is always one named end of the edge, so
changing an object replaces exactly the edges it declared and never one another object declared:
changing a destination never touches the edge an export declared into it.

## Keeping it current

Saved queries update their edges in the same change that saves or deletes them, and sources in the same
change that saves them (a deleted source is dropped from every read). The edges of alert rules, widgets, destinations, exports, joins and pipeline
rules are refreshed by a periodic rebuild instead, so they can lag behind a recent change; an answer that
leans on one of those kinds lists it in `coverage.unwired` rather than claiming that zero dependents is
zero. An object that no longer exists is dropped from every read whatever its edges say.

## Reading it

A read walks up, down or both from one object, at most three hops, breadth first, stopping at a cycle and
at a cap on objects. It returns the objects with their state, owner and last run, the edges, and what it
could not show.

Asking about a field (`fieldPath: "http.user_agent"` on `dataset:spans`) narrows the first hop to the
edges that name the field plus the edges that read the whole dataset. The second kind are marked
`match: "whole_object"`: they may read the field without naming it, so they are listed apart rather
than claimed as readers.

What a caller sees is narrowed to their own reach:

- every query carries the organization, and every object is looked up with it, so another
  organization's id names nothing;
- an edge declared by a project the caller cannot read is not followed; an org-level object needs
  `org:read`;
- another person's draft saved query or private board is counted in `hiddenPrivate` and never named,
  and the walk stops there;
- a deleted, archived or tombstoned object disappears with its edges.

Object names and owner names are text a member or an agent wrote. Every read lists them as untrusted;
the MCP tool scrubs and bounds them as the `service_name` class.

## Dependents on a card

Every approval card that shows dependents lists what sits downstream within three hops and what writes
into the object directly (an export names its destination), with owners, states and last runs. A card
reader is not authorized per project, so the object's own project and org-level objects are named and the rest are counted (`hiddenScope`).

`status` is `not_available` only when Bucker tracks lineage for no kind at all. Otherwise zero is zero,
and `coverage.undeclared` names any kind whose lineage Bucker does not track, so a dependent that is
missing is never read as one that is absent.

The destination card, the pipeline preview and the source card show dependents today. Export approval
cards do not show them yet.
