restore(main): долить фантомные ORCH-022/059/066/068 (4 потерянных PR) #71

Merged
admin merged 39 commits from integ/restore-main-2026-06-08 into main 2026-06-08 09:57:18 +03:00

39 Commits

Author SHA1 Message Date
stream
c90c01b919 fix(tests): integ fixtures — to_analyse always present (066), full status keys, security_gate registered (022)
All checks were successful
CI / test (pull_request) Successful in 20s
2026-06-08 06:41:52 +00:00
stream
2ec6873e33 integ: merge ORCH-068 reconciler livelock fix
# Conflicts:
#	docs/architecture/README.md
#	src/reconciler.py
2026-06-08 06:36:29 +00:00
stream
cac6539698 integ: merge ORCH-066 plane status model
# Conflicts:
#	CHANGELOG.md
#	docs/architecture/README.md
#	src/plane_sync.py
#	src/webhooks/plane.py
2026-06-08 06:34:37 +00:00
stream
af7472df05 integ: merge ORCH-059 confirm-deploy
# Conflicts:
#	CHANGELOG.md
#	docs/architecture/README.md
2026-06-08 06:32:53 +00:00
stream
995ba0af71 integ: merge ORCH-022 security/secret-scanning 2026-06-08 06:32:13 +00:00
post-deploy-monitor
06271b0bfb docs(ORCH-021): post-deploy HEALTHY/NONE for ORCH-068
All checks were successful
CI / test (push) Successful in 17s
CI / test (pull_request) Successful in 18s
2026-06-08 05:49:27 +00:00
deploy-finalizer
aa4161fc78 deploy(ORCH-036): finalize SUCCESS for ORCH-068
All checks were successful
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 20s
2026-06-08 05:34:23 +00:00
6bbd530caa tester(ET): auto-commit from tester run_id=351
All checks were successful
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 21s
2026-06-08 05:18:46 +00:00
4b03f213f7 reviewer(ET): auto-commit from reviewer run_id=349 2026-06-08 05:18:46 +00:00
1d72c44587 fix(reconciler): stop F-2 livelock spam on synced terminal tasks + cache TTL
Reconciler F-2 spammed Telegram "<wi> разблокирована" every ~120s for a
fully-synchronized Done task (incident ET-002, 191+ msgs/night) after the
ORCH-066 Plane status model merge. Two stacked defects (defense in depth):

- D1 (selection): actionable states were told apart by bare UUID, so a Done
  issue aliased onto the approved UUID entered the approved branch. Now
  terminal states are excluded by Plane state GROUP (completed/cancelled),
  a project-independent discriminator robust to UUID aliasing; per-issue
  check with a logical-key fallback when the group is unavailable.
  get_project_states caches {uuid -> group} from the same /states/ fetch;
  new sibling accessor get_project_state_groups.
- D2 (notification): _note_unblock fired unconditionally after _dispatch.
  Now it only fires on a confirmed state change (stage before/after _dispatch;
  task-appears for the start case) — handlers' contracts untouched.
- TR-3: in-memory dedup guard {issue_id -> last unblocked state} as a backstop.
- TR-4: _STATES_CACHE lived for the whole process lifetime, so a new Plane
  status was invisible without a restart. Added TTL ORCH_PLANE_STATES_TTL_S
  (default 300s; 0 = previous lifetime cache) reusing reload_project_states();
  a failed refresh serves the stale-but-correct set, not enduro defaults.

STAGE_TRANSITIONS / QG_CHECKS / DB schema / handle_* contracts / F-1 / F-3
unchanged; never-raise preserved; self-hosting tick never restarts prod.
Observability: skipped_terminal_total / deduped_total in /queue reconcile block.

Tests: tests/test_reconciler_plane.py (TC-01..TC-10),
tests/test_plane_states_cache.py (TC-11/TC-12).

Refs: ORCH-068

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-08 05:18:46 +00:00
0605309602 architect(ET): auto-commit from architect run_id=347 2026-06-08 05:18:46 +00:00
044894cbe9 analyst(ET): auto-commit from analyst run_id=346 2026-06-08 05:18:46 +00:00
cb11137a77 docs: init ORCH-068 business request 2026-06-08 05:18:46 +00:00
post-deploy-monitor
72d662ae88 docs(ORCH-021): post-deploy HEALTHY/NONE for ORCH-066
All checks were successful
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 19s
2026-06-07 22:33:36 +00:00
deploy-finalizer
348cf8c164 deploy(ORCH-036): finalize SUCCESS for ORCH-066
All checks were successful
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 19s
2026-06-07 22:18:32 +00:00
bc2347abd3 tester(ET): auto-commit from tester run_id=343
All checks were successful
CI / test (push) Successful in 21s
CI / test (pull_request) Successful in 18s
2026-06-07 22:02:45 +00:00
62c1fe3461 reviewer(ET): auto-commit from reviewer run_id=342 2026-06-07 22:02:45 +00:00
0dfddf93f0 feat(plane): осмысленная статусная модель Plane (слой B — индикация)
Приводит статусы доски Plane к смыслу стадий конвейера, сохраняя
инвариант «статус — индикация, а не управление». Меняется только слой B
(отображение: src/plane_sync.py + точки выставления статуса в
stage_engine.py/webhooks/plane.py/reconciler.py); слой A — машина стадий
src/stages.py::STAGE_TRANSITIONS — остаётся байт-в-байт неизменным (AC-21).

