feat(replication): расхардкод хоста + секреты нового хоста + smoke-runbook
All checks were successful
CI / test (push) Successful in 57s
CI / test (pull_request) Successful in 55s

Фундамент тиража 10-common (эпик ORCH-10): платформа разворачивается на
новой инфре без правки кода — только env/конфиг. Каждый дефолт = боевому
значению (пустой .env => поведение 1:1, kill-switch-природа, NFR-2);
STAGE_TRANSITIONS/QG_CHECKS/check_*/machine-verdict/схема БД не тронуты.

- config: agent_home_dir / agent_git_name / git_email_domain / staging_port
  (ADR-001 D2/D4); код-блокеры A1-A4 закрыты: plane_sync ссылки из
  gitea_public_url+gitea_owner, launcher - единый agent_git_env() (x2 места),
  self_deploy/post_deploy - HOME+домен из Settings (имена системных акторов -
  платформенные литералы)
- image_freshness: staging_port из конфига + fail-closed guard
  staging_port == прод-порт -> отказ ДО ssh/build (инвариант ORCH-058 AC-9
  стал исполняемым); REPO= передаётся хуку явно обоими инвокерами (D7)
- SELF_HOSTING_REPO - нормативная платформенная константа (D3, пин-тест)
- compose: полная ${VAR:-default}-интерполяция (реестр B, карта D6); группа
  ORCH-040 uid/gid/HOME/маунты двигается согласованно (build.args APP_*);
  group_add "МИНА 1" сохранён x3; оба app-сервиса с явным command:
- Dockerfile: ARG APP_UID/APP_GID/APP_USER/APP_HOME (CMD exec-form 8500
  сознательно не тронут - D5); deploy-hook: REPO="${REPO:-...}" (D1 реестра)
- секреты: stdlib scripts/gen_secrets.py (token_hex(32); печать по умолчанию;
  --write никогда не перезаписывает существующий .env молча, exit=2;
  перезапись только --force); .env.example дополнен до полноты ключей старта
- доки: новый docs/operations/REPLICATION.md (карта env, чек-лист секретов,
  smoke-процедура с PASS/FAIL, границы 10-common/Lite/Bundled), INFRA.md,
  README, CLAUDE.md, CHANGELOG
- анти-регресс: tests/test_no_host_hardcodes.py (tokenize-сканер запрещённых
  литералов, config-модули - структурное исключение, allowlist пуст,
  негативная самопроверка) + test_host_config_keys / test_infra_parametrization
  / test_secrets_gen / test_replication_smoke; согласованные структурные
  правки test_orch040_compose (судит резолв дефолтов) и
  test_deploy_hook_rollback_sim (REPO через env-override = контракт D7)

Полный регресс: 1764 passed.

Refs: ORCH-101

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 20:50:43 +03:00
parent 26bdd783d6
commit f1635ddb39
26 changed files with 1583 additions and 86 deletions

View File

@@ -55,6 +55,40 @@ class Settings(BaseSettings):
# DB
db_path: str = "/app/data/orchestrator.db"
# ORCH-101 (replication foundation, ADR-001 D2/D4): host-parametrization keys.
# config.py is the ONLY legitimate home of host-specific literals in src/**
# (BR-1); every default below equals the current production value, so an
# absent/unchanged .env keeps behaviour byte-for-byte (BR-5, kill-switch
# nature — no extra flag is introduced, NFR-2).
# agent_home_dir -> HOME of every actor subprocess env (agent CLI Popen +
# git commit/push in agents/launcher, self-deploy
# finalizer, post-deploy monitor). The SAME env name is
# interpolated by docker-compose.yml as the target of
# the .claude/.claude.json/.ssh mounts and wired into
# Dockerfile ARG APP_HOME — one env name per fact (D1);
# the ORCH-040 uid/HOME/mounts group moves together.
# Env ORCH_AGENT_HOME_DIR.
# agent_git_name -> GIT_AUTHOR/COMMITTER_NAME of agent commits (the
# customer-visible identity). Env ORCH_AGENT_GIT_NAME.
# git_email_domain -> domain of ALL actor git emails, built as
# f"{name}@{git_email_domain}"; name = agent_git_name
# for agents, and the PLATFORM literals
# deploy-finalizer / post-deploy-monitor for system
# actors (their names are not host-specific, D2).
# Env ORCH_GIT_EMAIL_DOMAIN.
# staging_port -> port of the staging instance (8501). Replaces the
# module constant image_freshness._STAGING_PORT; the
# SAME env name is interpolated into the staging
# compose `command:` so both readers see one fact (D1).
# Fail-closed guard in check_staging_image_fresh:
# staging_port == deploy_prod_target_port -> the
# freshness path REFUSES to run (ORCH-058 AC-9 made
# executable, D4). Env ORCH_STAGING_PORT.
agent_home_dir: str = "/home/slin"
agent_git_name: str = "claude-bot"
git_email_domain: str = "mva154.local"
staging_port: int = 8501
# ORCH-1 (F-2b): persistent job queue / background worker.
# max_concurrency -> max agent jobs running in parallel (env ORCH_MAX_CONCURRENCY)
# queue_poll_interval -> worker loop poll seconds (env ORCH_QUEUE_POLL_INTERVAL)