## TL;DR

`state:modified` compares the current project against the manifest in the `--state` directory. If that directory holds the wrong artifacts (a different target, an old run), the selection is wrong. Point `--state` at the right prior manifest, verify with `dbt ls`, then run.

## Error

```text
dbt state:modified bug: comparing wrong artifacts
```

## Steps

1. Check what is in your `--state` directory: look at the `manifest.json` timestamp and the target it was built from. Expected: you confirm whether it matches the baseline you intended.
2. Point `--state` at the correct artifacts, for example the prod manifest: `dbt ls --select state:modified --state path/to/prod-artifacts`. Expected: the command uses the intended baseline.
3. Inspect the selection: does it match the models you actually changed? Expected: the selected set looks right.
4. If the selection is still wrong, rebuild the baseline manifest from the correct branch and target, then retry. Expected: a fresh, trustworthy baseline.
5. Run your command with the corrected `--state` path. Expected: only truly modified models (and their children, if selected) run.

## When to use

- `state:modified` selects models you did not change, or misses ones you did.
- You just changed how CI stores or fetches artifacts.

## When not to use

- State selection works but is slow (an artifact-size problem).
- You want all models (drop the state selector entirely).

## Tool compatibility

- dbt Core 1.0 and later, all adapters. State selectors are adapter-independent.

## Variant phrasings

### state:modified selects everything on every run

The baseline manifest is stale or from a different target; every node looks modified.

### state:new misses a new model

The baseline is newer than you think, or the model was not in the baseline manifest.

## Why it happens

State comparison is only as good as the baseline. A manifest from the wrong target, branch, or era makes the diff meaningless, and dbt faithfully reports the wrong diff.

## Edge cases

- Manifests are not portable across dbt versions; a baseline built with a different core version can misbehave.
- Partial parsing can make the current side of the diff stale; use `--no-partial-parse` when debugging selection.
- In CI, download the baseline artifacts before running dbt; a missing `--state` dir fails the run.

## Provenance

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