From 291c33040c291cb44685871b2cf032b3e64e5e55 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 16:38:16 -0700 Subject: [PATCH] refactor(models): fold credential-file mtime fingerprinting into one helper --- hermes_cli/models.py | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/hermes_cli/models.py b/hermes_cli/models.py index 665647fd8f..e1971f08c4 100644 --- a/hermes_cli/models.py +++ b/hermes_cli/models.py @@ -1856,34 +1856,25 @@ def _credential_fingerprint(provider: str) -> str: + json.dumps(provider_cfg.get("extra_headers", {}), sort_keys=True, default=str) ) - # OAuth / external-file mtimes that change on re-auth + # OAuth / external credential-file mtimes that change on re-auth. + def _mtime_part(label: str, path) -> None: + try: + parts.append(f"{label}@{_os.stat(path).st_mtime_ns}") + except FileNotFoundError: + parts.append(f"{label}@missing") + except Exception: + pass + try: from hermes_constants import get_hermes_home for rel in ("auth.json", "credentials.json"): - p = get_hermes_home() / rel - try: - parts.append(f"{rel}@{p.stat().st_mtime_ns}") - except FileNotFoundError: - parts.append(f"{rel}@missing") - except Exception: - pass + _mtime_part(rel, get_hermes_home() / rel) except Exception: pass - - # External well-known credential file locations - for path in ( - _os.path.expanduser("~/.codex/auth.json"), - _os.path.expanduser("~/.claude/.credentials.json"), - _os.path.expanduser("~/.config/github-copilot/hosts.json"), - _os.path.expanduser("~/.minimax/credentials.json"), - ): - try: - mt = _os.stat(path).st_mtime_ns - parts.append(f"{path}@{mt}") - except FileNotFoundError: - parts.append(f"{path}@missing") - except Exception: - pass + for rel in ("~/.codex/auth.json", "~/.claude/.credentials.json", + "~/.config/github-copilot/hosts.json", "~/.minimax/credentials.json"): + path = _os.path.expanduser(rel) + _mtime_part(path, path) blob = "|".join(parts).encode("utf-8", errors="replace") # blake2b, not sha256: fingerprint only (collisions = a harmless cache miss), and CodeQL's