fix(cron): enforce one scheduler owner per home - #72179
Open
opita04 wants to merge 1 commit into
Open
Conversation
Collaborator
teknium1
reviewed
Jul 30, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for carrying the ownership problem through Gateway, Desktop, callbacks, and profile routing. The underlying bug is still present on current main: hermes_cli/web_server.py:150-168 starts a Desktop scheduler, while gateway/run.py:25491-25542 independently starts the Gateway scheduler; cron/scheduler.py:4099-4145 only serializes ticks.
Problems
cron/scheduler_runtime.py:44adds an independent behavioral config parser. Current main commited33ebca1d60ae5069f871e4e5f13d97df384e4cestablished canonical config loaders/shared raw-read primitives specifically to avoid managed-scope,${VAR}, and profile-path drift. Salvage this reader onto that current mechanism.- The user-facing cron guidance remains stale:
website/docs/guides/cron-troubleshooting.md:39-41says automatic cron requires a Gateway, but this change introduces Desktop ownership andcron.scheduler_ownerwithout a docs update.
Suggested changes
- Rework the exact-home policy read using the current shared config-read path before integration.
- Document owner modes, Desktop-only behavior, and the new status semantics.
Automated hermes-sweeper review.
| meaningful = [ | ||
| line.split("#", 1)[0].strip() | ||
| for line in raw.splitlines() | ||
| if line.split("#", 1)[0].strip() not in {"", "---", "..."} |
Contributor
There was a problem hiding this comment.
Current main's ed33ebca1d60ae5069f871e4e5f13d97df384e4c centralized behavioral config reads to prevent managed-overlay, ${VAR}, and profile-home drift. Please salvage this onto read_user_config_raw() plus the established exact-profile overlay/expansion path rather than adding a new parser.
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.
Summary
Hermes Desktop and Gateway could both schedule the same stateful cron job for one
HERMES_HOME. Whichever process won a tick could advance the job before discovering that its process lacked the configured delivery credentials, so generated output disappeared from the intended platform.This change makes scheduler ownership fail closed and exact-home scoped while preserving standalone Desktop compatibility, multiplex Gateway profiles, hosted callbacks, and external providers.
auto: Gateway is preferred when present; Desktop-only installs continue scheduling.gatewayanddesktopare strict; malformed or unavailable configurations do not silently fall back.HERMES_HOME; provider routing and module caches use that same boundary.The runtime also avoids Windows-dangerous process probes, detects PID reuse through process identity, keeps housekeeping independent from scheduler suppression, and reports configured policy, active provider, and lease state through the CLI.
Compatibility and safety
HERMES_HOME.os.kill(pid, 0).Validation
Tests ran with isolated
HOME/HERMES_HOME; the real cron registry was SHA-256 checked before and after each authoritative run.1235 passedacross cron, Chronos, Gateway callback/ownership/drain, dashboard cron, config, and cron-tool suites.519 passedin the completetests/hermes_cli/test_web_server.pysuite.git diff --checkpassed.~/.hermes/cron/jobs.jsonremained unchanged during each guarded run.One pre-existing mocked multi-target delivery test still emits an un-awaited coroutine warning; the affected suites otherwise pass.
New concepts
Admission barriers for resource-safe shutdown
Closing a scheduler’s public registry prevents new work, but already admitted callbacks may still hold and use its provider. The runtime therefore treats shutdown as a barrier:
This is preferable to stopping the provider first because callbacks cannot safely finish against closed network clients or schedulers. It is not needed for immutable, stateless resources with no concurrent borrowers.
Exact-home ownership
HERMES_HOMEis the scheduler’s tenancy boundary: policy, jobs, credentials, provider instance, callback authentication, and lease ownership all resolve from the same canonical home. That lets multiplex profiles share a process without sharing scheduler authority. A process-global singleton is simpler, but is unsafe whenever multiple profiles or homes coexist.