fix(cron): yield desktop ticker to running gateway#44050
Open
izumi0uu wants to merge 2 commits into
Open
Conversation
Desktop-spawned dashboard backends should not execute profile cron ticks when a same-profile gateway is already running. The shared tick lock prevents duplicate firing, but it does not preserve the gateway-owned execution ancestry that macOS TCC/FDA-sensitive jobs rely on. Constraint: Keep the fix issue-scoped and preserve desktop cron execution when no gateway is alive Rejected: New cross-process scheduler owner protocol | broader than NousResearch#43965 and unnecessary for the reported regression Confidence: high Scope-risk: narrow Directive: Keep dashboard ticker ownership checks aligned with gateway.status semantics for the active profile Tested: ./.venv/bin/pytest -q tests/hermes_cli/test_web_server.py -k 'TestDesktopCronTicker' Tested: ./.venv/bin/pytest -q tests/hermes_cli/test_web_server.py -k 'gateway_running or TestDesktopCronTicker' Not-tested: end-to-end macOS launchd/Desktop provenance on a live TCC/FDA-protected cron job
1 task
Use the gateway runtime lock as the scheduler-owner signal for Desktop dashboard ticks instead of duplicating gateway liveness checks in the web server. This keeps desktop-only cron working, but moves ownership deferral into cron.scheduler so the owner rule lives beside tick semantics. Constraint: Preserve existing gateway ticker behavior and keep the fix scoped to NousResearch#43965 Rejected: Keep the owner probe only in hermes_cli.web_server | smaller diff but weaker owner signal and duplicated scheduling policy Confidence: high Scope-risk: narrow Directive: New non-gateway tick callers should opt into defer_to_gateway_owner rather than reimplementing gateway-owner checks Tested: ./.venv/bin/pytest -q tests/cron/test_scheduler_ownership.py Tested: ./.venv/bin/pytest -q tests/hermes_cli/test_web_server.py -k 'TestDesktopCronTicker' Tested: ./.venv/bin/pytest -q tests/gateway/test_status.py -k 'runtime_lock or get_running_pid' Tested: ./.venv/bin/pytest -q tests/cron/test_parallel_pool.py tests/cron/test_scheduler_ownership.py Not-tested: end-to-end macOS launchd/Desktop provenance on a live TCC/FDA-protected cron job
Collaborator
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 the Desktop dashboard cron ticker from executing profile cron jobs when a same-profile gateway already owns scheduler execution.
The fix now uses the gateway runtime lock as the scheduler-owner signal. Desktop backends still keep a fallback ticker for profiles with no live gateway, but each desktop tick explicitly opts into scheduler-level deferral whenever the gateway owner is active.
Related Issue
Fixes #43965
Type of Change
Changes Made
_gateway_scheduler_owner_active()incron/scheduler.pyto delegate scheduler-ownership checks togateway.status.is_gateway_runtime_lock_active().cron.scheduler.tick(...)withdefer_to_gateway_owner=Falseso non-gateway tickers can opt into owner-aware deferral without changing gateway behavior.hermes_cli/web_server.pyso the desktop dashboard ticker callscron_tick(..., defer_to_gateway_owner=True)instead of duplicating a separate gateway-liveness check.tests/cron/test_scheduler_ownership.pyto cover owner detection, fail-open behavior, early deferral before lock acquisition, and the opt-in boundary.tests/hermes_cli/test_web_server.pyto assert that the desktop ticker requests gateway-owner deferral on every tick.How to Test
./.venv/bin/pytest -q tests/cron/test_scheduler_ownership.py../.venv/bin/pytest -q tests/hermes_cli/test_web_server.py -k 'TestDesktopCronTicker'../.venv/bin/pytest -q tests/gateway/test_status.py -k 'runtime_lock or get_running_pid'../.venv/bin/pytest -q tests/cron/test_parallel_pool.py tests/cron/test_scheduler_ownership.pyto confirm the new tick parameter does not disturb existing scheduler dispatch behavior.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A