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

dispatcher-recovery-harden.md

FACTORY_OUTCOME: COMPLETED

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

Итог: B1/B2 исправлены; независимое ревью кода и runbook — PASS в офлайн-границах. Активация остаётся PARKED.
Проблемы: полный набор — 218 passed / 15 failed (все перечислены); production/E2E и причина lock execution 343 не подтверждены.
Решение: принять офлайн-исправление; запуск разрешать отдельно только после drain и остановки старых workers, без смешанных версий.

Dispatcher recovery hardening — 2026-11-29

Read: docs/operating-model/02-security.md, task 255 report
dispatcher-recovery-fix.md, independent dispatcher-recovery-review.md, existing
Task Execution Runbook §8 and runtime documentation. Scope is B1/B2 only.
No production DB writes, activation receipt, migration, restart, deployment, real
executor CLI, external outreach, Coral or paused L-IT changes were performed.
Tests use temporary SQLite databases/artifacts and stub executors. There is no Git
repository; the pre-change dispatcher and final diff/hashes are retained below.

B1 — isolated recovery failures

dispatcher/control_plane_dispatcher.py isolates scan, fence, per-execution
recovery and worker-future failures. A poisoned prepared journal or artifact
failure cannot prevent recovery of subsequent rows or healthy READY dispatch.
One non-lock failure is the explicit bound (N=1): under the task fence, a minimal
separate transaction sets the execution INTERRUPTED, exit code NULL,
RECOVERY_FAILED, and a still-RUNNING task REVIEW. Owner overrides and R1/cycle
exclusions remain. Original journals are unchanged and retained; no executor or
verification is rerun. Invalid/incomplete journals preserve EVIDENCE_MISSING
handling when its transaction succeeds.

BUSY/LOCKED still uses four transaction attempts. Exhaustion leaves RUNNING and
its journal for a later poll, without consuming the non-lock bound. If REVIEW
cannot be persisted, the original execution remains RUNNING and the poll records
review_write_failed; other rows continue. No parking is attempted without the
worker fence. Artifact/telemetry calls are absent from the parking transaction.
Diagnostic events and stderr are best-effort; even a post-commit stdout failure
cannot turn committed success into a recovery error. A DB-wide writer lock can
still block all claims until released; this is not a promise to dispatch through
an unwritable database. Existing replay waits can reach about 20.35 s per locked
attempt; parking/diagnostics use a 50 ms SQLite busy timeout.

B2 — one version, controlled idle rollout

New control_plane/recovery_activation.py guards the default production DB before
cycle initialization, poll_recovery, claim and run_one. Missing, malformed,
wrong-version or wrong-path receipt refuses activation before recovery/claim.
No mixed-version support, age heuristic or interruption of live legacy work was
introduced. Offline tests substitute an isolated DB path; production relocation
must explicitly bind the gate to that path, not use the test override as a bypass.

The future operator helper requires named operator plus explicit old-workers-
stopped and launch-sources-disabled attestations. It acquires the existing global
flock nonblocking and queries the DB read-only: globally zero RUNNING/QUEUED
executions and zero RUNNING tasks are mandatory. Only then is a version/path-bound
receipt atomically published and fsynced. A new fully attested activation revokes
any old receipt before checking, so refusal cannot leave stale authorization.
The helper was exercised only against temporary DBs. Attestations are not process
detection: old/scoped workers may not hold that flock.

Updated existing runbook §8.1–8.3 documents drain without killing work, disabling
all admission/restart sources, stopping old processes only after completion,
process inventory, read-only global idle checks, backup, single-version startup,
receipt lifecycle, rollback and operator REVIEW resolution. Rollback also drains
new workers, removes the receipt before old startup and preserves current evidence;
it never blindly restores an old DB over completed work. Journals for unresolved
attempts are retained indefinitely; no GC/purge was added. Resolved journals may
only be archived during an authorized idle window with identity/checksum/backups;
deletion policy remains an owner decision. Journals share artifact sensitivity.

Evidence

All evidence paths below are relative to review/harden-evidence/.

Resumed after provider/quota interruption. Implementation, regression tests and
runbook were inspected and retained unchanged; this continuation completed the
unfinished verification and report. Tests ran from /home/iovon/ai-factory with
.venv/bin/python. Exact fresh commands: resume-commands.txt. No tests were
excluded from the fresh full Control Plane run.

VerificationResultEvidence
Fresh full control_plane/tests218 passed, 15 failed, 76 subtests passed, 2 deprecation warnings, 611.68 s; exit 1resume-full.log, resume-full.xml, resume-full-failures.json
Fresh outcome recovery + hardening + dispatcher RecoveryTests + checkpoint branch33 passed, 4 subtests passed, 133.32 s; exit 0resume-recovery.log, resume-recovery.xml
R1 + additive migration test, retained completed run51 passed, 3 subtests passed, 202.14 sr1.log; same 51 tests also pass in fresh full run
Legacy probe, retained completed run56 passed, 13 deselected, 15 subtests passed, 269.65 slegacy.log; fresh full run includes all 69 legacy tests and reproduces the same 13 failures
Hardening-only, retained completed run8 passed, 46.55 sharden-final-v2.log; all eight also pass in both fresh runs

