#!/usr/bin/env python3
from __future__ import annotations
import hashlib
import json
import sys
from pathlib import Path
from types import SimpleNamespace

PROFILE = Path("/home/cube/.hermes/profiles/dualcoachtest")
sys.path[:0] = [
    "/home/cube/.hermes/profiles/dualcoachtest/workspace/checkin_cli",
    "/home/cube/projects/richard/hermes-agent",
]


def main() -> int:
    from gateway.platforms.nutrition_coaching import load_committed_customer_registry
    from gateway.platforms.telegram import TelegramAdapter

    registry, path = load_committed_customer_registry(PROFILE)
    root, resolved = TelegramAdapter._configured_nutrition_registry(
        SimpleNamespace(registry_path="customers/registry.json"),
        SimpleNamespace(profile_root=PROFILE, extra={}),
    )
    if (
        len(registry.customers) != 0
        or path != PROFILE / "customers/registry.json"
        or resolved != path
        or root != PROFILE.resolve()
    ):
        raise RuntimeError("candidate registry resolution mismatch")
    out = {
        "schema": "task26-candidate-gateway-offline-registry-verification-v1",
        "status": "PASS",
        "configured_nutrition_registry": str(resolved),
        "load_committed_customer_registry_customers": 0,
        "registry_sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
        "network_calls": 0,
        "service_started": False,
    }
    print(json.dumps(out, sort_keys=True, separators=(",", ":")))
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
