STATE-WP-0069 T04: Sunset headers and POST /progress body metering
Add Sunset to legacy compat responses (Jun 2027 planning horizon). Meter POST /progress/ bodies that use workstream_id; wire hub-core body hook. Consolidate workstreams deprecation headers via legacy_compat.
This commit is contained in:
parent
05a138bc1c
commit
6e5e150803
8 changed files with 126 additions and 14 deletions
|
|
@ -2,7 +2,7 @@ import uuid
|
|||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
||||
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, model_validator
|
||||
|
||||
from api.schemas.compat import OptionalWorkplanIdCompatMixin
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ class ProgressEventCreate(BaseModel):
|
|||
default=None,
|
||||
validation_alias=AliasChoices("workplan_id", "workstream_id"),
|
||||
)
|
||||
used_legacy_workstream_id: bool = Field(default=False, exclude=True)
|
||||
task_id: uuid.UUID | None = None
|
||||
decision_id: uuid.UUID | None = None
|
||||
event_type: str
|
||||
|
|
@ -21,6 +22,14 @@ class ProgressEventCreate(BaseModel):
|
|||
author: str | None = None
|
||||
session_id: str | None = None
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _detect_legacy_workstream_id(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict):
|
||||
if data.get("workstream_id") is not None and data.get("workplan_id") is None:
|
||||
return {**data, "used_legacy_workstream_id": True}
|
||||
return data
|
||||
|
||||
|
||||
class ProgressEventRead(OptionalWorkplanIdCompatMixin, BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue