Repository navigation
Conversation
|
Independent verification on the PR head (4dbe839): tests/cron/test_restart_safe_worker.py passes locally, 20 passed, 5 skipped (canonical runner, macOS). The new fallback test passes; the new venv-lexical test is linux_only so it skipped here, but I exercised _external_cron_worker_python directly with a symlinked fake venv and it returns the lexical venv path as claimed. Premise holds on current main: _launch_external_cron_worker still spawns bare sys.executable (cron/scheduler.py:3105), so a symlinked interpreter loses the venv. The fix prefers VIRTUAL_ENV, then sys.prefix when it differs from base_prefix, checks the candidate is an executable file, and falls back to sys.executable. No shell, no injection surface. One note: the probe only looks under bin/, so on Windows it always falls through to sys.executable. That is a safe no-op rather than a bug, but it makes the fix POSIX-only. Either probe Scripts/python.exe behind a win32 check or say so in the docstring. |
4dbe839 to
7bc95aa
Compare
|
Closing because the proposed |
What does this PR do?
Restart-safe cron workers now retain the virtualenv's lexical
bin/python3orbin/pythonpath when Hermes runs inside a virtualenv. Previously the workerused symlink-resolved
sys.executable, which could launch the base runtimewithout Hermes packages and exit before acknowledging ownership. When no active
virtualenv interpreter is available, dispatch still uses
sys.executable.Related Issue
Fixes #112729
Type of Change
Changes Made
cron/scheduler.py— select an executable venvbin/python3orbin/pythonwithout resolving its symlink before constructing the external-worker command; retain the existing fallback.tests/cron/test_restart_safe_worker.py— cover dispatch through a symlinked venv interpreter and the non-venv fallback.How to Test
HERMES_PYTHON=/Users/blockkonit./Dev/hermes/hermes-agent/.venv/bin/python scripts/run_tests.sh tests/cron/test_restart_safe_worker.py -q— 20 passed, 5 Linux-only tests skipped on macOS.HERMES_PYTHON=/Users/blockkonit./Dev/hermes/hermes-agent/.venv/bin/python ruff check cron/scheduler.py tests/cron/test_restart_safe_worker.py— all checks passed.sys.executablewhen no virtualenv is active.Evidence
AttributeError: module 'cron.scheduler' has no attribute '_external_cron_worker_python'(1 failed, 1 Linux-only test skipped), demonstrating the missing venv-selection behavior.VIRTUAL_ENVor asys.prefixdistinct fromsys.base_prefix, and otherwise keeps the existing executable.Review follow-up
The symlinked systemd-worker regression is marked Linux-only and was skipped on this macOS host; it will run in the Linux CI lane. The classified Docker and Nix CI lanes were not run locally.
Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example: N/ACONTRIBUTING.mdorAGENTS.md: N/A