- 6 новых логических ключей статуса (to_analyse, analysis, code_review,
  awaiting_deploy, deploying, monitoring) + сеттеры и диспетчер
  set_issue_stage_state.
- Project-relative alias-fallback (BR-12): новый ключ деградирует на
  базовый UUID того же проекта → нулевая регрессия для enduro-trails.
- Самодеплой (ORCH-036) индицирует фазы: Awaiting Deploy / Deploying;
  terminal-sync для self-hosting → Monitoring after Deploy, для прочих →
  терминальный Done.
- Post-deploy монитор (ORCH-021): HEALTHY → Done, DEGRADED → Blocked
  (только индикация; self-hosting ALERT_ONLY, прод не трогается, BR-5).
- Reconciler: триггер старта/резюма на To Analyse; Guard 2 учитывает
  новые активные ожидания без расширения skip-set на алиасах.
- never-raise контракт сеттеров и резолвера состояний сохранён.
- Раскатка — созданием статусов в Plane оператором, без kill-switch.

Инварианты не менялись: STAGE_TRANSITIONS, QG_CHECKS (12 чеков),
check_deploy_status, exit-код-контракт хука, merge-gate, схема БД.

ADR: docs/work-items/ORCH-066/06-adr/ADR-001-plane-status-model.md
Тесты: test_plane_status_model, test_plane_to_analyse_resume,
test_plane_status_failclosed + TC в существующих наборах. 774 passed.

Refs: ORCH-066

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 22:02:45 +00:00
22d3b77426 architect(ET): auto-commit from architect run_id=340 2026-06-07 22:02:45 +00:00
4a06537afd analyst(ET): auto-commit from analyst run_id=339 2026-06-07 22:02:45 +00:00
b6c0e11e4d docs: init ORCH-066 business request 2026-06-07 22:02:45 +00:00
post-deploy-monitor
9f4d79baee docs(ORCH-021): post-deploy HEALTHY/NONE for ORCH-059
All checks were successful
CI / test (push) Successful in 18s
CI / test (pull_request) Successful in 19s
2026-06-07 19:44:39 +00:00
deploy-finalizer
7cdef6d377 deploy(ORCH-036): finalize SUCCESS for ORCH-059
All checks were successful
CI / test (push) Successful in 18s
CI / test (pull_request) Successful in 18s
2026-06-07 19:29:34 +00:00
post-deploy-monitor
0cbb7ef0bb docs(ORCH-021): post-deploy HEALTHY/NONE for ORCH-022
All checks were successful
CI / test (push) Successful in 18s
CI / test (pull_request) Successful in 18s
2026-06-07 19:24:29 +00:00
ca41d9210b tester(ET): auto-commit from tester run_id=337
All checks were successful
CI / test (push) Successful in 20s
CI / test (pull_request) Successful in 17s
2026-06-07 19:20:41 +00:00
48943fe10a reviewer(ET): auto-commit from reviewer run_id=336 2026-06-07 19:20:41 +00:00
86fe8dd509 feat(deploy): dedicated "Confirm Deploy" status triggers prod deploy
Split the overloaded `Approved` Plane status: it served BOTH as the human BRD
gate on `analysis` AND as the silent Phase B prod-deploy trigger on `deploy`
(ORCH-036), so a routine approve could launch a self-hosting prod restart.

