Skip to content

The agent that grows with you

fix(review): all-external fleet proves nothing for a SHA-less marker; holder argv strips both quote kinds

teknium17627eb466f29
diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.py
index 765fae19a61..49a30b827a5 100644
--- a/hermes_cli/update_cmd_fleet.py
+++ b/hermes_cli/update_cmd_fleet.py
@@ -437,9 +437,11 @@ def _marker_only_restart_obsolete() -> bool:
except Exception as exc:
logger.debug("Fleet probe failed; keeping fleet-restart-pending marker: %s", exc)
return False
- if not fleet:
+ if not fleet or (not expected_sha and all(row_is_external(row) for row in fleet)):
if owed is not None or not expected_sha:
- return False # Absence cannot prove recovery of the recorded inventory / unnamed code.
+ # Absence cannot prove recovery of the recorded inventory / unnamed code; a fleet
+ # whose every row serves ANOTHER checkout root is absence too, not evidence.
+ return False
return _discharge_gatewayless_marker(checkout_sha, expected_sha)
covered = _fleet_covered_gateways(fleet)
if covered is None:
diff --git a/hermes_cli/update_cmd_windows.py b/hermes_cli/update_cmd_windows.py
index d0d019d89b2..2dd7c35d03e 100644
--- a/hermes_cli/update_cmd_windows.py
+++ b/hermes_cli/update_cmd_windows.py
@@ -244,7 +244,7 @@ def _hermes_holder_subcommand(cmdline: str) -> str | None:
# inline source carries for a LATER spawn, not to this holder (#107002) -- unless the source is a
# Hermes bootstrap running the entry point in this process (#124318).
from gateway.status import command_line_runs_inline_source, inline_bootstrap_argv
- normalized = [t.strip('"').replace("\\", "/") for t in tokens]
+ normalized = [t.strip("\"'").replace("\\", "/") for t in tokens]
if command_line_runs_inline_source(normalized):
tokens = inline_bootstrap_argv(normalized)
if tokens is None:
diff --git a/tests/hermes_cli/test_update_fleet_restart_pending.py b/tests/hermes_cli/test_update_fleet_restart_pending.py
index 0168e7f7f5a..357dbd8c79a 100644
--- a/tests/hermes_cli/test_update_fleet_restart_pending.py
+++ b/tests/hermes_cli/test_update_fleet_restart_pending.py
@@ -1098,6 +1098,30 @@ def test_startup_warn_discharged_when_sha_less_marker_fleet_current(monkeypatch,
assert not update_cmd_fleet._fleet_restart_obligation_armed()
+def test_startup_warn_kept_when_sha_less_marker_fleet_is_all_external(monkeypatch, capsys):
+ """Every live gateway serving ANOTHER checkout root says nothing about this checkout's code:
+ the SHA-less marker stays armed exactly as it does with no fleet at all."""
+ checkout = "e" * 40
+ path = host_obligation.host_obligation_path()
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(json.dumps({
+ "version": 1, "started": 0.0, "pid": 424242, "armed_by_profile": "default", "expected_sha": "",
+ }), encoding="utf-8")
+ _patch_marker_sha(monkeypatch, checkout)
+ monkeypatch.setattr(
+ "hermes_cli.update_receipt.collect_fleet_versions",
+ lambda **kwargs: [
+ {"profile": "other", "pid": 43, "code_sha": "f" * 40, "code_version": "0.21.5", "state": "external",
+ "code_root": "/elsewhere/hermes-agent"}
+ ],
+ )
+
+ update_cmd._warn_pending_fleet_restart_on_startup()
+
+ assert "did not restart running gateways" in capsys.readouterr().err
+ assert update_cmd_fleet._fleet_restart_obligation_armed()
+
+
def test_completion_arms_obligation_with_checkout_sha_when_head_capture_empty(monkeypatch):
"""The armer must never record the poisoned shape: an empty head capture falls back to the
checkout identity the reader compares the fleet against."""
diff --git a/tests/hermes_cli/test_venv_holder_classifier.py b/tests/hermes_cli/test_venv_holder_classifier.py
index 63e7cbb6611..25411f2d768 100644
--- a/tests/hermes_cli/test_venv_holder_classifier.py
+++ b/tests/hermes_cli/test_venv_holder_classifier.py
@@ -37,3 +37,14 @@ class TestHolderSubcommand:
)
def test_parses_subcommand(self, cmdline, expected):
assert _hermes_holder_subcommand(cmdline) == expected
+
+ def test_shlex_joined_store_launcher_bootstrap_is_inventoried(self):
+ """launchd ProgramArguments arrive ``shlex.join``ed (single-quoted source); the dashboard
+ inventory must still read the subcommand behind the bootstrap."""
+ import shlex
+ from pathlib import Path
+
+ from hermes_cli._launchers import runtime_command
+
+ cmdline = shlex.join(runtime_command(Path("/opt/hermes-agent"), ["dashboard"], python="/opt/store/python"))
+ assert _hermes_holder_subcommand(cmdline) == "dashboard"