
## Trigger

Starting any card / registry / spec work that will regenerate
`static/ai/registry.json`, OR hitting a merge/rebase conflict in that file.

## Symptoms

- A PR shows `CONFLICTING` / `mergeStateStatus: DIRTY`, with the conflict only
  in `static/ai/registry.json`.
- `pull_request` CI never starts (GitHub can't build the merge ref while the PR
  is conflicting), so checks look "missing", not failed.
- A concurrently-merged card-lane PR added/changed cards while your branch was open.

## Diagnosis

`static/ai/registry.json` is a GENERATED file that is committed, and the ratified
**card lane auto-merges on green CI** — so `origin/main` frequently gains a new
card plus a regenerated registry. Branching from a stale local `main`, or working
while another card PR lands, makes two independently-regenerated registries collide.

## Fix

1. **Before branching**: `git fetch origin main` and branch from `origin/main`,
   not a stale local `main`. (`git rev-list --left-right --count HEAD...origin/main`
   right-side count must be 0.)
2. **On a registry.json conflict**: do NOT hand-merge the JSON — the conflict is
   only in the generated view. Take both card sets, then
   `python scripts/ai/build_registry.py` to rebuild from all `ai/cards/*.md`,
   `git add static/ai/registry.json`, and re-run `validate_assets.py` +
   `build_registry.py --check`.
3. If `origin/main` added a card during your branch, also confirm that card's
   `type` fits the current closed-set taxonomy before regenerating.

## Reuse Rule

- **Load when**: opening a branch / PR that touches `ai/cards/**` or
  `static/ai/registry.json`, or resolving a conflict in the registry.
- **Do not load when**: work that never regenerates the registry.

## Related

- `align-with-remote-before-consult` — the read-side twin (refresh local cards
  before a consult); this card is the write/PR-side rule.
