# Lineage

> Table-level and column-level lineage with upstream, downstream, and bidirectional modes, plus export to tree, JSON, DOT, and Mermaid.

---

LLMS index: [llms.txt](/codeweb/llms.txt)

---

## Run lineage {#run-lineage}

`codeweb lineage <TARGET>` computes how data reaches — and leaves — a table or column:

```bash
codeweb lineage "orders"                                   # table-level
codeweb lineage "orders.status"                            # column-level
codeweb lineage "public.orders.status"                     # schema-qualified column
codeweb lineage "table:public.orders"                      # node-key grammar, same as trace/detail
```

Options:

```bash
codeweb lineage "orders" --direction upstream    # who writes/defines it
codeweb lineage "orders" --direction downstream  # who consumes it
codeweb lineage "orders" --depth 5               # recursion depth (default 5)
codeweb lineage "orders" --flow-only             # hide reference-only sources
```

`--direction` accepts `upstream`, `downstream`, or `both` (default).

## Output formats {#output-formats}

```bash
codeweb lineage "orders" --format json      # machine-readable
codeweb lineage "orders" --format dot > lineage.dot
codeweb lineage "orders" --format mermaid   # markdown-embeddable
```

`--format dot` and `--format mermaid` export the entity subgraph. The default `--format tree` supports four renderings via `--view`:

| View | Rendering |
| ---- | --------- |
| `tree` (default) | Indented lineage tree |
| `entity` | Entities only, no processes |
| `relation` | Explicit `source──process──▶target` lines |
| `grouped` | Branches grouped by connecting process |

## Tune flow detection {#tune-flow-detection}

With `--flow-only`, codeweb hides sources that only reference a table without moving data. The thresholds live in `codeweb.toml`:

```toml
[lineage]
# minimum column overlap and ratio for a flow edge to count
```

The `[lineage]` section exposes flow thresholds (`flow_min_overlap`, `flow_min_ratio` defaults apply unless overridden).

## Column-level analysis {#column-level-analysis}

Lineage answers "where does this column come from". For the inverse question — "which filters, joins, and mappings does a procedure apply to its tables" — use the [column analysis](/codeweb/docs/column-analysis/) commands `codeweb columns` and `codeweb predicates`. The HTTP equivalent is `GET /api/v1/lineage`; the MCP equivalent is `codeweb_lineage`.

---

Backlinks:

- [CLI reference](/codeweb/docs/cli-reference/)
