← Назад к задаче

r15-dev-isolation.md

FACTORY_OUTCOME: COMPLETED

Сводка для владельца

Итог: создан отдельный лёгкий DEV-корень /home/iovon/ai-factory-dev (9 МБ, локальный Git, без секретов и данных); тесты идут в песочнице без сети и без PROD, 15 известных падений воспроизведены точным набором (ничего не скрыто и не «починено»); в DEV отказ активации теперь виден (выход 78 вместо тихого цикла).
Проблемы: доказанной точки отката для кода работающего диспетчера нет (архив 29.11 12:53 уже содержит новые библиотеки, а процесс запущен 28.11 07:08); любой рестарт PROD-диспетчера = тихий отказ без алерта; сейчас идёт 1 RUNNING (эта задача), активация была бы отклонена; PROD не менялся.
Решение: разрешить ли (а) окно «drain → закрепить старый релиз → рестарт → активация» по плану из §7 либо (б) принять письменно «рестарт = диспетчер остановлен до активации»; принять 15 падений как техдолг; и передать DEV на независимую проверку.

R1.5 — DEV isolation, rollback baseline, release procedure (task 259)

Scope kept: read-only on PROD; no PROD source edit, service change/restart, migration, deletion or activation. All edits/tests are in /home/iovon/ai-factory-dev (DEV). Sources read: docs/operating-model/02-security.md, docs/task-execution/Task-Execution-Runbook.md (§8), task 258 report dispatcher-recovery-harden-review.md (task 258 = FR-DISPATCHER-RECOVERY-HARDEN-REVIEW, COMPLETED). Nothing here is labelled "stable": no release has been proven by production operation.

1. Live release inventory (read-only, 2026-11-29 ~23:12)

ItemFact
Dispatcherai-factory-control-plane-dispatcher.service, PID 4063952, started 2026-11-28 07:08:14, Restart=on-failure, runs /home/iovon/ai-factory/dispatcher/control_plane_dispatcher.py (sha256 a27c7405…)
Consoleai-factory-console.service, PID 4063962, same start, uvicorn 127.0.0.1:8110
Supervisorai-factory-supervisor.service, PID 707, since 2026-10-17, python -m control_plane.supervisor
Timersclaude-health 09:00, claude-live 09:10, health-monitor hourly
Legacy unitai-factory-dispatcher.service loaded but not running
Other listeners (not FACTORY-RUNTIME)8101, 8200, 8300, 8765, 8090, 8400, 8501, 2222, tailscale 8443-8447; stray codex exec PIDs 1112341/1112352 running since 14 Nov
Receiptdata/factory.db.recovery-activation.json absent; data/artifacts/outcomes/ absent
DBdata/factory.db 24.6 MB; main-file sha256 ed297738… (unchanged from the task-258 observation); 1 RUNNING execution (351, task 259 = this task, claude-code), 1 RUNNING task
Resources2 vCPU, 1.9 GB RAM (~700 MB available), disk 18 GB free

Files changed on disk after the running processes started (they hold older code in memory): control_plane/verification.py (29.11 00:02), console/app.py 08:05, supervisor.py 08:06, console/owner_decisions.py 08:42, review_cycles.py 08:42, db.py 12:00, recovery.py/runtime.py 12:02, outcome_journal.py 12:04, service.py 12:07, recovery_activation.py and control_plane_dispatcher.py 12:58. So a restart of the dispatcher, the console or the supervisor loads code that has never run in production.

2. Backup inventory and rollback baseline

BackupCheckResult
backups/runtime-pre-recovery-hardening-20261129-125343/ (source.tar.gz + factory.db)sha256sum -c SHA256SUMS; DB integrity_check (read-only/immutable)both OK; DB ok, 256 tasks, max execution 346
interface-activation-20261128/factory-before-activation.dbintegrityok, 223 tasks, max exec 314 (DB only, no code)
factory-pre-r1-20261129-082817.db, factory-pre-recovery-20261129-111845.dbintegrityok (252 / 253 tasks)
deliverables-*, console-saas-*, otherslistedpartial single-file code copies, no complete set

