state-hub/dashboard/src/data/summary.json.py
tegwick 6d3de59436 STATE-WP-0070 T04 (partial): drop open_workstreams from /state/summary
Removes the redundant open_workstreams mirror field from StateSummary (schema,
router, MCP get_domain_summary reader, dashboard consumers + empty-state stub,
and tests). Consumers already preferred open_workplans, so this is the
low-risk half of T04.

Deferred (still have live callers — not yet retirement-ready):
- workstream_id query/body field alias on preferred routes — external
  session-close curls/scripts fleet-wide still send it.
- flows/workstream.yaml — /flows/workstream/{id} routes are still served and
  exercised by tests; retire only once no callers remain.

Staged on branch state-wp-0070-legacy-retirement — do not merge until the 7th
documented zero-usage window is captured.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-13 10:04:38 +02:00

41 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Observable data loader: fetches /state/summary from the API."""
import json
import os
import sys
import urllib.request
import urllib.error
API_BASE = os.environ.get("API_BASE", "http://127.0.0.1:8000").rstrip("/")
try:
with urllib.request.urlopen(f"{API_BASE}/state/summary", timeout=10) as resp:
data = json.loads(resp.read())
print(json.dumps(data))
except urllib.error.URLError as e:
# Return empty structure so the dashboard can show an error state
print(json.dumps({
"error": str(e),
"generated_at": None,
"totals": {
"topics": {"active": 0, "paused": 0, "archived": 0, "total": 0},
"workstreams": {
"proposed": 0,
"ready": 0,
"active": 0,
"blocked": 0,
"backlog": 0,
"finished": 0,
"archived": 0,
"total": 0,
},
"tasks": {"wait": 0, "todo": 0, "progress": 0, "done": 0, "cancel": 0, "total": 0},
"decisions": {"open": 0, "resolved": 0, "escalated": 0, "superseded": 0, "total": 0},
},
"topics": [],
"blocking_decisions": [],
"waiting_tasks": [],
"blocked_tasks": [],
"recent_progress": [],
"open_workplans": [],
}))