FACTORY_OUTCOME: COMPLETED ## Сводка для владельца Итог: независимый (Claude) вердикт — B1 и B2 закрыты PASS в офлайн-границах: хэши совпадают, 33/33 целевых и мои 7 дополнительных проб прошли, полный набор даёт те же 15 падений. Для R1.5 код готов только как «PARKED, без активации». Проблемы: (1) новый код с гейтом уже лежит в боевом каталоге, а работающий диспетчер (PID 4063952) запущен до этого и без receipt — любой его рестарт превратится в тихий бесконечный отказ (цикл ловит ошибку и просто спит), без падения сервиса и алерта; (2) сейчас в боевой БД 1 RUNNING execution и 1 RUNNING task — активация отказала бы (не idle); (3) активация опирается на аттестации оператора, а не на детекцию процессов; (4) 15 падений полного набора не устранены, причина lock execution 343 не доказана, у боевого диспетчера почасовые «database is locked». Решение: принять офлайн-вердикт PASS; активацию не разрешать до отдельного окна (drain → остановка всех старых процессов → activate); решить, как удерживать рестарт-риск до окна (пинить версию кода или принять тихий отказ), и считать ли 15 падений техдолгом. # Independent review — dispatcher recovery hardening (task 257), B1/B2 Reviewer: independent Claude (Sonnet 5.5). The Codex self-reviews (`independent-review.md`, `resume-independent-review.md`) were **not** used as acceptance; I used them only as claims to check. Scope: source, runbook, evidence and offline tests. I made no source repairs, no production DB writes, no migration, restart, deployment, activation or real executor CLI. Probes are in `/tmp/rev2/` (outside the repo); I added no repo files. There is no git repo, so I compared against the retained `*.before.py` and diff files. ## Verdict | Item | Verdict | |---|---| | B1 — per-row failure isolation, lock exhaustion, no dispatcher wedge | **PASS (offline)** | | B2 — single-version idle rollout, receipt, rollback docs | **PASS (offline), with operational conditions below** | | Owner/fence semantics | **PASS** | | Full suite green | **NO** — 15 failures, identical to the claimed set; not caused by this change | | Readiness for R1.5 | **Ready as PARKED/offline only. No activation.** Listed conditions apply before any window. | ## 1. Source and evidence hashes - All 11 SHA-256 values in `harden-evidence/resume-source-sha256.json` match the current files: dispatcher `a27c7405…`, recovery_activation `b2b442d3…`, tests `c0f82556…` and `1408798d…`, db `fcb01880…`, recovery `76bd8f32…`, outcome_journal `ba0635c1…`, runtime `4272ea72…`, service `10d1335f…`, the runbook `c39c92ae…` and `FACTORY_RUNTIME.md` `7aa167ae…`. - All 10 entries in `resume-evidence-sha256.json` match, including the harden report `2473e662…`. - File mtimes put the last source edit (12:58) before the resumed runs (17:4x–17:54), so no source edit happened during them. - `data/factory.db` main-file SHA-256 was `ed297738…` before and after my work. `data/artifacts/outcomes/` does not exist, so the journal has never run in production. No `*.recovery-activation.json` receipt exists. - The prior report's claim "independent" for its review refers to Codex agents. That is Codex self-review, not Claude acceptance. ## 2. B1 — failure isolation (checked in source, the diff and tests) - `poll_recovery` (`dispatcher/control_plane_dispatcher.py`) wraps the scan, the fence and each row separately. A scan failure returns `scan_failed`. A fence failure never mutates the row (`fence_failed`). - A non-lock failure parks the row once (N=1) with `_park_recovery`. It runs in its own `BEGIN IMMEDIATE`, with a 50 ms busy timeout, and uses no artifact or telemetry calls. It sets the execution INTERRUPTED with exit_code NULL and `RECOVERY_FAILED`, and sets the task to REVIEW only if it is still RUNNING. It skips cycle/R1-managed executions and keeps `OWNER_OVERRIDE`. The journal is untouched. - BUSY/LOCKED exhaustion leaves the row RUNNING with its journal and records `lock_exhausted`. A failed parking write records `review_write_failed` and leaves the row RUNNING. Neither case blocks other rows. - `cycle` catches non-activation errors from `poll_recovery` and from worker futures. Claim and dispatch continue. `ActivationRefused` is deliberately re-raised. - My extra probes (`/tmp/rev2/test_probe.py`, temp DB, stub executors) passed: - A fence held by a **separate process** over a poisoned journal gives `live_worker` and no mutation. - An owner-moved task (ACCEPTED) with a failing finalize gives INTERRUPTED/`OWNER_OVERRIDE` and the task stays ACCEPTED. - Three consecutive polls with a failing `finalize` call it exactly once. The parked row is not retried, so there is no duplicate attempt. - Receipt variants (wrong version/database, empty operator, false attestations, non-JSON) are each refused. - `activate` refuses when only a RUNNING task exists, and leaves no receipt. - `activate` on an idle DB publishes a receipt. **Residual B1 notes (non-blocking):** - N=1 means one transient non-lock error (for example a brief disk-full) permanently parks a good prepared outcome in REVIEW. This is conservative, and the runbook §8.1 operator procedure covers it. A parked execution is terminal, so there is no replay tool yet. - Worst-case lock wait is still about 20 s per row inside the single-threaded poll. - The journal-deleted-after-prepared re-execution risk (from task 255) remains. It is now documented in §8.3. ## 3. B2 — rollout gate, owner fencing, receipt - The gate runs in `cycle` (before `init_db`), `poll_recovery`, `claim` and `run_one`. It applies only when `db.DB_PATH` resolves to `ROOT/data/factory.db`. Tests use a temp DB path, which is the documented override; it is not a production bypass because the default path is gated. - `activate()` requires a named operator and both attestations. It takes the global flock non-blocking, queries `mode=ro` for zero RUNNING/QUEUED executions and zero RUNNING tasks, then writes the receipt atomically (temp file, fsync, `os.replace`, directory fsync). A fully attested call first deletes any old receipt, so a refused re-activation leaves no stale authorization. - Runbook §8.1–8.3 match the code: drain without killing work, process inventory, read-only global idle counts, backup, single version, rollback that removes the receipt before old startup, indefinite journal retention. **Limitations of the gate:** - The two attestations are operator statements, not process detection. An old dispatcher sleeping between cycles does not hold the global flock, so the flock check cannot prove it is gone. - The receipt binds only a constant `VERSION` string and the DB path, not a code hash. Edited code with the same VERSION still passes. - The receipt is a plain JSON file. Anyone with write access to `data/` can hand-write one. - A refused or failed re-activation revokes the receipt even while a new-version dispatcher is running. That dispatcher then refuses at its next cycle. ## 4. Restart refusal risk (the main operational finding) Read-only observations of the live host: - The new gated code is **already on disk** at `/home/iovon/ai-factory` (hashes match). `ai-factory-control-plane-dispatcher.service` runs the same path (`ExecStart=…/dispatcher/control_plane_dispatcher.py`) with `Restart=on-failure`. The running process (PID 4063952, started 2026-11-28 07:08) has old code in memory. - No receipt exists. Any restart (crash, host reboot, manual or service restart) loads the new code. `__main__` wraps `cycle()` in `except Exception: print(...); sleep(10)`, and `ActivationRefused` is a `RuntimeError`. The process therefore **stays alive and silently refuses every cycle**. systemd sees no failure, `Restart=on-failure` never fires, and only a log line is printed every 10 s. Dispatching stops with no alert. - The supervisor (PID 707, started 2026-10-17) also runs old code. Its restart behaviour was not exercised. - The current DB has 1 RUNNING execution and 1 RUNNING task (most likely this review task). Activation would be refused at this moment. - The live dispatcher logged "database is locked" 10 times since 2026-11-28 07:08, about hourly (latest 2026-11-29 21:36). This is the same class as the execution 343 incident. The hardening is not active in that process. Requirement: before any window, either keep a pinned copy of the old release for service restarts, or accept in writing that an unplanned restart equals "dispatcher halted until activation". Add an explicit non-zero exit or alert for `ActivationRefused` so the halt is visible. That is a code change for the next task, not a repair made here. ## 5. Test evidence (my own runs, offline, temp DBs, stub executors) | Run | Result | |---|---| | `test_outcome_recovery.py` + `test_recovery_harden.py` + dispatcher `RecoveryTests` + checkpoint-branch test | **33 passed, 4 subtests**, 61 s | | My probes (`/tmp/rev2/test_probe.py`, 7 new + inherited cases) | **13 passed**, 21 s | | Full `control_plane/tests` | **218 passed, 15 failed, 76 subtests passed**, 473 s (matches the claimed 218/15/76) | The 15 failing node IDs are **exactly identical** to `resume-full-failures.json` (set difference empty). They equal the 13 in `r1-evidence/legacy-known-failures.json` plus two `ExecutorPolicyTests` (`test_creation_forms_and_visible_roadmap`, `test_inline_javascript_persists_then_refreshes_and_reports_failure`). Nothing disappeared and nothing new appeared. The two extras match what the task-255 review found, and that review showed they fail identically with the connection change reverted. These are outdated executor-default, UI and fallback expectations (the same debt as the legacy DeepSeek expectations in project knowledge). They are not recovery regressions, but the suite is **not green**. R1 evidence: the same 51 R1 and migration tests pass inside the full run, and no R1 failure ID appears among the 15. ## 6. Blockers For R1.5 as PARKED / offline there are **no code blockers**. **Blockers before any activation or DEV/PROD separation:** 1. Restart-refusal handling (§4): silent spin on missing receipt. Needs a visible failure or pinned old release. 2. Process detection: activation relies on attestations only. Needs a recorded process inventory in the window, or a code-hash-bound receipt. 3. Receipt not code-bound, and path gating is hard-wired to `ROOT/data/factory.db`. A DEV copy has its own ROOT and receipt, which is acceptable. DEV must not share `data/control-plane-dispatcher.lock`, the artifact `outcomes/` journal root, or the DB. Journal paths hash the DB path, so they do not collide. The global lock path is derived from ROOT. Re-check any DEV setup that points two roots at one DB. 4. No version control. Rollback depends on manual copies; DEV/PROD parity cannot be checked by diff. Take a snapshot and hash set before any window. 5. The live dispatcher's hourly lock errors are unexplained; execution 343's holder is unproven. The fix is recoverability, not lock-cause removal. 6. The 15 suite failures should be triaged before DEV/PROD gating relies on the suite. ## 7. Limitations Offline only: temp SQLite, stub executors, single-host `flock`. I did not test power loss, a real executor CLI, production load, mixed versions or the real `activate` against production. I did not run `systemctl`, restart anything or read process memory. Service, process and journal observations were read-only (`ps`, `systemctl cat/list`, `journalctl`, read-only `sqlite3`). I did not use the Codex reviews as evidence. This verdict does not authorize migration, restart, deployment or activation. ## Сводка (RU) - Хэши исходников и доказательств (11 + 10) совпадают; код тот же, что описан. Боевая БД и артефакты не менялись. - B1: сбои по строкам изолированы; один нелоковый сбой паркует попытку в REVIEW (N=1), lock-исчерпание оставляет RUNNING и журнал; работоспособные задачи продолжают выполняться. Подтверждено кодом, 33/33 тестами и моими пробами (чужой процесс держит fence, OWNER_OVERRIDE, отсутствие повторных попыток). - B2: гейт на `cycle/poll_recovery/claim/run_one`, activation под глобальным flock с нулём RUNNING/QUEUED и RUNNING-задач, атомарный receipt, отзыв старого receipt, runbook §8.1–8.3 соответствует коду. - Полный набор: 218 passed / 15 failed, ID падений идентичны заявленным (13 легаси + 2 executor_policy), не связаны с исправлением; набор не зелёный. - Главный риск: новый код уже на диске, receipt нет, работающий диспетчер — старый. Рестарт приведёт к тихому бесконечному отказу (процесс жив, диспетчеризация стоит, без алерта). Сейчас в БД 1 RUNNING — активация была бы отклонена. - Прочее: активация держится на аттестациях оператора; receipt не привязан к хэшу кода; нет VCS; у боевого диспетчера почасовые «database is locked»; причина lock execution 343 не доказана. - Вердикт: PASS для офлайн-границ и R1.5 в статусе PARKED; активации нет; перед окном нужно решить вопрос рестарт-отказа и процесс-инвентаризации.