Skip to content

fix(cron): tolerate UTF-8 BOM in jobs.json readers and context files (salvage #66609, #41604) - #66825

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-c03a68df
Jul 18, 2026
Merged

fix(cron): tolerate UTF-8 BOM in jobs.json readers and context files (salvage #66609, #41604)#66825
teknium1 merged 3 commits into
mainfrom
hermes/hermes-c03a68df

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

~/.hermes/cron/jobs.json readers now tolerate a UTF-8 BOM (Windows Notepad / PowerShell 5.1 artifact). Previously a BOM'd jobs.json hard-crashed load_jobs() with RuntimeError: Cron database corrupted and unrepairable — the scheduler stopped running jobs, and hermes cron list / hermes status / hermes dump all failed. Fixes #66607.

Salvage of #66609 (@pnascimento9596) + the cron/context halves of #41604 (@deacon-botdoctor), widened to two additional sibling readers.

Changes

  • cron/jobs.py: both load_jobs() opens → utf-8-sig (from fix(cron): accept UTF-8 BOM when reading jobs.json #66609)
  • hermes_cli/dump.py, hermes_cli/status.py: jobs.json readers → utf-8-sig (from fix(cron): accept UTF-8 BOM when reading jobs.json #66609)
  • agent/prompt_builder.py: _scan_context_content() strips a leading U+FEFF so a BOM'd SOUL.md/AGENTS.md isn't wholesale-blocked as invisible_unicode; BOMs elsewhere in content still trip the threat scan (from fix: tolerate UTF-8 BOM in cron jobs.json and context files #41604)
  • hermes_cli/backup.py _count_cron_jobs()utf-8-sig (follow-up): a BOM made the count None, silently disabling the post-update cron-loss auto-restore safety net
  • agent/curator_backup.py _backup_cron_jobs_into()utf-8-sig (follow-up): BOM broke jobs_count with a spurious parse warning; snapshot copy is now written BOM-free so rollback restores a loadable file
  • scripts/release.py: AUTHOR_MAP entry for deacon-botdoctor
  • Writers everywhere remain plain utf-8 — saves stay BOM-free

Validation

Before After
load_jobs() on BOM'd file RuntimeError jobs load
hermes status / dump error reading correct counts
_count_cron_jobs (auto-restore net) None → net disabled correct count, restore fires
curator snapshot of BOM'd store count 0 + parse warning correct count, BOM-free backup
BOM'd SOUL.md BLOCKED (invisible_unicode) loaded, BOM stripped
mid-content BOM in context file blocked still blocked

Targeted suites green: tests/cron/test_jobs.py, tests/hermes_cli/test_jobs_json_utf8_bom.py, tests/agent/test_prompt_builder.py, tests/agent/test_curator_backup.py, tests/hermes_cli/test_backup.py — 494 passed. E2E verified against a temp HERMES_HOME with real BOM'd files across all six read sites.

Credit

Infographic

CRON SURVIVES THE BYTE ORDER MARK

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists needs-decision Awaiting maintainer decision before any implementation sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #66609 and #41604, not duplicate: this maintainer salvage keeps the BOM jobs-store repair while adding backup/auto-restore and context-file coverage. The broadened scope needs a maintainer merge choice.

pnascimento9596 and others added 2 commits July 18, 2026 02:12
Windows Notepad and PowerShell 5.1 Set-Content -Encoding UTF8 write a
leading UTF-8 BOM. json.load under encoding=utf-8 raises
JSONDecodeError("Unexpected UTF-8 BOM"), and load_jobs wraps that as
RuntimeError("Cron database corrupted and unrepairable"), taking down
cron CRUD/scheduler for a hand-edited jobs.json.

Read with utf-8-sig on all four independent jobs.json readers
(load_jobs primary + strict=False repair, dump _cron_summary, status
Scheduled Jobs). Write path stays plain utf-8 so the next save_jobs
heals a BOM'd file. Matches the env-class dialect (#65123).

Tests: BOM load (crash repro), bomless regression, empty store,
BOM+bare-list auto-repair, BOM+control-char strict=False arm, dump and
status CLI readers.
@teknium1
teknium1 force-pushed the hermes/hermes-c03a68df branch from 6de628c to 73332b7 Compare July 18, 2026 09:13
Follow-up to the salvaged #66609 (4 primary readers) and #41604 (context
files): two more jobs.json readers rejected a BOM'd file —

- hermes_cli/backup.py _count_cron_jobs: a BOM made the count None,
  silently disabling the post-update cron-loss auto-restore safety net
- agent/curator_backup.py _backup_cron_jobs_into: BOM broke the job
  count (spurious parse_warning) and propagated the BOM into snapshots

Both now read utf-8-sig; curator snapshots are written BOM-free so
rollback restores a file load_jobs can read. AUTHOR_MAP entry added
for deacon-botdoctor.

Tests: BOM'd-live-file auto-restore + BOM'd snapshot count/BOM-free copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron: UTF-8 BOM in jobs.json crashes load_jobs (RuntimeError)

4 participants