Skip to content

The agent that grows with you

fix(update): keep the retirement downgrade probe fail-closed

Teknium3bdb82d6ec4b
diff --git a/hermes_cli/source_releases.py b/hermes_cli/source_releases.py
index 831c9587635..8944a1198a5 100644
--- a/hermes_cli/source_releases.py
+++ b/hermes_cli/source_releases.py
@@ -218,17 +218,21 @@ def _refuse_retirement_downgrade(request: dict, terminal: dict, git_cmd, cwd) ->
if tuple(map(int, installed_version.split("."))) > tuple(map(int, request["sourceVersion"].split("."))):
raise ValueError("Source retirement would downgrade a newer source version; select the destination channel explicitly")
if git_cmd is not None:
- result = _probe(git_cmd, cwd, "rev-list", "--ancestry-path", f"{request['commit']}..HEAD")
+ from hermes_cli.source_check import source_git_env
+
+ result = subprocess.run(
+ [*git_cmd, "rev-list", "--ancestry-path", f"{request['commit']}..HEAD"], cwd=cwd,
+ capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=10,
+ stdin=subprocess.DEVNULL, env=source_git_env(),
+ check=False,
+ )
# The target need not exist locally before the updater's fetch. When it
# does, any descendants prove that this pinned build would roll us back.
- # An unanswered probe proves nothing either.
- if result is not None and result.returncode == 0 and result.stdout.strip():
+ if result.returncode == 0 and result.stdout.strip():
raise ValueError("Source retirement would downgrade a newer source commit; select the destination channel explicitly")
if terminal["head"]["sequence"] > request["sequence"]:
# Shallow checkouts may lack the qualified commit, even when HEAD is
# today's stable build. Read it with the protocol's full digest checks.
- from hermes_cli.source_check import source_git_env
-
current_manifest = _resolve_channel(terminal["name"], request["repository"]).manifest
if current_manifest is None:
raise ValueError("Source retirement cannot verify the current destination build")
diff --git a/tests/hermes_cli/test_stable_forward_only_shallow.py b/tests/hermes_cli/test_stable_forward_only_shallow.py
index a34a31becd1..74382ca863d 100644
--- a/tests/hermes_cli/test_stable_forward_only_shallow.py
+++ b/tests/hermes_cli/test_stable_forward_only_shallow.py
@@ -1,5 +1,5 @@
-"""An unchosen default channel never moves a checkout backward on a guess, and a probe that never
-answered never refuses the update (regression for #137646)."""
+"""An unchosen default channel never moves a checkout backward on a guess, and an ancestry probe
+that never answered never refuses the update (regression for #137646)."""
import subprocess
import pytest
@@ -79,13 +79,3 @@ def test_a_probe_that_never_answered_leaves_the_relation_unknown(history, monkey
monkeypatch.setattr(source_check, "_github_compare", lambda *a, **k: compare)
assert source_releases._head_containing(["git"], origin, shas[2], "o/r") == (shas[2] if keeps_head else None)
assert timed_out == [["git", "merge-base", "--is-ancestor", shas[2], shas[2]]]
-
-
-def test_a_probe_that_never_answered_cannot_refuse_a_retirement(tmp_path, monkeypatch):
- """The same silence on the retirement probe is not a proven downgrade either (#137646)."""
- timed_out = _timeout_git_probe(monkeypatch, "rev-list")
- checkout = tmp_path / "checkout"
- checkout.mkdir()
- request = {"commit": "0" * 40, "sequence": 1, "sourceVersion": "0.1.0", "repository": "o/r"}
- source_releases._refuse_retirement_downgrade(request, {"head": {"sequence": 1}}, ["git"], checkout)
- assert timed_out == [["git", "rev-list", "--ancestry-path", f"{request['commit']}..HEAD"]]