sched: typed history recorder with exactly-once terminal reconcile (F4)

This commit is contained in:
lda
2026-09-08 11:39:13 +07:00 Verified
parent 78a966d722
commit 5a6056b144
7 changed files with 879 additions and 82 deletions
+23
View File
@@ -168,6 +168,29 @@ class FileScheduleStore:
entries.append(record.model_dump(mode="json"))
self._write_json(path, entries)
def has_history_entry(
self,
schedule_id: str,
*,
run_id: str,
kind: str,
checkpoint_id: str | None = None,
) -> bool:
"""Whether this exact stopped result already has a history entry.
Idempotency identity is ``(run_id, kind, checkpoint_id)``: repeats
of one recovery pass dedup, while a resumed run that stops again
(new checkpoint id) records a new entry.
"""
for item in self._read_history_locked(schedule_id):
if (
item.get("run_id") == run_id
and item.get("kind") == kind
and item.get("checkpoint_id") == checkpoint_id
):
return True
return False
@staticmethod
def _sort_key(
item: OccurrenceRecord,