Files
claude-bot 720c31393a fix(reaper): Tier-2 finalization grace + claim-before-act (no dup advance)
Tier-2 reaped a LIVE, still-finalizing monitor: _monitor_agent writes
agent_runs.exit_code FIRST, then does git push / PR / Plane comments before
_finalize_job, and the agent pid is already dead in that window — so the old
"exit_code recorded -> reap now" had no grace and could race a healthy job.
Worse, _reap_known_outcome ran the advance (advance_stage -> enqueue_job)
BEFORE the atomic claim, so a reaper that lost the race had already enqueued
the next stage (dup advance / dup enqueue), violating ADR-001 Р-1.

Fix:
- Tier-2 grace: reap only once agent_runs.exit_code has been recorded for
  >= reaper_finalize_grace_s (new setting, default 300s; > max finalization
  window). A live finalizing monitor is never reaped (FR-1.3/AC-3). New
  finished_age_s column computed in get_running_jobs.
- claim-before-act for exit0: evaluate the canonical QG READ-ONLY (the
  reconciler pattern) to choose the terminal status, then atomically claim
  'done' FIRST; only the claim winner runs the advance. A loser performs no
  side effects -> no dup advance / dup enqueue.

Docs (golden source) updated in the same change: ADR-001, global adr-0011,
README, internals, .env.example, CHANGELOG (also fixes the P3 broken adr-0011
link). New tests cover the grace window, lost-claim no-side-effects, and the
already-advanced idempotent path.

Refs: ORCH-065

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 16:14:45 +00:00
..

Architecture Decision Records

Индекс сквозных (cross-cutting) ADR проекта orchestrator. Per-work-item решения живут в docs/work-items/<id>/06-adr/ADR-NNN-slug.md.

# Решение Статус Дата Источник
adr-0001 Реестр проектов (multi-repo) accepted 2026-06-02 ORCH-6
adr-0002 Очередь задач вместо in-process потоков accepted 2026-06-03 ORCH-1
adr-0003 Условный staging-гейт перед прод-деплоем accepted 2026-06-05 ORCH-35
adr-0004 Поллинг с ретраем в check_ci_green (фикс CI-race) accepted 2026-06-05 ORCH-045
adr-0005 Контейнеры бегут под uid:gid хоста (1000:1000) accepted 2026-06-06 ORCH-040
adr-0006 Merge-gate (догон main + re-test + сериализация слияний) proposed 2026-06-06 ORCH-043
adr-0007 Reconciler застрявших стадий (sweeper потерянных webhook) accepted 2026-06-06 ORCH-053
adr-0007 Исполняемый самодеплой стадии deploy (файл adr-0007-executable-self-deploy) accepted 2026-06-06 ORCH-036
adr-0008 Провенанс staging-образа перед BUILD-ONCE retag accepted 2026-06-06 ORCH-058
adr-0009 Толерантность staging-вердикта к инфраструктурным FAIL accepted 2026-06-07 ORCH-061
adr-0010 Post-deploy мониторинг прода + реакция на деградацию proposed 2026-06-07 ORCH-021
adr-0011 Job-reaper + проактивный реклейм merge-lease accepted 2026-06-07 ORCH-065

⚠️ Историческая коллизия: номер 0007 занят двумя файлами — adr-0007-reconciler.md (ORCH-053) и adr-0007-executable-self-deploy.md (ORCH-036). Оба accepted; для новых сквозных ADR использовать следующий свободный номер (текущий максимум — 0011).

Формат

Контекст → Решение → Альтернативы → Последствия → Связи. Статус: proposed / accepted / superseded. Принятый ADR не меняется — новое решение заводится отдельным файлом со ссылкой supersedes adr-XXXX. Новые ADR добавляет архитектор при принятии решения (см. CLAUDE.md → Конвенции).