23 lines
699 B
Python
23 lines
699 B
Python
"""Event journaling helpers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .errors import ValidationError
|
|
from .store import TaskPlaneStore
|
|
|
|
|
|
class TaskJournal:
|
|
def __init__(self, store: TaskPlaneStore):
|
|
self.store = store
|
|
|
|
def append(self, task_id: str, event_type: str, data: dict, *, subject: str | None = None) -> None:
|
|
if not event_type:
|
|
raise ValidationError("event_type required")
|
|
self.store.append_event(task_id, event_type, data, subject=subject)
|
|
|
|
def list(self, task_id: str) -> list[dict]:
|
|
return self.store.list_events(task_id)
|
|
|
|
def check_chain(self, task_id: str) -> bool:
|
|
return self.store.verify_event_chain(task_id)
|