scheduled-job-runner
Skill0 starsChanged 3 months agoMITView on GitHub
Use when creating, migrating, debugging, or reviewing Hermes cron jobs. Ships a tested execution adapter for interpreter resolution, overlap prevention, hard timeouts, quiet success, structured ledgers, bounded redacted logs, failure notification, run severity, and heartbeat reporting.
In this repository36 other files it gives its agents.
- check-upstream-firstSkill
- data-verificationSkill
- deep-diveSkill
- delegation-handoffSkill
- grok-searchSkill
- is-it-really-brokenSkill
- keep-goingSkill
- learn-from-conversationsSkill
- memory-cleanupSkill
- moa-solveSkill
- mob-checkSkill
- multi-reviewSkill
- project-stewardSkill
- prove-the-setting-worksSkill
- recallSkill
- reportSkill
- robustify-doctorSkill
- skill-librarianSkill
- trust-frameworkSkill
- address-pr-commentsSkill
- diagram-renderingSkill
- find-the-real-bottleneckSkill
- live-database-maintenanceSkill
- mini-appSkill
- pr-review-sweepSkill
- stop-the-noiseSkill
- upgrade-a-live-service-safelySkill
- vendor-switch-checkSkill
- writing-for-non-engineersSkill
- email-stewardSkill
- fieldySkill
- google-docsSkill
- google-sheetsSkill
- google-slidesSkill
- imessage-bluebubblesSkill
- vapi-callsSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Do not create another scheduler.
- Distinctive: line 40
Use this skill when:
- Distinctive: line 127
Never collapse terminal states into exit 1.
- Distinctive: line 185
Use placeholders in public examples:
- Very specific: line 218
Commit the generated lock.
- Distinctive: line 231
Blocking in a signal handler: Use the non-blocking append path.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scheduled Job Runner
Overview
Hermes cron remains the scheduler. jobrun.py is the execution adapter used
by each cron entry. Centralizing execution prevents every scheduled script from
reimplementing interpreter selection, overlap locks, timeout handling, output
policy, logging, and alerting differently.
The canonical implementation ships here:
scripts/jobrun.py— execution adapter and CLIscripts/jobrun_severity.py— per-run outcome classificationscripts/jobrun_repair.py— incident/dedup state and optional repair dispatchscripts/generate_launcher.py— filename-only cron launcher generatortests/jobrun_*_checks.py— standalone regression checks
Do not create another scheduler. Do not wrap jobs with tools that convert a child failure into exit 0.
When to Use
Use this skill when:
- adding or migrating a Hermes cron job;
- a job runs under the wrong Python or misses dependencies;
- success should be silent but failure must remain visible;
- overlapping or overlong runs are possible;
- an operator needs a durable run ledger rather than raw-output inference;
- a job appears successful while its output contains a real failure;
- a scheduler accepts only a script filename, not a command plus arguments.
Install and Verify
Copy all three runtime modules together; jobrun.py loads its sidecars lazily
from the same directory.
mkdir -p "$HERMES_HOME/scripts"
cp scripts/jobrun.py scripts/jobrun_severity.py scripts/jobrun_repair.py \
"$HERMES_HOME/scripts/"
chmod +x "$HERMES_HOME/scripts/jobrun.py"
python3 "$HERMES_HOME/scripts/jobrun.py" --selftestThe self-test starts real child processes and exits non-zero on any failed check.
Job Specification
Specs live under $HERMES_HOME/jobs.d/:
job_id = "daily-report"
script = "daily_report.py"
runtime = "auto" # auto | uv | python | bash | command
timeout = 300
overlap = "skip" # skip | allow | queue
output_policy = "silent" # passthrough | silent
args = ["--mode", "daily"]
owner = "platform-team"Validate without executing:
"$HERMES_HOME/scripts/jobrun.py" --spec daily-report --dry-runA bare spec name always resolves through $HERMES_HOME/jobs.d/; a same-named
working-directory file or directory cannot shadow it.
Generated Launchers Must Pin the Profile
Some Hermes cron configurations accept a script filename but cannot express
jobrun.py --spec daily-report. Generate a tiny launcher instead of resolving
HERMES_HOME dynamically:
python3 scripts/generate_launcher.py \
--job-id daily-report \
--profile-home /path/to/profile \
--jobrun /path/to/profile/scripts/jobrun.py \
--output /path/to/profile/scripts/run-daily-report.pyThe generated script assigns os.environ["HERMES_HOME"] before executing
jobrun.py. This is required when the scheduler process belongs to another
profile; otherwise a bare spec name can resolve against the wrong jobs.d.
Responsibilities
- Interpreter and dependency resolution — including locked PEP 723 scripts
via
uv run --locked --script. - Silence on success —
output_policy = "silent"suppresses routine output without suppressing failure cards. - Overlap prevention — advisory
flockwith skip, allow, or queue policy. - Hard timeout and signal handling — child process groups are terminated and reaped; timeouts and signals remain distinct outcomes.
- Structured JSONL run ledger — each terminal row includes severity before it is persisted.
- Bounded, redacted logs — capture is byte-bounded while the child runs.
- Heartbeat reporting — best-effort start and terminal pings never alter the child outcome.
Bookkeeping must never kill a job. Ledger, notifier, heartbeat, and incident-state failures are swallowed or reported without changing the terminal exit code.
Terminal Exit Codes
Never collapse terminal states into exit 1.
| State | Exit | Meaning |
success | 0 | Child completed successfully |
skipped_overlap | 0 | Existing run still holds the job lock |
config_error | 2 | Runner could not start the child |
child_failure | 3 | Child exited non-zero |
timeout | 4 | Deadline expired |
signal | 5 | Runner received a signal |
wrapper_error | 6 | Execution adapter failed |
Severity and Noteworthy Runs
The child exit code establishes the severity floor. A final structured result line may raise that severity but never lower a non-zero exit or override timeout, signal, launch, or wrapper failures.
A spec can translate a child-specific exit convention:
[exit_map]
10 = "noteworthy"
20 = "degraded"
30 = "broken"noteworthy means the job worked and found something worth reporting. It exits
0 from the wrapper, records a job.noteworthy event, and closes prior failure
conditions rather than leaving a stale incident open.
Failure detail selection scans both stdout and stderr for a failure-looking line. A later successful cleanup line cannot replace the actual error in the incident card.
Ledger Concurrency Invariants
The append and prune paths share a separate runs.jsonl.lock file. They never
lock the ledger inode itself because pruning replaces the ledger path; inode
locking would allow an append to land on the old file and disappear.
Signal handlers call append_ledger(..., blocking=False). flock is not
reentrant across file descriptors, so a blocking lock from a signal handler can
deadlock when the interrupted code already holds the prune lock.
The persisted job.finished row includes severity and reason_code. Compute
both before calling append_ledger; adding them afterward does not update JSONL.
Output and Notifications
passthroughpreserves successful stdout byte-for-byte, including a trailing control payload.silentsuppresses routine successful output.- Failures always render an incident card.
- Optional
notify_targetsends the card directly withhermes send --to. _v2_record_notificationrecords delivery truth so a failed notifier leaves the condition eligible to speak again.
Use placeholders in public examples:
notify_target = "<provider>:<destination>"Day-2 Commands
jobrun.py --list
jobrun.py --status daily-report
jobrun.py --failures 24
jobrun.py --bootstrapThe status API is $HERMES_HOME/jobstate/runs.jsonl. Do not infer health by
grepping raw job output.
Python Dependencies
A Python job can declare and lock dependencies inline:
# /// script
# requires-python = ">=3.13"
# dependencies = ["httpx"]
# ///uv lock --script daily_report.pyCommit the generated lock. A PEP 723 header does nothing unless the script is
actually routed through uv; the adapter detects the block and uses the locked
runtime.
Common Pitfalls
- Installing only
jobrun.py. Copy the severity and repair sidecars too. - Generating an unpinned launcher. It may use the scheduler's profile and resolve the wrong spec.
- Using the default timeout accidentally. Make it shorter than the schedule interval, especially for consequential jobs.
- Locking
runs.jsonldirectly. Prune replaces that inode; use the stable sidecar lock. - Blocking in a signal handler. Use the non-blocking append path.
- Computing severity after append. The persisted row will silently omit it.
- Treating missing telemetry as zero. Unknown is not a measured zero.
- Letting bookkeeping exceptions escape. Observability must not change a job's outcome.
Verification Checklist
python3 scripts/jobrun.py --selftestpasses.- Every
tests/jobrun_*_checks.pyscript passes. --dry-runreports the expected interpreter, argv, and profile spec.- Success is silent when configured and failure remains visible.
- Terminal states retain their distinct exit codes.
- A persisted terminal row contains
severityandreason_code. - Concurrent append/prune checks lose no rows.
- Generated launchers pin
os.environ["HERMES_HOME"]. - No private hostnames, paths, IDs, or domain-specific integrations appear in committed files.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

