STATE-WP-0069 T03: normalize MCP progress events to workplan_id
_emit_progress_event strips legacy workstream_id from POST /progress/ payloads. Task and decision side-effect events now set workplan_id explicitly so automatic progress logging stays workplan-first.
This commit is contained in:
parent
7b2348ef90
commit
242dd25253
4 changed files with 47 additions and 7 deletions
|
|
@ -152,12 +152,21 @@ def _response_error(
|
|||
return None
|
||||
|
||||
|
||||
def _normalize_progress_body(body: dict[str, Any]) -> dict[str, Any]:
|
||||
normalized = dict(body)
|
||||
workplan_id = normalized.get("workplan_id") or normalized.get("workstream_id")
|
||||
normalized.pop("workstream_id", None)
|
||||
if workplan_id is not None:
|
||||
normalized["workplan_id"] = workplan_id
|
||||
return normalized
|
||||
|
||||
|
||||
def _emit_progress_event(
|
||||
tool_name: str,
|
||||
write_result: dict[str, Any],
|
||||
body: dict[str, Any],
|
||||
) -> dict[str, Any] | None:
|
||||
progress = _post("/progress", body)
|
||||
progress = _post("/progress", _normalize_progress_body(body))
|
||||
error = _response_error(f"{tool_name}.progress_event", progress, ("id",))
|
||||
if error:
|
||||
return _mcp_error(
|
||||
|
|
@ -923,7 +932,7 @@ def update_task_status(
|
|||
|
||||
progress_error = _emit_progress_event("update_task_status", task, {
|
||||
"task_id": task_id,
|
||||
"workstream_id": task.get("workstream_id"),
|
||||
"workplan_id": task.get("workplan_id") or task.get("workstream_id"),
|
||||
"event_type": "task_status_changed",
|
||||
"summary": f"Task status → {status}: {task['title']}",
|
||||
"author": "custodian",
|
||||
|
|
@ -983,7 +992,7 @@ def flag_for_human(task_id: str, note: str) -> str:
|
|||
|
||||
progress_error = _emit_progress_event("flag_for_human", task, {
|
||||
"task_id": task_id,
|
||||
"workstream_id": task.get("workstream_id"),
|
||||
"workplan_id": task.get("workplan_id") or task.get("workstream_id"),
|
||||
"event_type": "task_flagged_human",
|
||||
"summary": f"Task flagged for human intervention: {task['title']}",
|
||||
"author": "custodian",
|
||||
|
|
@ -1012,7 +1021,7 @@ def clear_human_flag(task_id: str) -> str:
|
|||
|
||||
progress_error = _emit_progress_event("clear_human_flag", task, {
|
||||
"task_id": task_id,
|
||||
"workstream_id": task.get("workstream_id"),
|
||||
"workplan_id": task.get("workplan_id") or task.get("workstream_id"),
|
||||
"event_type": "task_flag_cleared",
|
||||
"summary": f"Human-intervention flag cleared: {task['title']}",
|
||||
"author": "custodian",
|
||||
|
|
@ -1128,7 +1137,7 @@ def resolve_decision(
|
|||
|
||||
progress_error = _emit_progress_event("resolve_decision", decision, {
|
||||
"topic_id": decision.get("topic_id"),
|
||||
"workstream_id": decision.get("workstream_id"),
|
||||
"workplan_id": decision.get("workplan_id") or decision.get("workstream_id"),
|
||||
"decision_id": decision_id,
|
||||
"event_type": "decision_resolved",
|
||||
"summary": f"Decision resolved by {decided_by}: {decision['title']}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue