sched: entry-level history cursor so tied occurrence entries paginate exactly once (B4)
This commit is contained in:
@@ -767,6 +767,74 @@ async def test_occurrences_pending_synthesis_first_page_only(tmp_path: Path) ->
|
||||
assert all(row["kind"] != "pending" for row in plain["occurrences"])
|
||||
|
||||
|
||||
async def test_occurrences_pagination_visits_tied_entries_once(tmp_path: Path) -> None:
|
||||
"""One occurrence's admission + stops each appear exactly once (B4).
|
||||
|
||||
Small-page traversal through the public API must not lose the tied
|
||||
stopped entries sharing the occurrence's ``(resolved_at,
|
||||
occurrence_id)``.
|
||||
"""
|
||||
api, sched_store, _, _, _ = _harness(tmp_path / "tied")
|
||||
await api.create_schedule(
|
||||
schedule_id="s", deployment_id="dep.personal", trigger=_cron()
|
||||
)
|
||||
base = ts(2026, 9, 8, 12, 0)
|
||||
recorder = FileScheduleHistoryRecorder(sched_store)
|
||||
recorder.record(
|
||||
HistoryEntry(
|
||||
schedule_id="s",
|
||||
kind="admitted",
|
||||
resolved_at=base,
|
||||
run_id="run-1",
|
||||
revision=1,
|
||||
reason="rev=1",
|
||||
created_at=base,
|
||||
)
|
||||
)
|
||||
recorder.record(
|
||||
HistoryEntry(
|
||||
schedule_id="s",
|
||||
kind="interrupted",
|
||||
resolved_at=base,
|
||||
run_id="run-1",
|
||||
revision=1,
|
||||
reason="fresh-result",
|
||||
checkpoint_id="run-1.000001",
|
||||
created_at=base + timedelta(minutes=5),
|
||||
)
|
||||
)
|
||||
recorder.record(
|
||||
HistoryEntry(
|
||||
schedule_id="s",
|
||||
kind="completed",
|
||||
resolved_at=base,
|
||||
run_id="run-1",
|
||||
revision=1,
|
||||
reason="reconciled-on-recovery",
|
||||
checkpoint_id="run-1.000002",
|
||||
created_at=base + timedelta(minutes=9),
|
||||
)
|
||||
)
|
||||
|
||||
seen: list[tuple[str, str | None]] = []
|
||||
cursor: str | None = None
|
||||
while True:
|
||||
page = await api.list_schedule_occurrences(
|
||||
schedule_id="s", cursor=cursor, limit=1
|
||||
)
|
||||
assert page["total"] == 3
|
||||
for row in page["occurrences"]:
|
||||
seen.append((row["kind"], row["checkpoint_id"]))
|
||||
cursor = page["next_cursor"]
|
||||
if cursor is None:
|
||||
break
|
||||
assert seen == [
|
||||
("admitted", None),
|
||||
("interrupted", "run-1.000001"),
|
||||
("completed", "run-1.000002"),
|
||||
]
|
||||
|
||||
|
||||
async def test_inspect_admitted_run_without_fabrication(tmp_path: Path) -> None:
|
||||
api, sched_store, run_store, artifact_store, context = _harness(
|
||||
tmp_path / "admitted"
|
||||
|
||||
Reference in New Issue
Block a user