"""SSE / replay envelope. Wire names are camelCase; payloads stay snake_case.""" from __future__ import annotations from typing import Any from pydantic import BaseModel, ConfigDict, Field from app.report_collaboration.contracts.enums import CollaborationEventType class CollaborationEventEnvelope(BaseModel): """Durable event envelope consumed by the frontend reducer.""" model_config = ConfigDict(extra="forbid", populate_by_name=True) event_id: str = Field(alias="eventId") session_id: str = Field(alias="sessionId") run_id: str | None = Field(default=None, alias="runId") seq: int = Field(ge=1) type: CollaborationEventType timestamp: str data: dict[str, Any] = Field(default_factory=dict) def to_sse_dict(self) -> dict[str, Any]: return self.model_dump(by_alias=True, exclude_none=False)