hermes - 💡(How to fix) Fix database.journal_size_limit and wal_autocheckpoint from config.yaml are never applied to SQLite connections [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

hermes_state.py SessionDB.__init__() (line 188-201) sets only two PRAGMAs:

self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA foreign_keys=ON")

It never reads config.yaml's database: section. Users can configure these settings in config.yaml:

database:
  journal_mode: WAL
  wal_autocheckpoint: 200       # ~800 KB
  journal_size_limit: 10485760  # 10 MB

But they are silently ignored. SQLite defaults remain:

  • journal_size_limit = -1 (unlimited)
  • wal_autocheckpoint = 1000 (~4 MB)

Fix Action

Fixed

Code Example

self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA foreign_keys=ON")

---

database:
  journal_mode: WAL
  wal_autocheckpoint: 200       # ~800 KB
  journal_size_limit: 10485760  # 10 MB

---

$ sqlite3 ~/.hermes/state.db "PRAGMA journal_size_limit; PRAGMA wal_autocheckpoint;"
-1
1000

---

10485760
200

---

# After existing PRAGMAs (line 202)
from hermes_cli.config import load_config
cfg = load_config()
db_cfg = cfg.get("database", {})
if "journal_size_limit" in db_cfg:
    self._conn.execute(f"PRAGMA journal_size_limit = {db_cfg['journal_size_limit']}")
if "wal_autocheckpoint" in db_cfg:
    self._conn.execute(f"PRAGMA wal_autocheckpoint = {db_cfg['wal_autocheckpoint']}")
RAW_BUFFERClick to expand / collapse

Problem

The database: section in config.yaml is documented but never read by SessionDB.__init__() when initializing the SQLite connection. Config settings like journal_size_limit and wal_autocheckpoint are silently ignored, causing the WAL file to grow without bound.

Root Cause

hermes_state.py SessionDB.__init__() (line 188-201) sets only two PRAGMAs:

self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA foreign_keys=ON")

It never reads config.yaml's database: section. Users can configure these settings in config.yaml:

database:
  journal_mode: WAL
  wal_autocheckpoint: 200       # ~800 KB
  journal_size_limit: 10485760  # 10 MB

But they are silently ignored. SQLite defaults remain:

  • journal_size_limit = -1 (unlimited)
  • wal_autocheckpoint = 1000 (~4 MB)

Verification

$ sqlite3 ~/.hermes/state.db "PRAGMA journal_size_limit; PRAGMA wal_autocheckpoint;"
-1
1000

Expected output (after applying config.yaml):

10485760
200

Impact

  1. WAL grows unbounded — no cap means the WAL file can reach 331+ MB
  2. Checkpoints happen too late — SQLite default 1000 pages (~4 MB) instead of configured 200 (~800 KB)
  3. hermes doctor --fix only treats symptoms — runs PRAGMA wal_checkpoint(PASSIVE) (doctor.py line 812) but never fixes the underlying config gap, so WAL regrows
  4. Multi-process amplification — gateway + webui + dashboard + workers all open separate connections, each missing the config settings
  5. Disk waste — state.db 335 MB + WAL 332 MB + .bak 339 MB ≈ 1 GB

Affected Code

  • hermes_state.py lines 188-201: connection init missing config read
  • hermes_cli/doctor.py lines 799-818: symptom detection without root cause fix

Proposed Fix

SessionDB.__init__() should read the database: section from config.yaml after connecting:

# After existing PRAGMAs (line 202)
from hermes_cli.config import load_config
cfg = load_config()
db_cfg = cfg.get("database", {})
if "journal_size_limit" in db_cfg:
    self._conn.execute(f"PRAGMA journal_size_limit = {db_cfg['journal_size_limit']}")
if "wal_autocheckpoint" in db_cfg:
    self._conn.execute(f"PRAGMA wal_autocheckpoint = {db_cfg['wal_autocheckpoint']}")

Alternatively, doctor.py --fix could apply these PRAGMAs in addition to the passive checkpoint.

System Info

  • Hermes version: latest main as of 2026-05-08
  • OS: WSL Debian on Windows
  • DB before fix: 335 MB state.db + 332 MB WAL = 667 MB total

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix database.journal_size_limit and wal_autocheckpoint from config.yaml are never applied to SQLite connections [1 pull requests]