from __future__ import annotations import hashlib import json from typing import Any def stable_hash(obj: Any) -> str: canonical = json.dumps(obj, ensure_ascii=False, separators=(",", ":"), sort_keys=True) return hashlib.sha256(canonical.encode("utf-8")).hexdigest()[:16]