STATE-WP-0069 T06: add workplan flow entity and prefer open_workplans
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Introduce flows/workplan.yaml and /flows/workplan/* routes alongside the
legacy workstream flow. Dashboard, README, and MCP flow docs now prefer
open_workplans with open_workstreams fallback until dual-key retirement.
This commit is contained in:
tegwick 2026-07-08 21:26:07 +02:00
parent f596fc27c7
commit 2b83654ac3
12 changed files with 122 additions and 13 deletions

View file

@ -24,12 +24,19 @@ from api.workplan_status import normalize_workplan_status
router = APIRouter(prefix="/flows", tags=["flows"])
_WORKPLAN_FLOW_ENTITY_TYPES = frozenset({"workplan", "workstream"})
def _is_workplan_flow(entity_type: str) -> bool:
return entity_type in _WORKPLAN_FLOW_ENTITY_TYPES
@router.get("/definitions")
async def list_flow_definitions() -> list[dict[str, Any]]:
flows = [
load_flow(entity_type)
for entity_type in (
"workplan",
"workstream",
"task",
"contribution",
@ -93,7 +100,7 @@ async def advance_workstation(
)
entity = await _entity(entity_type, entity_id, session)
if entity_type == "workstream":
if _is_workplan_flow(entity_type):
transition_workplan_status(entity, target_workstation)
elif entity_type == "task":
parent = await session.get(Workplan, entity.workplan_id)
@ -117,7 +124,9 @@ async def _flow_object(
) -> dict[str, Any]:
entity = await _entity(entity_type, entity_id, session)
status = _value(entity.status)
current_status = normalize_workplan_status(status) if entity_type == "workstream" else status
current_status = (
normalize_workplan_status(status) if _is_workplan_flow(entity_type) else status
)
obj: dict[str, Any] = {
"id": str(entity.id),
"status": current_status,
@ -125,7 +134,7 @@ async def _flow_object(
"previous_workstation": current_status,
}
if entity_type == "workstream":
if _is_workplan_flow(entity_type):
tasks = list((await session.execute(
select(Task).where(Task.workplan_id == entity_id)
)).scalars().all())
@ -163,6 +172,7 @@ async def _entity(
session: AsyncSession,
):
model_by_type = {
"workplan": Workplan,
"workstream": Workplan,
"task": Task,
"contribution": Contribution,