"""Custodian State Hub reporting (REST, no MCP) — the gateway's own audit trail. Mirrors rein-aharness's/rein-openweights's hub.py, but under glas-harness's own actor attribution. Both reins' CLIs are invoked with their own hub reporting disabled (`--no-hub`) by their glas-harness adapters — this module is what makes the gateway's audit trail exist independent of which rein ran (GLAS-WP-0002-T03). """ from __future__ import annotations import os from typing import Any import httpx _DEFAULT_URL = "http://127.0.0.1:8000" _TIMEOUT = 10.0 def _base_url() -> str: return os.environ.get("STATE_HUB_URL", _DEFAULT_URL).rstrip("/") def post_progress_event( summary: str, event_type: str, detail: dict[str, Any], task_id: str | None = None, ) -> bool: payload: dict[str, Any] = { "summary": summary, "event_type": event_type, "detail": detail, "author": "agt-glas-harness", } if task_id: payload["task_id"] = task_id try: resp = httpx.post(f"{_base_url()}/progress/", json=payload, timeout=_TIMEOUT) resp.raise_for_status() return True except httpx.HTTPError: return False