## TL;DR

The agent changed a working model to satisfy a downstream test and broke the model. Fixes must be minimal and verified both ways: run the model's own tests before the change (baseline) and after, review the diff, and prefer fixing the test or the downstream logic over altering a green model.

## Error

```text
agent's fix corrupted a working model while fixing its downstream test
```

## Steps

1. Assess the damage: `git diff` on the model to see what the agent changed. Expected: the full extent of the corruption is visible.
2. Revert the model change (`git checkout -- [MODEL]`) to restore the known-good state. Expected: the model is green again.
3. Run the model's own tests to confirm the baseline: `dbt test --select [MODEL]`. Expected: green baseline established.
4. Now fix the actual problem: the downstream test, the downstream model, or the data, without touching the working model. Expected: the fix lands in the right place.
5. Rerun both the model's tests and the downstream test. Expected: everything green, model untouched.

## When to use

- A fix for one failure breaks a previously working model.
- An agent edits upstream code to satisfy a downstream expectation.

## When not to use

- The model change was intentional and correct (then update its tests too).
- The model was already broken (no baseline to protect).

## Tool compatibility

- dbt Core 1.0 and later; git for diff and revert.

## Variant phrasings

### Agent "fixed" the test by changing the model

Inverting the dependency: tests describe the model, the model does not serve the test.

### Cascading breakage from one agent edit

Blast-radius discipline (baseline, minimal diff, both-ways verification) prevents it.

## Why it happens

Agents optimize for the failing check in front of them. Editing the upstream model is often the shortest path to green, but it violates the contract the model's own tests encode, trading one failure for another.

## Edge cases

- Sometimes the model really is wrong and the downstream test is right; then change the model deliberately and update its tests.
- Establish the baseline before any fix; without it you cannot tell what you broke.
- Keep fixes minimal: the smallest diff that resolves the failure.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_hYiAx0Y9elWfbSpkVq-7UA
