The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
docs(cron): name hermes_bootstrap as the pre-ack relaunch in the worker docstrings
kshitijk4poor73ccdeee5e9d
diff --git a/cron/scheduler.py b/cron/scheduler.pyindex 175cc28cf8b..c126e57bd72 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_loggingdiff --git a/cron/worker_bootstrap.py b/cron/worker_bootstrap.pyindex 5b5e332b7a2..0d5329aaa98 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 itstarts. ``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 aboot: 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::relauntree a killed ``hermes update`` half-wrote. ``finish_worker_boot()`` runs it fromthe worker's ``__main__`` before the payload is read, so a relaunch replays the whole worker: thepayload 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 annotationsdiff --git a/tests/cron/test_restart_safe_worker.py b/tests/cron/test_restart_safe_worker.pyindex c641074a8be..9ccba5328a7 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 sourceupdate (into an ``-I`` interpreter that ignores the pinned PYTHONPATH), or the restore of atree a killed ``hermes update`` half-wrote. Reached inside ``run_one_job``, either came afterthe ack: the payload was deleted, the marker consumed, and the new process died on ``ruamel``