hermes-state-db-wal
Skill1 starsChanged 5 months agoMITView on GitHub
Use when diagnosing Hermes state.db WAL advisories.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/AGENTS.mdAGENTS.md
- honcho-profile-tuningSkill
- crit-cliSkill
- critSkill
- global-coding-policySkill
- goal-promptSkill
- hermes-agent-skill-authoringSkill
- hermes-skill-lifecycleSkill
- meaning-preserving-rewriteSkill
- planSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
after hermes doctor --fix, the user asks whether the WAL shrank
- Very specific: line 24
Do not treat a large physical WAL alone as corruption or as a failed plan or policy validation.
- Very specific: line 73
all clients closed cleanly so the last close can remove -wal and -shm, or
- Very specific: line 76
Never delete state.db-wal while any Hermes process has the DB open.
- Distinctive: line 80
Do not issue checkpoint PRAGMAs while explaining size unless the user asked for cleanup.
- Distinctive: line 111
Verify sizes and a quick integrity check before restarting Hermes.
- Distinctive: line 112
Do not invent “delete the wal file” as the default fix.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Hermes state.db WAL diagnosis
Use when:
hermes doctorwarns about a largestate.db-wal(often >50 MiB)- the user asks what WAL is or why doctor flagged session storage
- after
hermes doctor --fix, the user asks whether the WAL shrank - session search or multi-process Hermes use may be holding the session DB open
Do not treat a large physical WAL alone as corruption or as a failed plan or policy validation. Session-store maintenance is separate from SOUL, AGENTS, and workspace-policy correctness unless state.db integrity or lock errors block work.
Core model
Hermes keeps the canonical session store at $HERMES_HOME/state.db (default ~/.hermes/state.db) with SQLite Write-Ahead Logging:
| Path | Role |
state.db | Main DB (sessions, FTS, messages) |
state.db-wal | Committed changes not yet fully absorbed or still allocated for reuse |
state.db-shm | Shared-memory WAL index and locks (not the primary content) |
Writers append to the WAL. Readers can proceed concurrently. A checkpoint copies eligible WAL pages into state.db. After reset or reuse, the physical -wal file often stays at its high-water size even when little content is still active.
Upstream: https://sqlite.org/wal.html
Doctor thresholds (physical size only)
Hermes Doctor checks the on-disk byte size of state.db-wal, not active frames:
- informational above ~10 MiB
- warning above ~50 MiB
Source of truth in a git install: hermes_cli/doctor.py (WAL size check near the session-store health section). Re-open that file if numbers drift.
Pitfall: Doctor can keep warning while logical active content is only a few MiB.
What hermes doctor --fix does
Doctor fix runs approximately:
PRAGMA wal_checkpoint(PASSIVE);PASSIVE:
- copies frames that can be checkpointed without waiting hard for every reader or writer
- does not truncate the allocated WAL file to zero
- can leave physical size unchanged while reducing active frames
So after --fix:
- Measure physical size again.
- Measure active frames from the SHM index (below).
- Report both. Do not claim disk was reclaimed if only
mxFramedropped.
To shrink the physical file, SQLite needs either:
- all clients closed cleanly so the last close can remove
-waland-shm, or - a controlled
TRUNCATE(or RESTART + truncate path) with no active multi-process use
Never delete state.db-wal while any Hermes process has the DB open. Committed data may still depend on it.
Safe read-only inspection (preferred first)
Do not issue checkpoint PRAGMAs while explaining size unless the user asked for cleanup.
- Confirm open clients:
lsof $HERMES_HOME/state.db $HERMES_HOME/state.db-wal $HERMES_HOME/state.db-shm - Record physical sizes of
state.db,state.db-wal,state.db-shm - Parse the WAL header for page size and frame capacity (see
references/wal-probe.md) - Parse the SHM header for
mxFrameandnBackfill(native endian on the host) - Active logical size ≈
32 + mxFrame * (page_size + 24)when page_size is 4096 (frame header is 24 bytes) - Compare active MiB to physical MiB; if active ≪ physical, the advisory is mostly high-water allocation
Hermes session code sets journal_mode=WAL with macOS durability helpers; it does not custom-set wal_autocheckpoint on state.db in normal setup. SQLite’s default auto-checkpoint is 1000 pages. Confirm in hermes_state.py (apply_wal_with_fallback) if behavior changes.
Urgency rubric
Low urgency when:
- SHM headers consistent (
isInit, matching dual header copies) - integrity and doctor schema checks pass
- Hermes still reads and writes sessions
- active frames are modest relative to allocation
Escalate when:
- active frames stay large and keep growing
database is locked, malformed schema, or I/O errors appear- disk is constrained and physical WAL keeps climbing after real load
Controlled reclaim (only when user wants disk back)
- Tell the user every Hermes surface must stop: CLI/TUI, desktop, gateway, dashboard, other profiles using the same
$HERMES_HOMEif shared incorrectly. - Back up
state.db(and preferably the trio of db/wal/shm if present). - With no other clients, run a TRUNCATE-style checkpoint under SQLite, or allow a clean last-close.
- Verify sizes and a quick integrity check before restarting Hermes.
- Do not invent “delete the wal file” as the default fix.
Response shape for users
Lead with the answer (shrank or not), then a small before/after table: physical size, active frames, estimated active MiB. Separate “logical checkpoint progress” from “disk reclaimed.” Keep WAL mechanics short unless the user asked for a full lesson.
References
references/wal-probe.md— header fields, probe snippets, PASSIVE vs TRUNCATE
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.