ORCH-059 introduces a dedicated logical status `confirm_deploy` ("Confirm
Deploy") that triggers ONLY Phase B on `deploy`; `Approved` stays purely a
pipeline gate.

- plane_sync: map "Confirm Deploy" -> "confirm_deploy" in _PLANE_NAME_TO_KEY;
  intentionally absent from _DEFAULT_STATES => fail-closed (no UUID -> .get
  yields None, no KeyError, no blind deploy).
- webhooks/plane: handle_issue_updated routes "Confirm Deploy" (fail-closed
  .get) to new handle_confirm_deploy (guarded to stage=="deploy") ->
  _try_advance_stage(confirm_deploy=True).
- stage_engine: advance_stage gains keyword-only confirm_deploy=False; Phase B
  block returns early for deploy+finished_agent is None but only initiates the
  deploy when confirm_deploy=True; a plain Approved is a deterministic no-op
  (returns before check_deploy_status -> no false БАГ-8 rollback).
- Phase A CTA now asks the operator for "Confirm Deploy", not "Approved".

Contracts unchanged: STAGE_TRANSITIONS, QG_CHECKS, check_deploy_status, hook
exit codes, Phases A/C, merge-gate, DB schema. Conditional like ORCH-35/36
(self-hosting only). Docs updated (CLAUDE.md, architecture/README.md, CHANGELOG).

Refs: ORCH-059

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 19:20:41 +00:00
dd07b58165 architect(ET): auto-commit from architect run_id=334 2026-06-07 19:20:41 +00:00
b67a61ecef analyst(ET): auto-commit from analyst run_id=333 2026-06-07 19:20:41 +00:00
8fcb867dcf docs: init ORCH-059 business request 2026-06-07 19:20:41 +00:00
deploy-finalizer
e07ee9e574 deploy(ORCH-036): finalize SUCCESS for ORCH-022
All checks were successful
CI / test (push) Successful in 17s
CI / test (pull_request) Successful in 17s
2026-06-07 18:42:29 +00:00
8cdb9f194a tester(ET): auto-commit from tester run_id=331
All checks were successful
CI / test (push) Successful in 19s
CI / test (pull_request) Successful in 19s
2026-06-07 18:04:50 +00:00
cb3bdd9c7a reviewer(ET): auto-commit from reviewer run_id=330 2026-06-07 18:04:50 +00:00
Dev
04233cb3c8 test(ORCH-022): isolate TC-17 worktree under tmp_path (fix CI PermissionError on /repos/_wt)
TC-17 seeded 17-security-report.md via get_worktree_path() which resolves to
settings.worktrees_dir (default /repos/_wt) -> the test wrote into the real shared
host worktree path. In CI that dir is owned by another user -> PermissionError.

Monkeypatch git_worktree.settings.worktrees_dir to tmp_path/_wt (same pattern as
test_git_worktree.py / test_merge_gate.py). Prod logic untouched.
2026-06-07 18:04:50 +00:00
stream
85ecf50926 ci: re-run after gitea restart (ORCH-022 flaky CI) 2026-06-07 18:04:50 +00:00
30b6187c73 feat(security): security-gate (gitleaks secret-scan + pip-audit) before merge
Add a deterministic (no-LLM) security sub-gate on the deploy-staging -> deploy
edge, run FIRST (before merge-gate ORCH-043 and image-freshness ORCH-058) so it
fails cheaply before any expensive rebase/rebuild, and scans origin/main..HEAD
before rebase so a task is never blamed for a CVE introduced by an updated main.

Why: the autonomous pipeline merged branches into main with no check for a leaked
secret or a vulnerable dependency. For the self-hosting orchestrator (one shared
prod instance serving every project from a shared DB) a single leak/CVE landed in
the prod of all projects (CLAUDE.md self-hosting, section 8).

- New leaf src/security_gate.py (never-raise): gitleaks (offline, fail-closed on
  tool error => secrets guarantee is unconditional) + pip-audit (best-effort;
  unreachable CVE feed degrades fail-open + loud warning by default, strict via
  security_dep_audit_fail_closed). Verdict lives ONLY in 17-security-report.md
  YAML frontmatter (write -> read-back single source of truth); FAIL is
  authoritative; missing/broken frontmatter => fail-closed.
- check_security_gate thin wrapper registered in QG_CHECKS (lazy import, no cycle).
- _handle_security_gate wired FIRST in advance_stage deploy-staging block: FAIL ->
  rollback to development + developer-retry (cap MAX_DEVELOPER_RETRIES); task_desc
  carries verbatim findings (ORCH-046 pattern). No merge-lease release (runs before
  lease acquire). Self-hosting safe: only reads/scans/writes, never deploys.
- Conditional rollout (security_gate_enabled + security_gate_repos; empty scope ->
  self-hosting only). 6 new ORCH_SECURITY_* settings.
- Infra: pinned gitleaks Go binary in Dockerfile (+curl/ca-certificates), pip-audit
  in requirements.txt, versioned .gitleaks.toml at repo root.
- STAGE_TRANSITIONS and DB schema unchanged.

Docs: docs/architecture/README.md (marked realized), CLAUDE.md (artifact 17),
CHANGELOG.md. Tests: test_security_gate.py, test_qg_security.py,
test_stage_engine_security_gate.py + updated registry/edge snapshots.

Refs: ORCH-022

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-07 18:04:50 +00:00
44db94e462 architect(ET): auto-commit from architect run_id=327 2026-06-07 18:04:50 +00:00
4f24f96169 analyst(ET): auto-commit from analyst run_id=326 2026-06-07 18:04:50 +00:00
2d20da295e docs: init ORCH-022 business request 2026-06-07 18:04:50 +00:00