sched: require proven ownership at poll/admin/recovery entries (F5)

This commit is contained in:
lda
2026-09-08 11:24:40 +07:00 Verified
parent 15bd472bdc
commit 993ed07fd3
7 changed files with 293 additions and 22 deletions
+8
View File
@@ -13,6 +13,8 @@ from __future__ import annotations
from datetime import datetime, timezone
from typing import Any
from wf_scheduling.ownership import SchedulerOwnership, SecondOwnerError
UTC = timezone.utc
ABANDONED_REASON = (
@@ -30,11 +32,17 @@ def recover(
schedule_store: Any,
run_store: Any,
now: datetime,
ownership: SchedulerOwnership,
record_history: Any | None = None,
) -> list[str]:
"""Reconcile durable state after a restart without executing work."""
from wf_artifacts.runs.models import StoredRunStatus
if ownership is None or not ownership.held:
raise SecondOwnerError(
"scheduler ownership is required before recovery: an unowned "
"recovery could abandon or redispatch another owner's work"
)
diags: list[str] = []
# Admission record is the recovery authority: admitted but never
# materialized views are completed here and flagged pending for the