Key finding — there is no proven code rollback baseline for the running processes. Extracting the 12:53 tarball and comparing with current PROD: it differs only in dispatcher/control_plane_dispatcher.py and two docs. It therefore already contains the new db.py, recovery.py, runtime.py, outcome_journal.py, service.py (edited 12:00–12:07) and lacks only the final gate. The name "pre-hardening" is misleading: it is not the 28.11 07:08 code the live processes run, and no archive of that code exists. Its dispatcher has no activation gate, so as a restart pin it avoids the silent refusal, but it is untested in production.
Test evidence for the tarball (DEV sandbox, path-rewritten copy under data/rb-candidate, not committed): control_plane/tests → 15 failed / 219 passed, identical failing IDs (data/test-logs/rollback-candidate.log). Status: "checksum-verified, test-equivalent candidate", UNVERIFIED as stable. DB backups are integrity-verified restore points for data only.

3. DEV baseline

Root /home/iovon/ai-factory-dev, 315 tracked files, 9.1 MB (code 2.7 MB + 3.2 MB ignored data/). Local Git (user.name DEV Baseline, no remote):

4. Isolation matrix

ResourcePRODDEV
Code root / ROOT/home/iovon/ai-factory/home/iovon/ai-factory-dev (derived from __file__)
DBdata/factory.dbDEV data/factory.db (empty schema) or temp DB; PROD DB not visible
Global/scoped locks, journals (outcomes/), artifacts, receiptPROD data/…DEV data/… (hash of DB path also differs)
Workspacesworkspaces/empty DEV workspaces/
Executorsreal modules, real CLIsdev_tools/fake_executors/* via AI_FACTORY_EXECUTOR_DIR; claude/codex shims exit 97
Credentialssecrets/, /etc/ai-factory/claude.envnone; /home/iovon, /etc/ai-factory, /var/www masked by tmpfs; HOME=/tmp/home
Network / ports8110 etc.--unshare-net; reserved 18110/18200, never started; none listening (checked)
Python.venvsame venv bind-mounted read-only at its PROD path (only PROD path visible)

Runner: dev_tools/run_sandboxed.sh (bubblewrap, nice 19, ionice -c3, timeout). Verified in sandbox: /home/iovon/ai-factory contains only .venv; no secrets/data; outbound connect fails; db.ROOT = DEV root. Caveat: executors' real modules still exist in DEV (path-rewritten) for test parity; they cannot reach credentials or CLIs.

5. Activation refusal (DEV)

Problem confirmed from code: __main__ catches every Exception, and ActivationRefused is a RuntimeError, so with no receipt the process stays alive, prints a line and sleeps 10 s — systemd sees no failure. I reproduced this on dev-baseline-0 (inside the sandbox, no receipt): it ran until my 25 s timeout killed it (exit 124), never exiting.
DEV fix: except ActivationRefused in __main__ prints REFUSED (activation required) to stderr and SystemExit(78) (EXIT_REFUSED, EX_CONFIG). Test: control_plane/tests/test_dev_activation_refusal.py runs the real script and expects exit 78 — passes. The receipt mechanism itself (gate, activate, version/db binding) was not changed; it still binds only a constant VERSION string, and attestations stay operator statements. Not applied to PROD. To make exit 78 non-restarting a PROD unit would need RestartPreventExitStatus=78 (service change, not made). With Restart=on-failure and no such setting systemd would respawn every 5 s (visible in systemctl status/journal as a failed-restart loop) — still visible, unlike today.

6. Tests and the 15 failures

Reproduce: dev_tools/test_all.sh (≈10 s; peak RSS 67 MB for the pytest process; no network).

Suite (sandbox)Result
Targeted recovery (test_outcome_recovery + test_recovery_harden)25 passed
control_plane/tests full15 failed / 219 passed / 76 subtests (234 tests; 233 PROD + my 1 new)
dispatcher/tests13 failed / 83 passed (not baselined in PROD evidence)
executors/tests (*0078* ignored)4 failed / 37 passed (test_claude_code; unbaselined)
tests/8 passed

The 0078 executor tests fail at collection because they load PROD workspaces/plan-0078-* scripts that are deliberately not in DEV; test_materializer.py has a basename collision between two dirs when collected together (run per directory).
Comparison: the 15 failing node IDs equal harden-evidence/resume-full-failures.json exactly (set difference empty both ways; 13 legacy + 2 executor_policy). Nothing fixed, skipped or edited to pass.
Environment-coupling discovered (these initially gave 18 failures in DEV, the extra 3 were DEV artefacts, not regressions): (1) fixtures hard-code the PROD workspace path → DeepSeek excluded in two supervisor tests (fixed by the path rewrite); (2) monitoring_executor_status.py reads the live data/factory.db → test_console_cache needs a schema-only DB (dev_tools/bootstrap.sh). Both show PROD tests are coupled to PROD paths/data.
Triage by assertion signature (not root-caused; each needs a repair task):

7. Release procedure (documented, NOT executed; every step needs owner approval)

Resource budget: DEV test run ≤ 70 MB RAM, ~10 s, one core at nice 19; DEV disk 9 MB (+ test logs). Run only when PROD has spare memory (≈700 MB free now); never concurrently with a PROD window.
Preconditions: (1) owner approves window; (2) pin created (below); (3) independent review of DEV baseline-1; (4) hash manifest of PROD code recorded (PROD_PARITY.sha256 pattern) and compared with the reviewed DEV tag after reverse path-rewrite.
A. Pin the old/known code for unplanned restarts (pre-window, needs approval). Option 1: copy checksum-verified source.tar.gz to /home/iovon/ai-factory-release/pinned-20261129/ and point a systemd drop-in ExecStart at it — but it must share data/ (needs AI_FACTORY data path, not currently configurable: ROOT is derived from __file__), so a pure pin is not feasible without a code change (symlink data → /home/iovon/ai-factory/data in the pin dir would work and should be reviewed). Option 2: owner accepts in writing that an unplanned restart = dispatcher halted until activation (with the exit-78 change this becomes visible).
B. Drain. Stop new launches via existing controls (pause projects / no READY approvals); wait until SELECT count(*) FROM executions WHERE status IN ('RUNNING','QUEUED') = 0 and RUNNING tasks = 0 (read-only mode=ro). Do not kill executors.
C. Inventory and stop. ps/systemctl list of dispatcher (incl. project-scoped control-plane-dispatcher.lock.* holders), supervisor, console, legacy dispatcher, timers; stop all launch sources; record PIDs; backup data/factory.db (+WAL checkpoint) and code tarball with SHA256SUMS.
D. Activate. Deploy reviewed code (single version), recovery_activation.activate(operator=…, old_workers_stopped=True, launch_sources_disabled=True) (refuses unless idle; publishes receipt), start dispatcher, then console/supervisor, verify one cycle and an activation receipt.
E. Rollback. Stop new processes, delete the receipt before starting old code, restore code from the verified tarball (and DB only if data corrupted, from the integrity-checked backup taken in C), keep data/artifacts/outcomes/ journals (never delete), restart. Note: rollback of the code returns to the 12:53 candidate, not to the 28.11 code (§2).
Unresolved PROD restart risk (explicit): receipt absent + new gated code on disk + old processes in memory → any crash/reboot/manual restart of the dispatcher stops dispatching silently; console/supervisor restarts load unexercised code; hourly "database is locked" errors (10 since 28.11) remain unexplained; activation attestations are not process-verified and the receipt is not code-hash-bound.

8. Process inventory at time of report

No DEV process or listener persists (pytest/bwrap finished; ports 18110/18200 free). PROD processes as in §1; I started/stopped none. Temporary extraction dir in /tmp removed. PROD data/factory.db main hash and dispatcher/gate hashes unchanged (ed297738…, a27c7405…, b2b442d3…).

9. Independent review readiness

Ready for independent review of: DEV tags above, dev_tools/*, the sandbox claim (§4), the test comparison (§6) and §7 plan. Not ready for activation. Items for the reviewer: root-cause groups A/B, especially the ABC tests; the pin feasibility (§7A); PROD-path coupling of tests; unbaselined dispatcher/tests (13) and executors/tests (4) failures — these were not run in PROD, so whether they predate DEV is unproven (expected to be the "twelve legacy dispatcher DeepSeek expectations" plus one, unverified).

Limitations

Sandbox tests prove logic offline only; no real executor, power-loss, load or mixed-version testing; systemctl cat/ps/read-only SQLite only on PROD; the 28.11 code could not be reconstructed; no independent Claude acceptance of this report yet.

Материалы