feat(labels): auto-mode by Plane labels — autoApprove + autoDeploy (ORCH-089) #89

Merged
admin merged 7 commits from feature/ORCH-089-autoapprove-brd-autodeploy into main 2026-06-09 12:38:53 +03:00
Owner

ORCH-089 — Авто-режим по лейблам: autoApprove + autoDeploy

Снимает два человеческих гейта конвейера, тормозящих пакетный автономный прогон (эпик ORCH-088): гейт BRD (analysis: ручной Approved) и гейт прод-деплоя (deploy Phase A: ручной Confirm Deploy, ORCH-059). Выборочно (лейбл Plane на задаче), декларативно, обратимо, без изменения ни одной технической проверки.

Что сделано

  • leaf src/labels.py (never-raise): auto_approve_applies/auto_deploy_applies (scope, kill-switch проверяется ПЕРВЫМ — без сети), has_label (единственный сетевой вызов, только при applies==True), snapshot.
  • autoApprove → врезка в stage_engine._handle_analysis_approved_flow (ветка files_ok): set_issue_approved + лог/Telegram/Plane-коммент + advance_stage(..., finished_agent=None)тот же путь, что человеческий Approved (approved-via-statusanalysis → architecture + mark_brd_review_ended). Без дублирования переходной логики; re-entrancy безопасна.
  • autoDeploy → врезка в stage_engine._handle_self_deploy_phase_a после advance на deploy+clear_state: лог/Telegram/Plane-коммент + _handle_self_deploy_phase_b (маркер INITIATED, Deploying, finalizer). BR-5 структурно: Phase A достигается только после зелёных под-гейтов ребра (security → merge-gate → image-freshness → staging) → autoDeploy физически не деплоит сломанное.
  • plane_sync: fetch_issue_labels (None при ошибке ≠ []), get_project_labels ({normalized_name→uuid}, TTL-кэш auto_label_states_ttl_s, сентинел __AMBIGUOUS__ при коллизии имён), set_issue_approved.
  • Флаги (config.py): auto_label_enabled, auto_approve_label/auto_deploy_label, auto_label_repos (пусто → self-hosting only), auto_label_states_ttl_s.
  • Наблюдаемость: read-only блок auto_labels в GET /queue.

Инварианты (не тронуты)

STAGE_TRANSITIONS, QG_CHECKS, check_analysis_approved/check_deploy_status/check_staging_status, все технические под-гейты, sentinel-маркеры self-deploy, exit-коды хука, схема БД — без изменений. Fail-safe: любая ошибка/неоднозначность → ручной гейт (never-raise). Kill-switch off → нулевая регрессия (enduro не затронут).

Тесты

TC-01…TC-26 в 7 модулях (test_labels, test_plane_sync_labels, test_auto_approve_brd, test_auto_deploy, test_auto_label_combinations, test_auto_labels_integration, test_auto_labels_invariants). Полный прогон: 1157 passed.

Документация (golden source, в этом же PR)

CLAUDE.md, docs/architecture/README.md, 06-adr/ADR-001-auto-label-gates.md + global adr-0018, 07-infra-requirements.md (создание лейблов в Plane ORCH), CHANGELOG.md.

⚠️ Инфра-предусловие

Создать лейблы autoApprove/autoDeploy в Plane-проекте ORCH (labels API). Их отсутствие = has_label False = ручной режим (fail-safe).

Refs: ORCH-089

🤖 Generated with Claude Code

