From 28dee4632aea22229a02cdce4e429250caf0d865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 31 Jul 2026 08:54:57 +0400 Subject: [PATCH] v1.2.0: unified executor + flexible instance refs + params-render.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 1 — New modules: - api/utils.py: find_uid(), uid_from_location() (replaces 2 duplicates) - operations/poll.py: poll_until_done() (shared sync/async polling) - operations/executor.py: execute_operation() (single CREATE/non-CREATE flow) Phase 2 — Format + validation: - routes/api_scenario_defs.py: _validate_steps with output/instance_ref/instance_uid - operations/scenario.py: resolve instance_uid > instance_ref > service_id, use executor + poll_until_done, persist instance_bindings Phase 3 — Migration: - routes/api_test.py: create/non-create through executor, _finish_op through poll_until_done - db/init_db.py: startup cleanup of stuck scenario_runs (>1h) Phase 4 — UI shared module: - static/js/params-render.js: renderParamRow, renderMapFixedRow, collectParams - static/js/operations.js: use params-render.js (remove duplicates) - templates/index.html: include params-render.js - app.py: bump 1.1.57 → 1.2.0 --- DOCS/architecture-next.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 DOCS/architecture-next.md diff --git a/DOCS/architecture-next.md b/DOCS/architecture-next.md new file mode 100644 index 0000000..f16e527 --- /dev/null +++ b/DOCS/architecture-next.md @@ -0,0 +1,38 @@ +# Архитектура app-autotest — план рефакторинга (2026-07-31) + +> Полный план: `DOCS/opus-plan-2026-07-31.md` +> Ветка: `opus-architecture-2026-07-31` + +## Проблемы + +1. **Дублирование CREATE-флоу:** `routes/api_test.py` и `operations/scenario.py` содержат идентичную логику POST /instances → POST /instanceOperations → send_params_terraform → /run. +2. **Ограничение instance_map:** сценарий привязан к `service_id`, нельзя два инстанса одного сервиса. +3. **Нет общей функции** — правки Terraform-флоу надо делать в двух местах. + +## Решение + +### Новые файлы +- `operations/executor.py` — `execute_operation()` (единый флоу до /run) +- `operations/poll.py` — `poll_until_done()` (общий цикл поллинга) +- `api/utils.py` — `find_uid()`, `uid_from_location()` (вместо дублей) +- `static/js/params-render.js` — общий рендер параметров + +### Новый формат шагов +```json +{"service_id": 1, "operation": "create", "params": {}, "output": "d1"} +{"service_id": 1, "operation": "modify", "params": {}, "instance_ref": "d1"} +{"service_id": 1, "operation": "delete", "params": {}, "instance_uid": "UUID"} +``` + +### Исправляемые файлы +- `routes/api_test.py` — через executor (+ CMDB delete отдельно) +- `operations/scenario.py` — через executor + poll_until_done + output/ref резолвинг +- `routes/api_scenario_defs.py` — _validate_steps с новыми ключами +- `db/init_db.py` — startup cleanup зависших scenario_runs +- `static/js/scenario-form.js` — модальный редактор с параметрами +- `static/js/operations.js` — использовать params-render.js +- `templates/index.html` — модал + params-render.js +- `app.py` — bump VERSION + +### Порядок +Фаза 1 (общие модули) → Фаза 2 (формат шагов) → Фаза 3 (миграция вызывающих) → Фаза 4 (UI)