opencode-config/docs/handoff/pr-182-adr-numbering-collision.md
Sergey 0bf97cf1c5
fix(scripts): compute next ADR as max+1 not count+1 in scaffold (#182)
* fix(scripts): compute next ADR as max+1 not count+1 in scaffold

* docs(handoff): add handoff and ADR-079 for ADR numbering fix

* docs(handoff): set PR number

---------

Co-authored-by: opencode-agent <agent@opencode.local>
2026-07-31 22:13:30 +03:00

19 lines
No EOL
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
pr: 182
title: fix(scripts): ADR numbering collision in scaffold-handoff.sh
---
## Что сделано
`scaffold-handoff.sh` вычислял next ADR как `ls | wc -l + 1`. Заменён на `max(existing) + 1` с guard loop для residual race и base-10 forcing (`10#`) для leading-zero номеров. Добавлены комментарии, объясняющие почему max+1, а не count+1.
## Почему
`count+1` не гарантирует уникальность: при параллельных pipeline или ручном добавлении ADR счётчик отстаёт → коллизия (два файла `073-pr-174-*.md` и `073-pr-175-*.md`). `max+1` race-resistant: каждый запуск читает текущий max. Guard loop покрывает residual race (файл создан между max-read и write).
## Pending
— (после merge: memory-syncer обновит ADR Index — добавит ADR-079, оставит ADR-073 collision note как есть)
## Watch out
- Существующие ADR-073 (оба) НЕ переименовывались — вне scope, ссылки в memory/handoff уже расставлены.
- `10#` обязателен: номера `078`/`079` с leading zero невалидны в bash octal arithmetic.
- `|| true` на grep обязателен: empty dir → grep exit 1 → `set -euo pipefail` убивает скрипт.
- Тестового слоя для scaffold нет — критерий «если есть test-слой» не применим.