## ORCH-089 — Авто-режим по лейблам: autoApprove + autoDeploy Снимает **два** человеческих гейта конвейера, тормозящих пакетный автономный прогон (эпик ORCH-088): гейт BRD (`analysis`: ручной `Approved`) и гейт прод-деплоя (`deploy` Phase A: ручной `Confirm Deploy`, ORCH-059). Выборочно (лейбл Plane на задаче), декларативно, обратимо, **без изменения ни одной технической проверки**. ### Что сделано - **leaf `src/labels.py`** (never-raise): `auto_approve_applies`/`auto_deploy_applies` (scope, kill-switch проверяется ПЕРВЫМ — без сети), `has_label` (единственный сетевой вызов, только при `applies==True`), `snapshot`. - **`autoApprove`** → врезка в `stage_engine._handle_analysis_approved_flow` (ветка `files_ok`): `set_issue_approved` + лог/Telegram/Plane-коммент + `advance_stage(..., finished_agent=None)` — **тот же путь, что человеческий Approved** (`approved-via-status` → `analysis → architecture` + `mark_brd_review_ended`). Без дублирования переходной логики; re-entrancy безопасна. - **`autoDeploy`** → врезка в `stage_engine._handle_self_deploy_phase_a` после advance на `deploy`+`clear_state`: лог/Telegram/Plane-коммент + `_handle_self_deploy_phase_b` (маркер `INITIATED`, `Deploying`, finalizer). **BR-5 структурно:** Phase A достигается только после зелёных под-гейтов ребра (security → merge-gate → image-freshness → staging) → autoDeploy физически не деплоит сломанное. - **`plane_sync`**: `fetch_issue_labels` (`None` при ошибке ≠ `[]`), `get_project_labels` (`{normalized_name→uuid}`, TTL-кэш `auto_label_states_ttl_s`, сентинел `__AMBIGUOUS__` при коллизии имён), `set_issue_approved`. - **Флаги** (`config.py`): `auto_label_enabled`, `auto_approve_label`/`auto_deploy_label`, `auto_label_repos` (пусто → self-hosting only), `auto_label_states_ttl_s`. - **Наблюдаемость**: read-only блок `auto_labels` в `GET /queue`. ### Инварианты (не тронуты) `STAGE_TRANSITIONS`, `QG_CHECKS`, `check_analysis_approved`/`check_deploy_status`/`check_staging_status`, все технические под-гейты, sentinel-маркеры self-deploy, exit-коды хука, **схема БД** — без изменений. Fail-safe: любая ошибка/неоднозначность → ручной гейт (never-raise). Kill-switch off → нулевая регрессия (enduro не затронут). ### Тесты TC-01…TC-26 в 7 модулях (`test_labels`, `test_plane_sync_labels`, `test_auto_approve_brd`, `test_auto_deploy`, `test_auto_label_combinations`, `test_auto_labels_integration`, `test_auto_labels_invariants`). Полный прогон: **1157 passed**. ### Документация (golden source, в этом же PR) `CLAUDE.md`, `docs/architecture/README.md`, `06-adr/ADR-001-auto-label-gates.md` + global `adr-0018`, `07-infra-requirements.md` (создание лейблов в Plane ORCH), `CHANGELOG.md`. ### ⚠️ Инфра-предусловие Создать лейблы `autoApprove`/`autoDeploy` в Plane-проекте ORCH (labels API). Их отсутствие = `has_label` False = ручной режим (fail-safe). Refs: ORCH-089 🤖 Generated with [Claude Code](https://claude.com/claude-code)
admin added 6 commits 2026-06-09 12:31:27 +03:00
Lift the two HUMAN gates that block an autonomous batch run (epic ORCH-088):
the BRD gate (analysis: manual Approved) and the prod-deploy gate (deploy
Phase A: manual Confirm Deploy, ORCH-059). Selective (a Plane label on the
issue), declarative, reversible, and WITHOUT touching a single technical check.

Additive, mirroring the conditional sub-gates (ORCH-035/043/058/088): leaf
src/labels.py (never-raise) + two point insertions + config flags.
STAGE_TRANSITIONS / QG_CHECKS / check_* / DB schema are NOT touched.

- autoApprove: врезка in _handle_analysis_approved_flow (files_ok branch) ->
  set_issue_approved + log/Telegram/Plane-comment + advance_stage(
  finished_agent=None) — the SAME path a human Approved takes (approved-via-
  status -> analysis->architecture + mark_brd_review_ended). No duplicated
  transition logic; re-entrancy safe.
- autoDeploy: врезка in _handle_self_deploy_phase_a after advance to deploy +
  clear_state -> log/Telegram/Plane-comment + _handle_self_deploy_phase_b
  (INITIATED marker, Deploying, finalizer). Only the indicative human steps are
  skipped. BR-5 holds structurally: Phase A is reached only after the green edge
  sub-gates, so autoDeploy can never deploy a broken build.
- plane_sync: fetch_issue_labels (None on error != []), get_project_labels
  ({normalized_name->uuid}, TTL cache, ambiguity sentinel), set_issue_approved.
- config flags: auto_label_enabled (kill-switch), auto_approve_label/
  auto_deploy_label, auto_label_repos (empty -> self-hosting only),
  auto_label_states_ttl_s. applies() (local) checked FIRST; has_label (network)
  only when applies==True -> zero network / zero regression when disabled (AC-8).
- Fail-safe (never auto on doubt), transparency via log+Telegram+Plane+card,
  read-only auto_labels block in GET /queue.
- Tests TC-01..TC-26 across 7 modules; docs (CLAUDE.md, architecture README,
  CHANGELOG) updated in the same PR.

Refs: ORCH-089

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tester(ET): auto-commit from tester run_id=445
All checks were successful
CI / test (push) Successful in 35s
CI / test (pull_request) Successful in 29s
9b3490ceaa
admin force-pushed feature/ORCH-089-autoapprove-brd-autodeploy from 542cd82f16 to 9b3490ceaa 2026-06-09 12:31:27 +03:00 Compare
admin merged commit 73d936a4c4 into main 2026-06-09 12:38:53 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/orchestrator#89