CUST-WP-0055 T05: workplan-first progress scope in sinks and resolvers
Prefer workplan_id in State Hub progress writes while dual-writing workstream_id for wire-compat. Extend schedule_health, evidence/report sinks, phase5 checks, k8s triage prose, and SCOPE terminology.
This commit is contained in:
parent
7947961ed4
commit
69fe69041f
12 changed files with 135 additions and 30 deletions
|
|
@ -4,7 +4,9 @@ from __future__ import annotations
|
|||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from activity_core.schedule_health import evaluate_schedule_health
|
||||
import httpx
|
||||
|
||||
from activity_core.schedule_health import evaluate_schedule_health, post_missed_fire_alert
|
||||
|
||||
NOW = datetime(2026, 6, 23, 12, 0, tzinfo=timezone.utc)
|
||||
|
||||
|
|
@ -70,6 +72,35 @@ def test_no_fire_recorded_for_due_schedule_is_unhealthy() -> None:
|
|||
assert "no recorded fire" in health.reasons[0]
|
||||
|
||||
|
||||
def test_post_missed_fire_alert_dual_writes_workplan_scope(monkeypatch) -> None:
|
||||
posts: list[dict] = []
|
||||
|
||||
class _Resp:
|
||||
def raise_for_status(self) -> None: ...
|
||||
def json(self) -> dict[str, str]:
|
||||
return {"id": "progress-1"}
|
||||
|
||||
monkeypatch.setattr(httpx, "post", lambda url, **kwargs: posts.append(kwargs) or _Resp())
|
||||
|
||||
health = evaluate_schedule_health(
|
||||
activity_id="daily",
|
||||
missed_catchup_window=1,
|
||||
last_fired_at=NOW - timedelta(days=2),
|
||||
now=NOW,
|
||||
expected_interval=timedelta(days=1),
|
||||
)
|
||||
result = post_missed_fire_alert(
|
||||
health,
|
||||
state_hub_url="http://state-hub.test",
|
||||
workplan_id="wp-123",
|
||||
)
|
||||
|
||||
assert result["status"] == "posted"
|
||||
body = posts[0]["json"]
|
||||
assert body["workplan_id"] == "wp-123"
|
||||
assert body["workstream_id"] == "wp-123"
|
||||
|
||||
|
||||
def test_no_interval_and_no_fire_is_not_flagged() -> None:
|
||||
# Without an expected interval we cannot assert a miss from absence alone.
|
||||
health = evaluate_schedule_health(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue