# V2 Cooking Dependency Graph

`V2/ue/Build/Cooking/v2-cooking-dependency-graph.json` defines the graph used by
incremental cooks. The graph direction is `sourceDependsOnTarget`: an edge from
a mesh to a material means the mesh depends on that material. Invalidation walks
the opposite direction through `reverseDependents`.

The required chain is material-aware. When texture changes are detected, the
planner finds all materials referencing that texture, then all meshes using
those materials, then all levels that package those meshes. Shader, audio, and
animation changes follow the same reverse-dependent rule into materials or
levels where applicable.

The `meshes using those materials` closure is required evidence for texture
changes.

`plan-v2-cooking-dependency-graph.py` merges the fixture graph with optional
`*.v2deps.json` sidecars, validates missing references, detects cycles, and
emits invalidation waves. For the arena fixture, a changed arena stone texture
produces these waves:

- texture: `tex-arena-stone`
- materials: `mat-arena-floor`, `mat-arena-trim`
- meshes: `mesh-arena-floor`, `mesh-arena-pillars`
- level: `level-arena-main`

Required gates:

- `cooking-dependency-graph-generated`
- `cooking-dependency-graph-material-links`
- `cooking-dependency-graph-texture-closure`
- `cooking-dependency-graph-cycle-free`
- `cooking-dependency-graph-missing-references`

The primary material coverage metric is
`cook.dependency_graph.material_reference_edge_count`. The texture closure
metric is `cook.dependency_graph.texture_closure_count`. The CI validator is:

```bash
python3 V2/ue/Tools/check-v2-cooking-dependency-graph.py
```