The eight hardening cases cover poison identity → one REVIEW/no duplicate attempt
plus healthy READY completion; artifact/event/stderr failure with later healthy
replay; real SQLite lock exhaustion preserving RUNNING/journal and later progress;
failed REVIEW persistence preserving the attempt; unexpected poll failure with
healthy dispatch; refusal for journal-less legacy RUNNING and QUEUED rows without
mutation; missing attestations/global lock/invalid receipt; stale receipt revocation
on failed reactivation. Outcome tests additionally cover corruption, original
baseline, replay idempotency, real contention, fences and owner/R1 exclusions.

Source/runbook SHA-256: resume-source-sha256.json; dispatcher diff against the
retained pre-hardening source: resume-dispatcher.diff. Prior dispatcher.diff
and before-image remain available. No source edits occurred during these runs.

Earlier evidence is not overwritten or represented as successful final evidence:
recovery.log contains 1 failed / 31 passed before the print guard correction;
harden-tests.log records the same intermediate issue. recovery-final.log,
full-suite.log and full-suite-final.log are incomplete interrupted runs.
harden-final.log and harden-final-v2.log are completed earlier hardening runs.

All 15 full-suite failures (no unrelated fixes)

The failure-ID set is exactly the 13 entries in
../r1-evidence/legacy-known-failures.json plus the two ExecutorPolicyTests
entries below. No historical failure ID disappeared and no additional ID appeared.
This matches the independent task-255 review's 15, not its predecessor's
understated 13 or the older accepted-knowledge note of 12. Historical causality
cannot be established without a version-control baseline; these failures remain
unresolved and the full suite is explicitly not green.

All paths below are under control_plane/tests/; full node IDs and unabridged
failure messages are in resume-full-failures.json and full tracebacks in the log.

File / classFailed testObserved failure in this run
test_approved_runtime.py / ApprovedRuntimeTeststest_unavailable_executor_falls_back_once_then_stopsNone != nemotron
test_executor_policy.py / ExecutorPolicyTeststest_creation_forms_and_visible_roadmapExpected Effective executor: dummy · Policy: PRIMARY absent from HTML
test_executor_policy.py / ExecutorPolicyTeststest_inline_javascript_persists_then_refreshes_and_reports_failureNode harness lacks document.getElementById; subprocess exit 1 instead of 0
test_owner_decisions.py / OwnerDecisionTeststest_accessible_compact_layout_contractExpected for="actor-1" absent
test_owner_decisions.py / OwnerDecisionTeststest_missing_executor_global_does_not_crash_templateJinja totals undefined
test_owner_decisions.py / OwnerDecisionTeststest_revision_compact_content_and_preserved_detailsSplit/unpack expected two values, got one
test_owner_decisions.py / OwnerDecisionTeststest_routes_and_single_collapsed_artifact_groupExpected Technical details absent
test_runtime.py / RuntimeTeststest_abc_transient_retry_fallback_and_artifact_continuityB remains READY instead of COMPLETED
test_runtime.py / RuntimeTeststest_coding_fallback_preserves_actual_executor_workspaceThird executor deepseek instead of claude-code
test_runtime.py / RuntimeTeststest_monitor_template_exposes_recoveryJinja totals undefined
test_runtime.py / RuntimeTeststest_no_capable_fallback_stops_for_ownerREADY instead of REVIEW
test_runtime.py / RuntimeTeststest_repeated_crash_has_durable_backoff_and_fallbackantigravity instead of nemotron
test_runtime.py / RuntimeTeststest_root_coding_workspace_is_not_moved_for_fallbackcodex instead of claude-code
test_supervisor.py / SupervisorTeststest_abc_dispatcher_failure_fallback_checkpoint_and_outputsActual COMPLETED/REVIEW/WAITING/WAITING/WAITING differs from expected completed chain
test_supervisor.py / SupervisorTeststest_released_codex_failure_prefers_project_secondary_within_budgetNone != claude-code

The two executor-policy failure messages above are the fresh observations, not
copied attributions from the previous review. No executor defaults, templates,
JavaScript harnesses or unrelated expectations were changed to obtain passes.

Independent review: independent-review.md, separate Codex reviewer, PASS within
offline scope. It found the post-commit print issue and stale-receipt risk during
review; both were corrected and independently rechecked. This is not a claim of
production acceptance or a new Claude review.

Resumed independent source/runbook review by separate Codex agent
/root/resume_independent_review: PASS for B1/B2 within offline scope;
resume-independent-review.md. It confirmed the preserved code and prior review
claims; it ran no tests and saw unfinished logs. The completed test results above
are the main agent's evidence, not an independent test rerun. Activation remains
PARKED and requires the separately authorized runbook procedure.

Limitations: single-host Linux flock/local filesystem semantics; no distributed
lease, power-cut testing, real executor E2E or production load testing. The holder
of the historical execution 343 lock remains unknown. R1 remains PARKED; no
unrelated executor/UI expectation fixes or expanded exclusions were made.

Материалы