"""Stable workbench event-stream and synchronization contracts.""" from __future__ import annotations from typing import Literal from uuid import UUID from pydantic import Field, JsonValue from app.domain.schemas.operational_task import ( OperationalTaskNotification, OperationalTaskSummary, ) from app.domain.schemas.shared import NonEmptyStr, PositiveInt, StrictModel from app.domain.schemas.workbench_runtime import WorkbenchDateTime, WorkbenchRuntimeSnapshot WorkbenchEventTopic = Literal[ "operational.task.changed", "operational.run.queued", "operational.run.changed", "operational.report.published", "operational.progress.changed", "operational.presentation.requested", "operational.action.changed", "operational.notification.changed", "workbench.alert.changed", "workbench.work_order.changed", "analysis.run.changed", ] class WorkbenchEvent(StrictModel): schema_name: Literal["workbench-event@1"] = Field(alias="schema") event_seq: PositiveInt event_id: UUID project_id: UUID topic: WorkbenchEventTopic aggregate_type: NonEmptyStr aggregate_id: NonEmptyStr aggregate_revision: PositiveInt occurred_at: WorkbenchDateTime metadata: dict[str, JsonValue] class WorkbenchSyncSnapshot(StrictModel): schema_name: Literal["workbench-sync-snapshot@1"] = Field(alias="schema") event_cursor: int = Field(ge=0) runtime: WorkbenchRuntimeSnapshot tasks: list[OperationalTaskSummary] notifications: list[OperationalTaskNotification] generated_at: WorkbenchDateTime