Files
hermes-agent/hermes_cli
teknium1 f079458401 fix: post-update fleet settle poll no longer ends early on inconclusive signals
Two ways the 120 s fleet settle window in `_collect_fleet_snapshot` closed before
the relaunched gateway could publish its identity, both turning a clean update
into a wrong verdict:

* `_restarted_units_gone()` asked `systemctl is-active` in the scope named by the
  bookkeeping string. A user unit asked in the system scope answers `inactive`
  (rc 4) exactly like a dead unit, so one scope-mismatched entry aborted the poll
  on its first iteration -> "Fleet version check returned no rows", exit 1,
  `fleet_restart_pending` left behind (#112466). Death is now proven positively:
  `show -p LoadState,ActiveState` in that scope, and only `LoadState=loaded` with
  a non-active state counts; `not-found` (wrong scope, bare/legacy name) is
  inconclusive and keeps waiting like the existing systemctl-missing/slow cases.

* An `unknown` row counted as "row-capable -> done", so the one-shot probe
  returned ~2 s after a relaunched gateway's process appeared but ~10 s before its
  first runtime-status write, and the matrix printed "gateway predates version
  stamping; restart to enable" for a gateway this very run had just restarted on
  the new code (#112634). An unknown row without a sha whose pid is NOT in the
  pre-restart snapshot is a successor still booting: keep polling until it turns
  `current`; at the deadline the row is flagged `identity_pending` (carried into
  the receipt) and the matrix prints restart-aware copy pointing at
  `hermes gateway status`. Surviving pre-restart pids settle as before, so a
  genuinely pre-stamping gateway does not hold the poll open.

Existing dead-unit test updated to the `show` output shape; three invariant tests
added (scope mismatch keeps waiting, relaunched pid is waited for / survivor is
not / deadline flag, restart-aware copy).

Fixes #112466
Fixes #112634
Co-authored-by: KoNit-K <124019182+KoNit-K@users.noreply.github.com>
2026-09-16 17:04:46 -07:00
..
…
…
…
…
…
…
…
…