## TL;DR

The agent pointed --state at a directory with no (or stale) manifest, so every node looked modified and everything rebuilt. Point --state at the real prior-run artifacts directory containing manifest.json, verify with dbt ls, then re-run the slim selection.

## Error

```text
agent state:modified comparison used the wrong artifacts path: rebuilt everything
```

## Steps

1. Check what --state pointed at: does the directory contain a manifest.json, and what is its generated_at timestamp?
   Expected: You find the path was wrong, empty, or held a stale manifest.

2. Locate the correct artifacts: the target/ directory from the last production run (or the CI artifact from the prod job).
   Expected: A manifest.json from the real baseline run.

3. Dry-run the selection: dbt ls --select state:modified --state /correct/path to see the true modified set.
   Expected: A small sensible list of actually-changed nodes, not everything.

4. Re-run the slim command with the correct --state path.
   Expected: Only modified nodes and their children build.

## When to use

- state:modified selected everything after an agent set the path
- a slim CI job rebuilt the whole DAG
- the --state directory was empty or stale

## When not to use

- everything genuinely changed (then a full build is correct)
- you want state:modified against a different baseline deliberately (then the path is right, the expectation was wrong)
- no --state was passed at all (then add it)

## Tool compatibility

- dbt ls --select state:modified --state to dry-run selections
- manifest.json generated_at to verify the baseline
- CI artifacts to pass prod manifests between jobs

## Variant phrasings

### agent used a relative path that resolved elsewhere
Relative --state paths resolve from the project dir; the agent may have run from elsewhere. Use absolute paths.

### state comparison against the wrong target's manifest
A dev manifest compared against prod code marks everything modified. Baselines must come from the same target lineage.

## Why it happens

state:modified diffs the current project against the baseline manifest. No baseline (or a wrong one) means every node diffs as new, so the selector matches the whole DAG. The agent saw a valid command and an invalid path and trusted the command.

## Edge cases

- Manifest schema versions must match between baseline and current dbt; a version mismatch can also mark everything modified.
- Always dry-run state selectors with dbt ls before the build; it is cheap and catches path mistakes.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_8hPZVq6J5PeO4896rT2QBw
