The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(doctor): classify certificate-anchored DRs as stable + keep explicit env_map hermetic
Teknium6cb3a26353ad
diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.pyindex ba30f11c34e..4dbe8445995 100644--- a/hermes_cli/doctor.py+++ b/hermes_cli/doctor.py@@ -616,9 +616,15 @@ def collect_relay_plugin_cutover_findings()effective_env = dict(env_map or {})- for name in (*LEGACY_RELAY_EXPORT_ENV_VARS, RELAY_PLUGINS_CONFIG_ENV):- if name not in effective_env and os.environ.get(name) is not None:- effective_env[name] = os.environ[name]+ # Fall through to process-level env ONLY when no explicit env_map was+ # given: run_doctor passes None and wants live-process vars included, but+ # callers (and tests) that hand in an explicit map are describing a+ # complete environment — merging os.environ on top breaks hermeticity on+ # any box that exports legacy relay vars (10-vs-2 findings, Aug 2026).+ if env_map is None:+ for name in (*LEGACY_RELAY_EXPORT_ENV_VARS, RELAY_PLUGINS_CONFIG_ENV):+ if name not in effective_env and os.environ.get(name) is not None:+ effective_env[name] = os.environ[name]if not str(effective_env.get(RELAY_PLUGINS_CONFIG_ENV, "")).strip():for name in configured_legacy_relay_env_vars(effective_env):findings.append(@@ -1086,10 +1092,19 @@ def check_macos_tcc_grants() -> None:"identity, then re-grant permissions once.",)return- check_ok(- "macOS TCC signing identity is stable",- "(identifier-pinned DR; grants survive rebuilds)",- )+ if "certificate" in dr.lower():+ # Certificate-anchored DR (hermes desktop --setup-tcc-identity, or a+ # notarized release build): the strongest anchor TCC can key on.+ check_ok(+ "macOS TCC signing identity is stable",+ "(certificate-anchored DR; grants survive rebuilds)",+ )+ else:+ check_ok(+ "macOS TCC signing identity is stable",+ "(identifier-pinned DR; grants survive rebuilds — for the strongest "+ "anchor, see `hermes desktop --setup-tcc-identity`)",+ )check_info("If macOS still re-prompts for permissions (toggle shows ON): the stored ""grant is stale — run `tccutil reset ScreenCapture com.nousresearch.hermes` "diff --git a/tests/hermes_cli/test_doctor.py b/tests/hermes_cli/test_doctor.pyindex 8c9163be29a..08e6a15e393 100644--- a/tests/hermes_cli/test_doctor.py+++ b/tests/hermes_cli/test_doctor.py@@ -1576,10 +1576,36 @@ class TestMacOSTCCGrants:doctor_mod.check_macos_tcc_grants()out = capsys.readouterr().outassert "TCC signing identity is stable" in out+ assert "identifier-pinned" in out+ # Identifier-pinned is stable but not the strongest anchor — the check+ # should point at the cert-anchored upgrade path.+ assert "--setup-tcc-identity" in outassert "tccutil reset ScreenCapture com.nousresearch.hermes" in outassert "toggle" in outassert "relaunch" in out+ def test_ok_on_certificate_anchored_dr(self, monkeypatch, capsys, tmp_path):+ """A cert-anchored DR (hermes desktop --setup-tcc-identity, or a+ notarized release) classifies as stable in its own class — no upgrade+ hint, still prints the stale-grant repair info."""+ monkeypatch.setattr(doctor_mod.sys, "platform", "darwin")+ monkeypatch.setattr(+ doctor_mod,+ "_desktop_app_bundle",+ lambda: tmp_path / "Hermes.app",+ )+ monkeypatch.setattr(+ doctor_mod,+ "_macos_desktop_dr",+ lambda app: 'designated => identifier "com.nousresearch.hermes" and certificate root = H"aabbcc"',+ )+ doctor_mod.check_macos_tcc_grants()+ out = capsys.readouterr().out+ assert "TCC signing identity is stable" in out+ assert "certificate-anchored" in out+ assert "--setup-tcc-identity" not in out+ assert "tccutil reset ScreenCapture com.nousresearch.hermes" in out+def test_warns_when_dr_unreadable(self, monkeypatch, capsys, tmp_path):"""codesign failure → warn, never crash."""monkeypatch.setattr(doctor_mod.sys, "platform", "darwin")