fix(cron): block in-gateway lifecycle jobs - #82079
Closed
SommelierLuc wants to merge 1 commit into
Closed
Conversation
Reject gateway restart, stop, and kill jobs at create, update, resume, and fire time so an in-process scheduler cannot enter a supervisor respawn loop.\n\nRefs NousResearch#30719
Contributor
|
This was generated by AI during triage. Summary: Problems:
Solution: Checked against |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Prevents an in-process cron scheduler from scheduling or firing a job that restarts, stops, reloads, or kills its own Hermes gateway. Without this guard, the gateway can terminate before a once-job persists completion; launchd/systemd then revives it and the same job can fire again, creating the respawn loop described in #30719.
The defense is applied at create, update, resume, and fire time. The fire-time backstop runs before the
no_agentshort-circuit, covers transientextra_promptcontext, and fails closed if the guard itself cannot be evaluated.This is intentionally focused. It does not include the cron ContextVar/approval changes discussed in #76797, Kanban policy, or local deployment policy. It complements the restart-loop breaker in #82039 by preventing the self-targeting job from reaching the gateway lifecycle command in the first place.
Related Issue
Refs #30719
Type of Change
Changes Made
tools/cron_gateway_guard.pywith bounded, cross-platform lifecycle-command detection.How to Test
scripts/run_tests.sh -j 3 tests/cron/test_cron_gateway_runtime_guard.py tests/tools/test_cronjob_tools.py tests/hermes_cli/test_gateway_restart_loop.py -q..venv/bin/python tools/cron_gateway_guard.py.py_compile, andgit diff --checkon the five changed Python files.Local result: 195 passed, 0 failed. Ruff, Python compilation, guard self-test, diff check, local-policy scan, and secret-pattern scan passed.
Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.example: N/A; no config keys changedCONTRIBUTING.md/AGENTS.md: N/A; no workflow contract changedFull-suite attempt
The full repository suite was also attempted on this macOS checkout. It currently reports broad unrelated optional-dependency/platform failures on
main(159 failures plus collection/import failures across 52 unrelated files). Neither changed test file failed; the focused 195-test suite above remains green. The only isolated approval failure is the existing macOS/tmpalias issue already covered by #70415; broader macOS suite work is tracked in #82023. The full-suite checkbox therefore remains intentionally unchecked rather than overstating the result.