STATE-WP-0070: identity headers, archive 0069, phase-2 workplan
Some checks failed
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Has been cancelled

Add X-StateHub-Component to fix-consistency and other State Hub REST callers for
legacy-meter attribution. Archive STATE-WP-0069; open STATE-WP-0070 for
meter-gated phase-2 retirement. Task POST bodies use workplan_id only.
This commit is contained in:
tegwick 2026-07-09 00:39:09 +02:00
parent 2f06751d4f
commit bb6bec9f10
10 changed files with 198 additions and 17 deletions

View file

@ -25,6 +25,7 @@ from statehub_register import run_register as run_statehub_register
STATE_HUB_DIR = Path(__file__).resolve().parent
API_BASE = os.environ.get("API_BASE", "http://127.0.0.1:8000")
_LEGACY_METER_HEADERS = {"X-StateHub-Component": "state-hub.custodian-cli"}
TEMPLATE = STATE_HUB_DIR / "scripts" / "project_claude_md.template"
PATCH_CWD = STATE_HUB_DIR / "scripts" / "patch_mcp_cwd.py"
@ -81,7 +82,8 @@ _ONBOARDING_TASKS = [
def _api_get(path: str) -> object:
url = API_BASE.rstrip("/") + path
try:
with urllib.request.urlopen(url, timeout=10) as r:
req = urllib.request.Request(url, headers=_LEGACY_METER_HEADERS)
with urllib.request.urlopen(req, timeout=10) as r:
return json.loads(r.read())
except urllib.error.URLError as e:
print(f"ERROR: Cannot reach API at {API_BASE}: {e}")
@ -92,7 +94,11 @@ def _api_get(path: str) -> object:
def _api_post(path: str, body: dict) -> object:
url = API_BASE.rstrip("/") + path
data = json.dumps({k: v for k, v in body.items() if v is not None}).encode()
req = urllib.request.Request(url, data=data, headers={"Content-Type": "application/json"})
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json", **_LEGACY_METER_HEADERS},
)
with urllib.request.urlopen(req, timeout=10) as r:
return json.loads(r.read())
@ -103,7 +109,7 @@ def _api_patch(path: str, body: dict) -> object:
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json"},
headers={"Content-Type": "application/json", **_LEGACY_METER_HEADERS},
method="PATCH",
)
with urllib.request.urlopen(req, timeout=10) as r: