From 73ccdeee5e9da5df1ee92f50ef4b591473382b52 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Wed, 7 Oct 2026 11:12:35 +0530 Subject: [PATCH] docs(cron): name hermes_bootstrap as the pre-ack relaunch in the worker docstrings After the previous commit the worker's pre-ack recovery is the import of hermes_bootstrap, not run_agent's copy; the module docstring and the relaunch test still credited run_agent. Also restore the scheduler comment's original wrap (whitespace-only churn from the first pick). (Lead fold: quality + thermo + reuse lenses, Low.) --- cron/scheduler.py | 7 ++++--- cron/worker_bootstrap.py | 7 +++---- tests/cron/test_restart_safe_worker.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 175cc28cf8..c126e57bd7 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -4442,9 +4442,10 @@ if __name__ == "__main__": parser.add_argument("--external-worker-file", type=Path, required=True) parser.add_argument("--ack-file", type=Path, required=True) args = parser.parse_args() - # The gateway spawns this worker with stdout on DEVNULL and stderr on a capture file it - # only reads back if we die before the ack; without a log handler every adoption/ack - # failure below would otherwise be invisible to the persistent log. + # The gateway spawns this worker with stdout on DEVNULL and stderr on a + # capture file it only reads back if we die before the ack; without a + # log handler every adoption/ack failure below would otherwise be + # invisible to the persistent log. try: from hermes_logging import setup_logging diff --git a/cron/worker_bootstrap.py b/cron/worker_bootstrap.py index 5b5e332b7a..0d5329aaa9 100644 --- a/cron/worker_bootstrap.py +++ b/cron/worker_bootstrap.py @@ -2,7 +2,7 @@ ``sys.executable -m cron.scheduler --external-worker-file ...`` (``cron/scheduler.py::_launch_external_cron_worker``) is a full Hermes entry point that -does not go through ``hermes_bootstrap``, and it imports Hermes packages the moment it +reaches ``hermes_bootstrap`` only from its ``__main__``, and it imports Hermes packages the moment it starts. ``cron/scheduler_worker_env.py`` restores the committed generation's ``site-packages`` on its ``PYTHONPATH`` so those imports resolve, but a pinned path is not a boot: the worker holds no lease on the generation, so the PM collector may remove it @@ -30,9 +30,8 @@ and may relaunch the process into a fresh one (``hermes_cli/venv_sync.py::relaun tree a killed ``hermes update`` half-wrote. ``finish_worker_boot()`` runs it from the worker's ``__main__`` before the payload is read, so a relaunch replays the whole worker: the payload is still on disk and the marker still set, and the new process boots its dependencies -again. Left to ``run_agent``'s import inside ``run_one_job``, the relaunch came after the ack, with -the payload deleted and the marker consumed: the new process died on ``ruamel`` and the adopted -run was left ``unknown``. +again. ``hermes_bootstrap`` re-runs the (idempotent) dependency boot; the package-init call above +must stay, because ``cron.jobs`` needs dependencies before ``__main__`` can run. """ from __future__ import annotations diff --git a/tests/cron/test_restart_safe_worker.py b/tests/cron/test_restart_safe_worker.py index c641074a8b..9ccba5328a 100644 --- a/tests/cron/test_restart_safe_worker.py +++ b/tests/cron/test_restart_safe_worker.py @@ -810,7 +810,7 @@ runpy.run_module("cron.scheduler", run_name="__main__", alter_sys=True) @pytest.mark.parametrize("cause", ["source_update", "interrupted_pull"]) def test_relaunch_replays_the_worker_before_its_ack(tmp_path, cause): - """``run_agent``'s import may relaunch the process: ``hermes_bootstrap`` finishing a source + """Importing ``hermes_bootstrap`` may relaunch the process: finishing a source update (into an ``-I`` interpreter that ignores the pinned PYTHONPATH), or the restore of a tree a killed ``hermes update`` half-wrote. Reached inside ``run_one_job``, either came after the ack: the payload was deleted, the marker consumed, and the new process died on ``ruamel``