The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(update): one deferral core, shared reason prefix, per-line Desktop hint; review folds
kshitijk4poor3752497cc4d2
diff --git a/hermes_cli/dashboard_procs.py b/hermes_cli/dashboard_procs.pyindex 06b0aac0259..3f8d9b24ab0 100644--- a/hermes_cli/dashboard_procs.py+++ b/hermes_cli/dashboard_procs.py@@ -605,8 +605,8 @@ def _kill_stale_dashboard_processes(Manually-started dashboards are not auto-restarted because we don't know the original launch args(--host, --port, --insecure, --tui, --no-open). See #68934.*already_restarted_units* names units (no ``.service`` suffix) the caller already handled directly —- e.g. ``hermes update``'s systemd fleet-restart loop, which restarts (or, without root, declines and- names) ``hermes-serve*``/``hermes-dashboard*`` units before this function runs. Without excluding them,+ e.g. ``hermes update``'s systemd fleet-restart loop, which restarts, declines (without root) or fails+ ``hermes-serve*``/``hermes-dashboard*`` units, reporting each, before this function runs. Without excluding them,a Serve-only install's freshly restarted process is found again here and restarted a second time forno benefit (review on #83595), and a declined system unit is retried into a polkit prompt (#141021)."""diff --git a/hermes_cli/main_dashboard.py b/hermes_cli/main_dashboard.pyindex c53daa3388c..4567fb0fb95 100644--- a/hermes_cli/main_dashboard.py+++ b/hermes_cli/main_dashboard.py@@ -247,6 +247,11 @@ def _systemd_restart_commands(unit: str, scope: str | None) -> list[str]:return {"user": [user_cmd], "system": [system_cmd]}.get(scope or "", [user_cmd, system_cmd])+def _format_restart_commands(commands: list[str]) -> str:+ """Join restart commands as a user-facing hint: each backticked, separated by " or "."""+ return " or ".join(f"`{c}`" for c in commands)++def _try_restart_systemd_service(svc_name: str, cgroup_path: str | None = None) -> bool:"""Restart *svc_name* via systemctl (``--user`` for user-scope units). True on success.diff --git a/hermes_cli/update_abort_recovery.py b/hermes_cli/update_abort_recovery.pyindex 462b6b40514..44d300c9b2d 100644--- a/hermes_cli/update_abort_recovery.py+++ b/hermes_cli/update_abort_recovery.py@@ -244,11 +244,11 @@ def _warn_stale_serve_runtimes(rows) -> None:print(" Ask their owner to relaunch `hermes serve` / `hermes dashboard`, or reconnect Desktop for an SSH backend.")# A unit-managed backend restarts through its own unit and scope — never "ask the owner to# relaunch", and never a hardcoded user-scope hermes-serve (#141021).- from hermes_cli.main_dashboard import _systemd_restart_commands+ from hermes_cli.main_dashboard import _format_restart_commands, _systemd_restart_commandsfor row in unit_rows:commands = _systemd_restart_commands(row.get("systemd_unit") or "<unit>", row.get("systemd_scope"))- print(f" pid {row.get('pid')} is managed by systemd: {' or '.join(f'`{c}`' for c in commands)}")+ print(f" pid {row.get('pid')} is managed by systemd: {_format_restart_commands(commands)}")if sys.platform == "darwin" and any(row.get("supervisor") == "launchd" for row in rows):print(" For launchd-managed backends: `launchctl kickstart -k gui/$UID/<label>`.")diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.pyindex 22bee8db8e7..4ce7a469cfb 100644--- a/hermes_cli/update_cmd_fleet.py+++ b/hermes_cli/update_cmd_fleet.py@@ -735,6 +735,19 @@ def _scoped_manual_gateway_pids(pids, *, keep=(), quiet: bool = False) -> list[ireturn [pid for pid in pids if pid in keep or pid in owned]+def _is_serve_or_dashboard_unit(unit: str) -> bool:+ """``hermes-serve*``/``hermes-dashboard*`` (``.service``) by the same exact-or-hyphenated shape."""+ return (+ unit == "hermes-serve.service"+ or unit.startswith("hermes-serve-")+ # #125297: ``hermes-dashboard*`` units are systemd-supervised dashboard backends — the+ # same fleet this pass restarts. Leaving them out meant a successful update reported+ # the dashboard ``deferred`` (still on pre-update code) while nothing ever restarted it.+ or unit == "hermes-dashboard.service"+ or unit.startswith("hermes-dashboard-")+ )++def _is_hermes_gateway_unit(unit: str) -> bool:"""Exact base unit or hyphenated profile family only: ``startswith("hermes-serve")``would accept ``hermes-server.service``."""@@ -743,13 +756,7 @@ def _is_hermes_gateway_unit(unit: str) -> bool:# cannot enter the restart path. See #83595.unit == "hermes-gateway.service"or unit.startswith("hermes-gateway-")- or unit == "hermes-serve.service"- or unit.startswith("hermes-serve-")- # #125297: ``hermes-dashboard*`` units are systemd-supervised dashboard backends — the- # same fleet this pass restarts. Leaving them out meant a successful update reported- # the dashboard ``deferred`` (still on pre-update code) while nothing ever restarted it.- or unit == "hermes-dashboard.service"- or unit.startswith("hermes-dashboard-")+ or _is_serve_or_dashboard_unit(unit))@@ -1018,7 +1025,7 @@ _DESKTOP_SERVE_SKIP_REASON = (# survivors reported by _surviving_pre_update_serve_runtimes._SERVE_SKIP_REASON = ("no per-profile relaunch command reaches a serve/dashboard runtime; recovered by the fresh"- " systemd unit pass when it owns a hermes-serve* unit, else left running for explicit"+ " systemd unit pass when a hermes-serve*/hermes-dashboard* unit owns it, else left running for explicit"" operator restart")# A launchd-owned backend (#116503): the fresh child has no per-label kickstart for serve/dashboarddiff --git a/hermes_cli/update_cmd_fleet_verify.py b/hermes_cli/update_cmd_fleet_verify.pyindex 6cc4b201c42..ddad307e690 100644--- a/hermes_cli/update_cmd_fleet_verify.py+++ b/hermes_cli/update_cmd_fleet_verify.py@@ -183,13 +183,12 @@ def _named_gateways_still_owed() -> bool:def _is_serve_unit(name: object) -> bool:- """A serve/dashboard unit by the fleet loop's OWN name gate (``hermes-serve*``/``hermes-dashboard*``,+ """A serve/dashboard unit by the fleet loop's own name gate (``hermes-serve*``/``hermes-dashboard*``,bare or ``.service``). Anything else it records as failed (gateway units, launchd labels,listing-failure markers) is gateway evidence."""- from hermes_cli.update_cmd_fleet import _is_hermes_gateway_unit, _service_unit_supports_graceful_sigusr1_restart+ from hermes_cli.update_cmd_fleet import _is_serve_or_dashboard_unit- base = str(name).removesuffix(".service")- return _is_hermes_gateway_unit(f"{base}.service") and not _service_unit_supports_graceful_sigusr1_restart(base)+ return _is_serve_or_dashboard_unit(f"{str(name).removesuffix('.service')}.service")def _restart_phase_owes_gateway(restart) -> bool:@@ -210,6 +209,14 @@ def _split_unaccounted(outcomes) -> tuple[bool, set]:return any(o.get("kind") not in _SERVE_KINDS for o in missed), serve_pids+# The Desktop hand-offs (scripts/desktop-update/posix.sh, windows.ps1) drop their "Run hermes gateway+# restart" hint only when every gateway_restart reason starts with this prefix, so every serve-only+# part below starts with it and the gateway part always comes first (#141071).+SERVE_ONLY_REASON_PREFIX = "serve/dashboard "+_GATEWAY_OWED_REASON = "gateways may still run pre-update code or were stopped without a successor"+_GATEWAY_RECOVERY = "; recover with `hermes gateway restart`"++def _owed_restart_reason(restart, stopped, *, gateway_owed: bool, stale_serves: set, down_serves: set) -> str:"""The ``gateway_restart`` follow-up's reason, naming what is actually owed (#141021).@@ -219,25 +226,24 @@ def _owed_restart_reason(restart, stopped, *, gateway_owed: bool, stale_serves:parts = []if gateway_owed:parts.append(- "gateways may still run pre-update code or were stopped without a successor"+ _GATEWAY_OWED_REASON+ (f" (stopped PIDs {', '.join(map(str, stopped))})" if stopped else "")- + "; recover with `hermes gateway restart`")+ + _GATEWAY_RECOVERY)units = sorted({str(u).removesuffix(".service") for u in restart.failed_or_stale_units if _is_serve_unit(u)})if units:parts.append(- f"serve/dashboard unit(s) {', '.join(units)} were not restarted onto the new code;"+ f"{SERVE_ONLY_REASON_PREFIX}unit(s) {', '.join(units)} were not restarted onto the new code;"" see the systemctl advice above")if down_serves:parts.append(- f"serve/dashboard process(es) {', '.join(map(str, sorted(down_serves)))} were stopped during the"+ f"{SERVE_ONLY_REASON_PREFIX}process(es) {', '.join(map(str, sorted(down_serves)))} were stopped during the"" update and not brought back; relaunch `hermes serve` / `hermes dashboard`")if stale_serves - down_serves:parts.append(- f"serve/dashboard process(es) {', '.join(map(str, sorted(stale_serves - down_serves)))} still run"+ f"{SERVE_ONLY_REASON_PREFIX}process(es) {', '.join(map(str, sorted(stale_serves - down_serves)))} still run"" pre-update code; restart them as advised above")# Nothing classified (an unknown incompleteness): keep the historical, conservative wording.- return "; ".join(parts) or (- "gateways may still run pre-update code or were stopped without a successor; recover with `hermes gateway restart`")+ return "; ".join(parts) or (_GATEWAY_OWED_REASON + _GATEWAY_RECOVERY)def _verify_fleet_after_update(restart, *, _pre_update_plan, _windows_gateway_resume, update_complete):diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.pyindex a9ad0e28a73..1e2ab5b2c24 100644--- a/hermes_cli/update_cmd_maint.py+++ b/hermes_cli/update_cmd_maint.py@@ -273,8 +273,8 @@ def _refresh_dashboard_after_update(*, already_restarted_units: set[str] | Nonestopped and could not bring back, so the receipt records them ``failed`` (#109290).*already_restarted_units*: systemd unit names (no ``.service``) the fleet-restart loop- already handled (restarted, or declined and named), so a Serve-only install isn't- restarted a second time here and a declined system unit isn't retried (#141021).+ already handled (restarted, declined, or failed; each already reported), so a Serve-only+ install isn't restarted a second time here and a declined or failed unit isn't retried (#141021).See #83595."""diff --git a/hermes_cli/update_serve_obligations.py b/hermes_cli/update_serve_obligations.pyindex fcd5871d72b..4adcc9bd661 100644--- a/hermes_cli/update_serve_obligations.py+++ b/hermes_cli/update_serve_obligations.py@@ -16,15 +16,19 @@ logger = logging.getLogger(__name__)def defer_manual_serve(runtime: dict, *, require_alive: bool = False) -> bool:"""Transfer an identified manual runtime to its own durable restart reminder."""- from hermes_cli.process_identity import _pid_alive_matches-if runtime.get("kind") not in ("serve", "dashboard") or runtime.get("supervisor") != "manual-serve" or runtime.get("restart_via") != "respawn-argv":return False- pid = runtime.get("pid")- detail = runtime.get("detail")- if not isinstance(detail, dict):+ if not isinstance(runtime.get("detail"), dict):return False- created = detail.get("create_time")+ return _defer_identified(runtime, require_alive=require_alive)+++def _defer_identified(runtime: dict, *, extra: dict | None = None, require_alive: bool = False) -> bool:+ """Shared tail of the manual and unit deferrals: True when the incarnation is gone or its reminder+ (plus *extra* fields) was filed; False while it is still owed and nothing durable was written."""+ from hermes_cli.process_identity import _pid_alive_matches++ pid, created = runtime.get("pid"), runtime["detail"].get("create_time")if type(pid) is not int or pid <= 0:return Falseidentified = type(created) in (int, float) and math.isfinite(created) and created > 0@@ -38,10 +42,11 @@ def defer_manual_serve(runtime: dict, *, require_alive: bool = False) -> bool:return Falseif alive is False:return True- _write_reminder({"kind": runtime["kind"], "profile": runtime.get("profile", "unknown"), "pid": pid, "create_time": created})+ _write_reminder({"kind": runtime["kind"], "profile": runtime.get("profile", "unknown"), "pid": pid,+ "create_time": created, **(extra or {})})return Trueexcept (OSError, ValueError, TypeError) as exc:- logger.debug("Could not preserve manual serve obligation: %s", exc)+ logger.debug("Could not preserve serve restart obligation: %s", exc)return False@@ -84,26 +89,12 @@ def defer_unit_serve(runtime: dict) -> bool:``--no-gateway-restart``) is never mentioned again. True when the row is discharged (process gone)or the reminder was filed; False when it is still owed and nothing durable could be written."""from hermes_cli.main_dashboard import _systemd_restart_commands- from hermes_cli.process_identity import _pid_alive_matchesif not is_unit_serve_row(runtime):return False- detail, pid = runtime["detail"], runtime.get("pid")- created = detail.get("create_time")- if type(pid) is not int or pid <= 0:- return False- if not (type(created) in (int, float) and math.isfinite(created) and created > 0):- return _pid_alive_matches(pid, None) is False- try:- if _pid_alive_matches(pid, created) is False:- return True- _write_reminder({"kind": runtime["kind"], "profile": runtime.get("profile", "unknown"), "pid": pid,- "create_time": created,- "restart": _systemd_restart_commands(str(detail["systemd_unit"]), detail.get("systemd_scope"))})- return True- except (OSError, ValueError, TypeError) as exc:- logger.debug("Could not preserve unit serve obligation: %s", exc)- return False+ detail = runtime["detail"]+ return _defer_identified(runtime, extra={+ "restart": _systemd_restart_commands(str(detail["systemd_unit"]), detail.get("systemd_scope"))})def retain_receipt_manual_serves(receipt: dict) -> list[dict]:@@ -129,6 +120,7 @@ def retain_receipt_manual_serves(receipt: dict) -> list[dict]:def warn_pending_manual_serves(*, startup: bool = False, pending_manual: list[dict] | None = None) -> None:"""Warn about manual debt independently of gateway evidence; optionally reuse a snapshot's failed transfers."""+ from hermes_cli.main_dashboard import _format_restart_commands, _systemd_restart_commandsfrom hermes_cli.process_identity import _pid_alive_matchesfrom hermes_cli.update_receipt import read_latest_receipt@@ -136,13 +128,12 @@ def warn_pending_manual_serves(*, startup: bool = False, pending_manual: list[diif pending_manual is None:pending_manual = retain_receipt_manual_serves(read_latest_receipt() or {})for row in pending_manual:- print(f" ⚠ {row['kind']} [{row.get('profile', 'unknown')}] pid {row.get('pid', 'unknown')}: manual restart reminder could not be saved; restart remains pending in the update receipt.", file=stream)+ unit_row = is_unit_serve_row(row)+ print(f" ⚠ {row['kind']} [{row.get('profile', 'unknown')}] pid {row.get('pid', 'unknown')}: {'unit' if unit_row else 'manual'} restart reminder could not be saved; restart remains pending in the update receipt.", file=stream)detail = row.get("detail") if isinstance(row.get("detail"), dict) else {}- if is_unit_serve_row(row):- from hermes_cli.main_dashboard import _systemd_restart_commands-+ if unit_row:commands = _systemd_restart_commands(str(detail["systemd_unit"]), detail.get("systemd_scope"))- print(f" Restart its unit: {' or '.join(f'`{c}`' for c in commands)}", file=stream)+ print(f" Restart its unit: {_format_restart_commands(commands)}", file=stream)elif type(detail.get("create_time")) in (int, float):print(" Ask its owner to relaunch `hermes serve` / `hermes dashboard`; check reminder storage permissions and free space.", file=stream)else:@@ -158,7 +149,7 @@ def warn_pending_manual_serves(*, startup: bool = False, pending_manual: list[direstart = row.get("restart")if isinstance(restart, list) and restart:print(f" ⚠ {row['kind']} [{row['profile']}] pid {row['pid']}: unit restart still pending; this process may still serve pre-update code.", file=stream)- print(f" Restart its unit: {' or '.join(f'`{c}`' for c in restart)}", file=stream)+ print(f" Restart its unit: {_format_restart_commands(restart)}", file=stream)continueprint(f" ⚠ {row['kind']} [{row['profile']}] pid {row['pid']}: manual restart still pending; this process may still serve pre-update code.", file=stream)print(" Ask its owner to relaunch `hermes serve` / `hermes dashboard` (reconnect Desktop for an SSH backend).", file=stream)diff --git a/scripts/desktop-update/posix.sh b/scripts/desktop-update/posix.shindex 5147ff4cf4a..1ef18a2d998 100755--- a/scripts/desktop-update/posix.sh+++ b/scripts/desktop-update/posix.sh@@ -1279,11 +1279,13 @@ if [ "$CODE" -eq 0 ]; then FINAL_CODE=0 FINAL_MSG="Update complete." UPDATE_COMMOWED_STEPS="$(owed_followup_steps)"if [ -n "$OWED_STEPS" ]; then# A gateway_restart owed only for serve/dashboard units (the reason then starts with- # "serve/dashboard") names their own command in the log; every other gateway_restart reason,- # including a raw restart-phase error, keeps the gateway hint (#141071).+ # "serve/dashboard ", hermes_cli/update_cmd_fleet_verify.SERVE_ONLY_REASON_PREFIX) names their own+ # command in the log. The hint drops only when EVERY gateway_restart line is serve-only; any other+ # reason, including a raw restart-phase error, keeps it (#141071).case " $OWED_STEPS " in *" gateway_restart "*) OWED_HINT=" Run hermes gateway restart to move the messaging gateway onto the new code now." ;; *) OWED_HINT="" ;; esac- if printf '%s\n' "$OUT" | grep -Eq "Update follow-up 'gateway_restart' did not finish: serve/dashboard " \- && ! printf '%s\n' "$OUT" | grep -Eq "Update follow-up 'gateway_restart' did not finish: .*hermes gateway restart"; then+ GW_REASONS="$(printf '%s\n' "$OUT" | grep "Update follow-up 'gateway_restart' did not finish: ")"+ if [ -n "$GW_REASONS" ] && ! printf '%s\n' "$GW_REASONS" | grep -vq "did not finish: serve/dashboard " \+ && ! printf '%s\n' "$GW_REASONS" | grep -q "hermes gateway restart"; thenOWED_HINT=""fiif [ -n "$DONE_NOTE" ]; then DONE_NOTE="$DONE_NOTE Follow-up steps still owed: $OWED_STEPS.$OWED_HINT"diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1index 131e0df7ad7..48b11d656af 100644--- a/scripts/desktop-update/windows.ps1+++ b/scripts/desktop-update/windows.ps1@@ -1686,10 +1686,11 @@ try {ForEach-Object { $_.Groups[1].Value } | Select-Object -Unique)if ($owedSteps.Count -gt 0) {# A gateway_restart owed only for serve/dashboard units (the reason then starts with- # "serve/dashboard") names their own command in the log; every other gateway_restart reason,- # including a raw restart-phase error, keeps the gateway hint (#141071).- $owedText = $res.Output -join "`n"- $serveOnly = ($owedText -match "Update follow-up 'gateway_restart' did not finish: serve/dashboard ") -and -not ($owedText -match "Update follow-up 'gateway_restart' did not finish: .*hermes gateway restart")+ # "serve/dashboard ", hermes_cli/update_cmd_fleet_verify.SERVE_ONLY_REASON_PREFIX) names their own+ # command in the log. The hint drops only when EVERY gateway_restart line is serve-only; any other+ # reason, including a raw restart-phase error, keeps it (#141071).+ $gwReasons = @((($res.Output -join "`n") -split "`r?`n") | Where-Object { $_ -cmatch "Update follow-up 'gateway_restart' did not finish: " })+ $serveOnly = ($gwReasons.Count -gt 0) -and -not @($gwReasons | Where-Object { ($_ -cnotmatch "did not finish: serve/dashboard ") -or ($_ -cmatch "hermes gateway restart") }).Count$owedHint = if (($owedSteps -contains 'gateway_restart') -and -not $serveOnly) { " Run 'hermes gateway restart' to move the messaging gateway onto the new code now." } else { '' }Add-Followup ("followup: owed by the committed update: " + ($owedSteps -join ', ')) ("some follow-up steps did not finish (" + ($owedSteps -join ', ') + "). The next launch or 'hermes update' retries them; the update log has the details." + $owedHint) -Manual}diff --git a/tests/hermes_cli/test_update_system_dashboard_unit.py b/tests/hermes_cli/test_update_system_dashboard_unit.pyindex 9136a48b4f0..65c5e35e3c8 100644--- a/tests/hermes_cli/test_update_system_dashboard_unit.py+++ b/tests/hermes_cli/test_update_system_dashboard_unit.py@@ -307,30 +307,46 @@ def test_next_run_carries_a_unit_row_forward_from_the_previous_receipt(monkeypatassert [row["pid"] for row in carried] == [DASH_PID][email protected]("reason, hinted", [- ("serve/dashboard unit(s) hermes-dashboard were not restarted onto the new code; see the systemctl advice above", False),- ("gateways may still run pre-update code or were stopped without a successor; recover with `hermes gateway restart`", True),- ("gateways may still run pre-update code or were stopped without a successor; recover with `hermes gateway restart`;"- " serve/dashboard unit(s) hermes-dashboard were not restarted onto the new code", True),+def _producer_reason(*, gateway_owed=False, units=(), down=(), stale=()):+ restart = SimpleNamespace(failed_or_stale_units=list(units))+ return fleet_verify._owed_restart_reason(+ restart, [], gateway_owed=gateway_owed, stale_serves=set(stale), down_serves=set(down))++[email protected]("reasons, hinted", [+ ([_producer_reason(units=["hermes-dashboard"])], False),+ ([_producer_reason(down=[4242])], False),+ ([_producer_reason(stale=[4242], units=["hermes-serve-work.service"])], False),+ ([_producer_reason(gateway_owed=True)], True),+ ([_producer_reason(gateway_owed=True, units=["hermes-dashboard"])], True),+ ([_producer_reason()], True), # nothing classified: the historical gateway wording# update_finish owes gateway_restart with the raw exception when the restart phase itself crashes.- ("RuntimeError: systemctl list-units timed out", True),+ (["RuntimeError: systemctl list-units timed out"], True),+ # A serve-only line next to a raw-exception line: a gateway may still be owed.+ ([_producer_reason(units=["hermes-dashboard"]), "RuntimeError: boom"], True),])-def test_desktop_handoffs_add_the_gateway_hint_only_when_gateways_are_blamed(capsys, reason, hinted):+def test_desktop_handoffs_add_the_gateway_hint_only_when_gateways_are_blamed(capsys, reasons, hinted):"""#141071: both Desktop hand-offs keyed the "Run hermes gateway restart" hint on the step id alone.- Now only a serve/dashboard-only reason drops it; every other gateway_restart reason keeps it. Pin- each script's predicate against the line the producer prints."""+ Now the hint drops only when every gateway_restart reason the producer prints is serve/dashboard-only.+ Runs the real posix.sh block in bash, and windows.ps1's two patterns with its per-line rule."""import refrom pathlib import Path- update_receipt.record_followup("gateway_restart", reason)+ for reason in reasons:+ update_receipt.record_followup("gateway_restart", reason)out = capsys.readouterr().outscripts = Path(__file__).resolve().parents[2] / "scripts/desktop-update"posix = (scripts / "posix.sh").read_text(encoding="utf-8")- serve_re, gw_re = re.findall(r'grep -Eq "(Update follow-up .gateway_restart[^"]+)"', posix)- sh = f'printf "%s\\n" "$OUT" | grep -Eq "{serve_re}" && ! printf "%s\\n" "$OUT" | grep -Eq "{gw_re}"'- serve_only = subprocess.run(["bash", "-c", sh], env={**os.environ, "OUT": out},- capture_output=True, text=True, encoding="utf-8", check=False).returncode == 0- assert (not serve_only) is hinted+ block = posix[posix.index(' GW_REASONS="$('):]+ block = block[:block.index("\n fi\n") + len("\n fi\n")]+ sh = f'OWED_HINT=hint\n{block}\nprintf %s "$OWED_HINT"'+ posix_hint = subprocess.run(["bash", "-c", sh], env={**os.environ, "OUT": out}, capture_output=True,+ text=True, encoding="utf-8", check=True).stdout == "hint"+ assert posix_hint is hintedps = (scripts / "windows.ps1").read_text(encoding="utf-8")- ps_serve, ps_gw = re.findall(r'-match "(Update follow-up .gateway_restart[^"]+)"', ps)- assert (not (bool(re.search(ps_serve, out)) and not re.search(ps_gw, out))) is hinted+ line_pat = re.search(r'\$_ -cmatch "(Update follow-up [^"]+)"', ps).group(1)+ serve_pat = re.search(r'\$_ -cnotmatch "([^"]+)"', ps).group(1)+ gw_pat = re.search(r'\(\$_ -cmatch "(hermes gateway restart)"\)', ps).group(1)+ lines = [ln for ln in out.splitlines() if re.search(line_pat, ln)]+ serve_only = bool(lines) and not [ln for ln in lines if not re.search(serve_pat, ln) or re.search(gw_pat, ln)]+ assert (not serve_only) is hinted