fix(cron): resolve relative script paths at job creation to prevent cross-profile breakage - #2
Merged
Conversation
…ross-profile breakage Relative script paths in cron jobs were stored as-is and resolved against whatever profile's HERMES_HOME happened to be active when the tick executed. With multiple gateways running different profiles, the same relative path (e.g. "backup.sh") resolved to different directories on different ticks, causing script-not-found errors. Changes: - Add _normalize_script() which resolves relative paths against the creating profile's HERMES_DIR/scripts/ at create time - Wire _normalize_script() into create_job() and update_job() - Relax _run_job_script() security check to accept scripts from any scripts/ directory (not just the current profile's), since paths are now validated at creation time - Update tests to expect absolute stored paths
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
Relative script paths in cron jobs were stored as-is and resolved against whatever profile's HERMES_HOME happened to be active when the tick executed. With multiple gateways running different profiles, the same relative path (e.g.
backup.sh) resolved to different directories on different ticks, causing script-not-found errors.Changes
_normalize_script()function: resolves relative script paths against the creating profile'sHERMES_DIR/scripts/at creation time and stores the absolute path_normalize_script()into bothcreate_job()andupdate_job()_run_job_script()security check: accepts scripts from anyscripts/directory (not just the current profile's). Paths validated at creation time; still blocks arbitrary absolute pathsRoot cause
_run_job_script()resolved relative paths against_get_hermes_home() / "scripts"at tick execution time._get_hermes_home()varies per-profile, so the same relative path resolved to different locations depending on which profile's gateway happened to win the tick lock.Test plan
Closes NousResearch#57608.
Refs https://github.com/arc-butler/hermes-agent/pull/1 (previous PR for NousResearch#57683 — abandoned due to duplicate).